ole32/tests: Skip some tests if not allowed to modify the Classes registry key.

Francois Gouget fgouget at free.fr
Tue Sep 20 17:42:06 CDT 2011


---

On Windows 7, if not running the tests with elevated privileges some 
registry keys/values cannot be modified. This fixes the test on my 
Windows 7 VM.

 dlls/ole32/tests/marshal.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c
index 33e074c..c178912 100644
--- a/dlls/ole32/tests/marshal.c
+++ b/dlls/ole32/tests/marshal.c
@@ -2268,7 +2268,7 @@ static void test_freethreadedmarshaler(void)
     IMarshal_Release(pFTMarshal);
 }
 
-static void reg_unreg_wine_test_class(BOOL Register)
+static HRESULT reg_unreg_wine_test_class(BOOL Register)
 {
     HRESULT hr;
     char buffer[256];
@@ -2286,9 +2286,16 @@ static void reg_unreg_wine_test_class(BOOL Register)
     if (Register)
     {
         error = RegCreateKeyEx(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey, &dwDisposition);
+        if (error == ERROR_ACCESS_DENIED)
+        {
+            skip("Not authorized to modify the Classes key\n");
+            return E_FAIL;
+        }
         ok(error == ERROR_SUCCESS, "RegCreateKeyEx failed with error %d\n", error);
+        if (error != ERROR_SUCCESS) hr = E_FAIL;
         error = RegSetValueEx(hkey, NULL, 0, REG_SZ, (const unsigned char *)"\"ole32.dll\"", strlen("\"ole32.dll\"") + 1);
         ok(error == ERROR_SUCCESS, "RegSetValueEx failed with error %d\n", error);
+        if (error != ERROR_SUCCESS) hr = E_FAIL;
         RegCloseKey(hkey);
     }
     else
@@ -2297,6 +2304,7 @@ static void reg_unreg_wine_test_class(BOOL Register)
         *strrchr(buffer, '\\') = '\0';
         RegDeleteKey(HKEY_CLASSES_ROOT, buffer);
     }
+    return hr;
 }
 
 static void test_inproc_handler(void)
@@ -2305,7 +2313,8 @@ static void test_inproc_handler(void)
     IUnknown *pObject;
     IUnknown *pObject2;
 
-    reg_unreg_wine_test_class(TRUE);
+    if (FAILED(reg_unreg_wine_test_class(TRUE)))
+        return;
 
     hr = CoCreateInstance(&CLSID_WineTest, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&pObject);
     ok_ole_success(hr, "CoCreateInstance");
@@ -2386,7 +2395,8 @@ static void test_handler_marshaling(void)
     HANDLE thread;
     static const LARGE_INTEGER ullZero;
 
-    reg_unreg_wine_test_class(TRUE);
+    if (FAILED(reg_unreg_wine_test_class(TRUE)))
+        return;
     cLocks = 0;
 
     hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
-- 
1.7.5.4




More information about the wine-patches mailing list