Fix the advapi32/regitry tests

Francois Gouget fgouget at free.fr
Sun Jan 12 04:15:40 CST 2003


With this patch the test succeed on Win95, Win98 and NT4. A couple of
checks still fail on XP SP1 because XP has two big bugs. Well, more on
that later I guess...


Changelog:

 * dlls/advapi32/tests/registry.c

   Use only Ansi APIs for cleaning up the registry
   Skip Unicode tests if the Unicode APIs are not implemented
   If the value name buffer is too small, Win9x returns the number of
characters returned as specified in the MSDN while other Windows return
the number of bytes written (including the trailing '\0')


Index: dlls/advapi32/tests/registry.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/tests/registry.c,v
retrieving revision 1.3
diff -u -r1.3 registry.c
--- dlls/advapi32/tests/registry.c	17 Sep 2002 00:04:35 -0000	1.3
+++ dlls/advapi32/tests/registry.c	12 Jan 2003 07:16:13 -0000
@@ -29,13 +29,13 @@
 /* delete key and all its subkeys */
 static DWORD delete_key( HKEY hkey )
 {
-    WCHAR name[MAX_PATH];
+    char name[MAX_PATH];
     DWORD ret;

-    while (!(ret = RegEnumKeyW(hkey, 0, name, sizeof(name))))
+    while (!(ret = RegEnumKeyA(hkey, 0, name, sizeof(name))))
     {
         HKEY tmp;
-        if (!(ret = RegOpenKeyExW( hkey, name, 0, KEY_ENUMERATE_SUB_KEYS, &tmp )))
+        if (!(ret = RegOpenKeyExA( hkey, name, 0, KEY_ENUMERATE_SUB_KEYS, &tmp )))
         {
             ret = delete_key( tmp );
             RegCloseKey( tmp );
@@ -90,7 +90,8 @@
     strcpy( data, "xxxxxxxxxx" );
     res = RegEnumValueA( hkey_main, 0, value, &val_count, NULL, &type, data, &data_count );
     ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld", res );
-    ok( val_count == 3, "val_count set to %ld", val_count );
+    /* Win9x returns 2 as specified by MSDN but NT returns 3... */
+    ok( val_count == 2 || val_count == 3, "val_count set to %ld", val_count );
     ok( data_count == 7, "data_count set to %ld instead of 7", data_count );
     ok( type == REG_SZ, "type %ld is not REG_SZ", type );
     ok( !strcmp( value, "Te" ), "value set to '%s' instead of 'Te'", value );
@@ -140,7 +141,10 @@

     /* Unicode tests */

+    SetLastError(0);
     res = RegSetValueExW( hkey_main, testW, 0, REG_SZ, (BYTE *)foobarW, 7*sizeof(WCHAR) );
+    if (res==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
+        goto CLEANUP;
     ok( res == 0, "RegSetValueExW failed error %ld", res );

     /* overflow both name and data */
@@ -199,6 +203,7 @@
     ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'" );
     ok( !memcmp( dataW, foobarW, sizeof(foobarW) ), "data is not 'foobar'" );

+CLEANUP:
     /* cleanup */
     RegDeleteValueA( hkey_main, "Test" );
 }




-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
            Before you criticize someone, walk a mile in his shoes.
       That way, if he gets angry, he'll be a mile away - and barefoot.




More information about the wine-patches mailing list