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
39d8f137
Commit
39d8f137
authored
Nov 01, 2009
by
Michael Martin
Committed by
Alexandre Julliard
Nov 04, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Additional tests for CopyFile/MoveFile used on mapped files.
parent
59bb360a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
file.c
dlls/kernel32/tests/file.c
+70
-0
No files found.
dlls/kernel32/tests/file.c
View file @
39d8f137
...
@@ -563,6 +563,7 @@ static void test_CopyFileA(void)
...
@@ -563,6 +563,7 @@ static void test_CopyFileA(void)
char
source
[
MAX_PATH
],
dest
[
MAX_PATH
];
char
source
[
MAX_PATH
],
dest
[
MAX_PATH
];
static
const
char
prefix
[]
=
"pfx"
;
static
const
char
prefix
[]
=
"pfx"
;
HANDLE
hfile
;
HANDLE
hfile
;
HANDLE
hmapfile
;
FILETIME
ft1
,
ft2
;
FILETIME
ft1
,
ft2
;
char
buf
[
10
];
char
buf
[
10
];
DWORD
ret
;
DWORD
ret
;
...
@@ -628,6 +629,32 @@ static void test_CopyFileA(void)
...
@@ -628,6 +629,32 @@ static void test_CopyFileA(void)
ok
(
retok
&&
ret
==
sizeof
(
prefix
),
ok
(
retok
&&
ret
==
sizeof
(
prefix
),
"ReadFile: error %d
\n
"
,
GetLastError
());
"ReadFile: error %d
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
prefix
,
buf
,
sizeof
(
prefix
)),
"buffer contents mismatch
\n
"
);
ok
(
!
memcmp
(
prefix
,
buf
,
sizeof
(
prefix
)),
"buffer contents mismatch
\n
"
);
/* check error on copying over a mapped file that was opened with FILE_SHARE_READ */
hmapfile
=
CreateFileMapping
(
hfile
,
NULL
,
PAGE_READONLY
|
SEC_COMMIT
,
0
,
0
,
NULL
);
ok
(
hmapfile
!=
NULL
,
"CreateFileMapping: error %d
\n
"
,
GetLastError
());
ret
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"CopyFileA with mapped dest file: expected ERROR_SHARING_VIOLATION, got %d
\n
"
,
GetLastError
());
CloseHandle
(
hmapfile
);
CloseHandle
(
hfile
);
hfile
=
CreateFileA
(
dest
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open destination file
\n
"
);
/* check error on copying over a mapped file that was opened with FILE_SHARE_WRITE */
hmapfile
=
CreateFileMapping
(
hfile
,
NULL
,
PAGE_READONLY
|
SEC_COMMIT
,
0
,
0
,
NULL
);
ok
(
hmapfile
!=
NULL
,
"CreateFileMapping: error %d
\n
"
,
GetLastError
());
ret
=
CopyFileA
(
source
,
dest
,
FALSE
);
todo_wine
{
ok
(
!
ret
&&
GetLastError
()
==
ERROR_USER_MAPPED_FILE
,
"CopyFileA with mapped dest file: expected ERROR_USER_MAPPED_FILE, got %d
\n
"
,
GetLastError
());
}
CloseHandle
(
hmapfile
);
CloseHandle
(
hfile
);
CloseHandle
(
hfile
);
ret
=
DeleteFileA
(
source
);
ret
=
DeleteFileA
(
source
);
...
@@ -1263,7 +1290,10 @@ static void test_MoveFileA(void)
...
@@ -1263,7 +1290,10 @@ static void test_MoveFileA(void)
char
tempdir
[
MAX_PATH
];
char
tempdir
[
MAX_PATH
];
char
source
[
MAX_PATH
],
dest
[
MAX_PATH
];
char
source
[
MAX_PATH
],
dest
[
MAX_PATH
];
static
const
char
prefix
[]
=
"pfx"
;
static
const
char
prefix
[]
=
"pfx"
;
HANDLE
hfile
;
HANDLE
hmapfile
;
DWORD
ret
;
DWORD
ret
;
BOOL
retok
;
ret
=
GetTempPathA
(
MAX_PATH
,
tempdir
);
ret
=
GetTempPathA
(
MAX_PATH
,
tempdir
);
ok
(
ret
!=
0
,
"GetTempPathA error %d
\n
"
,
GetLastError
());
ok
(
ret
!=
0
,
"GetTempPathA error %d
\n
"
,
GetLastError
());
...
@@ -1282,6 +1312,46 @@ static void test_MoveFileA(void)
...
@@ -1282,6 +1312,46 @@ static void test_MoveFileA(void)
ret
=
DeleteFileA
(
dest
);
ret
=
DeleteFileA
(
dest
);
ok
(
ret
,
"DeleteFileA: error %d
\n
"
,
GetLastError
());
ok
(
ret
,
"DeleteFileA: error %d
\n
"
,
GetLastError
());
hfile
=
CreateFileA
(
source
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open source file
\n
"
);
retok
=
WriteFile
(
hfile
,
prefix
,
sizeof
(
prefix
),
&
ret
,
NULL
);
ok
(
retok
&&
ret
==
sizeof
(
prefix
),
"WriteFile error %d
\n
"
,
GetLastError
());
hmapfile
=
CreateFileMapping
(
hfile
,
NULL
,
PAGE_READONLY
|
SEC_COMMIT
,
0
,
0
,
NULL
);
ok
(
hmapfile
!=
NULL
,
"CreateFileMapping: error %d
\n
"
,
GetLastError
());
ret
=
MoveFileA
(
source
,
dest
);
todo_wine
{
ok
(
!
ret
,
"MoveFileA: expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"MoveFileA: expected ERROR_SHARING_VIOLATION, got %d
\n
"
,
GetLastError
());
}
CloseHandle
(
hmapfile
);
CloseHandle
(
hfile
);
/* if MoveFile succeeded, move back to dest */
if
(
ret
)
MoveFile
(
dest
,
source
);
hfile
=
CreateFileA
(
source
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open source file
\n
"
);
hmapfile
=
CreateFileMapping
(
hfile
,
NULL
,
PAGE_READONLY
|
SEC_COMMIT
,
0
,
0
,
NULL
);
ok
(
hmapfile
!=
NULL
,
"CreateFileMapping: error %d
\n
"
,
GetLastError
());
ret
=
MoveFileA
(
source
,
dest
);
todo_wine
{
ok
(
!
ret
,
"MoveFileA: expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"MoveFileA: expected ERROR_SHARING_VIOLATION, got %d
\n
"
,
GetLastError
());
}
CloseHandle
(
hmapfile
);
CloseHandle
(
hfile
);
/* if MoveFile succeeded, move back to dest */
if
(
ret
)
MoveFile
(
dest
,
source
);
ret
=
MoveFileA
(
source
,
dest
);
ret
=
MoveFileA
(
source
,
dest
);
ok
(
ret
,
"MoveFileA: failed, error %d
\n
"
,
GetLastError
());
ok
(
ret
,
"MoveFileA: failed, error %d
\n
"
,
GetLastError
());
...
...
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