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
304fb43a
Commit
304fb43a
authored
Apr 09, 2019
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Apr 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Test readonly file access.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
b193e6a7
Hide 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 @
304fb43a
...
...
@@ -5228,6 +5228,75 @@ static void test_overlapped_read(void)
ok
(
ret
,
"Unexpected error %u.
\n
"
,
GetLastError
());
}
static
void
test_file_readonly_access
(
void
)
{
static
const
DWORD
default_sharing
=
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
;
static
const
CHAR
prefix
[]
=
"pfx"
;
CHAR
file_name
[
MAX_PATH
],
file_name2
[
MAX_PATH
];
CHAR
temp_path
[
MAX_PATH
];
HANDLE
handle
;
DWORD
error
;
DWORD
ret
;
/* Set up */
ret
=
GetTempPathA
(
MAX_PATH
,
temp_path
);
ok
(
ret
!=
0
,
"GetTempPathA error %d
\n
"
,
GetLastError
());
ok
(
ret
<
MAX_PATH
,
"temp path should fit into MAX_PATH
\n
"
);
ret
=
GetTempFileNameA
(
temp_path
,
prefix
,
0
,
file_name
);
ok
(
ret
!=
0
,
"GetTempFileNameA error %d
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
file_name
);
ok
(
ret
,
"expect success
\n
"
);
ret
=
GetTempFileNameA
(
temp_path
,
prefix
,
0
,
file_name2
);
ok
(
ret
!=
0
,
"GetTempFileNameA error %d
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
file_name2
);
ok
(
ret
,
"expect success
\n
"
);
handle
=
CreateFileA
(
file_name
,
0
,
default_sharing
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_READONLY
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileA: error %d
\n
"
,
GetLastError
());
CloseHandle
(
handle
);
/* CreateFile GENERIC_WRITE */
SetLastError
(
0xdeadbeef
);
handle
=
CreateFileA
(
file_name
,
GENERIC_WRITE
,
default_sharing
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
0
);
error
=
GetLastError
();
ok
(
handle
==
INVALID_HANDLE_VALUE
,
"expect failure
\n
"
);
ok
(
error
==
ERROR_ACCESS_DENIED
,
"wrong error code: %#x
\n
"
,
error
);
/* CreateFile DELETE without FILE_FLAG_DELETE_ON_CLOSE */
handle
=
CreateFileA
(
file_name
,
DELETE
,
default_sharing
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"expect success
\n
"
);
CloseHandle
(
handle
);
/* CreateFile DELETE with FILE_FLAG_DELETE_ON_CLOSE */
SetLastError
(
0xdeadbeef
);
handle
=
CreateFileA
(
file_name
,
DELETE
,
default_sharing
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_DELETE_ON_CLOSE
|
FILE_ATTRIBUTE_NORMAL
,
0
);
error
=
GetLastError
();
ok
(
handle
==
INVALID_HANDLE_VALUE
,
"expect failure
\n
"
);
ok
(
error
==
ERROR_ACCESS_DENIED
,
"wrong error code: %#x
\n
"
,
error
);
ret
=
MoveFileA
(
file_name
,
file_name2
);
ok
(
ret
,
"expect success
\n
"
);
ret
=
MoveFileA
(
file_name2
,
file_name
);
ok
(
ret
,
"expect success
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
DeleteFileA
(
file_name
);
error
=
GetLastError
();
ok
(
!
ret
,
"expect failure
\n
"
);
ok
(
error
==
ERROR_ACCESS_DENIED
,
"wrong error code: %#x
\n
"
,
error
);
ret
=
GetFileAttributesA
(
file_name
);
ok
(
ret
&
FILE_ATTRIBUTE_READONLY
,
"got wrong attribute: %#x.
\n
"
,
ret
);
/* Clean up */
SetFileAttributesA
(
file_name
,
FILE_ATTRIBUTE_NORMAL
);
ret
=
DeleteFileA
(
file_name
);
ok
(
ret
,
"DeleteFileA: error %d
\n
"
,
GetLastError
());
}
START_TEST
(
file
)
{
char
temp_path
[
MAX_PATH
];
...
...
@@ -5298,4 +5367,5 @@ START_TEST(file)
test_GetFileAttributesExW
();
test_post_completion
();
test_overlapped_read
();
test_file_readonly_access
();
}
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