Commit f0686919 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg/tests: Modify delete_key() to support use of RegDeleteKeyEx().

parent 612c1b66
......@@ -138,15 +138,22 @@ void add_key_(const char *file, unsigned line, const HKEY hkey, const char *path
RegCloseKey(new_key);
}
void delete_key_(const char *file, unsigned line, const HKEY hkey, const char *path)
void delete_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam)
{
if (path && *path)
{
LONG err;
LONG err;
err = RegDeleteKeyA(hkey, path);
if (!path) return;
if (!sam)
{
err = RegDeleteKeyA(root, path);
lok(err == ERROR_SUCCESS, "RegDeleteKeyA failed: got error %d\n", err);
}
else
{
err = RegDeleteKeyExA(root, path, sam, 0);
lok(err == ERROR_SUCCESS, "RegDeleteKeyExA failed: got error %d\n", err);
}
}
LONG delete_tree(const HKEY key, const char *subkey)
......@@ -345,7 +352,7 @@ static void test_add(void)
verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Specifying a value name doesn't initialize the Default value in a new key */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v Test /t REG_SZ /d \"Just me here\" /f", &r);
......@@ -357,7 +364,7 @@ static void test_add(void)
verify_reg_nonexist(hkey, NULL);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
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);
......@@ -423,7 +430,7 @@ static void test_reg_none(void)
verify_reg(hkey, "none1", REG_NONE, "\0", 2, 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_reg_sz(void)
......@@ -501,7 +508,7 @@ static void test_reg_sz(void)
verify_reg(hkey, "\\foo\\bar", REG_SZ, "", 1, 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_reg_expand_sz(void)
......@@ -542,7 +549,7 @@ static void test_reg_expand_sz(void)
verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_reg_binary(void)
......@@ -606,7 +613,7 @@ static void test_reg_binary(void)
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_reg_dword(void)
......@@ -709,7 +716,7 @@ static void test_reg_dword(void)
verify_reg(hkey, "DWORD_LE", REG_DWORD_LITTLE_ENDIAN, &dword, sizeof(dword), 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
/* REG_DWORD_BIG_ENDIAN is broken in every version of Windows. It behaves
......@@ -742,7 +749,7 @@ static void test_reg_dword_big_endian(void)
verify_reg(hkey, "Test4", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_reg_multi_sz(void)
......@@ -841,7 +848,7 @@ static void test_reg_multi_sz(void)
verify_reg(hkey, "multi21", REG_MULTI_SZ, "two\\0\\0strings\0", 16, 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
START_TEST(add)
......
......@@ -143,7 +143,7 @@ static void test_copy_empty_key(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE " /f", &r);
......@@ -154,7 +154,7 @@ static void test_copy_empty_key(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE "\\ /f", &r);
......@@ -165,7 +165,7 @@ static void test_copy_empty_key(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE "\\ /f", &r);
......@@ -213,7 +213,7 @@ static void test_copy_simple_data(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE " /f", &r);
......@@ -224,7 +224,7 @@ static void test_copy_simple_data(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE "\\ /f", &r);
......@@ -235,7 +235,7 @@ static void test_copy_simple_data(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE "\\ /f", &r);
......@@ -406,8 +406,8 @@ static void test_copy_hex_data(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", empty_hex_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, COPY_SRC);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Try copying after importing alternative registry data types */
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -425,8 +425,8 @@ static void test_copy_hex_data(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", empty_hex_test2, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, COPY_SRC);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Try copying more complex hex data */
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -531,8 +531,8 @@ static void test_copy_escaped_null_values(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", escaped_null_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, COPY_SRC);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_copy_key_class(void)
......@@ -573,8 +573,8 @@ static void test_copy_key_class(void)
RegCloseKey(hkey);
delete_key(HKEY_CURRENT_USER, COPY_SRC);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_copy_overwrite(void)
......@@ -611,8 +611,8 @@ static void test_copy_overwrite(void)
verify_reg(hkey, NULL, REG_SZ, "Constant value", 15, 0);
close_key(hkey);
delete_key(HKEY_CURRENT_USER, COPY_SRC);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, COPY_SRC, 0);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
START_TEST(copy)
......
......@@ -297,8 +297,8 @@ static void test_export(void)
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);
ok(compare_export("file.reg", key_order_test, 0), "compare_export() failed\n");
delete_key(hkey, "Subkey1");
delete_key(hkey, "Subkey2");
delete_key(hkey, "Subkey1", 0);
delete_key(hkey, "Subkey2", 0);
/* Test the export order of registry values. Windows exports registry values
* in order of creation; Wine uses alphabetical order.
......@@ -310,7 +310,7 @@ static void test_export(void)
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);
ok(compare_export("file.reg", value_order_test, TODO_REG_COMPARE), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test registry export with empty hex data */
add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
......@@ -327,7 +327,7 @@ static void test_export(void)
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);
ok(compare_export("file.reg", empty_hex_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test registry export after importing alternative registry data types */
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -345,7 +345,7 @@ static void test_export(void)
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);
ok(compare_export("file.reg", empty_hex_test2, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -364,7 +364,7 @@ static void test_export(void)
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);
ok(compare_export("file.reg", hex_types_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test registry export with embedded null characters */
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -401,7 +401,7 @@ static void test_export(void)
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);
ok(compare_export("file.reg", embedded_null_test, 0), "compare_export() failed\n");
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
/* Test registry export with forward and back slashes */
add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
......
......@@ -860,7 +860,7 @@ static void test_import(void)
open_key(hkey, "Subkey\"1", 0, &subkey);
verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1", 0);
test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
......@@ -869,7 +869,7 @@ static void test_import(void)
open_key(hkey, "Subkey/2", 0, &subkey);
verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
close_key(subkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2", 0);
/* Test key creation */
test_import_str("REGEDIT4\n\n"
......@@ -896,13 +896,13 @@ static void test_import(void)
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1c ]\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_key(hkey, "Subkey1c ");
delete_key(hkey, "Subkey1c ");
delete_key(hkey, "Subkey1c ", 0);
test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1d\t]\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_key(hkey, "Subkey1d\t");
delete_key(hkey, "Subkey1d\t");
delete_key(hkey, "Subkey1d\t", 0);
test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1e\\]\n"
......@@ -913,7 +913,7 @@ static void test_import(void)
open_key(hkey, "Subkey1e", 0, &subkey);
verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(hkey, "Subkey1e");
delete_key(hkey, "Subkey1e", 0);
test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1f\\\\]\n"
......@@ -925,7 +925,7 @@ static void test_import(void)
open_key(hkey, "Subkey1f\\\\", 0, &subkey);
verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(hkey, "Subkey1f\\\\");
delete_key(hkey, "Subkey1f\\\\", 0);
test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1g\\\\\\\\]\n"
......@@ -938,7 +938,7 @@ static void test_import(void)
open_key(hkey, "Subkey1g\\\\", 0, &subkey);
verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(hkey, "Subkey1g\\\\");
delete_key(hkey, "Subkey1g\\\\", 0);
/* Test key deletion. We start by creating some registry keys. */
test_import_str("REGEDIT4\n\n"
......@@ -1183,7 +1183,7 @@ static void test_import(void)
verify_reg_nonexist(hkey, "Wine54b");
verify_key(hkey, "Subkey2");
delete_key(hkey, "Subkey2");
delete_key(hkey, "Subkey2", 0);
test_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -2399,7 +2399,7 @@ static void test_unicode_import(void)
open_key(hkey, "Subkey\"1", 0, &subkey);
verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1", 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
......@@ -2408,7 +2408,7 @@ static void test_unicode_import(void)
open_key(hkey, "Subkey/2", 0, &subkey);
verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
close_key(subkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2", 0);
/* Test key creation */
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -2435,13 +2435,13 @@ static void test_unicode_import(void)
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1c ]\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_key(hkey, "Subkey1c ");
delete_key(hkey, "Subkey1c ");
delete_key(hkey, "Subkey1c ", 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1d\t]\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_key(hkey, "Subkey1d\t");
delete_key(hkey, "Subkey1d\t");
delete_key(hkey, "Subkey1d\t", 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1e\\]\n"
......@@ -2452,7 +2452,7 @@ static void test_unicode_import(void)
open_key(hkey, "Subkey1e", 0, &subkey);
verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(hkey, "Subkey1e");
delete_key(hkey, "Subkey1e", 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1f\\\\]\n"
......@@ -2464,7 +2464,7 @@ static void test_unicode_import(void)
open_key(hkey, "Subkey1f\\\\", 0, &subkey);
verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(hkey, "Subkey1f\\\\");
delete_key(hkey, "Subkey1f\\\\", 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1g\\\\\\\\]\n"
......@@ -2477,7 +2477,7 @@ static void test_unicode_import(void)
open_key(hkey, "Subkey1g\\\\", 0, &subkey);
verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
close_key(subkey);
delete_key(hkey, "Subkey1g\\\\");
delete_key(hkey, "Subkey1g\\\\", 0);
/* Test key deletion. We start by creating some registry keys. */
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -2725,7 +2725,7 @@ static void test_unicode_import(void)
verify_reg_nonexist(hkey, "Wine54b");
verify_key(hkey, "Subkey2");
delete_key(hkey, "Subkey2");
delete_key(hkey, "Subkey2", 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -3315,7 +3315,7 @@ static void test_import_with_whitespace(void)
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_unicode_import_with_whitespace(void)
......@@ -3461,7 +3461,7 @@ static void test_unicode_import_with_whitespace(void)
close_key(hkey);
delete_key(HKEY_CURRENT_USER, KEY_BASE);
delete_key(HKEY_CURRENT_USER, KEY_BASE, 0);
}
static void test_import_win31(void)
......@@ -3585,7 +3585,7 @@ static void test_import_win31(void)
close_key(hkey);
delete_key(HKEY_CLASSES_ROOT, KEY_BASE);
delete_key(HKEY_CLASSES_ROOT, KEY_BASE, 0);
}
START_TEST(import)
......
......@@ -62,8 +62,8 @@ void verify_key_nonexist_(const char *file, unsigned line, HKEY key_base, const
#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 delete_key(k,p) delete_key_(__FILE__,__LINE__,k,p)
void delete_key_(const char *file, unsigned line, const HKEY hkey, 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(const HKEY key, const char *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