From 5a0796af64d474437f7c26620efe6560f8961b55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 29 May 2017 01:59:36 +0200
Subject: advapi32/tests: Add test for perflib registry key.

---
 dlls/advapi32/tests/registry.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index ddde9059222..f6b7736c83c 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -3293,6 +3293,38 @@ static void test_classesroot_mask(void)
     RegCloseKey( hkey );
 }
 
+static void test_perflib_key(void)
+{
+    DWORD size;
+    LONG ret;
+    HKEY key;
+
+    ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009", &key);
+    ok(ret == ERROR_SUCCESS, "RegOpenKeyA failed with error %u\n", ret);
+
+    ret = RegQueryValueExA(key, "Counter", NULL, NULL, NULL, &size);
+    if (ret != ERROR_SUCCESS)
+    {
+        skip("Perflib\\009\\Counter does not exist, skipping perflib test\n");
+        goto done;
+    }
+    ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
+
+    /* Windows only compares the first few characters of the value name.
+     * On Windows XP / 2003, it is sufficient to use "Cou", newer versions
+     * require a longer substring. */
+
+    ret = RegQueryValueExA(key, "Counters", NULL, NULL, NULL, &size);
+    ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
+    ret = RegQueryValueExA(key, "Counter2", NULL, NULL, NULL, &size);
+    todo_wine ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
+    ret = RegQueryValueExA(key, "CounterWine", NULL, NULL, NULL, &size);
+    todo_wine ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
+
+done:
+    RegCloseKey(key);
+}
+
 static void test_deleted_key(void)
 {
     HKEY hkey, hkey2;
@@ -3741,6 +3773,7 @@ START_TEST(registry)
     test_classesroot();
     test_classesroot_enum();
     test_classesroot_mask();
+    test_perflib_key();
     test_reg_save_key();
     test_reg_load_key();
     test_reg_unload_key();
-- 
2.12.2

