ReactOS 0.4.15-dev-8408-g466a198
delete.c File Reference
#include "reg_test.h"
Include dependency graph for delete.c:

Go to the source code of this file.

Functions

static void test_command_syntax (void)
 
static void test_delete (void)
 
 START_TEST (delete)
 

Function Documentation

◆ START_TEST()

START_TEST ( delete  )

Definition at line 400 of file delete.c.

401{
402 DWORD r;
403
404 if (!run_reg_exe("reg.exe /?", &r)) {
405 win_skip("reg.exe not available, skipping 'delete' tests\n");
406 return;
407 }
408
410 test_delete();
411
412 /* Check if reg.exe is running with elevated privileges */
413 if (!is_elevated_process())
414 {
415 win_skip("reg.exe is not running with elevated privileges; "
416 "skipping registry view tests\n");
417 return;
418 }
419
420#if 0
421 test_registry_view_win32();
422 test_registry_view_win64();
423 test_registry_view_wow64();
424#endif
425
426}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void test_delete(void)
Definition: delete.c:80
static void test_command_syntax(void)
Definition: delete.c:22
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 22 of file delete.c.

23{
24 DWORD r;
25
27
28 run_reg_exe("reg delete", &r);
29 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
30
31 run_reg_exe("reg delete /?", &r);
32 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
33
34 run_reg_exe("reg delete /h", &r);
35 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
36
37 run_reg_exe("reg delete -H", &r);
38 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
39
40 /* Multiple /v* switches */
41 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /ve", &r);
42 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
43
44 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /va", &r);
45 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
46
47 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /ve", &r);
48 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
49
50 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /va", &r);
51 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
52
53 run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /va", &r);
54 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
55
56 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Test /ve /va", &r);
57 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
58
59 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /v Test /f", &r);
60 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
61
62 /* No /v argument */
63 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v", &r);
64 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
65
66 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /v", &r);
67 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
68
69 /* Test registry view */
70 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /reg:32 /reg:32", &r);
71 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
72
73 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /reg:32 /reg:64", &r);
74 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
75
76 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /reg:64 /reg:64", &r);
77 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
78}
#define ok(value,...)
Definition: atltest.h:57
#define REG_EXIT_FAILURE
Definition: reg_test.h:31
#define delete_tree(r, p, s)
Definition: reg_test.h:67
#define REG_EXIT_SUCCESS
Definition: reg_test.h:30
#define KEY_BASE
Definition: reg_test.h:29
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by START_TEST().

◆ test_delete()

static void test_delete ( void  )
static

Definition at line 80 of file delete.c.

81{
82 HKEY hkey;
83 DWORD r;
84 const DWORD deadbeef = 0xdeadbeef;
85
87
88 /* Create a test key */
90 add_value(hkey, "foo", REG_DWORD, &deadbeef, sizeof(deadbeef));
91 add_value(hkey, "bar", REG_DWORD, &deadbeef, sizeof(deadbeef));
92 add_value(hkey, NULL, REG_DWORD, &deadbeef, sizeof(deadbeef));
93
94 add_key(hkey, "subkey", 0, NULL);
95
96 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v bar /f", &r);
97 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
98 verify_reg_nonexist(hkey, "bar");
99
100 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
101 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
102 verify_reg_nonexist(hkey, "");
103
104 run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
105 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
106 verify_reg_nonexist(hkey, "foo");
107 verify_key(hkey, "subkey", 0);
108
109 /* Test forward and back slashes */
110 add_key(hkey, "https://winehq.org", 0, NULL);
111 add_value(hkey, "count/up", REG_SZ, "one/two/three", 14);
112 add_value(hkey, "\\foo\\bar", REG_SZ, "", 1);
113
114 run_reg_exe("reg delete HKCU\\" KEY_BASE "\\https://winehq.org /f", &r);
115 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
116 verify_key_nonexist(hkey, "https://winehq.org", 0);
117
118 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v count/up /f", &r);
119 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
120 verify_reg_nonexist(hkey, "count/up");
121
122 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v \\foo\\bar /f", &r);
123 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
124 verify_reg_nonexist(hkey, "\\foo\\bar");
125
126 add_value(hkey, "string\\01", REG_SZ, "Value", 6);
127 add_value(hkey, "string2", REG_SZ, "foo\\0bar", 9);
128 add_value(hkey, "\\0", REG_SZ, "Value", 6);
129
130 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v string\\01 /f", &r);
131 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
132 verify_reg_nonexist(hkey, "string\\01");
133
134 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v string2 /f", &r);
135 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
136 verify_reg_nonexist(hkey, "string2");
137
138 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v \\0 /f", &r);
139 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
140 verify_reg_nonexist(hkey, "\\0");
141
142 close_key(hkey);
143
144 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
145 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
147
148 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
149 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
150}
#define NULL
Definition: types.h:112
#define REG_SZ
Definition: layer.c:22
#define add_value(k, n, t, d, s)
Definition: reg_test.h:70
#define add_key(r, p, s, k)
Definition: reg_test.h:61
#define verify_key(r, p, s)
Definition: reg_test.h:55
#define verify_key_nonexist(r, p, s)
Definition: reg_test.h:58
#define close_key(k)
Definition: reg_test.h:52
#define verify_reg_nonexist(k, v)
Definition: reg_test.h:46
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by START_TEST().