[2/2] wintrust/tests: Skip the WintrustSetRegPolicyFlags() tests if the registry key/value is missing.

Francois Gouget fgouget at codeweavers.com
Tue Jun 12 11:01:27 CDT 2007


At the end of the test, restore the registry value.
---

As is the patch would create the registry key if it was missing, and set 
the value to semi-random garbage. We could try to delete the key, 
subkeys and/or values after the test if they did not exist, but that 
seems like too much complexity for a case that apparently should not 
happen (i.e. is most likely wrong) in the first place.


 dlls/wintrust/tests/register.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/dlls/wintrust/tests/register.c b/dlls/wintrust/tests/register.c
index 049e8e3..a4b3e52 100644
--- a/dlls/wintrust/tests/register.c
+++ b/dlls/wintrust/tests/register.c
@@ -313,11 +313,22 @@ static void test_RegPolicyFlags(void)
 
     r = RegOpenKeyExA(HKEY_CURRENT_USER, Software_Publishing, 0, KEY_ALL_ACCESS,
      &key);
-    ok(!r, "RegOpenKeyEx failed: %d\n", r);
+    if (r)
+    {
+        /* Exit so we don't modify the registry */
+        ok(0, "RegOpenKeyEx failed: %d\n", r);
+        return;
+    }
 
     size = sizeof(flags1);
     r = RegQueryValueExA(key, State, NULL, NULL, (LPBYTE)&flags1, &size);
-    ok(!r, "RegQueryValueEx failed: %d\n", r);
+    if (r)
+    {
+        /* Exit so we don't modify the registry */
+        ok(0, "RegQueryValueEx failed: %d\n", r);
+        RegCloseKey(key);
+        return;
+    }
 
     pGetFlags(&flags2);
     ok(flags1 == flags2, "Got %08x flags instead of %08x\n", flags1, flags2);
@@ -329,7 +340,8 @@ static void test_RegPolicyFlags(void)
     r = RegQueryValueExA(key, State, NULL, NULL, (LPBYTE)&flags1, &size);
     ok(flags1 == flags3, "Got %08x flags instead of %08x\n", flags1, flags3);
 
-    pSetFlags(flags2);
+    /* Restore the registry */
+    pSetFlags(flags1);
 
     RegCloseKey(key);
 }
-- 
1.4.4.4




More information about the wine-patches mailing list