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
08a7836e
Commit
08a7836e
authored
Sep 18, 2017
by
Hugh McMaster
Committed by
Alexandre Julliard
Sep 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg/tests: Use a helper function to write registry files.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
733350b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
reg.c
programs/reg/tests/reg.c
+25
-27
No files found.
programs/reg/tests/reg.c
View file @
08a7836e
...
...
@@ -731,23 +731,33 @@ static BOOL write_reg_file(const char *value, char *tmp_name)
return
ret
;
}
static
BOOL
write_file
(
const
void
*
str
,
DWORD
size
)
{
HANDLE
file
;
BOOL
ret
;
DWORD
written
;
file
=
CreateFileA
(
"test.reg"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"Failed to create registry file
\n
"
);
if
(
file
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
ret
=
WriteFile
(
file
,
str
,
size
,
&
written
,
NULL
);
ok
(
ret
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
file
);
return
ret
;
}
#define test_import_str(c,r) test_import_str_(__LINE__,c,r)
static
BOOL
test_import_str_
(
unsigned
line
,
const
char
*
file_contents
,
DWORD
*
rc
)
{
HANDLE
regfile
;
DWORD
written
;
BOOL
ret
;
regfile
=
CreateFileA
(
"test.reg"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
lok
(
regfile
!=
INVALID_HANDLE_VALUE
,
"Failed to create test.reg file
\n
"
);
if
(
regfile
==
INVALID_HANDLE_VALUE
)
if
(
!
write_file
(
file_contents
,
strlen
(
file_contents
)))
return
FALSE
;
ret
=
WriteFile
(
regfile
,
file_contents
,
strlen
(
file_contents
),
&
written
,
NULL
);
lok
(
ret
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
regfile
);
run_reg_exe
(
"reg import test.reg"
,
rc
);
ret
=
DeleteFileA
(
"test.reg"
);
...
...
@@ -761,9 +771,7 @@ static BOOL test_import_wstr_(unsigned line, const char *file_contents, DWORD *r
{
int
lenA
,
len
,
memsize
;
WCHAR
*
wstr
;
HANDLE
regfile
;
DWORD
written
;
BOOL
ret
;
BOOL
ret
=
FALSE
;
lenA
=
strlen
(
file_contents
);
...
...
@@ -773,26 +781,16 @@ static BOOL test_import_wstr_(unsigned line, const char *file_contents, DWORD *r
if
(
!
wstr
)
return
FALSE
;
MultiByteToWideChar
(
CP_UTF8
,
0
,
file_contents
,
lenA
,
wstr
,
len
);
regfile
=
CreateFileA
(
"test.reg"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
lok
(
regfile
!=
INVALID_HANDLE_VALUE
,
"Failed to create test.reg file
\n
"
);
if
(
regfile
==
INVALID_HANDLE_VALUE
)
{
HeapFree
(
GetProcessHeap
(),
0
,
wstr
);
return
FALSE
;
}
ret
=
WriteFile
(
regfile
,
wstr
,
memsize
,
&
written
,
NULL
);
lok
(
ret
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
regfile
);
HeapFree
(
GetProcessHeap
(),
0
,
wstr
);
if
(
!
write_file
(
wstr
,
memsize
))
goto
exit
;
run_reg_exe
(
"reg import test.reg"
,
rc
);
ret
=
DeleteFileA
(
"test.reg"
);
lok
(
ret
,
"DeleteFile failed: %u
\n
"
,
GetLastError
());
exit:
HeapFree
(
GetProcessHeap
(),
0
,
wstr
);
return
ret
;
}
...
...
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