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
a5b58144
Commit
a5b58144
authored
Aug 20, 2015
by
Jianqiu Zhang
Committed by
Alexandre Julliard
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add basic tests for FileRenameInformation.
parent
48ed6a6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
file.c
dlls/ntdll/tests/file.c
+106
-0
No files found.
dlls/ntdll/tests/file.c
View file @
a5b58144
...
...
@@ -1435,6 +1435,111 @@ static void test_file_all_information(void)
CloseHandle
(
h
);
}
static
void
test_file_rename_information
(
void
)
{
static
const
WCHAR
fooW
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
WCHAR
tmp_path
[
MAX_PATH
],
oldpath
[
MAX_PATH
],
newpath
[
MAX_PATH
];
FILE_RENAME_INFORMATION
*
fri
;
UNICODE_STRING
name_str
;
IO_STATUS_BLOCK
io
;
BOOL
fileDeleted
;
HANDLE
handle
;
NTSTATUS
res
;
GetTempPathW
(
MAX_PATH
,
tmp_path
);
/* oldpath is a file, newpath doesn't exist */
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
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
DeleteFileW
(
newpath
);
fri
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
name_str
.
Length
);
fri
->
Replace
=
FALSE
;
fri
->
RootDir
=
NULL
;
fri
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fri
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fri
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
fri
->
FileNameLength
,
FileRenameInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
STATUS_SUCCESS
,
"io.Status expected STATUS_SUCCESS, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
todo_wine
ok
(
fileDeleted
,
"file should not exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
todo_wine
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fri
);
DeleteFileW
(
oldpath
);
DeleteFileW
(
newpath
);
/* oldpath is a file, newpath is a file, Replace = FALSE */
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
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fri
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
name_str
.
Length
);
fri
->
Replace
=
FALSE
;
fri
->
RootDir
=
NULL
;
fri
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fri
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fri
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
fri
->
FileNameLength
,
FileRenameInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
,
"res expected STATUS_OBJECT_NAME_COLLISION, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
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
);
DeleteFileW
(
oldpath
);
DeleteFileW
(
newpath
);
/* oldpath is a file, newpath is a file, Replace = TRUE */
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
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fri
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
name_str
.
Length
);
fri
->
Replace
=
TRUE
;
fri
->
RootDir
=
NULL
;
fri
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fri
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fri
,
sizeof
(
FILE_RENAME_INFORMATION
)
+
fri
->
FileNameLength
,
FileRenameInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
STATUS_SUCCESS
,
"io.Status expected STATUS_SUCCESS, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
todo_wine
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
);
DeleteFileW
(
oldpath
);
DeleteFileW
(
newpath
);
}
static
void
test_file_both_information
(
void
)
{
IO_STATUS_BLOCK
io
;
...
...
@@ -2858,6 +2963,7 @@ START_TEST(file)
test_file_name_information
();
test_file_full_size_information
();
test_file_all_name_information
();
test_file_rename_information
();
test_file_disposition_information
();
test_query_volume_information_file
();
test_query_attribute_information_file
();
...
...
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