From 405853adb53695c0fd3f7d38ac733dd6900a48dd Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mon, 22 Feb 2021 17:29:57 +1100 Subject: [PATCH] reg/tests: Ensure test key is fully removed before each sequence begins. Signed-off-by: Hugh McMaster Signed-off-by: Alexandre Julliard --- programs/reg/tests/reg.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c index 4be9e635ed7..e11e4e9227e 100644 --- a/programs/reg/tests/reg.c +++ b/programs/reg/tests/reg.c @@ -222,6 +222,9 @@ static void test_add(void) DWORD r, dword, type, size; char buffer[22]; + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); + run_reg_exe("reg add", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -234,11 +237,6 @@ static void test_add(void) run_reg_exe("reg add -H", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); - - verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); - run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -602,12 +600,11 @@ static void test_add(void) static void test_delete(void) { HKEY hkey, hsubkey; - LONG err; DWORD r; const DWORD deadbeef = 0xdeadbeef; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); run_reg_exe("reg delete", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -664,8 +661,8 @@ static void test_query(void) const DWORD dword1 = 0x123; const DWORD dword2 = 0xabc; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); run_reg_exe("reg query", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -858,8 +855,8 @@ static void test_import(void) LONG err; BYTE hex[8]; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); run_reg_exe("reg import", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -2387,8 +2384,8 @@ static void test_unicode_import(void) char buffer[24]; BYTE hex[8]; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); test_import_wstr("REGEDIT\n", &r); ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */, @@ -3910,8 +3907,8 @@ static void test_import_with_whitespace(void) DWORD r, dword; LONG err; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); test_import_str(" REGEDIT4\n\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n\n", &r); @@ -4058,8 +4055,8 @@ static void test_unicode_import_with_whitespace(void) DWORD r, dword; LONG err; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); test_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n\n", &r); @@ -4453,8 +4450,8 @@ static void test_export(void) "\"Wine4g\"=\"Value2\"\r\n" "\"Wine4h\"=\"abc\"\r\n\r\n"; - err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE); - ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); run_reg_exe("reg export", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); @@ -4691,6 +4688,9 @@ static void test_copy(void) { DWORD r; + delete_tree(HKEY_CURRENT_USER, KEY_BASE); + verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); + run_reg_exe("reg copy", &r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);