Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 7 +++++-- programs/reg/tests/reg_test.h | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index 36fa634796d..469f354de39 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -154,7 +154,7 @@ void delete_key_(const char *file, unsigned line, HKEY root, const char *path, R } }
-LONG delete_tree(HKEY root, const char *path, REGSAM sam) +LONG delete_tree_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam) { HKEY hkey; LONG ret; @@ -163,6 +163,7 @@ LONG delete_tree(HKEY root, const char *path, REGSAM sam) static const char empty[1];
ret = RegOpenKeyExA(root, path, 0, KEY_READ|sam, &hkey); + lok(!ret || ret == ERROR_FILE_NOT_FOUND, "RegOpenKeyExA failed, got error %d\n", ret); if (ret) return ret;
ret = RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, &max_subkey_len, @@ -184,7 +185,7 @@ LONG delete_tree(HKEY root, const char *path, REGSAM sam) ret = RegEnumKeyExA(hkey, 0, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); if (ret == ERROR_NO_MORE_ITEMS) break; if (ret) goto cleanup; - ret = delete_tree(hkey, subkey_name, sam); + ret = delete_tree_(file, line, hkey, subkey_name, sam); if (ret) goto cleanup; }
@@ -193,6 +194,8 @@ LONG delete_tree(HKEY root, const char *path, REGSAM sam) else ret = RegDeleteKeyExA(hkey, empty, sam, 0);
+ lok(!ret, "Failed to delete registry key, got error %d\n", ret); + cleanup: HeapFree(GetProcessHeap(), 0, subkey_name); RegCloseKey(hkey); diff --git a/programs/reg/tests/reg_test.h b/programs/reg/tests/reg_test.h index a5d7169beb4..3f64e552a19 100644 --- a/programs/reg/tests/reg_test.h +++ b/programs/reg/tests/reg_test.h @@ -64,7 +64,8 @@ void add_key_(const char *file, unsigned line, const HKEY root, const char *path #define delete_key(r,p,s) delete_key_(__FILE__,__LINE__,r,p,s) void delete_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
-LONG delete_tree(HKEY root, const char *path, REGSAM sam); +#define delete_tree(r,p,s) delete_tree_(__FILE__,__LINE__,r,p,s) +LONG delete_tree_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
#define add_value(k,n,t,d,s) add_value_(__FILE__,__LINE__,k,n,t,d,s) void add_value_(const char *file, unsigned line, HKEY hkey, const char *name,
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 1 - programs/reg/tests/copy.c | 27 --------------------------- programs/reg/tests/delete.c | 9 --------- programs/reg/tests/export.c | 1 - programs/reg/tests/import.c | 4 ---- programs/reg/tests/query.c | 1 - 6 files changed, 43 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index 469f354de39..2c1a2cf35e3 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -226,7 +226,6 @@ static void test_command_syntax(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg add", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); diff --git a/programs/reg/tests/copy.c b/programs/reg/tests/copy.c index c6a83e57276..e9542a67f5e 100644 --- a/programs/reg/tests/copy.c +++ b/programs/reg/tests/copy.c @@ -127,10 +127,7 @@ static void test_copy_empty_key(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, NULL);
@@ -192,10 +189,7 @@ static void test_copy_simple_data(void) DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey);
@@ -262,10 +256,7 @@ static void test_copy_complex_data(void) DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey);
@@ -331,10 +322,7 @@ static void test_copy_key_order(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); add_key(hkey, "Subkey2", 0, NULL); @@ -356,10 +344,7 @@ static void test_copy_value_order(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); add_value(hkey, "Value 2", REG_SZ, "I was added first!", 19); @@ -381,10 +366,7 @@ static void test_copy_hex_data(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Try copying empty hex values */ add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); @@ -450,10 +432,7 @@ static void test_copy_embedded_null_values(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" "[HKEY_CURRENT_USER\" COPY_SRC "]\n" @@ -483,10 +462,7 @@ static void test_copy_slashes(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); add_key(hkey, "https://winehq.org", 0, NULL); @@ -509,10 +485,7 @@ static void test_copy_escaped_null_values(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC, 0); - verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0); - delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); add_value(hkey, "Wine5a", REG_SZ, "\0", 3); diff --git a/programs/reg/tests/delete.c b/programs/reg/tests/delete.c index 0c313c12a31..2bc1abadfcb 100644 --- a/programs/reg/tests/delete.c +++ b/programs/reg/tests/delete.c @@ -24,7 +24,6 @@ static void test_command_syntax(void) DWORD r;
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg delete", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -85,7 +84,6 @@ static void test_delete(void) const DWORD deadbeef = 0xdeadbeef;
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Create a test key */ add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); @@ -184,7 +182,6 @@ static void test_registry_view_win32(void) if (!is_win32) return;
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); - verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
/* Test deletion from the 32-bit registry view (32-bit Windows) */ create_test_key(KEY_WOW64_32KEY); @@ -257,10 +254,7 @@ static void test_registry_view_win64(void) if (!is_win64) return;
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); - verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); - delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); - verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
/* Test deletion from the 32-bit registry view (64-bit Windows) */ create_test_key(KEY_WOW64_32KEY); @@ -336,10 +330,7 @@ static void test_registry_view_wow64(void) if (!is_wow64) return;
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); - verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); - delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); - verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
/* Test deletion from the 32-bit registry view (WOW64) */ create_test_key(KEY_WOW64_32KEY); diff --git a/programs/reg/tests/export.c b/programs/reg/tests/export.c index 0f48443384e..e32f750079e 100644 --- a/programs/reg/tests/export.c +++ b/programs/reg/tests/export.c @@ -177,7 +177,6 @@ static void test_export(void) BYTE hex[4], buffer[8];
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg export", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); diff --git a/programs/reg/tests/import.c b/programs/reg/tests/import.c index 2531ba336e8..ace45cf5984 100644 --- a/programs/reg/tests/import.c +++ b/programs/reg/tests/import.c @@ -102,7 +102,6 @@ static void test_import(void) BYTE hex[8];
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg import", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -1655,7 +1654,6 @@ static void test_unicode_import(void) BYTE hex[8];
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("REGEDIT\n", &r); ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */, @@ -3201,7 +3199,6 @@ static void test_import_with_whitespace(void) DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_str(" REGEDIT4\n\n" "[HKEY_CURRENT_USER\" KEY_BASE "]\n\n", &r); @@ -3347,7 +3344,6 @@ static void test_unicode_import_with_whitespace(void) DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n" "[HKEY_CURRENT_USER\" KEY_BASE "]\n\n", &r); diff --git a/programs/reg/tests/query.c b/programs/reg/tests/query.c index 590d322c37c..eca392b64d9 100644 --- a/programs/reg/tests/query.c +++ b/programs/reg/tests/query.c @@ -204,7 +204,6 @@ static void test_query(void) BYTE buf[512];
delete_tree(HKEY_CURRENT_USER, KEY_BASE, 0); - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Key not present */ run_reg_exe("reg query HKCU\" KEY_BASE, &r);
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/query.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/programs/reg/tests/query.c b/programs/reg/tests/query.c index eca392b64d9..dcc98a9a0c4 100644 --- a/programs/reg/tests/query.c +++ b/programs/reg/tests/query.c @@ -322,6 +322,12 @@ static const char *test9b = "\r\n" " Test4 REG_DWORD 0xabc\r\n" " Wine REG_SZ Second instance\r\n\r\n";
+static const char *test9c = "\r\n" + "HKEY_LOCAL_MACHINE\" KEY_BASE "\r\n" + " Wine REG_SZ First instance\r\n\r\n" + "HKEY_LOCAL_MACHINE\" KEY_BASE "\subkey\r\n" + " Wine REG_SZ Second instance\r\n\r\n"; + static void create_test_key(REGSAM sam) { HKEY hkey, subkey; @@ -367,6 +373,10 @@ static void test_registry_view_win32(void) ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test9b, FALSE, 0);
+ read_reg_output("reg query HKLM\" KEY_BASE " /v Wine /s /reg:32", buf, sizeof(buf), &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + compare_query(buf, test9c, TRUE, 0); + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
/* Try querying the 64-bit registry view, which doesn't exist on 32-bit Windows */ @@ -380,6 +390,10 @@ static void test_registry_view_win32(void) ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test9b, FALSE, 0);
+ read_reg_output("reg query HKLM\" KEY_BASE " /v Wine /s /reg:64", buf, sizeof(buf), &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + compare_query(buf, test9c, TRUE, 0); + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); }
@@ -407,6 +421,10 @@ static void test_registry_view_win64(void) todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test9b, FALSE, TODO_REG_COMPARE);
+ read_reg_output("reg query HKLM\" KEY_BASE " /v Wine /s /reg:32", buf, sizeof(buf), &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + compare_query(buf, test9c, TRUE, TODO_REG_COMPARE); + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
@@ -421,6 +439,10 @@ static void test_registry_view_win64(void) ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test9b, FALSE, 0);
+ read_reg_output("reg query HKLM\" KEY_BASE " /v Wine /s /reg:64", buf, sizeof(buf), &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + compare_query(buf, test9c, TRUE, 0); + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); }
@@ -447,6 +469,10 @@ static void test_registry_view_wow64(void) ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test9b, FALSE, 0);
+ read_reg_output("reg query HKLM\" KEY_BASE " /v Wine /s /reg:32", buf, sizeof(buf), &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + compare_query(buf, test9c, TRUE, 0); + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
@@ -461,6 +487,10 @@ static void test_registry_view_wow64(void) todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); compare_query(buf, test9b, FALSE, TODO_REG_COMPARE);
+ read_reg_output("reg query HKLM\" KEY_BASE " /v Wine /s /reg:64", buf, sizeof(buf), &r); + todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + compare_query(buf, test9c, TRUE, TODO_REG_COMPARE); + delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); }