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
556121b1
Commit
556121b1
authored
Jun 25, 2021
by
Hugh McMaster
Committed by
Alexandre Julliard
Jun 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg/tests: Test deletion of keys and values using registry views.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8ad9c21b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
275 additions
and
0 deletions
+275
-0
delete.c
programs/reg/tests/delete.c
+275
-0
No files found.
programs/reg/tests/delete.c
View file @
556121b1
...
...
@@ -66,6 +66,16 @@ static void test_command_syntax(void)
run_reg_exe
(
"reg delete HKCU
\\
"
KEY_BASE
" /f /v"
,
&
r
);
ok
(
r
==
REG_EXIT_FAILURE
,
"got exit code %d, expected 1
\n
"
,
r
);
/* Test registry view */
run_reg_exe
(
"reg delete HKCU
\\
"
KEY_BASE
" /f /reg:32 /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_FAILURE
,
"got exit code %d, expected 1
\n
"
,
r
);
run_reg_exe
(
"reg delete HKCU
\\
"
KEY_BASE
" /f /reg:32 /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_FAILURE
,
"got exit code %d, expected 1
\n
"
,
r
);
run_reg_exe
(
"reg delete HKCU
\\
"
KEY_BASE
" /f /reg:64 /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_FAILURE
,
"got exit code %d, expected 1
\n
"
,
r
);
}
static
void
test_delete
(
void
)
...
...
@@ -141,6 +151,259 @@ static void test_delete(void)
ok
(
r
==
REG_EXIT_FAILURE
,
"got exit code %d, expected 1
\n
"
,
r
);
}
static
void
create_test_key
(
REGSAM
sam
)
{
HKEY
hkey
,
subkey
;
DWORD
dword
;
add_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
sam
,
&
hkey
);
dword
=
0x100
;
add_value
(
hkey
,
"DWORD"
,
REG_DWORD
,
&
dword
,
sizeof
(
dword
));
add_value
(
hkey
,
"String"
,
REG_SZ
,
"Your text here..."
,
18
);
add_value
(
hkey
,
NULL
,
REG_SZ
,
"Default value name"
,
19
);
add_value
(
hkey
,
"Multiple Strings"
,
REG_MULTI_SZ
,
"Line1
\0
Line2
\0
Line3
\0
"
,
19
);
add_key
(
hkey
,
"Subkey"
,
sam
,
&
subkey
);
add_value
(
subkey
,
"Binary"
,
REG_BINARY
,
"
\x11\x22\x33\x44
"
,
4
);
add_value
(
subkey
,
"Undefined hex"
,
0x100
,
"%PATH%"
,
7
);
close_key
(
subkey
);
close_key
(
hkey
);
}
static
void
test_registry_view_win32
(
void
)
{
HKEY
hkey
;
DWORD
r
;
BOOL
is_wow64
,
is_win32
;
IsWow64Process
(
GetCurrentProcess
(),
&
is_wow64
);
is_win32
=
!
is_wow64
&&
(
sizeof
(
void
*
)
==
sizeof
(
int
));
if
(
!
is_win32
)
return
;
delete_tree
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
/* Test deletion from the 32-bit registry view (32-bit Windows) */
create_test_key
(
KEY_WOW64_32KEY
);
open_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
,
&
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /v DWORD /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"DWORD"
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /ve /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
NULL
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /va /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"String"
);
verify_reg_nonexist
(
hkey
,
"Multiple Strings"
);
verify_key
(
hkey
,
"Subkey"
,
KEY_WOW64_32KEY
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
"
\\
Subkey /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
hkey
,
"Subkey"
,
KEY_WOW64_32KEY
);
close_key
(
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
/* Test deletion from the 64-bit registry view, which doesn't exist on 32-bit Windows */
create_test_key
(
KEY_WOW64_64KEY
);
open_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
,
&
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /v DWORD /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"DWORD"
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /ve /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
NULL
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /va /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"String"
);
verify_reg_nonexist
(
hkey
,
"Multiple Strings"
);
verify_key
(
hkey
,
"Subkey"
,
KEY_WOW64_64KEY
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
"
\\
Subkey /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
hkey
,
"Subkey"
,
KEY_WOW64_64KEY
);
close_key
(
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
}
static
void
test_registry_view_win64
(
void
)
{
HKEY
hkey
;
DWORD
r
;
BOOL
is_wow64
,
is_win64
;
IsWow64Process
(
GetCurrentProcess
(),
&
is_wow64
);
is_win64
=
!
is_wow64
&&
(
sizeof
(
void
*
)
>
sizeof
(
int
));
if
(
!
is_win64
)
return
;
delete_tree
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
delete_tree
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
/* Test deletion from the 32-bit registry view (64-bit Windows) */
create_test_key
(
KEY_WOW64_32KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
open_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
,
&
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /v DWORD /f /reg:32"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg_nonexist
(
hkey
,
"DWORD"
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /ve /f /reg:32"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg_nonexist
(
hkey
,
NULL
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /va /f /reg:32"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg_nonexist
(
hkey
,
"String"
);
todo_wine
verify_reg_nonexist
(
hkey
,
"Multiple Strings"
);
verify_key
(
hkey
,
"Subkey"
,
KEY_WOW64_32KEY
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
"
\\
Subkey /f /reg:32"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_key_nonexist
(
hkey
,
"Subkey"
,
KEY_WOW64_32KEY
);
close_key
(
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /f /reg:32"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
/* Test deletion from the 64-bit registry view (64-bit Windows) */
create_test_key
(
KEY_WOW64_64KEY
);
todo_wine
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
open_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
,
&
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /v DWORD /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"DWORD"
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /ve /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
NULL
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /va /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"String"
);
verify_reg_nonexist
(
hkey
,
"Multiple Strings"
);
verify_key
(
hkey
,
"Subkey"
,
KEY_WOW64_64KEY
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
"
\\
Subkey /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
hkey
,
"Subkey"
,
KEY_WOW64_64KEY
);
close_key
(
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /f /reg:64"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
}
static
void
test_registry_view_wow64
(
void
)
{
HKEY
hkey
;
DWORD
r
;
BOOL
is_wow64
;
IsWow64Process
(
GetCurrentProcess
(),
&
is_wow64
);
if
(
!
is_wow64
)
return
;
delete_tree
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
delete_tree
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
/* Test deletion from the 32-bit registry view (WOW64) */
create_test_key
(
KEY_WOW64_32KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
open_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
,
&
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /v DWORD /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"DWORD"
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /ve /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
NULL
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /va /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg_nonexist
(
hkey
,
"String"
);
verify_reg_nonexist
(
hkey
,
"Multiple Strings"
);
verify_key
(
hkey
,
"Subkey"
,
KEY_WOW64_32KEY
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
"
\\
Subkey /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
hkey
,
"Subkey"
,
KEY_WOW64_32KEY
);
close_key
(
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /f /reg:32"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
/* Test deletion from the 64-bit registry view (WOW64) */
create_test_key
(
KEY_WOW64_64KEY
);
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_32KEY
);
open_key
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
,
&
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /v DWORD /f /reg:64"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg_nonexist
(
hkey
,
"DWORD"
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /ve /f /reg:64"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg_nonexist
(
hkey
,
NULL
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /va /f /reg:64"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg_nonexist
(
hkey
,
"String"
);
todo_wine
verify_reg_nonexist
(
hkey
,
"Multiple Strings"
);
verify_key
(
hkey
,
"Subkey"
,
KEY_WOW64_64KEY
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
"
\\
Subkey /f /reg:64"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_key_nonexist
(
hkey
,
"Subkey"
,
KEY_WOW64_64KEY
);
close_key
(
hkey
);
run_reg_exe
(
"reg delete HKLM
\\
"
KEY_BASE
" /f /reg:64"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_key_nonexist
(
HKEY_LOCAL_MACHINE
,
KEY_BASE
,
KEY_WOW64_64KEY
);
}
START_TEST
(
delete
)
{
DWORD
r
;
...
...
@@ -152,4 +415,16 @@ START_TEST(delete)
test_command_syntax
();
test_delete
();
/* Check if reg.exe is running with elevated privileges */
if
(
!
is_elevated_process
())
{
win_skip
(
"reg.exe is not running with elevated privileges; "
"skipping registry view tests
\n
"
);
return
;
}
test_registry_view_win32
();
test_registry_view_win64
();
test_registry_view_wow64
();
}
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