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
b4e375ec
Commit
b4e375ec
authored
Sep 25, 2013
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Sep 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add DuplicateHandle test to the file access tests.
parent
2a39cb37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
3 deletions
+48
-3
file.c
dlls/kernel32/tests/file.c
+48
-3
No files found.
dlls/kernel32/tests/file.c
View file @
b4e375ec
...
...
@@ -3890,11 +3890,27 @@ static void test_SetFileValidData(void)
DeleteFile
(
filename
);
}
static
unsigned
file_map_access
(
unsigned
access
)
{
if
(
access
&
GENERIC_READ
)
access
|=
FILE_GENERIC_READ
;
if
(
access
&
GENERIC_WRITE
)
access
|=
FILE_GENERIC_WRITE
;
if
(
access
&
GENERIC_EXECUTE
)
access
|=
FILE_GENERIC_EXECUTE
;
if
(
access
&
GENERIC_ALL
)
access
|=
FILE_ALL_ACCESS
;
return
access
&
~
(
GENERIC_READ
|
GENERIC_WRITE
|
GENERIC_EXECUTE
|
GENERIC_ALL
);
}
static
BOOL
is_access_compatible
(
unsigned
obj_access
,
unsigned
desired_access
)
{
obj_access
=
file_map_access
(
obj_access
);
desired_access
=
file_map_access
(
desired_access
);
return
(
obj_access
&
desired_access
)
==
desired_access
;
}
static
void
test_file_access
(
void
)
{
static
const
struct
{
int
access
,
create_error
,
write_error
,
read_error
;
unsigned
access
,
create_error
,
write_error
,
read_error
;
}
td
[]
=
{
{
GENERIC_READ
|
GENERIC_WRITE
,
0
,
0
,
0
},
...
...
@@ -3910,8 +3926,8 @@ static void test_file_access(void)
};
char
path
[
MAX_PATH
],
fname
[
MAX_PATH
];
unsigned
char
buf
[
16
];
HANDLE
hfile
;
DWORD
i
,
ret
,
bytes
;
HANDLE
hfile
,
hdup
;
DWORD
i
,
j
,
ret
,
bytes
;
GetTempPath
(
MAX_PATH
,
path
);
GetTempFileName
(
path
,
"foo"
,
0
,
fname
);
...
...
@@ -3930,6 +3946,35 @@ static void test_file_access(void)
else
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"%d: CreateFile error %d
\n
"
,
i
,
GetLastError
());
for
(
j
=
0
;
j
<
sizeof
(
td
)
/
sizeof
(
td
[
0
]);
j
++
)
{
SetLastError
(
0xdeadbeef
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
hfile
,
GetCurrentProcess
(),
&
hdup
,
td
[
j
].
access
,
0
,
0
);
if
(
is_access_compatible
(
td
[
i
].
access
,
td
[
j
].
access
))
ok
(
ret
,
"DuplicateHandle(%#x => %#x) error %d
\n
"
,
td
[
i
].
access
,
td
[
j
].
access
,
GetLastError
());
else
{
/* FIXME: Remove once Wine is fixed */
if
((
td
[
j
].
access
&
(
GENERIC_READ
|
GENERIC_WRITE
))
||
(
!
(
td
[
i
].
access
&
(
GENERIC_WRITE
|
FILE_WRITE_DATA
))
&&
(
td
[
j
].
access
&
FILE_WRITE_DATA
))
||
(
!
(
td
[
i
].
access
&
(
GENERIC_READ
|
FILE_READ_DATA
))
&&
(
td
[
j
].
access
&
FILE_READ_DATA
))
||
(
!
(
td
[
i
].
access
&
(
GENERIC_WRITE
))
&&
(
td
[
j
].
access
&
FILE_APPEND_DATA
)))
{
todo_wine
ok
(
!
ret
,
"DuplicateHandle(%#x => %#x) should fail
\n
"
,
td
[
i
].
access
,
td
[
j
].
access
);
todo_wine
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
}
else
{
ok
(
!
ret
,
"DuplicateHandle(%#x => %#x) should fail
\n
"
,
td
[
i
].
access
,
td
[
j
].
access
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
}
}
if
(
ret
)
CloseHandle
(
hdup
);
}
SetLastError
(
0xdeadbeef
);
bytes
=
0xdeadbeef
;
ret
=
WriteFile
(
hfile
,
"
\x5e\xa7
"
,
2
,
&
bytes
,
NULL
);
...
...
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