Francois Gouget : advapi32/tests: Fix some Perflib subkey tests.
Alexandre Julliard
julliard at winehq.org
Wed Sep 1 15:45:09 CDT 2021
Module: wine
Branch: master
Commit: ab6edd0932c5f43abf9a6df1b55c67ab423a6353
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ab6edd0932c5f43abf9a6df1b55c67ab423a6353
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Wed Sep 1 08:52:19 2021 +0200
advapi32/tests: Fix some Perflib subkey tests.
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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/advapi32/tests/registry.c | 64 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 57 insertions(+), 7 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 5ed220095bb..b6f906fd689 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -3929,10 +3929,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);
@@ -4027,21 +4028,70 @@ 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);
+ if (is_special_key(key))
+ {
+ 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);
+ }
+ }
+ else
+ {
+ /* Windows 7 does not always return a special key for 009
+ * when running without elevated privileges.
+ */
+ ok(broken(l == 0), "expected a special handle, got %p\n", key);
+ }
+
+ ret = RegCloseKey(key);
+ ok(!ret, "got %u\n", ret);
+ }
+ winetest_pop_context();
+ }
- sprintf(lang_name, "%03x", primary_lang);
- if (primary_lang != LANG_ENGLISH)
+ /* 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);
More information about the wine-cvs
mailing list