advapi32: Add some tests for RegDeleteTreeA.
This commit is contained in:
parent
6230222aab
commit
0dcf196001
|
@ -35,6 +35,7 @@ static const char * sTestpath2 = "%FOO%\\subdir1";
|
|||
|
||||
static HMODULE hadvapi32;
|
||||
static DWORD (WINAPI *pRegGetValueA)(HKEY,LPCSTR,LPCSTR,DWORD,LPDWORD,PVOID,LPDWORD);
|
||||
static DWORD (WINAPI *pRegDeleteTreeA)(HKEY,LPCSTR);
|
||||
|
||||
#define ADVAPI32_GET_PROC(func) \
|
||||
p ## func = (void*)GetProcAddress(hadvapi32, #func); \
|
||||
|
@ -47,6 +48,7 @@ static void InitFunctionPtrs(void)
|
|||
|
||||
/* This function was introduced with Windows 2003 SP1 */
|
||||
ADVAPI32_GET_PROC(RegGetValueA)
|
||||
ADVAPI32_GET_PROC(RegDeleteTreeA)
|
||||
}
|
||||
|
||||
/* delete key and all its subkeys */
|
||||
|
@ -892,6 +894,62 @@ cleanup:
|
|||
RegCloseKey(subkey);
|
||||
}
|
||||
|
||||
static void test_reg_delete_tree(void)
|
||||
{
|
||||
CHAR buffer[MAX_PATH];
|
||||
HKEY subkey, subkey2;
|
||||
LONG size, ret;
|
||||
|
||||
if(!pRegDeleteTreeA) {
|
||||
skip("Skipping RegDeleteTreeA tests, function not present\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = RegCreateKeyA(hkey_main, "subkey", &subkey);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ret = RegCreateKeyA(subkey, "subkey2", &subkey2);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ret = RegSetValueA(subkey, NULL, REG_SZ, "data", 4);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ret = RegSetValueA(subkey2, NULL, REG_SZ, "data2", 5);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ret = RegCloseKey(subkey2);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
|
||||
ret = pRegDeleteTreeA(subkey, "subkey2");
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ok(RegOpenKeyA(subkey, "subkey2", &subkey2),
|
||||
"subkey2 was not deleted\n");
|
||||
size = MAX_PATH;
|
||||
ok(!RegQueryValueA(subkey, NULL, buffer, &size),
|
||||
"Default value of subkey not longer present\n");
|
||||
|
||||
ret = RegCreateKeyA(subkey, "subkey2", &subkey2);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ret = RegCloseKey(subkey2);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ret = pRegDeleteTreeA(hkey_main, "subkey\\subkey2");
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ok(RegOpenKeyA(subkey, "subkey2", &subkey2),
|
||||
"subkey2 was not deleted\n");
|
||||
ok(!RegQueryValueA(subkey, NULL, buffer, &size),
|
||||
"Default value of subkey not longer present\n");
|
||||
|
||||
ret = pRegDeleteTreeA(subkey, NULL);
|
||||
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
|
||||
ok(!RegOpenKeyA(hkey_main, "subkey", &subkey),
|
||||
"subkey was deleted\n");
|
||||
ret = RegQueryValueA(subkey, NULL, buffer, &size);
|
||||
ok(ret == ERROR_SUCCESS,
|
||||
"Default value of subkey is not present\n");
|
||||
ok(!lstrlenA(buffer),
|
||||
"Expected length 0 got length %u(%s)\n", lstrlenA(buffer), buffer);
|
||||
|
||||
ret = pRegDeleteTreeA(hkey_main, "not-here");
|
||||
ok(ret == ERROR_FILE_NOT_FOUND,
|
||||
"Expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
|
||||
}
|
||||
|
||||
START_TEST(registry)
|
||||
{
|
||||
/* Load pointers for functions that are not available in all Windows versions */
|
||||
|
@ -921,6 +979,8 @@ START_TEST(registry)
|
|||
set_privileges(SE_RESTORE_NAME, FALSE);
|
||||
}
|
||||
|
||||
test_reg_delete_tree();
|
||||
|
||||
/* cleanup */
|
||||
delete_key( hkey_main );
|
||||
|
||||
|
|
Loading…
Reference in New Issue