ReactOS 0.4.16-dev-197-g92996da
copy.c File Reference
#include "reg_test.h"
Include dependency graph for copy.c:

Go to the source code of this file.

Macros

#define COPY_SRC   KEY_WINE "\\reg_copy"
 

Functions

static void test_command_syntax (void)
 
static void test_copy_empty_key (void)
 
static void test_copy_simple_data (void)
 
static void test_copy_complex_data (void)
 
static void test_copy_key_order (void)
 
static void test_copy_value_order (void)
 
static void test_copy_hex_data (void)
 
static void test_copy_embedded_null_values (void)
 
static void test_copy_slashes (void)
 
static void test_copy_escaped_null_values (void)
 
static void test_copy_key_class (void)
 
static void test_copy_overwrite (void)
 
 START_TEST (copy)
 

Macro Definition Documentation

◆ COPY_SRC

#define COPY_SRC   KEY_WINE "\\reg_copy"

Definition at line 21 of file copy.c.

Function Documentation

◆ START_TEST()

START_TEST ( copy  )

Definition at line 753 of file copy.c.

754{
755 DWORD r;
756
757 if (!run_reg_exe("reg.exe /?", &r)) {
758 win_skip("reg.exe not available, skipping 'copy' tests\n");
759 return;
760 }
761
774
775 /* Check if reg.exe is running with elevated privileges */
776 if (!is_elevated_process())
777 {
778 win_skip("reg.exe is not running with elevated privileges; "
779 "skipping registry view tests\n");
780 return;
781 }
782
783#if 0
784 test_registry_view_win32();
785 test_registry_view_win64();
786 test_registry_view_wow64();
787#endif
788
789}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void test_copy_escaped_null_values(void)
Definition: copy.c:482
static void test_copy_key_class(void)
Definition: copy.c:511
static void test_copy_slashes(void)
Definition: copy.c:459
static void test_copy_hex_data(void)
Definition: copy.c:363
static void test_copy_complex_data(void)
Definition: copy.c:253
static void test_copy_simple_data(void)
Definition: copy.c:186
static void test_copy_key_order(void)
Definition: copy.c:319
static void test_copy_value_order(void)
Definition: copy.c:341
static void test_copy_overwrite(void)
Definition: copy.c:553
static void test_copy_empty_key(void)
Definition: copy.c:125
static void test_command_syntax(void)
Definition: copy.c:23
static void test_copy_embedded_null_values(void)
Definition: copy.c:430
BOOL is_elevated_process(void)
Definition: import.c:21
#define run_reg_exe(c, r)
Definition: reg_test.h:39
#define win_skip
Definition: test.h:163

◆ test_command_syntax()

static void test_command_syntax ( void  )
static

Definition at line 23 of file copy.c.

24{
25 DWORD r;
26
27 run_reg_exe("reg copy", &r);
28 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
29
30 run_reg_exe("reg copy /?", &r);
31 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
32
33 run_reg_exe("reg copy /h", &r);
34 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
35
36 run_reg_exe("reg copy -H", &r);
37 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
38
39 run_reg_exe("reg copy /? /f", &r);
40 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
41
42 run_reg_exe("reg copy /h /f", &r);
43 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
44
45 run_reg_exe("reg copy /? /s", &r);
46 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
47
48 run_reg_exe("reg copy /h /s", &r);
49 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
50
51 run_reg_exe("reg copy /f", &r);
52 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
53
54 run_reg_exe("reg copy /s", &r);
55 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
56
57 run_reg_exe("reg copy /s /f", &r);
58 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
59
60 run_reg_exe("reg copy /f /s", &r);
61 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
62
63 run_reg_exe("reg copy HKCU\\" COPY_SRC " /f", &r);
64 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
65
66 run_reg_exe("reg copy HKCU\\" COPY_SRC " foo /f", &r);
67 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
68
69 run_reg_exe("reg copy /f HKCU\\" COPY_SRC " HKCU\\" KEY_BASE, &r);
70 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
71
72 run_reg_exe("reg copy HKCU\\" COPY_SRC " /f HKCU\\" KEY_BASE, &r);
73 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
74
75 run_reg_exe("reg copy HKCU\\" COPY_SRC " /s HKCU\\" KEY_BASE, &r);
76 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
77
78 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /a", &r);
79 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
80
81 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f /a", &r);
82 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
83
84 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\", &r);
85 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
86
87 /* Source and destination keys are the same */
88 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" COPY_SRC, &r);
89 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
90
91 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" COPY_SRC, &r);
92 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
93
94 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" COPY_SRC "\\", &r);
95 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
96
97 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" COPY_SRC "\\", &r);
98 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
99
100 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" COPY_SRC " /f", &r);
101 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
102
103 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" COPY_SRC " /f", &r);
104 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
105
106 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" COPY_SRC "\\ /f", &r);
107 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
108
109 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" COPY_SRC "\\ /f", &r);
110 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
111
112 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" COPY_SRC " /s /f", &r);
113 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
114
115 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" COPY_SRC " /s /f", &r);
116 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
117
118 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" COPY_SRC "\\ /s /f", &r);
119 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
120
121 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" COPY_SRC "\\ /s /f", &r);
122 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
123}
#define ok(value,...)
Definition: atltest.h:57
#define COPY_SRC
Definition: copy.c:21
#define REG_EXIT_FAILURE
Definition: reg_test.h:31
#define REG_EXIT_SUCCESS
Definition: reg_test.h:30
#define KEY_BASE
Definition: reg_test.h:29

Referenced by START_TEST().

◆ test_copy_complex_data()

static void test_copy_complex_data ( void  )
static

Definition at line 253 of file copy.c.

254{
255 HKEY hkey, subkey;
256 DWORD r, dword;
257
260
262
263 dword = 0x100;
264 add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword));
265 add_value(hkey, "String", REG_SZ, "Your text here...", 18);
266
267 add_key(hkey, "Subkey1", 0, &subkey);
268 add_value(subkey, "Binary", REG_BINARY, "\x11\x22\x33\x44", 4);
269 add_value(subkey, "Undefined hex", 0x100, "%PATH%", 7);
270 close_key(subkey);
271
272 add_key(hkey, "Subkey2a", 0, &subkey);
273 add_value(subkey, "double\"quote", REG_SZ, "\"Hello, World!\"", 16);
274 dword = 0x8;
275 add_value(subkey, "single'quote", REG_DWORD, &dword, sizeof(dword));
276 close_key(subkey);
277
278 add_key(hkey, "Subkey2a\\Subkey2b", 0, &subkey);
279 add_value(subkey, NULL, REG_SZ, "Default value name", 19);
280 add_value(subkey, "Multiple strings", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19);
281 close_key(subkey);
282
283 add_key(hkey, "Subkey3a", 0, &subkey);
284 add_value(subkey, "Backslash", REG_SZ, "Use \\\\ to escape a backslash", 29);
285 close_key(subkey);
286
287 add_key(hkey, "Subkey3a\\Subkey3b\\Subkey3c", 0, &subkey);
288 add_value(subkey, "String expansion", REG_EXPAND_SZ, "%HOME%\\%PATH%", 14);
289 add_value(subkey, "Zero data type", REG_NONE, "Value", 6);
290 close_key(subkey);
291
292 add_key(hkey, "Subkey4", 0, &subkey);
293 dword = 0x12345678;
294 add_value(subkey, NULL, REG_DWORD, &dword, sizeof(dword));
295 add_value(subkey, "43981", 0xabcd, "Value", 6);
296 close_key(subkey);
297
298 close_key(hkey);
299
300 /* Copy values only */
301 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
302 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
304
305 run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r);
306 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
307 ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
308
309 /* Copy subkeys and values */
310 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
311 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
313
314 run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r);
315 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
316 ok(compare_export("file.reg", complex_data_test, 0), "compare_export() failed\n");
317}
#define NULL
Definition: types.h:112
#define REG_SZ
Definition: layer.c:22
const char * complex_data_test
Definition: export.c:75
const char * simple_data_test
Definition: export.c:69
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define REG_NONE
Definition: nt_native.h:1492
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define add_value(k, n, t, d, s)
Definition: reg_test.h:70
#define compare_export(f, e, todo)
Definition: reg_test.h:78
#define add_key(r, p, s, k)
Definition: reg_test.h:61
#define delete_tree(r, p, s)
Definition: reg_test.h:67
#define verify_key(r, p, s)
Definition: reg_test.h:55
#define close_key(k)
Definition: reg_test.h:52
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by START_TEST().

◆ test_copy_embedded_null_values()

static void test_copy_embedded_null_values ( void  )
static

Definition at line 430 of file copy.c.

431{
432 DWORD r;
433
436
437 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
438 "[HKEY_CURRENT_USER\\" COPY_SRC "]\n"
439 "\"Wine4a\"=dword:00000005\n"
440 "\"Wine4b\"=hex(1):00,00,00,00,00,00,00,00\n"
441 "\"Wine4c\"=\"Value\"\n"
442 "\"Wine4d\"=hex(1):00,00,61,00,62,00,63,00\n"
443 "\"Wine4e\"=dword:00000100\n"
444 "\"Wine4f\"=hex(1):00,00,56,00,61,00,6c,00,75,00,65,00,00,00\n"
445 "\"Wine4g\"=\"Value2\"\n"
446 "\"Wine4h\"=hex(1):61,00,62,00,63,00,00,00, \\\n"
447 " 64,00,65,00,66,00,00,00\n\n", &r);
448 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
449
450 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
451 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
453
454 run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r);
455 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
456 ok(compare_export("file.reg", embedded_null_test, 0), "compare_export() failed\n");
457}
const char * embedded_null_test
Definition: export.c:139
#define test_import_wstr(c, r)
Definition: reg_test.h:101

Referenced by START_TEST().

◆ test_copy_empty_key()

static void test_copy_empty_key ( void  )
static

Definition at line 125 of file copy.c.

126{
127 DWORD r;
128
131
133
134
135 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
136 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
138
139 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
140 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
141 ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
142
144
145
146 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE " /f", &r);
147 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
149
150 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
151 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
152 ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
153
155
156
157 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE "\\ /f", &r);
158 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
160
161 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
162 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
163 ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
164
166
167
168 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE "\\ /f", &r);
169 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
171
172 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
173 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
174 ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
175
176
177 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
178 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
180
181 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg", &r);
182 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
183 ok(compare_export("file.reg", empty_key_test, 0), "compare_export() failed\n");
184}
const char * empty_key_test
Definition: export.c:65
#define delete_key(r, p, s)
Definition: reg_test.h:64

Referenced by START_TEST().

◆ test_copy_escaped_null_values()

static void test_copy_escaped_null_values ( void  )
static

Definition at line 482 of file copy.c.

483{
484 HKEY hkey;
485 DWORD r;
486
489
491 add_value(hkey, "Wine5a", REG_SZ, "\\0", 3);
492 add_value(hkey, "Wine5b", REG_SZ, "\\0\\0", 5);
493 add_value(hkey, "Wine5c", REG_SZ, "Value1\\0", 9);
494 add_value(hkey, "Wine5d", REG_SZ, "Value2\\0\\0\\0\\0", 15);
495 add_value(hkey, "Wine5e", REG_SZ, "Value3\\0Value4", 15);
496 add_value(hkey, "Wine5f", REG_SZ, "\\0Value5", 9);
497 close_key(hkey);
498
499 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
500 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
502
503 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
504 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
505 ok(compare_export("file.reg", escaped_null_test, 0), "compare_export() failed\n");
506
509}
const char * escaped_null_test
Definition: export.c:158

Referenced by START_TEST().

◆ test_copy_hex_data()

static void test_copy_hex_data ( void  )
static

Definition at line 363 of file copy.c.

364{
365 HKEY hkey;
366 DWORD r;
367
370
371 /* Try copying empty hex values */
373 add_value(hkey, "Wine1a", REG_NONE, NULL, 0);
374 add_value(hkey, "Wine1b", REG_SZ, NULL, 0);
375 add_value(hkey, "Wine1c", REG_EXPAND_SZ, NULL, 0);
376 add_value(hkey, "Wine1d", REG_BINARY, NULL, 0);
377 add_value(hkey, "Wine1e", REG_DWORD, NULL, 0);
378 add_value(hkey, "Wine1f", REG_MULTI_SZ, NULL, 0);
379 add_value(hkey, "Wine1g", 0x100, NULL, 0);
380 add_value(hkey, "Wine1h", 0xabcd, NULL, 0);
381 close_key(hkey);
382
383 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
384 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
386
387 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
388 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
389 ok(compare_export("file.reg", empty_hex_test, 0), "compare_export() failed\n");
390
393
394 /* Try copying after importing alternative registry data types */
395 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
396 "[HKEY_CURRENT_USER\\" COPY_SRC "]\n"
397 "\"Wine2a\"=hex(1):\n"
398 "\"Wine2b\"=hex(3):\n"
399 "\"Wine2c\"=hex(4):\n\n", &r);
400 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
401
402 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
403 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
405
406 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
407 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
408 ok(compare_export("file.reg", empty_hex_test2, 0), "compare_export() failed\n");
409
412
413 /* Try copying more complex hex data */
414 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
415 "[HKEY_CURRENT_USER\\" COPY_SRC "]\n"
416 "\"Wine3a\"=hex(1):56,00,61,00,6c,00,75,00,65,00,00,00\n"
417 "\"Wine3b\"=hex(3):12,34,56,78\n"
418 "\"Wine3c\"=hex(4):40,30,20,10\n\n", &r);
419 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
420
421 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
422 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
424
425 run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r);
426 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
427 ok(compare_export("file.reg", hex_types_test, 0), "compare_export() failed\n");
428}
const char * empty_hex_test2
Definition: export.c:125
const char * hex_types_test
Definition: export.c:132
const char * empty_hex_test
Definition: export.c:113

Referenced by START_TEST().

◆ test_copy_key_class()

static void test_copy_key_class ( void  )
static

Definition at line 511 of file copy.c.

512{
513 HKEY hkey;
514 LONG rc;
515 char class[] = "class";
516 char buf[16];
517 DWORD buf_size, r;
518
520 KEY_READ|KEY_WRITE, NULL, &hkey, NULL);
521 ok(rc == ERROR_SUCCESS, "RegCreateKeyExA failed: got %d, expected 0\n", rc);
522
523 add_value(hkey, "String", REG_SZ, "Data", 5);
524
525 buf_size = sizeof(buf);
526
527 rc = RegQueryInfoKeyA(hkey, buf, &buf_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
528 ok(rc == ERROR_SUCCESS, "RegQueryInfoKeyA failed: got %d, expected 0\n", rc);
529 ok(!strcmp(buf, "class"), "Incorrect key class set; got '%s', expected '%s'\n", buf, class);
530
531 RegCloseKey(hkey);
532
533 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
534 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
536
538 verify_reg(hkey, "String", REG_SZ, "Data", 5, 0);
539
540 memset(buf, 0, sizeof(buf));
541 buf_size = sizeof(buf);
542
543 rc = RegQueryInfoKeyA(hkey, buf, &buf_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
544 ok(rc == ERROR_SUCCESS, "RegQueryInfoKeyA failed: got %d, expected 0\n", rc);
545 ok(strlen(buf) == 0, "Key class should not exist\n");
546
547 RegCloseKey(hkey);
548
551}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3583
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1034
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
long LONG
Definition: pedump.c:60
#define verify_reg(k, v, t, d, s, todo)
Definition: reg_test.h:42
#define open_key(r, p, s, k)
Definition: reg_test.h:49
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_copy_key_order()

static void test_copy_key_order ( void  )
static

Definition at line 319 of file copy.c.

320{
321 HKEY hkey;
322 DWORD r;
323
326
328 add_key(hkey, "Subkey2", 0, NULL);
329 add_key(hkey, "Subkey1", 0, NULL);
330 close_key(hkey);
331
332 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
333 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
335
336 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
337 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
338 ok(compare_export("file.reg", key_order_test, 0), "compare_export() failed\n");
339}
const char * key_order_test
Definition: export.c:101

Referenced by START_TEST().

◆ test_copy_overwrite()

static void test_copy_overwrite ( void  )
static

Definition at line 553 of file copy.c.

554{
555 HKEY hkey;
556 DWORD r, dword;
557
559 add_value(hkey, "Wine1", REG_SZ, "def", 4);
560 dword = 0x5;
561 add_value(hkey, "Wine2", REG_DWORD, &dword, sizeof(dword));
562 add_value(hkey, "Wine3", REG_BINARY, "\x11\x22\x33\x44", 4);
563 add_value(hkey, "Wine4", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19);
564 close_key(hkey);
565
567 add_value(hkey, "Wine1", REG_SZ, "abc", 4);
568 verify_reg_nonexist(hkey, "Wine2");
569 add_value(hkey, "Wine3", REG_EXPAND_SZ, "%HOME%\\%PATH%", 14);
570 dword = 0x1;
571 add_value(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword));
572 add_value(hkey, NULL, REG_SZ, "Constant value", 15);
573 close_key(hkey);
574
575 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
576 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
577
579 verify_reg(hkey, "Wine1", REG_SZ, "def", 4, 0);
580 dword = 0x5;
581 verify_reg(hkey, "Wine2", REG_DWORD, &dword, sizeof(dword), 0);
582 verify_reg(hkey, "Wine3", REG_BINARY, "\x11\x22\x33\x44", 4, 0);
583 verify_reg(hkey, "Wine4", REG_MULTI_SZ, "Line1\0Line2\0Line3\0", 19, 0);
584 verify_reg(hkey, NULL, REG_SZ, "Constant value", 15, 0);
585 close_key(hkey);
586
589}
#define verify_reg_nonexist(k, v)
Definition: reg_test.h:46

Referenced by START_TEST().

◆ test_copy_simple_data()

static void test_copy_simple_data ( void  )
static

Definition at line 186 of file copy.c.

187{
188 HKEY hkey;
189 DWORD r, dword;
190
193
195
196 dword = 0x100;
197 add_value(hkey, "DWORD", REG_DWORD, &dword, sizeof(dword));
198 add_value(hkey, "String", REG_SZ, "Your text here...", 18);
199 close_key(hkey);
200
201
202 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
203 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
205
206 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
207 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
208 ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
209
211
212
213 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE " /f", &r);
214 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
216
217 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
218 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
219 ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
220
222
223
224 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE "\\ /f", &r);
225 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
227
228 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
229 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
230 ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
231
233
234
235 run_reg_exe("reg copy HKCU\\" COPY_SRC "\\ HKCU\\" KEY_BASE "\\ /f", &r);
236 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
238
239 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
240 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
241 ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
242
243
244 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
245 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
247
248 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
249 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
250 ok(compare_export("file.reg", simple_data_test, 0), "compare_export() failed\n");
251}

Referenced by START_TEST().

◆ test_copy_slashes()

static void test_copy_slashes ( void  )
static

Definition at line 459 of file copy.c.

460{
461 HKEY hkey;
462 DWORD r;
463
466
468 add_key(hkey, "https://winehq.org", 0, NULL);
469 add_value(hkey, "count/up", REG_SZ, "one/two/three", 14);
470 add_value(hkey, "\\foo\\bar", REG_SZ, "", 1);
471 close_key(hkey);
472
473 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /s /f", &r);
474 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
476
477 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
478 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
479 ok(compare_export("file.reg", slashes_test, TODO_REG_COMPARE), "compare_export() failed\n");
480}
const char * slashes_test
Definition: export.c:151
#define TODO_REG_COMPARE
Definition: reg_test.h:36

Referenced by START_TEST().

◆ test_copy_value_order()

static void test_copy_value_order ( void  )
static

Definition at line 341 of file copy.c.

342{
343 HKEY hkey;
344 DWORD r;
345
348
350 add_value(hkey, "Value 2", REG_SZ, "I was added first!", 19);
351 add_value(hkey, "Value 1", REG_SZ, "I was added second!", 20);
352 close_key(hkey);
353
354 run_reg_exe("reg copy HKCU\\" COPY_SRC " HKCU\\" KEY_BASE " /f", &r);
355 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
357
358 run_reg_exe("reg export HKCU\\" KEY_BASE " file.reg /y", &r);
359 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
360 ok(compare_export("file.reg", value_order_test, TODO_REG_COMPARE), "compare_export() failed\n");
361}
const char * value_order_test
Definition: export.c:107

Referenced by START_TEST().