Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/reg/tests/add.c | 30 +++++++++++++-------------- programs/reg/tests/copy.c | 38 +++++++++++++++++------------------ programs/reg/tests/delete.c | 6 +++--- programs/reg/tests/export.c | 28 +++++++++++++------------- programs/reg/tests/query.c | 14 ++++++------- programs/reg/tests/reg_test.h | 4 ++-- 6 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index 48e33f6564a..384eb9012c7 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -121,17 +121,17 @@ void verify_key_nonexist_(const char *file, unsigned line, HKEY root, const char RegCloseKey(hkey); }
-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 root, const char *path, REGSAM sam, HKEY *hkey) { LONG err; HKEY new_key;
- err = RegCreateKeyExA(hkey, path, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ|KEY_WRITE, NULL, &new_key, NULL); + err = RegCreateKeyExA(root, path, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_READ|KEY_WRITE|sam, NULL, &new_key, NULL); lok(err == ERROR_SUCCESS, "RegCreateKeyExA failed: got error %d\n", err);
- if (subkey) - *subkey = new_key; + if (hkey) + *hkey = new_key; else RegCloseKey(new_key); } @@ -282,7 +282,7 @@ static void test_key_formats(void) DWORD r; LONG err;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add \HKCU\" KEY_BASE "\keytest0 /f", &r); ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r); @@ -365,7 +365,7 @@ static void test_add(void) delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Adding a registry key via WinAPI doesn't initialize the Default value... */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); verify_reg_nonexist(hkey, NULL);
/* ... but we can add it without passing [/f] to reg.exe */ @@ -375,7 +375,7 @@ static void test_add(void) delete_value(hkey, NULL);
/* Test whether overwriting a registry key modifies existing keys and values */ - add_key(hkey, "Subkey", NULL); + add_key(hkey, "Subkey", 0, NULL); add_value(hkey, "Test1", REG_SZ, "Value1", 7); dword = 0x123; add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword)); @@ -407,7 +407,7 @@ static void test_reg_none(void) HKEY hkey; DWORD r;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_NONE /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -436,7 +436,7 @@ static void test_reg_sz(void) HKEY hkey; DWORD r;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); @@ -514,7 +514,7 @@ static void test_reg_expand_sz(void) HKEY hkey; DWORD r;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_EXPAND_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); @@ -557,7 +557,7 @@ static void test_reg_binary(void) char buffer[22]; LONG err;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_BINARY /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); @@ -620,7 +620,7 @@ static void test_reg_dword(void) DWORD r, dword, type, size; LONG err;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r); ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */), @@ -734,7 +734,7 @@ static void test_reg_dword_big_endian(void) run_reg_exe("reg add HKCU\" KEY_BASE " /v Test2 /t REG_DWORD_BIG_ENDIAN /f", &r); ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d, expected 1\n", r);
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /v Test3 /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -755,7 +755,7 @@ static void test_reg_multi_sz(void) HKEY hkey; DWORD r;
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg add HKCU\" KEY_BASE " /t REG_MULTI_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); diff --git a/programs/reg/tests/copy.c b/programs/reg/tests/copy.c index 5573dd58acc..2b461c17f5e 100644 --- a/programs/reg/tests/copy.c +++ b/programs/reg/tests/copy.c @@ -132,7 +132,7 @@ static void test_copy_empty_key(void) delete_tree(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, 0, NULL);
run_reg_exe("reg copy HKCU\" COPY_SRC " HKCU\" KEY_BASE " /f", &r); @@ -197,7 +197,7 @@ static void test_copy_simple_data(void) delete_tree(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, 0, &hkey);
dword = 0x100; add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword)); @@ -267,38 +267,38 @@ static void test_copy_complex_data(void) delete_tree(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, 0, &hkey);
dword = 0x100; add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword)); add_value(hkey, "String", REG_SZ, "Your text here...", 18);
- add_key(hkey, "Subkey1", &subkey); + add_key(hkey, "Subkey1", 0, &subkey); add_value(subkey, "Binary", REG_BINARY, "\x11\x22\x33\x44", 4); add_value(subkey, "Undefined hex", 0x100, "%PATH%", 7); close_key(subkey);
- add_key(hkey, "Subkey2a", &subkey); + add_key(hkey, "Subkey2a", 0, &subkey); add_value(subkey, "double"quote", REG_SZ, ""Hello, World!"", 16); dword = 0x8; add_value(subkey, "single'quote", REG_DWORD, &dword, sizeof(dword)); close_key(subkey);
- add_key(hkey, "Subkey2a\Subkey2b", &subkey); + add_key(hkey, "Subkey2a\Subkey2b", 0, &subkey); add_value(subkey, NULL, REG_SZ, "Default value name", 19); add_value(subkey, "Multiple strings", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19); close_key(subkey);
- add_key(hkey, "Subkey3a", &subkey); + add_key(hkey, "Subkey3a", 0, &subkey); add_value(subkey, "Backslash", REG_SZ, "Use \\ to escape a backslash", 29); close_key(subkey);
- add_key(hkey, "Subkey3a\Subkey3b\Subkey3c", &subkey); + add_key(hkey, "Subkey3a\Subkey3b\Subkey3c", 0, &subkey); add_value(subkey, "String expansion", REG_EXPAND_SZ, "%HOME%\%PATH%", 14); add_value(subkey, "Zero data type", REG_NONE, "Value", 6); close_key(subkey);
- add_key(hkey, "Subkey4", &subkey); + add_key(hkey, "Subkey4", 0, &subkey); dword = 0x12345678; add_value(subkey, NULL, REG_DWORD, &dword, sizeof(dword)); add_value(subkey, "43981", 0xabcd, "Value", 6); @@ -336,9 +336,9 @@ static void test_copy_key_order(void) delete_tree(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, "Subkey2", NULL); - add_key(hkey, "Subkey1", NULL); + add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); + add_key(hkey, "Subkey2", 0, NULL); + add_key(hkey, "Subkey1", 0, NULL); close_key(hkey);
run_reg_exe("reg copy HKCU\" COPY_SRC " HKCU\" KEY_BASE " /s /f", &r); @@ -361,7 +361,7 @@ static void test_copy_value_order(void) delete_tree(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, 0, &hkey); add_value(hkey, "Value 2", REG_SZ, "I was added first!", 19); add_value(hkey, "Value 1", REG_SZ, "I was added second!", 20); close_key(hkey); @@ -387,7 +387,7 @@ static void test_copy_hex_data(void) verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Try copying empty hex values */ - add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); + add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); add_value(hkey, "Wine1a", REG_NONE, NULL, 0); add_value(hkey, "Wine1b", REG_SZ, NULL, 0); add_value(hkey, "Wine1c", REG_EXPAND_SZ, NULL, 0); @@ -488,8 +488,8 @@ static void test_copy_slashes(void) delete_tree(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, "https://winehq.org", NULL); + add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); + add_key(hkey, "https://winehq.org", 0, NULL); add_value(hkey, "count/up", REG_SZ, "one/two/three", 14); add_value(hkey, "\foo\bar", REG_SZ, "", 1); close_key(hkey); @@ -514,7 +514,7 @@ static void test_copy_escaped_null_values(void) delete_tree(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, 0, &hkey); add_value(hkey, "Wine5a", REG_SZ, "\0", 3); add_value(hkey, "Wine5b", REG_SZ, "\0\0", 5); add_value(hkey, "Wine5c", REG_SZ, "Value1\0", 9); @@ -582,7 +582,7 @@ static void test_copy_overwrite(void) HKEY hkey; DWORD r, dword;
- add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey); + add_key(HKEY_CURRENT_USER, COPY_SRC, 0, &hkey); add_value(hkey, "Wine1", REG_SZ, "def", 4); dword = 0x5; add_value(hkey, "Wine2", REG_DWORD, &dword, sizeof(dword)); @@ -590,7 +590,7 @@ static void test_copy_overwrite(void) add_value(hkey, "Wine4", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19); close_key(hkey);
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); add_value(hkey, "Wine1", REG_SZ, "abc", 4); verify_reg_nonexist(hkey, "Wine2"); add_value(hkey, "Wine3", REG_EXPAND_SZ, "%HOME%\%PATH%", 14); diff --git a/programs/reg/tests/delete.c b/programs/reg/tests/delete.c index e84d78808ca..22c5e867461 100644 --- a/programs/reg/tests/delete.c +++ b/programs/reg/tests/delete.c @@ -70,12 +70,12 @@ static void test_delete(void) ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
/* Create a test key */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); add_value(hkey, "foo", REG_DWORD, &deadbeef, sizeof(deadbeef)); add_value(hkey, "bar", REG_DWORD, &deadbeef, sizeof(deadbeef)); add_value(hkey, NULL, REG_DWORD, &deadbeef, sizeof(deadbeef));
- add_key(hkey, "subkey", NULL); + add_key(hkey, "subkey", 0, NULL);
run_reg_exe("reg delete HKCU\" KEY_BASE " /v bar /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -91,7 +91,7 @@ static void test_delete(void) verify_key(hkey, "subkey", 0);
/* Test forward and back slashes */ - add_key(hkey, "https://winehq.org", NULL); + add_key(hkey, "https://winehq.org", 0, NULL); add_value(hkey, "count/up", REG_SZ, "one/two/three", 14); add_value(hkey, "\foo\bar", REG_SZ, "", 1);
diff --git a/programs/reg/tests/export.c b/programs/reg/tests/export.c index 24a5dbd2405..df44baddb30 100644 --- a/programs/reg/tests/export.c +++ b/programs/reg/tests/export.c @@ -219,7 +219,7 @@ static void test_export(void) ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
/* Test registry export with an empty key */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
run_reg_exe("reg export HKEY_CURRENT_USER\" KEY_BASE " file.reg", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -251,32 +251,32 @@ static void test_export(void) ok(compare_export("foo", simple_data_test, 0), "compare_export() failed\n");
/* Test registry export with a complex data structure */ - add_key(hkey, "Subkey1", &subkey); + add_key(hkey, "Subkey1", 0, &subkey); add_value(subkey, "Binary", REG_BINARY, "\x11\x22\x33\x44", 4); add_value(subkey, "Undefined hex", 0x100, "%PATH%", 7); close_key(subkey);
- add_key(hkey, "Subkey2a", &subkey); + add_key(hkey, "Subkey2a", 0, &subkey); add_value(subkey, "double"quote", REG_SZ, ""Hello, World!"", 16); dword = 0x8; add_value(subkey, "single'quote", REG_DWORD, &dword, sizeof(dword)); close_key(subkey);
- add_key(hkey, "Subkey2a\Subkey2b", &subkey); + add_key(hkey, "Subkey2a\Subkey2b", 0, &subkey); add_value(subkey, NULL, REG_SZ, "Default value name", 19); add_value(subkey, "Multiple strings", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19); close_key(subkey);
- add_key(hkey, "Subkey3a", &subkey); + add_key(hkey, "Subkey3a", 0, &subkey); add_value(subkey, "Backslash", REG_SZ, "Use \\ to escape a backslash", 29); close_key(subkey);
- add_key(hkey, "Subkey3a\Subkey3b\Subkey3c", &subkey); + add_key(hkey, "Subkey3a\Subkey3b\Subkey3c", 0, &subkey); add_value(subkey, "String expansion", REG_EXPAND_SZ, "%HOME%\%PATH%", 14); add_value(subkey, "Zero data type", REG_NONE, "Value", 6); close_key(subkey);
- add_key(hkey, "Subkey4", &subkey); + add_key(hkey, "Subkey4", 0, &subkey); dword = 0x12345678; add_value(subkey, NULL, REG_DWORD, &dword, sizeof(dword)); add_value(subkey, "43981", 0xabcd, "Value", 6); @@ -290,9 +290,9 @@ static void test_export(void) delete_tree(HKEY_CURRENT_USER, KEY_BASE);
/* Test the export order of registry keys */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); - add_key(hkey, "Subkey2", NULL); - add_key(hkey, "Subkey1", NULL); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); + add_key(hkey, "Subkey2", 0, NULL); + add_key(hkey, "Subkey1", 0, NULL);
run_reg_exe("reg export HKEY_CURRENT_USER\" KEY_BASE " file.reg /y", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -313,7 +313,7 @@ static void test_export(void) delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test registry export with empty hex data */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); add_value(hkey, "Wine1a", REG_NONE, NULL, 0); add_value(hkey, "Wine1b", REG_SZ, NULL, 0); add_value(hkey, "Wine1c", REG_EXPAND_SZ, NULL, 0); @@ -404,8 +404,8 @@ static void test_export(void) delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test registry export with forward and back slashes */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); - add_key(hkey, "https://winehq.org", NULL); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); + add_key(hkey, "https://winehq.org", 0, NULL); add_value(hkey, "count/up", REG_SZ, "one/two/three", 14); add_value(hkey, "\foo\bar", REG_SZ, "", 1); close_key(hkey); @@ -416,7 +416,7 @@ static void test_export(void) delete_tree(HKEY_CURRENT_USER, KEY_BASE);
/* Test escaped null characters */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); add_value(hkey, "Wine5a", REG_SZ, "\0", 3); add_value(hkey, "Wine5b", REG_SZ, "\0\0", 5); add_value(hkey, "Wine5c", REG_SZ, "Value1\0", 9); diff --git a/programs/reg/tests/query.c b/programs/reg/tests/query.c index 4754c2bf05f..3e8b134363b 100644 --- a/programs/reg/tests/query.c +++ b/programs/reg/tests/query.c @@ -184,7 +184,7 @@ static void test_query(void) ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
/* Create a test key */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); add_value(hkey, "Test1", REG_SZ, "Hello, World", 13); add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword));
@@ -221,7 +221,7 @@ static void test_query(void) add_value(hkey, "Wine", REG_SZ, "First instance", 15);
/* Create a test subkey */ - add_key(hkey, "subkey", &subkey); + add_key(hkey, "subkey", 0, &subkey);
read_reg_output("reg query HKCU\" KEY_BASE, buf, sizeof(buf), &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -273,11 +273,11 @@ static void test_query(void) delete_tree(HKEY_CURRENT_USER, KEY_BASE);
/* Subkeys only */ - add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); - add_key(hkey, "subkey1", NULL); - add_key(hkey, "subkey2", NULL); - add_key(hkey, "subkey3", NULL); - add_key(hkey, "subkey4", NULL); + add_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey); + add_key(hkey, "subkey1", 0, NULL); + add_key(hkey, "subkey2", 0, NULL); + add_key(hkey, "subkey3", 0, NULL); + add_key(hkey, "subkey4", 0, NULL); close_key(hkey);
read_reg_output("reg query HKCU\" KEY_BASE, buf, sizeof(buf), &r); diff --git a/programs/reg/tests/reg_test.h b/programs/reg/tests/reg_test.h index 1f57a3e9596..db525619978 100644 --- a/programs/reg/tests/reg_test.h +++ b/programs/reg/tests/reg_test.h @@ -58,8 +58,8 @@ void verify_key_(const char *file, unsigned line, HKEY root, const char *path, R #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 root, const char *path, REGSAM sam);
-#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); +#define add_key(r,p,s,k) add_key_(__FILE__,__LINE__,r,p,s,k) +void add_key_(const char *file, unsigned line, const HKEY root, const char *path, REGSAM sam, HKEY *hkey);
#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);