reg/tests: Remove write_reg_file() and rewrite associated tests.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6f52f666e5
commit
d75e38c718
|
@ -778,29 +778,6 @@ static void test_v_flags(void)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL write_reg_file(const char *value, char *tmp_name)
|
|
||||||
{
|
|
||||||
static const char regedit4[] = "REGEDIT4";
|
|
||||||
static const char key[] = "[HKEY_CURRENT_USER\\" KEY_BASE "]";
|
|
||||||
char file_data[MAX_PATH], tmp_path[MAX_PATH];
|
|
||||||
HANDLE hfile;
|
|
||||||
DWORD written;
|
|
||||||
BOOL ret;
|
|
||||||
|
|
||||||
sprintf(file_data, "%s\n\n%s\n%s\n", regedit4, key, value);
|
|
||||||
|
|
||||||
GetTempPathA(MAX_PATH, tmp_path);
|
|
||||||
GetTempFileNameA(tmp_path, "reg", 0, tmp_name);
|
|
||||||
|
|
||||||
hfile = CreateFileA(tmp_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
|
||||||
if (hfile == INVALID_HANDLE_VALUE)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
ret = WriteFile(hfile, file_data, strlen(file_data), &written, NULL);
|
|
||||||
CloseHandle(hfile);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL write_file(const void *str, DWORD size)
|
static BOOL write_file(const void *str, DWORD size)
|
||||||
{
|
{
|
||||||
HANDLE file;
|
HANDLE file;
|
||||||
|
@ -857,8 +834,7 @@ static BOOL import_reg(unsigned line, const char *contents, BOOL unicode, DWORD
|
||||||
static void test_import(void)
|
static void test_import(void)
|
||||||
{
|
{
|
||||||
DWORD r, dword = 0x123, type, size;
|
DWORD r, dword = 0x123, type, size;
|
||||||
char test1_reg[MAX_PATH], test2_reg[MAX_PATH], cmdline[MAX_PATH];
|
char buffer[24];
|
||||||
char test_string[] = "Test string", buffer[24];
|
|
||||||
HKEY hkey, subkey = NULL;
|
HKEY hkey, subkey = NULL;
|
||||||
LONG err;
|
LONG err;
|
||||||
BYTE hex[8];
|
BYTE hex[8];
|
||||||
|
@ -875,35 +851,9 @@ static void test_import(void)
|
||||||
run_reg_exe("reg import missing.reg", &r);
|
run_reg_exe("reg import missing.reg", &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);
|
||||||
|
|
||||||
/* Create test files */
|
run_reg_exe("reg import a.reg b.reg", &r);
|
||||||
ok(write_reg_file("\"Wine\"=dword:00000123", test1_reg), "Failed to write registry file\n");
|
|
||||||
ok(write_reg_file("@=\"Test string\"", test2_reg), "Failed to write registry file\n");
|
|
||||||
|
|
||||||
sprintf(cmdline, "reg import %s", test1_reg);
|
|
||||||
run_reg_exe(cmdline, &r);
|
|
||||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
|
||||||
|
|
||||||
sprintf(cmdline, "reg import %s", test2_reg);
|
|
||||||
run_reg_exe(cmdline, &r);
|
|
||||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
|
||||||
|
|
||||||
open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
|
|
||||||
|
|
||||||
verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
|
|
||||||
verify_reg(hkey, "", REG_SZ, test_string, sizeof(test_string), 0);
|
|
||||||
|
|
||||||
err = RegCloseKey(hkey);
|
|
||||||
ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
|
|
||||||
|
|
||||||
delete_key(HKEY_CURRENT_USER, KEY_BASE);
|
|
||||||
|
|
||||||
sprintf(cmdline, "reg import %s %s", test1_reg, test2_reg);
|
|
||||||
run_reg_exe(cmdline, &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);
|
||||||
|
|
||||||
DeleteFileA(test1_reg);
|
|
||||||
DeleteFileA(test2_reg);
|
|
||||||
|
|
||||||
/* Test file contents */
|
/* Test file contents */
|
||||||
test_import_str("regedit\n", &r);
|
test_import_str("regedit\n", &r);
|
||||||
ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
|
ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
|
||||||
|
@ -961,6 +911,18 @@ static void test_import(void)
|
||||||
|
|
||||||
open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_SET_VALUE, &hkey);
|
open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_SET_VALUE, &hkey);
|
||||||
|
|
||||||
|
test_import_str("REGEDIT4\n"
|
||||||
|
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
||||||
|
"\"Wine\"=dword:00000123\n\n", &r);
|
||||||
|
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||||
|
verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
|
||||||
|
|
||||||
|
test_import_str("REGEDIT4\n"
|
||||||
|
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
||||||
|
"@=\"Test string\"\n\n", &r);
|
||||||
|
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||||
|
verify_reg(hkey, NULL, REG_SZ, "Test string", 12, 0);
|
||||||
|
|
||||||
test_import_str("REGEDIT3\n\n"
|
test_import_str("REGEDIT3\n\n"
|
||||||
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
||||||
"\"Test1\"=\"Value\"\n", &r);
|
"\"Test1\"=\"Value\"\n", &r);
|
||||||
|
@ -2550,6 +2512,18 @@ static void test_unicode_import(void)
|
||||||
"got exit code %d, expected 1\n", r);
|
"got exit code %d, expected 1\n", r);
|
||||||
verify_reg_nonexist(hkey, "Test12");
|
verify_reg_nonexist(hkey, "Test12");
|
||||||
|
|
||||||
|
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
|
||||||
|
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
||||||
|
"\"Wine\"=dword:00000123\n\n", &r);
|
||||||
|
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||||
|
verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
|
||||||
|
|
||||||
|
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
|
||||||
|
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
||||||
|
"@=\"Test string\"\n\n", &r);
|
||||||
|
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||||
|
verify_reg(hkey, NULL, REG_SZ, "Test string", 12, 0);
|
||||||
|
|
||||||
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n"
|
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n"
|
||||||
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
|
||||||
"\"Unicode4\"=\"Value4\"\n", &r);
|
"\"Unicode4\"=\"Value4\"\n", &r);
|
||||||
|
|
Loading…
Reference in New Issue