https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3969dcc3de1271e3d233f…
commit 3969dcc3de1271e3d233f2f55bfcb2c16d5ed096
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Jan 16 21:08:23 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:33 2022 +0200
[WINESYNC] reg/tests: Refactor 'add' tests into registry types, keys and
syntax checks.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 45b66285c38462bb57e8ab8a577f8df2dba15363 by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
modules/rostests/winetests/reg/add.c | 253 +++++++++++++++++++++++------------
sdk/tools/winesync/reg.cfg | 2 +-
2 files changed, 168 insertions(+), 87 deletions(-)
diff --git a/modules/rostests/winetests/reg/add.c b/modules/rostests/winetests/reg/add.c
index 30e5fe55667..8357e9ad0bc 100644
--- a/modules/rostests/winetests/reg/add.c
+++ b/modules/rostests/winetests/reg/add.c
@@ -204,12 +204,9 @@ void delete_value_(const char *file, unsigned line, const HKEY hkey,
const char
/* Unit tests */
-static void test_add(void)
+static void test_command_syntax(void)
{
- HKEY hkey, hsubkey;
- LONG err;
- DWORD r, dword, type, size;
- char buffer[22];
+ DWORD r;
delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
@@ -226,19 +223,56 @@ 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);
- run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ /* Duplicate switches */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v
Test /f", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f
/t REG_SZ", &r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f
/d 456", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /f /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
- open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ /* No /v argument */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ /* Test invalid switches */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a",
&r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae",
&r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
/* Test empty type */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\"
/d WineTest /f", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+}
+
+static void test_key_formats(void)
+{
+ HKEY hkey;
+ DWORD r;
+ LONG err;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- /* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f",
&r);
ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
verify_key_nonexist(hkey, "keytest0");
@@ -257,13 +291,19 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f",
&r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_key(hkey, "keytest3");
- delete_key(hkey, "keytest3");
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_key(hkey, "keytest4");
- delete_key(hkey, "keytest4");
+ run_reg_exe("reg add HKCU\\" KEY_BASE "\\https://winehq.org /f",
&r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ verify_key(hkey, "https://winehq.org");
+
+ close_key(hkey);
+ delete_tree(HKEY_CURRENT_USER, KEY_BASE);
+
+ /* Test validity of trailing backslash after system key */
run_reg_exe("reg add HKCU\\ /v Value1 /t REG_SZ /d foo /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
todo_wine verify_reg_nonexist(HKEY_CURRENT_USER, "Value1");
@@ -271,8 +311,44 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\ /v Value2 /t REG_SZ /d bar /f",
&r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
todo_wine verify_reg_nonexist(HKEY_CURRENT_USER, "Value2");
+}
+
+static void test_add(void)
+{
+ HKEY hkey, hsubkey;
+ DWORD r, dword;
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_WRITE, &hkey);
+
+ /* Test whether overwriting a registry key modifies existing keys and values */
+ add_key(hkey, "Subkey", &hsubkey);
+ close_key(hsubkey);
+ add_value(hkey, "Test1", REG_SZ, "Value1", 7);
+ dword = 0x123;
+ add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword));
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ verify_key(HKEY_CURRENT_USER, KEY_BASE);
+ verify_key(hkey, "Subkey");
+ verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
+ verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0);
+
+ close_key(hkey);
+ delete_tree(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_none(void)
+{
+ HKEY hkey;
+ DWORD r;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- /* REG_NONE */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t
REG_NONE /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0",
18, 0);
@@ -285,7 +361,17 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0);
- /* REG_SZ */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_sz(void)
+{
+ HKEY hkey;
+ DWORD r;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f",
&r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %d, expected 0\n", r);
@@ -340,7 +426,26 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, "\\0", REG_SZ, "Value", 6, 0);
- /* REG_EXPAND_SZ */
+ /* Test support for forward and back slashes in value names */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v count/up /d one/two/three
/f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ verify_reg(hkey, "count/up", REG_SZ, "one/two/three", 14, 0);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v \\foo\\bar /f",
&r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ verify_reg(hkey, "\\foo\\bar", REG_SZ, "", 1, 0);
+
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_expand_sz(void)
+{
+ HKEY hkey;
+ DWORD r;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d
\"dead%PATH%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15,
0);
@@ -365,7 +470,19 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0);
- /* REG_BINARY */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_binary(void)
+{
+ HKEY hkey;
+ DWORD r, dword, type, size;
+ char buffer[22];
+ LONG err;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0
/f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, "bin0", REG_BINARY, buffer, 0, 0);
@@ -389,7 +506,7 @@ static void test_add(void)
/* Remaining nibble prefixed */
buffer[0] = 0x0d; buffer[1] = 0xea; buffer[2] = 0xdb;
buffer[3] = 0xee; buffer[4] = 0xf0; buffer[5] = 0xdd;
- /* Remaining nibble suffixed on winXP */
+ /* Remaining nibble suffixed on WinXP */
buffer[6] = 0xde; buffer[7] = 0xad; buffer[8] = 0xbe;
buffer[9] = 0xef; buffer[10] = 0x0d; buffer[11] = 0xd0;
size = 6;
@@ -411,7 +528,18 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0);
- /* REG_DWORD */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_dword(void)
+{
+ HKEY hkey;
+ DWORD r, dword, type, size;
+ LONG err;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d
12345678", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %d, expected 0\n", r);
@@ -510,7 +638,18 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD_BIG_ENDIAN
/f", &r);
ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit
code %u, expected 1\n", r);
- /* REG_MULTI_SZ */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_multi_sz(void)
+{
+ HKEY hkey;
+ DWORD r;
+ char buffer[22];
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d
\"three\\0little\\0strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
memcpy(buffer, "three\0little\0strings\0", 22);
@@ -596,74 +735,8 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_MULTI_SZ, buffer, 1, 0);
- /* Test forward and back slashes */
- run_reg_exe("reg add HKCU\\" KEY_BASE "\\https://winehq.org /f",
&r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_key(hkey, "https://winehq.org");
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v count/up /d one/two/three
/f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "count/up", REG_SZ, "one/two/three", 14, 0);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v \\foo\\bar /f",
&r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "\\foo\\bar", REG_SZ, "", 1, 0);
-
close_key(hkey);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE);
-
- /* Test duplicate switches */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v
Test /f", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f
/t REG_SZ", &r);
- ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
- "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f
/d 456", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- /* Multiple /v* switches */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- /* No /v argument */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- /* Test invalid switches */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a",
&r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae",
&r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- /* Test whether overwriting a registry key modifies existing keys and values */
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- add_key(hkey, "Subkey", &hsubkey);
- close_key(hsubkey);
- add_value(hkey, "Test1", REG_SZ, "Value1", 7);
- dword = 0x123;
- add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword));
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
-
- verify_key(HKEY_CURRENT_USER, KEY_BASE);
- verify_key(hkey, "Subkey");
- verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
- verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0);
-
- delete_tree(HKEY_CURRENT_USER, KEY_BASE);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
}
START_TEST(add)
@@ -675,5 +748,13 @@ START_TEST(add)
return;
}
+ test_command_syntax();
+ test_key_formats();
test_add();
+ test_reg_none();
+ test_reg_sz();
+ test_reg_expand_sz();
+ test_reg_binary();
+ test_reg_dword();
+ test_reg_multi_sz();
}
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index 968d8ec828e..10c74a333ae 100644
--- a/sdk/tools/winesync/reg.cfg
+++ b/sdk/tools/winesync/reg.cfg
@@ -4,4 +4,4 @@ directories:
files:
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
tags:
- wine: f6566bf7493dea2511238ad59aae873168b16963
+ wine: 45b66285c38462bb57e8ab8a577f8df2dba15363