Commit 9780dfc0 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg/tests: Modify verify_key_nonexist() to support registry views.

parent fdceb5ed
...@@ -109,14 +109,13 @@ void verify_key_(const char *file, unsigned line, HKEY root, const char *path, R ...@@ -109,14 +109,13 @@ void verify_key_(const char *file, unsigned line, HKEY root, const char *path, R
RegCloseKey(hkey); RegCloseKey(hkey);
} }
void verify_key_nonexist_(const char *file, unsigned line, HKEY key_base, const char *subkey) void verify_key_nonexist_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam)
{ {
HKEY hkey; HKEY hkey;
LONG err; LONG err;
err = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey); err = RegOpenKeyExA(root, path, 0, KEY_READ|sam, &hkey);
lok(err == ERROR_FILE_NOT_FOUND, "registry key '%s' shouldn't exist; got %d, expected 2\n", lok(err == ERROR_FILE_NOT_FOUND, "registry key '%s' shouldn't exist; got %d, expected 2\n", path, err);
subkey, err);
if (hkey) if (hkey)
RegCloseKey(hkey); RegCloseKey(hkey);
...@@ -221,7 +220,7 @@ static void test_command_syntax(void) ...@@ -221,7 +220,7 @@ static void test_command_syntax(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg add", &r); run_reg_exe("reg add", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
...@@ -287,11 +286,11 @@ static void test_key_formats(void) ...@@ -287,11 +286,11 @@ static void test_key_formats(void)
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r); run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
verify_key_nonexist(hkey, "keytest0"); verify_key_nonexist(hkey, "keytest0", 0);
run_reg_exe("reg add \\\\HKCU\\" KEY_BASE "\\keytest1 /f", &r); run_reg_exe("reg add \\\\HKCU\\" KEY_BASE "\\keytest1 /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
verify_key_nonexist(hkey, "keytest1"); verify_key_nonexist(hkey, "keytest1", 0);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r); run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
......
...@@ -127,10 +127,10 @@ static void test_copy_empty_key(void) ...@@ -127,10 +127,10 @@ static void test_copy_empty_key(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, NULL); add_key(HKEY_CURRENT_USER, COPY_SRC, NULL);
...@@ -192,10 +192,10 @@ static void test_copy_simple_data(void) ...@@ -192,10 +192,10 @@ static void test_copy_simple_data(void)
DWORD r, dword; DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
...@@ -262,10 +262,10 @@ static void test_copy_complex_data(void) ...@@ -262,10 +262,10 @@ static void test_copy_complex_data(void)
DWORD r, dword; DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
...@@ -331,10 +331,10 @@ static void test_copy_key_order(void) ...@@ -331,10 +331,10 @@ static void test_copy_key_order(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
add_key(hkey, "Subkey2", NULL); add_key(hkey, "Subkey2", NULL);
...@@ -356,10 +356,10 @@ static void test_copy_value_order(void) ...@@ -356,10 +356,10 @@ static void test_copy_value_order(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
add_value(hkey, "Value 2", REG_SZ, "I was added first!", 19); add_value(hkey, "Value 2", REG_SZ, "I was added first!", 19);
...@@ -381,10 +381,10 @@ static void test_copy_hex_data(void) ...@@ -381,10 +381,10 @@ static void test_copy_hex_data(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Try copying empty hex values */ /* Try copying empty hex values */
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
...@@ -450,10 +450,10 @@ static void test_copy_embedded_null_values(void) ...@@ -450,10 +450,10 @@ static void test_copy_embedded_null_values(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" COPY_SRC "]\n" "[HKEY_CURRENT_USER\\" COPY_SRC "]\n"
...@@ -483,10 +483,10 @@ static void test_copy_slashes(void) ...@@ -483,10 +483,10 @@ static void test_copy_slashes(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
add_key(hkey, "https://winehq.org", NULL); add_key(hkey, "https://winehq.org", NULL);
...@@ -509,10 +509,10 @@ static void test_copy_escaped_null_values(void) ...@@ -509,10 +509,10 @@ static void test_copy_escaped_null_values(void)
DWORD r; DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC); delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC); verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
add_value(hkey, "Wine5a", REG_SZ, "\\0", 3); add_value(hkey, "Wine5a", REG_SZ, "\\0", 3);
......
...@@ -26,7 +26,7 @@ static void test_delete(void) ...@@ -26,7 +26,7 @@ static void test_delete(void)
const DWORD deadbeef = 0xdeadbeef; const DWORD deadbeef = 0xdeadbeef;
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg delete", &r); run_reg_exe("reg delete", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
...@@ -97,7 +97,7 @@ static void test_delete(void) ...@@ -97,7 +97,7 @@ static void test_delete(void)
run_reg_exe("reg delete HKCU\\" KEY_BASE "\\https://winehq.org /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE "\\https://winehq.org /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_key_nonexist(hkey, "https://winehq.org"); verify_key_nonexist(hkey, "https://winehq.org", 0);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v count/up /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE " /v count/up /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
...@@ -127,7 +127,7 @@ static void test_delete(void) ...@@ -127,7 +127,7 @@ static void test_delete(void)
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r); run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
......
...@@ -177,7 +177,7 @@ static void test_export(void) ...@@ -177,7 +177,7 @@ static void test_export(void)
BYTE hex[4], buffer[8]; BYTE hex[4], buffer[8];
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg export", &r); run_reg_exe("reg export", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
......
...@@ -165,7 +165,7 @@ static void test_query(void) ...@@ -165,7 +165,7 @@ static void test_query(void)
BYTE buf[512]; BYTE buf[512];
delete_tree(HKEY_CURRENT_USER, KEY_BASE); delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg query", &r); run_reg_exe("reg query", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
......
...@@ -55,8 +55,8 @@ void close_key_(const char *file, unsigned line, HKEY hkey); ...@@ -55,8 +55,8 @@ void close_key_(const char *file, unsigned line, HKEY hkey);
#define verify_key(r,p,s) verify_key_(__FILE__,__LINE__,r,p,s) #define verify_key(r,p,s) verify_key_(__FILE__,__LINE__,r,p,s)
void verify_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam); void verify_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
#define verify_key_nonexist(k,s) verify_key_nonexist_(__FILE__,__LINE__,k,s) #define verify_key_nonexist(r,p,s) verify_key_nonexist_(__FILE__,__LINE__,r,p,s)
void verify_key_nonexist_(const char *file, unsigned line, HKEY key_base, const char *subkey); void verify_key_nonexist_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
#define add_key(k,p,s) add_key_(__FILE__,__LINE__,k,p,s) #define add_key(k,p,s) add_key_(__FILE__,__LINE__,k,p,s)
void add_key_(const char *file, unsigned line, const HKEY hkey, const char *path, HKEY *subkey); void add_key_(const char *file, unsigned line, const HKEY hkey, const char *path, HKEY *subkey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment