[PATCH 1/6] regedit/tests: Check for elevated privileges before cleaning up the Windows 3.1 test key and running unit tests

Hugh McMaster hugh.mcmaster at outlook.com
Mon Feb 22 05:24:00 CST 2021


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/regedit/tests/regedit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index 66b95624455..de4ddfa76a3 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -1094,15 +1094,12 @@ static void test_basic_import_unicode(void)
 static void test_basic_import_31(void)
 {
     HKEY hkey;
+    DWORD dispos;
     LONG lr;
 
-    lr = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
-    ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND,
-            "RegDeleteKeyA failed: %d\n", lr);
-
     /* Check if regedit.exe is running with elevated privileges */
     lr = RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE,
-                         KEY_READ, NULL, &hkey, NULL);
+                         KEY_READ|KEY_SET_VALUE, NULL, &hkey, &dispos);
     if (lr == ERROR_ACCESS_DENIED)
     {
         win_skip("regedit.exe is not running with elevated privileges; "
@@ -1110,6 +1107,9 @@ static void test_basic_import_31(void)
         return;
     }
 
+    if (dispos == REG_OPENED_EXISTING_KEY)
+        delete_value(hkey, NULL);
+
     /* Test simple value */
     exec_import_str("REGEDIT\r\n"
 		    "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value0\r\n");
-- 
2.30.1




More information about the wine-devel mailing list