advapi32/tests: remove Win9x hacks

Austin English austinenglish at gmail.com
Wed Feb 16 19:31:45 CST 2011


I originally looked at the file to fix a Clang warning about dead code:
1523	if (outsize == insize)
1524	{
1525	/* RegQueryValueExA may return a string with no trailing '\0' */
1526	outsize=insize;

Assigned value is always the same as the existing value

that initial check only failed on Win9x, which we no longer test. I
cleaned up the rest of the file while I was at it :-).

Cleared WTB, aside from 9x:
https://testbot.winehq.org/JobDetails.pl?Key=9321

-- 
-Austin
-------------- next part --------------
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 5316e95..2809559 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -189,8 +189,7 @@ static void _test_hkey_main_Value_A(int line, LPCSTR name, LPCSTR string,
 
     str_byte_len = (string ? lstrlenA(string) : 0) + 1;
     lok(type == REG_SZ, "RegQueryValueExA/1 returned type %d\n", type);
-    lok(cbData == full_byte_len || cbData == str_byte_len /* Win9x */,
-        "cbData=%d instead of %d or %d\n", cbData, full_byte_len, str_byte_len);
+    lok(cbData == full_byte_len, "cbData=%d instead of %d or %d\n", cbData, full_byte_len, str_byte_len);
 
     value = HeapAlloc(GetProcessHeap(), 0, cbData+1);
     memset(value, 0xbd, cbData+1);
@@ -201,8 +200,7 @@ static void _test_hkey_main_Value_A(int line, LPCSTR name, LPCSTR string,
     if (!string)
     {
         /* When cbData == 0, RegQueryValueExA() should not modify the buffer */
-        lok(*value == 0xbd || (cbData == 1 && *value == '\0') /* Win9x */,
-           "RegQueryValueExA overflowed: cbData=%u *value=%02x\n", cbData, *value);
+        lok(*value == 0xbd, "RegQueryValueExA overflowed: cbData=%u *value=%02x\n", cbData, *value);
     }
     else
     {
@@ -303,19 +301,13 @@ static void test_set_value(void)
 
     /* only REG_SZ is supported on NT*/
     ret = RegSetValueA(hkey_main, NULL, REG_BINARY, string2A, sizeof(string2A));
-    /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_SUCCESS */
-    ok(ret == ERROR_INVALID_PARAMETER || broken(ret == ERROR_SUCCESS),
-        "got %d (expected ERROR_INVALID_PARAMETER or ERROR_SUCCESS)\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret);
 
     ret = RegSetValueA(hkey_main, NULL, REG_EXPAND_SZ, string2A, sizeof(string2A));
-    /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_SUCCESS */
-    ok(ret == ERROR_INVALID_PARAMETER || broken(ret == ERROR_SUCCESS),
-        "got %d (expected ERROR_INVALID_PARAMETER or ERROR_SUCCESS)\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret);
 
     ret = RegSetValueA(hkey_main, NULL, REG_MULTI_SZ, string2A, sizeof(string2A));
-    /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_SUCCESS */
-    ok(ret == ERROR_INVALID_PARAMETER || broken(ret == ERROR_SUCCESS),
-        "got %d (expected ERROR_INVALID_PARAMETER or ERROR_SUCCESS)\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret);
 
     /* Test RegSetValueExA with a 'zero-byte' string (as Office 2003 does).
      * Surprisingly enough we're supposed to get zero bytes out of it.
@@ -349,9 +341,6 @@ static void test_set_value(void)
     test_hkey_main_Value_A(name2A, string2A, sizeof(string2A));
     test_hkey_main_Value_W(name2W, string2W, sizeof(string2W));
 
-    /* 9x doesn't support W-calls, so don't test them then */
-    if(GLE == ERROR_CALL_NOT_IMPLEMENTED) return; 
-
     if (0)
     {
         /* Crashes on NT4, Windows 2000 and XP SP1 */
@@ -477,8 +466,7 @@ static void test_enum_value(void)
     strcpy( data, "xxxxxxxxxx" );
     res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
     ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
-    /* Win9x returns 2 as specified by MSDN but NT returns 3... */
-    ok( val_count == 2 || val_count == 3, "val_count set to %d\n", val_count );
+    ok( val_count == 3, "val_count set to %d\n", val_count );
     ok( data_count == 7 || broken( data_count == 8 ), "data_count set to %d instead of 7\n", data_count );
     ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
     /* v5.1.2600.0 (XP Home and Professional) does not touch value or data in this case */
@@ -619,20 +607,7 @@ static void test_query_value_ex(void)
     size = 0xdeadbeef;
     ret = RegQueryValueExA(HKEY_CLASSES_ROOT, "Nonexistent Value", NULL, &type, NULL, &size);
     ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
-    /* the type parameter is cleared on Win9x, but is set to a random value on
-     * NT, so don't do that test there. The size parameter is left untouched on Win9x
-     * but cleared on NT+, this can be tested on all platforms.
-     */
-    if (GetVersion() & 0x80000000)
-    {
-        ok(type == 0, "type should have been set to 0 instead of 0x%x\n", type);
-        ok(size == 0xdeadbeef, "size should have been left untouched (0xdeadbeef)\n");
-    }
-    else
-    {
-        trace("test_query_value_ex: type set to: 0x%08x\n", type);
-        ok(size == 0, "size should have been set to 0 instead of %d\n", size);
-    }
+    ok(size == 0, "size should have been set to 0 instead of %d\n", size);
 
     size = sizeof(buffer);
     ret = RegQueryValueExA(HKEY_CLASSES_ROOT, "Nonexistent Value", NULL, &type, buffer, &size);
@@ -867,53 +842,48 @@ static void test_reg_open_key(void)
     ok(hkResult != NULL, "expected hkResult != NULL\n");
     hkPreserve = hkResult;
 
-    /* these tests fail on Win9x, but we want to be compatible with NT, so
-     * run them if we can */
-    if (!(GetVersion() & 0x80000000))
-    {
-        /* open same key twice */
-        ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkResult);
-        ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
-        ok(hkResult != hkPreserve, "epxected hkResult != hkPreserve\n");
-        ok(hkResult != NULL, "hkResult != NULL\n");
-        RegCloseKey(hkResult);
-    
-        /* open nonexistent key
-        * check that hkResult is set to NULL
-        */
-        hkResult = hkPreserve;
-        ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult);
-        ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
-        ok(hkResult == NULL, "expected hkResult == NULL\n");
-    
-        /* open the same nonexistent key again to make sure the key wasn't created */
-        hkResult = hkPreserve;
-        ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult);
-        ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
-        ok(hkResult == NULL, "expected hkResult == NULL\n");
-    
-        /* send in NULL lpSubKey
-        * check that hkResult receives the value of hKey
-        */
-        hkResult = hkPreserve;
-        ret = RegOpenKeyA(HKEY_CURRENT_USER, NULL, &hkResult);
-        ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
-        ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n");
-    
-        /* send empty-string in lpSubKey */
-        hkResult = hkPreserve;
-        ret = RegOpenKeyA(HKEY_CURRENT_USER, "", &hkResult);
-        ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
-        ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n");
-    
-        /* send in NULL lpSubKey and NULL hKey
-        * hkResult is set to NULL
-        */
-        hkResult = hkPreserve;
-        ret = RegOpenKeyA(NULL, NULL, &hkResult);
-        ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
-        ok(hkResult == NULL, "expected hkResult == NULL\n");
-    }
+    /* open same key twice */
+    ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkResult);
+    ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
+    ok(hkResult != hkPreserve, "epxected hkResult != hkPreserve\n");
+    ok(hkResult != NULL, "hkResult != NULL\n");
+    RegCloseKey(hkResult);
+
+    /* open nonexistent key
+    * check that hkResult is set to NULL
+    */
+    hkResult = hkPreserve;
+    ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult);
+    ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
+    ok(hkResult == NULL, "expected hkResult == NULL\n");
+
+    /* open the same nonexistent key again to make sure the key wasn't created */
+    hkResult = hkPreserve;
+    ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult);
+    ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
+    ok(hkResult == NULL, "expected hkResult == NULL\n");
+
+    /* send in NULL lpSubKey
+    * check that hkResult receives the value of hKey
+    */
+    hkResult = hkPreserve;
+    ret = RegOpenKeyA(HKEY_CURRENT_USER, NULL, &hkResult);
+    ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
+    ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n");
+
+    /* send empty-string in lpSubKey */
+    hkResult = hkPreserve;
+    ret = RegOpenKeyA(HKEY_CURRENT_USER, "", &hkResult);
+    ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
+    ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n");
+
+    /* send in NULL lpSubKey and NULL hKey
+    * hkResult is set to NULL
+    */
+    hkResult = hkPreserve;
+    ret = RegOpenKeyA(NULL, NULL, &hkResult);
+    ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
+    ok(hkResult == NULL, "expected hkResult == NULL\n");
 
     /* only send NULL hKey
      * the value of hkResult remains unchanged
@@ -938,7 +908,6 @@ static void test_reg_open_key(void)
     /*  beginning backslash character */
     ret = RegOpenKeyA(HKEY_CURRENT_USER, "\\Software\\Wine\\Test", &hkResult);
     ok(ret == ERROR_BAD_PATHNAME || /* NT/2k/XP */
-       ret == ERROR_FILE_NOT_FOUND || /* Win9x,ME */
        broken(ret == ERROR_SUCCESS),  /* wow64 */
        "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret);
     if (!ret) RegCloseKey(hkResult);
@@ -946,9 +915,8 @@ static void test_reg_open_key(void)
     hkResult = NULL;
     ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, "\\clsid", 0, KEY_QUERY_VALUE, &hkResult);
     ok(ret == ERROR_SUCCESS || /* 2k/XP */
-       ret == ERROR_BAD_PATHNAME || /* NT */
-       ret == ERROR_FILE_NOT_FOUND /* Win9x,ME */
-       , "expected ERROR_SUCCESS, ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret);
+       ret == ERROR_BAD_PATHNAME, /* NT */
+       "expected ERROR_SUCCESS, ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret);
     RegCloseKey(hkResult);
 
     /* WOW64 flags */
@@ -1072,8 +1040,7 @@ static void test_reg_create_key(void)
     ret = RegCreateKeyExA(hkey_main, "Volatile", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey1, NULL);
     ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
     ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
-    ok(ret == ERROR_CHILD_MUST_BE_VOLATILE || broken(!ret), /* win9x */
-       "RegCreateKeyExA failed with error %d\n", ret);
+    ok(ret == ERROR_CHILD_MUST_BE_VOLATILE, "RegCreateKeyExA failed with error %d\n", ret);
     if (!ret) RegCloseKey( hkey2 );
     ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
     ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
@@ -1510,62 +1477,58 @@ static void test_string_termination(void)
     ret = RegQueryValueExA(subkey, "stringtest", NULL, NULL, buffer, &outsize);
     ok(ret == ERROR_MORE_DATA, "RegQueryValueExA returned: %d\n", ret);
 
-    /* Off-by-two RegSetValueExA -> no trailing '\0', except on Win9x */
+    /* Off-by-two RegSetValueExA -> no trailing '\0' */
     insize=sizeof(string)-2;
     ret = RegSetValueExA(subkey, "stringtest", 0, REG_SZ, (BYTE*)string, insize);
     ok(ret == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", ret);
     outsize=0;
     ret = RegQueryValueExA(subkey, "stringtest", NULL, NULL, NULL, &outsize);
     ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", ret);
-    ok(outsize == insize || broken(outsize == sizeof(string)) /* Win9x */,
-       "wrong size %u != %u\n", outsize, insize);
+    ok(outsize == insize, "wrong size %u != %u\n", outsize, insize);
 
-    if (outsize == insize)
-    {
-        /* RegQueryValueExA may return a string with no trailing '\0' */
-        outsize=insize;
-        memset(buffer, 0xbd, sizeof(buffer));
-        ret = RegQueryValueExA(subkey, "stringtest", NULL, NULL, buffer, &outsize);
-        ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", ret);
-        ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
-        ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
-           wine_debugstr_an((char*)buffer, outsize), outsize, string);
-        ok(buffer[insize] == 0xbd, "buffer overflow at %u %02x\n", insize, buffer[insize]);
-
-        /* RegQueryValueExA adds a trailing '\0' if there is room */
-        outsize=insize+1;
-        memset(buffer, 0xbd, sizeof(buffer));
-        ret = RegQueryValueExA(subkey, "stringtest", NULL, NULL, buffer, &outsize);
-        ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", ret);
-        ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
-        ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
-           wine_debugstr_an((char*)buffer, outsize), outsize, string);
-        ok(buffer[insize] == 0, "buffer overflow at %u %02x\n", insize, buffer[insize]);
-
-        /* RegEnumValueA may return a string with no trailing '\0' */
-        outsize=insize;
-        memset(buffer, 0xbd, sizeof(buffer));
-        nsize=sizeof(name);
-        ret = RegEnumValueA(subkey, 0, name, &nsize, NULL, NULL, buffer, &outsize);
-        ok(ret == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", ret);
-        ok(strcmp(name, "stringtest") == 0, "wrong name: %s\n", name);
-        ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
-        ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
-           wine_debugstr_an((char*)buffer, outsize), outsize, string);
-        ok(buffer[insize] == 0xbd, "buffer overflow at %u %02x\n", insize, buffer[insize]);
-
-        /* RegEnumValueA adds a trailing '\0' if there is room */
-        outsize=insize+1;
-        memset(buffer, 0xbd, sizeof(buffer));
-        nsize=sizeof(name);
-        ret = RegEnumValueA(subkey, 0, name, &nsize, NULL, NULL, buffer, &outsize);
-        ok(ret == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", ret);
-        ok(strcmp(name, "stringtest") == 0, "wrong name: %s\n", name);
-        ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
-        ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
-           wine_debugstr_an((char*)buffer, outsize), outsize, string);
-        ok(buffer[insize] == 0, "buffer overflow at %u %02x\n", insize, buffer[insize]);
-    }
+    /* RegQueryValueExA may return a string with no trailing '\0' */
+    outsize=insize;
+    memset(buffer, 0xbd, sizeof(buffer));
+    ret = RegQueryValueExA(subkey, "stringtest", NULL, NULL, buffer, &outsize);
+    ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", ret);
+    ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
+    ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
+       wine_debugstr_an((char*)buffer, outsize), outsize, string);
+    ok(buffer[insize] == 0xbd, "buffer overflow at %u %02x\n", insize, buffer[insize]);
+
+    /* RegQueryValueExA adds a trailing '\0' if there is room */
+    outsize=insize+1;
+    memset(buffer, 0xbd, sizeof(buffer));
+    ret = RegQueryValueExA(subkey, "stringtest", NULL, NULL, buffer, &outsize);
+    ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", ret);
+    ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
+    ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
+       wine_debugstr_an((char*)buffer, outsize), outsize, string);
+    ok(buffer[insize] == 0, "buffer overflow at %u %02x\n", insize, buffer[insize]);
+
+    /* RegEnumValueA may return a string with no trailing '\0' */
+    outsize=insize;
+    memset(buffer, 0xbd, sizeof(buffer));
+    nsize=sizeof(name);
+    ret = RegEnumValueA(subkey, 0, name, &nsize, NULL, NULL, buffer, &outsize);
+    ok(ret == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", ret);
+    ok(strcmp(name, "stringtest") == 0, "wrong name: %s\n", name);
+    ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
+    ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
+       wine_debugstr_an((char*)buffer, outsize), outsize, string);
+    ok(buffer[insize] == 0xbd, "buffer overflow at %u %02x\n", insize, buffer[insize]);
+
+    /* RegEnumValueA adds a trailing '\0' if there is room */
+    outsize=insize+1;
+    memset(buffer, 0xbd, sizeof(buffer));
+    nsize=sizeof(name);
+    ret = RegEnumValueA(subkey, 0, name, &nsize, NULL, NULL, buffer, &outsize);
+    ok(ret == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", ret);
+    ok(strcmp(name, "stringtest") == 0, "wrong name: %s\n", name);
+    ok(outsize == insize, "wrong size: %u != %u\n", outsize, insize);
+    ok(memcmp(buffer, string, outsize) == 0, "bad string: %s/%u != %s\n",
+       wine_debugstr_an((char*)buffer, outsize), outsize, string);
+    ok(buffer[insize] == 0, "buffer overflow at %u %02x\n", insize, buffer[insize]);
 
     RegDeleteKeyA(subkey, "");
     RegCloseKey(subkey);
@@ -2108,7 +2071,7 @@ static void test_classesroot(void)
     res = RegOpenKeyExA( HKEY_CLASSES_ROOT, "WineTestCls", 0,
                          KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcr );
     todo_wine ok(res == ERROR_SUCCESS ||
-                 broken(res == ERROR_FILE_NOT_FOUND /* Win9x */),
+                 broken(res == ERROR_FILE_NOT_FOUND /* WinNT */),
                  "test key not found in hkcr: %d\n", res);
     if (res)
     {


More information about the wine-patches mailing list