Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
31152763
Commit
31152763
authored
May 14, 2021
by
Hugh McMaster
Committed by
Alexandre Julliard
May 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg/tests: Add complex data and hex type tests for the 'copy' command.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
48cd2588
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
198 additions
and
53 deletions
+198
-53
copy.c
programs/reg/tests/copy.c
+141
-0
export.c
programs/reg/tests/export.c
+53
-53
reg_test.h
programs/reg/tests/reg_test.h
+4
-0
No files found.
programs/reg/tests/copy.c
View file @
31152763
...
...
@@ -256,6 +256,145 @@ static void test_copy_simple_data(void)
todo_wine
ok
(
compare_export
(
"file.reg"
,
simple_data_test
,
0
),
"compare_export() failed
\n
"
);
}
static
void
test_copy_complex_data
(
void
)
{
HKEY
hkey
,
subkey
;
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
);
add_key
(
hkey
,
"Subkey1"
,
&
subkey
);
add_value
(
subkey
,
"Binary"
,
REG_BINARY
,
"
\x11\x22\x33\x44
"
,
4
);
add_value
(
subkey
,
"Undefined hex"
,
0x100
,
"%PATH%"
,
7
);
close_key
(
subkey
);
add_key
(
hkey
,
"Subkey2a"
,
&
subkey
);
add_value
(
subkey
,
"double
\"
quote"
,
REG_SZ
,
"
\"
Hello, World!
\"
"
,
16
);
dword
=
0x8
;
add_value
(
subkey
,
"single'quote"
,
REG_DWORD
,
&
dword
,
sizeof
(
dword
));
close_key
(
subkey
);
add_key
(
hkey
,
"Subkey2a
\\
Subkey2b"
,
&
subkey
);
add_value
(
subkey
,
NULL
,
REG_SZ
,
"Default value name"
,
19
);
add_value
(
subkey
,
"Multiple strings"
,
REG_MULTI_SZ
,
"Line1
\0
Line2
\0
Line3
\0
"
,
19
);
close_key
(
subkey
);
add_key
(
hkey
,
"Subkey3a"
,
&
subkey
);
add_value
(
subkey
,
"Backslash"
,
REG_SZ
,
"Use
\\\\
to escape a backslash"
,
29
);
close_key
(
subkey
);
add_key
(
hkey
,
"Subkey3a
\\
Subkey3b
\\
Subkey3c"
,
&
subkey
);
add_value
(
subkey
,
"String expansion"
,
REG_EXPAND_SZ
,
"%HOME%
\\
%PATH%"
,
14
);
add_value
(
subkey
,
"Zero data type"
,
REG_NONE
,
"Value"
,
6
);
close_key
(
subkey
);
add_key
(
hkey
,
"Subkey4"
,
&
subkey
);
dword
=
0x12345678
;
add_value
(
subkey
,
NULL
,
REG_DWORD
,
&
dword
,
sizeof
(
dword
));
add_value
(
subkey
,
"43981"
,
0xabcd
,
"Value"
,
6
);
close_key
(
subkey
);
close_key
(
hkey
);
/* Copy values only */
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 HKEY_CURRENT_USER
\\
"
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
"
);
/* Copy subkeys and values */
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 HKEY_CURRENT_USER
\\
"
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"
,
complex_data_test
,
0
),
"compare_export() failed
\n
"
);
}
static
void
test_copy_hex_data
(
void
)
{
HKEY
hkey
;
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
);
/* Try copying empty hex values */
add_key
(
HKEY_CURRENT_USER
,
COPY_SRC
,
&
hkey
);
add_value
(
hkey
,
"Wine1a"
,
REG_NONE
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1b"
,
REG_SZ
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1c"
,
REG_EXPAND_SZ
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1d"
,
REG_BINARY
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1e"
,
REG_DWORD
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1f"
,
REG_MULTI_SZ
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1g"
,
0x100
,
NULL
,
0
);
add_value
(
hkey
,
"Wine1h"
,
0xabcd
,
NULL
,
0
);
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"
,
empty_hex_test
,
0
),
"compare_export() failed
\n
"
);
delete_key
(
HKEY_CURRENT_USER
,
COPY_SRC
);
todo_wine
delete_key
(
HKEY_CURRENT_USER
,
KEY_BASE
);
/* Try copying after importing alternative registry data types */
test_import_wstr
(
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\n\n
"
"[HKEY_CURRENT_USER
\\
"
COPY_SRC
"]
\n
"
"
\"
Wine2a
\"
=hex(1):
\n
"
"
\"
Wine2b
\"
=hex(3):
\n
"
"
\"
Wine2c
\"
=hex(4):
\n\n
"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
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"
,
empty_hex_test2
,
0
),
"compare_export() failed
\n
"
);
delete_key
(
HKEY_CURRENT_USER
,
COPY_SRC
);
todo_wine
delete_key
(
HKEY_CURRENT_USER
,
KEY_BASE
);
/* Try copying more complex hex data */
test_import_wstr
(
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\n\n
"
"[HKEY_CURRENT_USER
\\
"
COPY_SRC
"]
\n
"
"
\"
Wine3a
\"
=hex(1):56,00,61,00,6c,00,75,00,65,00,00,00
\n
"
"
\"
Wine3b
\"
=hex(3):12,34,56,78
\n
"
"
\"
Wine3c
\"
=hex(4):40,30,20,10
\n\n
"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
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 HKEY_CURRENT_USER
\\
"
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"
,
hex_types_test
,
0
),
"compare_export() failed
\n
"
);
}
START_TEST
(
copy
)
{
DWORD
r
;
...
...
@@ -268,4 +407,6 @@ START_TEST(copy)
test_command_syntax
();
test_copy_empty_key
();
test_copy_simple_data
();
test_copy_complex_data
();
test_copy_hex_data
();
}
programs/reg/tests/export.c
View file @
31152763
...
...
@@ -73,6 +73,58 @@ const char *simple_data_test =
"
\"
DWORD
\"
=dword:00000100
\r\n
"
"
\"
String
\"
=
\"
Your text here...
\"\r\n\r\n
"
;
const
char
*
complex_data_test
=
"
\xef\xbb\xbf
Windows 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
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey1]
\r\n
"
"
\"
Binary
\"
=hex:11,22,33,44
\r\n
"
"
\"
Undefined hex
\"
=hex(100):25,50,41,54,48,25,00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey2a]
\r\n
"
"
\"
double
\\\"
quote
\"
=
\"\\\"
Hello, World!
\\\"\"\r\n
"
"
\"
single'quote
\"
=dword:00000008
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey2a
\\
Subkey2b]
\r\n
"
"@=
\"
Default value name
\"\r\n
"
"
\"
Multiple strings
\"
=hex(7):4c,00,69,00,6e,00,65,00,31,00,00,00,4c,00,69,00,6e,
\\\r\n
"
" 00,65,00,32,00,00,00,4c,00,69,00,6e,00,65,00,33,00,00,00,00,00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey3a]
\r\n
"
"
\"
Backslash
\"
=
\"
Use
\\\\\\\\
to escape a backslash
\"\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey3a
\\
Subkey3b]
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey3a
\\
Subkey3b
\\
Subkey3c]
\r\n
"
"
\"
String expansion
\"
=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,25,00,50,
\\\r\n
"
" 00,41,00,54,00,48,00,25,00,00,00
\r\n
"
"
\"
Zero data type
\"
=hex(0):56,61,6c,75,65,00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey4]
\r\n
"
"@=dword:12345678
\r\n
"
"
\"
43981
\"
=hex(abcd):56,61,6c,75,65,00
\r\n\r\n
"
;
const
char
*
empty_hex_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
"
\"
Wine1a
\"
=hex(0):
\r\n
"
"
\"
Wine1b
\"
=
\"\"\r\n
"
"
\"
Wine1c
\"
=hex(2):
\r\n
"
"
\"
Wine1d
\"
=hex:
\r\n
"
"
\"
Wine1e
\"
=hex(4):
\r\n
"
"
\"
Wine1f
\"
=hex(7):
\r\n
"
"
\"
Wine1g
\"
=hex(100):
\r\n
"
"
\"
Wine1h
\"
=hex(abcd):
\r\n\r\n
"
;
const
char
*
empty_hex_test2
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
"
\"
Wine2a
\"
=
\"\"\r\n
"
"
\"
Wine2b
\"
=hex:
\r\n
"
"
\"
Wine2c
\"
=hex(4):
\r\n\r\n
"
;
const
char
*
hex_types_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
"
\"
Wine3a
\"
=
\"
Value
\"\r\n
"
"
\"
Wine3b
\"
=hex:12,34,56,78
\r\n
"
"
\"
Wine3c
\"
=dword:10203040
\r\n\r\n
"
;
/* Unit tests */
...
...
@@ -83,32 +135,6 @@ static void test_export(void)
HKEY
hkey
,
subkey
;
BYTE
hex
[
4
],
buffer
[
8
];
const
char
*
complex_test
=
"
\xef\xbb\xbf
Windows 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
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey1]
\r\n
"
"
\"
Binary
\"
=hex:11,22,33,44
\r\n
"
"
\"
Undefined hex
\"
=hex(100):25,50,41,54,48,25,00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey2a]
\r\n
"
"
\"
double
\\\"
quote
\"
=
\"\\\"
Hello, World!
\\\"\"\r\n
"
"
\"
single'quote
\"
=dword:00000008
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey2a
\\
Subkey2b]
\r\n
"
"@=
\"
Default value name
\"\r\n
"
"
\"
Multiple strings
\"
=hex(7):4c,00,69,00,6e,00,65,00,31,00,00,00,4c,00,69,00,6e,
\\\r\n
"
" 00,65,00,32,00,00,00,4c,00,69,00,6e,00,65,00,33,00,00,00,00,00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey3a]
\r\n
"
"
\"
Backslash
\"
=
\"
Use
\\\\\\\\
to escape a backslash
\"\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey3a
\\
Subkey3b]
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey3a
\\
Subkey3b
\\
Subkey3c]
\r\n
"
"
\"
String expansion
\"
=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,25,00,50,
\\\r\n
"
" 00,41,00,54,00,48,00,25,00,00,00
\r\n
"
"
\"
Zero data type
\"
=hex(0):56,61,6c,75,65,00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"
\\
Subkey4]
\r\n
"
"@=dword:12345678
\r\n
"
"
\"
43981
\"
=hex(abcd):56,61,6c,75,65,00
\r\n\r\n
"
;
const
char
*
key_order_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n\r\n
"
...
...
@@ -121,32 +147,6 @@ static void test_export(void)
"
\"
Value 2
\"
=
\"
I was added first!
\"\r\n
"
"
\"
Value 1
\"
=
\"
I was added second!
\"\r\n\r\n
"
;
const
char
*
empty_hex_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
"
\"
Wine1a
\"
=hex(0):
\r\n
"
"
\"
Wine1b
\"
=
\"\"\r\n
"
"
\"
Wine1c
\"
=hex(2):
\r\n
"
"
\"
Wine1d
\"
=hex:
\r\n
"
"
\"
Wine1e
\"
=hex(4):
\r\n
"
"
\"
Wine1f
\"
=hex(7):
\r\n
"
"
\"
Wine1g
\"
=hex(100):
\r\n
"
"
\"
Wine1h
\"
=hex(abcd):
\r\n\r\n
"
;
const
char
*
empty_hex_test2
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
"
\"
Wine2a
\"
=
\"\"\r\n
"
"
\"
Wine2b
\"
=hex:
\r\n
"
"
\"
Wine2c
\"
=hex(4):
\r\n\r\n
"
;
const
char
*
hex_types_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
"
\"
Wine3a
\"
=
\"
Value
\"\r\n
"
"
\"
Wine3b
\"
=hex:12,34,56,78
\r\n
"
"
\"
Wine3c
\"
=dword:10203040
\r\n\r\n
"
;
const
char
*
embedded_null_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
...
...
@@ -286,7 +286,7 @@ static void test_export(void)
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
(
compare_export
(
"file.reg"
,
complex_test
,
0
),
"compare_export() failed
\n
"
);
ok
(
compare_export
(
"file.reg"
,
complex_
data_
test
,
0
),
"compare_export() failed
\n
"
);
delete_tree
(
HKEY_CURRENT_USER
,
KEY_BASE
);
/* Test the export order of registry keys */
...
...
programs/reg/tests/reg_test.h
View file @
31152763
...
...
@@ -80,6 +80,10 @@ 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
;
extern
const
char
*
complex_data_test
;
extern
const
char
*
empty_hex_test
;
extern
const
char
*
empty_hex_test2
;
extern
const
char
*
hex_types_test
;
/* import.c */
#define test_import_str(c,r) import_reg(__FILE__,__LINE__,c,FALSE,r)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment