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
9970ccb9
Commit
9970ccb9
authored
Apr 08, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Apr 09, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Add tests for SetupDecompressOrCopyFile.
parent
c1950e2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
0 deletions
+121
-0
misc.c
dlls/setupapi/tests/misc.c
+121
-0
No files found.
dlls/setupapi/tests/misc.c
View file @
9970ccb9
...
...
@@ -258,6 +258,25 @@ static void create_source_file(LPSTR filename, const BYTE *data, DWORD size)
CloseHandle
(
handle
);
}
static
BOOL
compare_file_data
(
LPSTR
file
,
const
BYTE
*
data
,
DWORD
size
)
{
DWORD
read
;
HANDLE
handle
;
BOOL
ret
=
FALSE
;
LPBYTE
buffer
;
handle
=
CreateFileA
(
file
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
buffer
)
{
ReadFile
(
handle
,
buffer
,
size
,
&
read
,
NULL
);
if
(
read
==
size
&&
!
memcmp
(
data
,
buffer
,
size
))
ret
=
TRUE
;
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
CloseHandle
(
handle
);
return
ret
;
}
static
const
BYTE
uncompressed
[]
=
{
'u'
,
'n'
,
'c'
,
'o'
,
'm'
,
'p'
,
'r'
,
'e'
,
's'
,
's'
,
'e'
,
'd'
,
'\r'
,
'\n'
};
...
...
@@ -360,10 +379,112 @@ static void test_SetupGetFileCompressionInfoEx(void)
DeleteFileA
(
source
);
}
static
void
test_SetupDecompressOrCopyFile
(
void
)
{
DWORD
ret
;
char
source
[
MAX_PATH
],
target
[
MAX_PATH
],
temp
[
MAX_PATH
],
*
p
;
UINT
type
;
GetTempPathA
(
sizeof
(
temp
),
temp
);
GetTempFileNameA
(
temp
,
"doc"
,
0
,
source
);
GetTempFileNameA
(
temp
,
"doc"
,
0
,
target
);
/* parameter tests */
create_source_file
(
source
,
uncompressed
,
sizeof
(
uncompressed
));
ret
=
SetupDecompressOrCopyFileA
(
NULL
,
NULL
,
NULL
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"SetupDecompressOrCopyFile failed unexpectedly
\n
"
);
type
=
FILE_COMPRESSION_NONE
;
ret
=
SetupDecompressOrCopyFileA
(
NULL
,
target
,
&
type
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"SetupDecompressOrCopyFile failed unexpectedly
\n
"
);
ret
=
SetupDecompressOrCopyFileA
(
source
,
NULL
,
&
type
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"SetupDecompressOrCopyFile failed unexpectedly
\n
"
);
type
=
5
;
/* try an invalid compression type */
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
&
type
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"SetupDecompressOrCopyFile failed unexpectedly
\n
"
);
DeleteFileA
(
target
);
/* no compression tests */
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
NULL
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
uncompressed
,
sizeof
(
uncompressed
)),
"incorrect target file
\n
"
);
/* try overwriting existing file */
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
NULL
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
DeleteFileA
(
target
);
type
=
FILE_COMPRESSION_NONE
;
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
&
type
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
uncompressed
,
sizeof
(
uncompressed
)),
"incorrect target file
\n
"
);
DeleteFileA
(
target
);
type
=
FILE_COMPRESSION_WINLZA
;
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
&
type
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
uncompressed
,
sizeof
(
uncompressed
)),
"incorrect target file
\n
"
);
DeleteFileA
(
target
);
/* lz compression tests */
create_source_file
(
source
,
comp_lzx
,
sizeof
(
comp_lzx
));
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
NULL
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
DeleteFileA
(
target
);
/* zip compression tests */
create_source_file
(
source
,
comp_zip
,
sizeof
(
comp_zip
));
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
NULL
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
comp_zip
,
sizeof
(
comp_zip
)),
"incorrect target file
\n
"
);
DeleteFileA
(
target
);
/* cabinet compression tests */
create_source_file
(
source
,
comp_cab_zip
,
sizeof
(
comp_cab_zip
));
p
=
strrchr
(
target
,
'\\'
);
lstrcpyA
(
p
+
1
,
"wine"
);
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
NULL
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
uncompressed
,
sizeof
(
uncompressed
)),
"incorrect target file
\n
"
);
/* try overwriting existing file */
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
NULL
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
/* try zip compression */
type
=
FILE_COMPRESSION_MSZIP
;
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
&
type
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
uncompressed
,
sizeof
(
uncompressed
)),
"incorrect target file
\n
"
);
/* try no compression */
type
=
FILE_COMPRESSION_NONE
;
ret
=
SetupDecompressOrCopyFileA
(
source
,
target
,
&
type
);
ok
(
!
ret
,
"SetupDecompressOrCopyFile failed unexpectedly: %d
\n
"
,
ret
);
ok
(
compare_file_data
(
target
,
comp_cab_zip
,
sizeof
(
comp_cab_zip
)),
"incorrect target file
\n
"
);
DeleteFileA
(
target
);
DeleteFileA
(
source
);
}
START_TEST
(
misc
)
{
GetCurrentDirectoryA
(
MAX_PATH
,
CURR_DIR
);
test_SetupCopyOEMInf
();
test_SetupGetFileCompressionInfoEx
();
test_SetupDecompressOrCopyFile
();
}
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