Author: tfaber
Date: Sat Oct 1 14:41:41 2016
New Revision: 72876
URL:
http://svn.reactos.org/svn/reactos?rev=72876&view=rev
Log:
[ADVAPI32_APITEST]
- Add a test for RegEnumKeyExW showing that it should return ERROR_MORE_DATA instead of
ERROR_BUFFER_OVERFLOW when the name buffer is too small. Based on a patch by Doug Lyons.
CORE-12030
Added:
trunk/rostests/apitests/advapi32/RegEnumKey.c (with props)
Modified:
trunk/rostests/apitests/advapi32/CMakeLists.txt
trunk/rostests/apitests/advapi32/testlist.c
Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
==============================================================================
--- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Sat Oct 1 14:41:41 2016
@@ -7,6 +7,7 @@
IsTextUnicode.c
LockDatabase.c
QueryServiceConfig2.c
+ RegEnumKey.c
RegEnumValueW.c
RegQueryInfoKey.c
RtlEncryptMemory.c
Added: trunk/rostests/apitests/advapi32/RegEnumKey.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/RegEnum…
==============================================================================
--- trunk/rostests/apitests/advapi32/RegEnumKey.c (added)
+++ trunk/rostests/apitests/advapi32/RegEnumKey.c [iso-8859-1] Sat Oct 1 14:41:41 2016
@@ -0,0 +1,86 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for the RegEnumKey API
+ * PROGRAMMER: Thomas Faber & Doug Lyons
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <winreg.h>
+
+START_TEST(RegEnumKey)
+{
+ LONG ErrorCode;
+ HKEY TestKey;
+ HKEY hKey;
+ WCHAR nameBuf[4];
+ DWORD nameLen;
+
+ /* Base key for our test */
+ ErrorCode = RegCreateKeyExW(HKEY_CURRENT_USER,
L"Software\\ReactOS_apitest", 0, NULL, 0, KEY_CREATE_SUB_KEY |
KEY_ENUMERATE_SUB_KEYS, NULL, &hKey, NULL);
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+
+ /* Create 1 char subkey */
+ ErrorCode = RegCreateKeyExW(hKey, L"1", 0, NULL, 0, READ_CONTROL, NULL,
&TestKey, NULL);
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+ RegCloseKey(TestKey);
+
+ /* Enumerate first key with space for 1 char */
+ nameLen = 1;
+ FillMemory(nameBuf, sizeof(nameBuf), 0x55);
+ ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
+ ok_dec(ErrorCode, ERROR_MORE_DATA);
+ ok_hex(nameBuf[0], 0x5555);
+ ok_hex(nameBuf[1], 0x5555);
+ ok_dec(nameLen, 1);
+
+ /* Enumerate first key with space for 2 chars */
+ nameLen = 2;
+ FillMemory(nameBuf, sizeof(nameBuf), 0x55);
+ ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+ ok_hex(nameBuf[0], L'1');
+ ok_hex(nameBuf[1], 0);
+ ok_hex(nameBuf[2], 0x5555);
+ ok_dec(nameLen, 1);
+
+ /* Delete the subkey */
+ ErrorCode = RegDeleteKeyW(hKey, L"1");
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+
+ /* Create 2 char subkey */
+ ErrorCode = RegCreateKeyExW(hKey, L"12", 0, NULL, 0, READ_CONTROL, NULL,
&TestKey, NULL);
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+ RegCloseKey(TestKey);
+
+ /* Enumerate first key with space for 2 chars */
+ FillMemory(nameBuf, sizeof(nameBuf), 0x55);
+ nameLen = 2;
+ ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
+ ok_dec(ErrorCode, ERROR_MORE_DATA);
+ ok_hex(nameBuf[0], 0x5555);
+ ok_hex(nameBuf[1], 0x5555);
+ ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen);
+
+ /* Enumerate first key with space for 3 chars */
+ FillMemory(nameBuf, sizeof(nameBuf), 0x55);
+ nameLen = 3;
+ ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+ ok_hex(nameBuf[0], L'1');
+ ok_hex(nameBuf[1], L'2');
+ ok_hex(nameBuf[2], 0);
+ ok_hex(nameBuf[3], 0x5555);
+ ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen);
+
+ /* Delete the subkey */
+ ErrorCode = RegDeleteKeyW(hKey, L"12");
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+
+ /* Delete our parent key */
+ ErrorCode = RegDeleteKeyW(hKey, L"");
+ ok_dec(ErrorCode, ERROR_SUCCESS);
+ RegCloseKey(hKey);
+}
Propchange: trunk/rostests/apitests/advapi32/RegEnumKey.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/advapi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
==============================================================================
--- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Sat Oct 1 14:41:41 2016
@@ -10,6 +10,7 @@
extern void func_IsTextUnicode(void);
extern void func_LockDatabase(void);
extern void func_QueryServiceConfig2(void);
+extern void func_RegEnumKey(void);
extern void func_RegEnumValueW(void);
extern void func_RegQueryInfoKey(void);
extern void func_RtlEncryptMemory(void);
@@ -24,6 +25,7 @@
{ "IsTextUnicode" , func_IsTextUnicode },
{ "LockDatabase" , func_LockDatabase },
{ "QueryServiceConfig2", func_QueryServiceConfig2 },
+ { "RegEnumKey", func_RegEnumKey },
{ "RegEnumValueW", func_RegEnumValueW },
{ "RegQueryInfoKey", func_RegQueryInfoKey },
{ "RtlEncryptMemory", func_RtlEncryptMemory },