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
73161220
Commit
73161220
authored
Jun 25, 2021
by
Qian Hong
Committed by
Alexandre Julliard
Jun 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Test deleting files with an open mapping.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e5f42e9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
2 deletions
+91
-2
file.c
dlls/ntdll/tests/file.c
+91
-2
No files found.
dlls/ntdll/tests/file.c
View file @
73161220
...
@@ -2960,12 +2960,13 @@ static void test_file_disposition_information(void)
...
@@ -2960,12 +2960,13 @@ static void test_file_disposition_information(void)
{
{
char
tmp_path
[
MAX_PATH
],
buffer
[
MAX_PATH
+
16
];
char
tmp_path
[
MAX_PATH
],
buffer
[
MAX_PATH
+
16
];
DWORD
dirpos
;
DWORD
dirpos
;
HANDLE
handle
,
handle2
,
handle3
;
HANDLE
handle
,
handle2
,
handle3
,
mapping
;
NTSTATUS
res
;
NTSTATUS
res
;
IO_STATUS_BLOCK
io
;
IO_STATUS_BLOCK
io
;
FILE_DISPOSITION_INFORMATION
fdi
;
FILE_DISPOSITION_INFORMATION
fdi
;
BOOL
fileDeleted
;
BOOL
fileDeleted
;
DWORD
fdi2
;
DWORD
fdi2
,
size
;
void
*
view
;
GetTempPathA
(
MAX_PATH
,
tmp_path
);
GetTempPathA
(
MAX_PATH
,
tmp_path
);
...
@@ -3312,6 +3313,94 @@ todo_wine
...
@@ -3312,6 +3313,94 @@ todo_wine
ok
(
!
fileDeleted
,
"Directory shouldn't have been deleted
\n
"
);
ok
(
!
fileDeleted
,
"Directory shouldn't have been deleted
\n
"
);
fileDeleted
=
RemoveDirectoryA
(
buffer
);
fileDeleted
=
RemoveDirectoryA
(
buffer
);
ok
(
fileDeleted
,
"Directory should have been deleted
\n
"
);
ok
(
fileDeleted
,
"Directory should have been deleted
\n
"
);
/* a file with an open mapping handle cannot be deleted */
GetTempFileNameA
(
tmp_path
,
"dis"
,
0
,
buffer
);
handle
=
CreateFileA
(
buffer
,
GENERIC_READ
|
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"failed to create file, error %u
\n
"
,
GetLastError
()
);
WriteFile
(
handle
,
"data"
,
4
,
&
size
,
NULL
);
mapping
=
CreateFileMappingA
(
handle
,
NULL
,
PAGE_READONLY
,
0
,
4
,
NULL
);
ok
(
!!
mapping
,
"failed to create mapping, error %u
\n
"
,
GetLastError
()
);
fdi
.
DoDeleteFile
=
FALSE
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
&
fdi
,
sizeof
(
fdi
),
FileDispositionInformation
);
ok
(
!
res
,
"got %#x
\n
"
,
res
);
fdi
.
DoDeleteFile
=
TRUE
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
&
fdi
,
sizeof
(
fdi
),
FileDispositionInformation
);
todo_wine
ok
(
res
==
STATUS_CANNOT_DELETE
,
"got %#x
\n
"
,
res
);
res
=
GetFileAttributesA
(
buffer
);
ok
(
res
!=
INVALID_FILE_ATTRIBUTES
,
"expected file to exist
\n
"
);
CloseHandle
(
mapping
);
CloseHandle
(
handle
);
res
=
DeleteFileA
(
buffer
);
todo_wine
ok
(
res
,
"got error %u
\n
"
,
GetLastError
()
);
GetTempFileNameA
(
tmp_path
,
"dis"
,
0
,
buffer
);
handle
=
CreateFileA
(
buffer
,
GENERIC_READ
|
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"failed to create file, error %u
\n
"
,
GetLastError
()
);
WriteFile
(
handle
,
"data"
,
4
,
&
size
,
NULL
);
mapping
=
CreateFileMappingA
(
handle
,
NULL
,
PAGE_READONLY
,
0
,
4
,
NULL
);
ok
(
!!
mapping
,
"failed to create mapping, error %u
\n
"
,
GetLastError
()
);
CloseHandle
(
mapping
);
fdi
.
DoDeleteFile
=
TRUE
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
&
fdi
,
sizeof
(
fdi
),
FileDispositionInformation
);
ok
(
!
res
,
"got %#x
\n
"
,
res
);
CloseHandle
(
handle
);
res
=
DeleteFileA
(
buffer
);
ok
(
!
res
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"got error %u
\n
"
,
GetLastError
()
);
/* a file with an open view cannot be deleted */
GetTempFileNameA
(
tmp_path
,
"dis"
,
0
,
buffer
);
handle
=
CreateFileA
(
buffer
,
GENERIC_READ
|
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"failed to create file, error %u
\n
"
,
GetLastError
()
);
WriteFile
(
handle
,
"data"
,
4
,
&
size
,
NULL
);
mapping
=
CreateFileMappingA
(
handle
,
NULL
,
PAGE_READONLY
,
0
,
4
,
NULL
);
ok
(
!!
mapping
,
"failed to create mapping, error %u
\n
"
,
GetLastError
()
);
view
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
4
);
ok
(
!!
view
,
"failed to map view, error %u
\n
"
,
GetLastError
()
);
CloseHandle
(
mapping
);
fdi
.
DoDeleteFile
=
FALSE
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
&
fdi
,
sizeof
(
fdi
),
FileDispositionInformation
);
ok
(
!
res
,
"got %#x
\n
"
,
res
);
fdi
.
DoDeleteFile
=
TRUE
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
&
fdi
,
sizeof
(
fdi
),
FileDispositionInformation
);
todo_wine
ok
(
res
==
STATUS_CANNOT_DELETE
,
"got %#x
\n
"
,
res
);
res
=
GetFileAttributesA
(
buffer
);
ok
(
res
!=
INVALID_FILE_ATTRIBUTES
,
"expected file to exist
\n
"
);
UnmapViewOfFile
(
view
);
CloseHandle
(
handle
);
res
=
DeleteFileA
(
buffer
);
todo_wine
ok
(
res
,
"got error %u
\n
"
,
GetLastError
()
);
GetTempFileNameA
(
tmp_path
,
"dis"
,
0
,
buffer
);
handle
=
CreateFileA
(
buffer
,
GENERIC_READ
|
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"failed to create file, error %u
\n
"
,
GetLastError
()
);
WriteFile
(
handle
,
"data"
,
4
,
&
size
,
NULL
);
mapping
=
CreateFileMappingA
(
handle
,
NULL
,
PAGE_READONLY
,
0
,
4
,
NULL
);
ok
(
!!
mapping
,
"failed to create mapping, error %u
\n
"
,
GetLastError
()
);
view
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
4
);
ok
(
!!
view
,
"failed to map view, error %u
\n
"
,
GetLastError
()
);
CloseHandle
(
mapping
);
UnmapViewOfFile
(
view
);
fdi
.
DoDeleteFile
=
TRUE
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
&
fdi
,
sizeof
(
fdi
),
FileDispositionInformation
);
ok
(
!
res
,
"got %#x
\n
"
,
res
);
CloseHandle
(
handle
);
res
=
DeleteFileA
(
buffer
);
ok
(
!
res
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"got error %u
\n
"
,
GetLastError
()
);
}
}
static
void
test_file_name_information
(
void
)
static
void
test_file_name_information
(
void
)
...
...
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