Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
07e40a6f
Commit
07e40a6f
authored
Sep 20, 2023
by
Joel Holdsworth
Committed by
Alexandre Julliard
Oct 05, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add tests for FILE_RENAME_IGNORE_READONLY_ATTRIBUTE.
Signed-off-by:
Joel Holdsworth
<
joel@airwebreathe.org.uk
>
parent
ad232b53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
1 deletion
+96
-1
file.c
dlls/ntdll/tests/file.c
+96
-1
No files found.
dlls/ntdll/tests/file.c
View file @
07e40a6f
...
@@ -1502,7 +1502,9 @@ static void test_file_all_information(void)
...
@@ -1502,7 +1502,9 @@ static void test_file_all_information(void)
static
void
delete_object
(
WCHAR
*
path
)
static
void
delete_object
(
WCHAR
*
path
)
{
{
BOOL
ret
=
DeleteFileW
(
path
);
BOOL
ret
=
SetFileAttributesW
(
path
,
FILE_ATTRIBUTE_NORMAL
);
ok
(
ret
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"SetFileAttribute failed with %lu
\n
"
,
GetLastError
()
);
ret
=
DeleteFileW
(
path
);
ok
(
ret
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
||
GetLastError
()
==
ERROR_ACCESS_DENIED
,
ok
(
ret
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
||
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"DeleteFileW failed with %lu
\n
"
,
GetLastError
()
);
"DeleteFileW failed with %lu
\n
"
,
GetLastError
()
);
if
(
!
ret
&&
GetLastError
()
==
ERROR_ACCESS_DENIED
)
if
(
!
ret
&&
GetLastError
()
==
ERROR_ACCESS_DENIED
)
...
@@ -2178,6 +2180,98 @@ static void test_file_rename_information(FILE_INFORMATION_CLASS class)
...
@@ -2178,6 +2180,98 @@ static void test_file_rename_information(FILE_INFORMATION_CLASS class)
delete_object
(
oldpath
);
delete_object
(
oldpath
);
}
}
static
void
test_file_rename_information_ex
(
void
)
{
static
const
WCHAR
fooW
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
WCHAR
tmp_path
[
MAX_PATH
],
oldpath
[
MAX_PATH
+
16
],
newpath
[
MAX_PATH
+
16
];
FILE_RENAME_INFORMATION
*
fri
;
BOOL
fileDeleted
;
UNICODE_STRING
name_str
;
HANDLE
handle
,
handle2
;
IO_STATUS_BLOCK
io
;
NTSTATUS
res
;
GetTempPathW
(
MAX_PATH
,
tmp_path
);
/* oldpath is a file, newpath is a read-only file, with FILE_RENAME_REPLACE_IF_EXISTS */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_READONLY
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
CloseHandle
(
handle2
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fri
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
name_str
.
Length
);
fri
->
Flags
=
FILE_RENAME_REPLACE_IF_EXISTS
;
fri
->
RootDirectory
=
NULL
;
fri
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fri
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
io
.
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fri
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
fri
->
FileNameLength
,
FileRenameInformationEx
);
if
(
res
==
STATUS_NOT_IMPLEMENTED
||
res
==
STATUS_INVALID_INFO_CLASS
)
{
win_skip
(
"FileRenameInformationEx not supported
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fri
);
delete_object
(
oldpath
);
return
;
}
todo_wine
ok
(
io
.
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %lx
\n
"
,
io
.
Status
);
todo_wine
ok
(
res
==
STATUS_ACCESS_DENIED
,
"res expected STATUS_ACCESS_DENIED, got %lx
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
todo_wine
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fri
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a read-only file, with FILE_RENAME_REPLACE_IF_EXISTS and FILE_RENAME_IGNORE_READONLY_ATTRIBUTE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_READONLY
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
CloseHandle
(
handle2
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fri
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
name_str
.
Length
);
fri
->
Flags
=
FILE_RENAME_REPLACE_IF_EXISTS
|
FILE_RENAME_IGNORE_READONLY_ATTRIBUTE
;
fri
->
RootDirectory
=
NULL
;
fri
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fri
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
io
.
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fri
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
fri
->
FileNameLength
,
FileRenameInformationEx
);
ok
(
io
.
Status
==
STATUS_SUCCESS
,
"io.Status expected STATUS_SUCCESS, got %lx
\n
"
,
io
.
Status
);
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %lx
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
fileDeleted
,
"file should not exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fri
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
}
static
void
test_file_link_information
(
FILE_INFORMATION_CLASS
class
)
static
void
test_file_link_information
(
FILE_INFORMATION_CLASS
class
)
{
{
static
const
WCHAR
foo_txtW
[]
=
{
'\\'
,
'f'
,
'o'
,
'o'
,
'.'
,
't'
,
'x'
,
't'
,
0
};
static
const
WCHAR
foo_txtW
[]
=
{
'\\'
,
'f'
,
'o'
,
'o'
,
'.'
,
't'
,
'x'
,
't'
,
0
};
...
@@ -5699,6 +5793,7 @@ START_TEST(file)
...
@@ -5699,6 +5793,7 @@ START_TEST(file)
test_file_all_name_information
();
test_file_all_name_information
();
test_file_rename_information
(
FileRenameInformation
);
test_file_rename_information
(
FileRenameInformation
);
test_file_rename_information
(
FileRenameInformationEx
);
test_file_rename_information
(
FileRenameInformationEx
);
test_file_rename_information_ex
();
test_file_link_information
(
FileLinkInformation
);
test_file_link_information
(
FileLinkInformation
);
test_file_link_information
(
FileLinkInformationEx
);
test_file_link_information
(
FileLinkInformationEx
);
test_file_disposition_information
();
test_file_disposition_information
();
...
...
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