Stefan Leichter wrote:
ChangeLog
add some tests for RegDeleteTreeA
Hi Stefan
good to see someone picked up this thing. I ran your new tests on Vista Ultimate and comments are below. (I ran the tests while bypassing UAC, as administrator).
--- ../wine-git/dlls/advapi32/tests/registry.c 2007-03-17 08:36:33.000000000 +0100 +++ dlls/advapi32/tests/registry.c 2007-04-01 14:00:12.000000000 +0200 @@ -35,6 +35,7 @@
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 @@
/* This function was introduced with Windows 2003 SP1 */ ADVAPI32_GET_PROC(RegGetValueA)
- ADVAPI32_GET_PROC(RegDeleteTreeA)
}
/* delete key and all its subkeys */ @@ -872,6 +874,53 @@ RegDeleteKeyA(subkey, ""); }
+static void test_reg_delete_tree(void) +{
- CHAR buffer[MAX_PATH];
- HKEY subkey, subkey2;
- LONG size, ret;
- if(!pRegDeleteTreeA) return;
Can you add a skip here?
- 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, "subkey", buffer, &size),
"Default value of subkey not longer present\n");
This test fails so it must mean the default value should have been deleted.
- 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, "subkey", buffer, &size),
"Default value of subkey not longer present\n");
This test fails so it must mean the default value should have been deleted.
- ret = pRegDeleteTreeA(subkey, NULL);
- ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
- ok(RegOpenKeyA(hkey_main, "subkey", &subkey),
"subkey was not deleted\n");
The subkey will not be deleted by RegDeleteTree (see MSDN). This is the main difference between RegDeleteTree and SHDeleteKey (where the main key is deleted).
- ret = pRegDeleteTreeA(hkey_main, "not-here");
- trace("deleting an not existing key returned %d\n", ret);
The answer to this one is 2 : ERROR_FILE_NOT_FOUND
+}
START_TEST(registry) { /* Load pointers for functions that are not available in all Windows versions */ @@ -901,6 +950,8 @@ set_privileges(SE_RESTORE_NAME, FALSE); }
- test_reg_delete_tree();
- /* cleanup */ delete_key( hkey_main );
Cheers,
Paul.