Hugh McMaster : regedit/tests: Check if regedit.exe has elevated privileges before starting some tests.

Alexandre Julliard julliard at winehq.org
Thu Jul 6 16:25:17 CDT 2017


Module: wine
Branch: master
Commit: 499733f400d0400577f7c4e4aba3fcbdf363fe00
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=499733f400d0400577f7c4e4aba3fcbdf363fe00

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Thu Jul  6 11:17:54 2017 +0000

regedit/tests: Check if regedit.exe has elevated privileges before starting some tests.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/regedit/tests/regedit.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index 2b33bc9..dad482e 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -513,11 +513,19 @@ static void test_basic_import_31(void)
     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);
+    if (lr == ERROR_ACCESS_DENIED)
+    {
+        win_skip("regedit.exe is not running with elevated privileges; "
+                 "skipping Windows 3.1 import tests\n");
+        return;
+    }
+
     /* Test simple value */
     exec_import_str("REGEDIT\r\n"
 		    "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value0\r\n");
-    lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, KEY_READ, &hkey);
-    ok(lr == ERROR_SUCCESS, "RegOpenKeyExA failed: %d\n", lr);
     verify_reg(hkey, "", REG_SZ, "Value0", 7, 0);
 
     /* Test proper handling of spaces and equals signs */
@@ -1058,9 +1066,15 @@ static void test_invalid_import_31(void)
     HKEY hkey;
     LONG 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);
-    ok(lr == ERROR_SUCCESS, "RegCreateKeyExA failed: %d\n", lr);
+    if (lr == ERROR_ACCESS_DENIED)
+    {
+        win_skip("regedit.exe is not running with elevated privileges; "
+            "skipping Windows 3.1 invalid import tests\n");
+        return;
+    }
 
     /* Test character validity at the start of the line */
     exec_import_str("REGEDIT\r\n"




More information about the wine-cvs mailing list