Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
bb609c6a
Commit
bb609c6a
authored
May 13, 2021
by
Hugh McMaster
Committed by
Alexandre Julliard
May 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg/tests: Add data tests for the 'copy' command.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9a4fa43a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
15 deletions
+158
-15
copy.c
programs/reg/tests/copy.c
+136
-0
export.c
programs/reg/tests/export.c
+15
-15
reg_test.h
programs/reg/tests/reg_test.h
+7
-0
No files found.
programs/reg/tests/copy.c
View file @
bb609c6a
...
...
@@ -122,6 +122,140 @@ static void test_command_syntax(void)
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
)
{
DWORD
r
;
...
...
@@ -132,4 +266,6 @@ START_TEST(copy)
}
test_command_syntax
();
test_copy_empty_key
();
test_copy_simple_data
();
}
programs/reg/tests/export.c
View file @
bb609c6a
...
...
@@ -18,9 +18,8 @@
#include "reg_test.h"
#define compare_export(f,e,todo) compare_export_(__FILE__,__LINE__,f,e,todo)
static
BOOL
compare_export_
(
const
char
*
file
,
unsigned
line
,
const
char
*
filename
,
const
char
*
expected
,
DWORD
todo
)
BOOL
compare_export_
(
const
char
*
file
,
unsigned
line
,
const
char
*
filename
,
const
char
*
expected
,
DWORD
todo
)
{
FILE
*
fp
;
long
file_size
;
...
...
@@ -64,6 +63,17 @@ error:
return
FALSE
;
}
const
char
*
empty_key_test
=
"
\xef\xbb\xbf
Windows 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\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
"
;
/* Unit tests */
static
void
test_export
(
void
)
...
...
@@ -73,16 +83,6 @@ static void test_export(void)
HKEY
hkey
,
subkey
;
BYTE
hex
[
4
],
buffer
[
8
];
const
char
*
empty_key_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n\r\n
"
;
const
char
*
simple_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
"
;
const
char
*
complex_test
=
"
\xef\xbb\xbf
Windows Registry Editor Version 5.00
\r\n\r\n
"
"[HKEY_CURRENT_USER
\\
"
KEY_BASE
"]
\r\n
"
...
...
@@ -243,12 +243,12 @@ 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"
,
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 */
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
(
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 */
add_key
(
hkey
,
"Subkey1"
,
&
subkey
);
...
...
programs/reg/tests/reg_test.h
View file @
bb609c6a
...
...
@@ -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)
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 */
#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)
...
...
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