[PATCH] advapi32/tests: Fix some Perflib subkey tests.

Francois Gouget fgouget at codeweavers.com
Mon Aug 16 10:46:33 CDT 2021


Some languages don't have a subkey (e.g. German), and for others the
subkey is the full language id rather than the primary language id (e.g.
Portuguese).
Furthermore there should be a CurrentLanguage key with localized values.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This should fix the failures on w7u-pt-PT.
https://test.winehq.org/data/patterns.html#advapi32:registry
---
 dlls/advapi32/tests/registry.c | 56 +++++++++++++++++++++++++++++-----
 1 file changed, 49 insertions(+), 7 deletions(-)

diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index bccc5706131..85be22bd74e 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -3928,10 +3928,11 @@ static void test_perflib_key(void)
     HKEY perflib_key, key, key2;
     OBJECT_ATTRIBUTES attr;
     UNICODE_STRING string;
-    char lang_name[4];
+    char lang_name[5];
+    const char *knames[2] = {"009", "CurrentLanguage"};
     char *buffer;
     DWORD size;
-    LONG ret;
+    LONG ret, l;
 
     ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
             "Software\\Microsoft\\Windows NT\\CurrentVersion\\Perflib", 0, KEY_READ, &perflib_key);
@@ -4026,21 +4027,62 @@ static void test_perflib_key(void)
     else
         ok(!ret, "got %#x\n", ret);
 
-    /* multilingual support was not really completely thought through */
+    for (l = 0; l < ARRAY_SIZE(knames); l++)
+    {
+        winetest_push_context("%d", l);
+      todo_wine_if(l == 1) {
+        ret = RegOpenKeyExA(perflib_key, knames[l], 0, KEY_READ, &key);
+        ok(!ret, "got %u\n", ret);
+        ok(is_special_key(key), "expected a special handle, got %p\n", key);
 
-    sprintf(lang_name, "%03x", primary_lang);
-    if (primary_lang != LANG_ENGLISH)
+        size = buffer_size;
+        ret = RegQueryValueExA(key, "counter", NULL, NULL, (BYTE *)buffer, &size);
+        ok(!ret, "got %u\n", ret);
+        if (!ret)
+        {
+            char *str;
+            int c = 0;
+            for (str = buffer; *str; str += strlen(str) + 1)
+                c++;
+            /* Note that the two keys may not have the same number of entries
+             * if they are in different languages.
+             */
+            ok(c >= 2 && (c % 2) == 0, "%d is not a valid number of entries in %s\n", c, knames[l]);
+            trace("%s has %d entries\n", knames[l], c);
+        }
+
+        ret = RegCloseKey(key);
+        ok(!ret, "got %u\n", ret);
+      }
+        winetest_pop_context();
+    }
+
+    /* multilingual support was not really completely thought through */
+    switch (primary_lang)
+    {
+    case LANG_PORTUGUESE:
+    case LANG_CHINESE:
+        sprintf(lang_name, "%04x", GetUserDefaultLangID());
+        break;
+    default:
+        sprintf(lang_name, "%03x", primary_lang);
+        break;
+    }
+    if (primary_lang != LANG_ENGLISH &&
+        !RegOpenKeyExA(perflib_key, lang_name, 0, KEY_READ, &key))
     {
-        ret = RegOpenKeyExA(perflib_key, lang_name, 0, KEY_READ, &key);
-        todo_wine ok(!ret, "got %u\n", ret);
         ok(!is_special_key(key), "expected a normal handle, got %p\n", key);
 
+        size = buffer_size;
         ret = RegQueryValueExA(key, "counter", NULL, NULL, (BYTE *)buffer, &size);
         todo_wine ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret);
 
         ret = RegCloseKey(key);
         todo_wine ok(!ret, "got %u\n", ret);
     }
+    /* else some languages don't have their own key. The keys are not really
+     * usable anyway so assume it does not really matter.
+     */
 
     ret = RegCloseKey(perflib_key);
     ok(!ret, "got %u\n", ret);
-- 
2.20.1




More information about the wine-devel mailing list