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

reg/tests: Add data tests for the 'copy' command.

parent 9a4fa43a
...@@ -122,6 +122,140 @@ static void test_command_syntax(void) ...@@ -122,6 +122,140 @@ static void test_command_syntax(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 void test_copy_empty_key(void)
{
DWORD r;
delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC);
delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
add_key(HKEY_CURRENT_USER, COPY_SRC, NULL);
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
todo_wine delete_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE " /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
todo_wine delete_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE "\\ /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
todo_wine delete_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE "\\ /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
}
static void test_copy_simple_data(void)
{
HKEY hkey;
DWORD r, dword;
delete_tree(HKEY_CURRENT_USER, COPY_SRC);
verify_key_nonexist(HKEY_CURRENT_USER, COPY_SRC);
delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
add_key(HKEY_CURRENT_USER, COPY_SRC, &hkey);
dword = 0x100;
add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword));
add_value(hkey, "String", REG_SZ, "Your text here...", 18);
close_key(hkey);
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
todo_wine delete_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE " /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
todo_wine delete_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE "\\ /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
todo_wine delete_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE "\\ /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_key(HKEY_CURRENT_USER, KEY_BASE);
run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
}
START_TEST(copy) START_TEST(copy)
{ {
DWORD r; DWORD r;
...@@ -132,4 +266,6 @@ START_TEST(copy) ...@@ -132,4 +266,6 @@ START_TEST(copy)
} }
test_command_syntax(); test_command_syntax();
test_copy_empty_key();
test_copy_simple_data();
} }
...@@ -18,9 +18,8 @@ ...@@ -18,9 +18,8 @@
#include "reg_test.h" #include "reg_test.h"
#define compare_export(f,e,todo) compare_export_(__FILE__,__LINE__,f,e,todo) BOOL compare_export_(const char *file, unsigned line, const char *filename,
static BOOL compare_export_(const char *file, unsigned line, const char *filename, const char *expected, DWORD todo)
const char *expected, DWORD todo)
{ {
FILE *fp; FILE *fp;
long file_size; long file_size;
...@@ -64,6 +63,17 @@ error: ...@@ -64,6 +63,17 @@ error:
return FALSE; return FALSE;
} }
const char *empty_key_test =
"\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n\r\n";
const char *simple_data_test =
"\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n"
"\"DWORD\"=dword:00000100\r\n"
"\"String\"=\"Your text here...\"\r\n\r\n";
/* Unit tests */ /* Unit tests */
static void test_export(void) static void test_export(void)
...@@ -73,16 +83,6 @@ static void test_export(void) ...@@ -73,16 +83,6 @@ static void test_export(void)
HKEY hkey, subkey; HKEY hkey, subkey;
BYTE hex[4], buffer[8]; BYTE hex[4], buffer[8];
const char *empty_key_test =
"\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n\r\n";
const char *simple_test =
"\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n"
"\"DWORD\"=dword:00000100\r\n"
"\"String\"=\"Your text here...\"\r\n\r\n";
const char *complex_test = const char *complex_test =
"\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n" "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n"
...@@ -243,12 +243,12 @@ static void test_export(void) ...@@ -243,12 +243,12 @@ static void test_export(void)
run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r); 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(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", simple_test, 0), "compare_export() failed\n"); ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
/* Test whether a .reg file extension is required when exporting */ /* Test whether a .reg file extension is required when exporting */
run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " foo /y", &r); run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " foo /y", &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);
ok(compare_export("foo", simple_test, 0), "compare_export() failed\n"); ok(compare_export("foo", simple_data_test, 0), "compare_export() failed\n");
/* Test registry export with a complex data structure */ /* Test registry export with a complex data structure */
add_key(hkey, "Subkey1", &subkey); add_key(hkey, "Subkey1", &subkey);
......
...@@ -74,6 +74,13 @@ void add_value_(const char *file, unsigned line, HKEY hkey, const char *name, ...@@ -74,6 +74,13 @@ void add_value_(const char *file, unsigned line, HKEY hkey, const char *name,
#define delete_value(k,n) delete_value_(__FILE__,__LINE__,k,n) #define delete_value(k,n) delete_value_(__FILE__,__LINE__,k,n)
void delete_value_(const char *file, unsigned line, const HKEY hkey, const char *name); void delete_value_(const char *file, unsigned line, const HKEY hkey, const char *name);
/* export.c */
#define compare_export(f,e,todo) compare_export_(__FILE__,__LINE__,f,e,todo)
BOOL compare_export_(const char *file, unsigned line, const char *filename,
const char *expected, DWORD todo);
extern const char *empty_key_test;
extern const char *simple_data_test;
/* import.c */ /* import.c */
#define test_import_str(c,r) import_reg(__FILE__,__LINE__,c,FALSE,r) #define test_import_str(c,r) import_reg(__FILE__,__LINE__,c,FALSE,r)
#define test_import_wstr(c,r) import_reg(__FILE__,__LINE__,c,TRUE,r) #define test_import_wstr(c,r) import_reg(__FILE__,__LINE__,c,TRUE,r)
......
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