Module: wine Branch: master Commit: 5b75d943044feba2ac92f8e05e3827c8ac3e8a4d URL: https://source.winehq.org/git/wine.git/?a=commit;h=5b75d943044feba2ac92f8e05...
Author: Zebediah Figura z.figura12@gmail.com Date: Tue Mar 10 22:38:22 2020 -0500
ntdll/tests: Add tests for linking a file to the same name.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/tests/file.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index e71f887c2b..a05b124fd2 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -2759,6 +2759,36 @@ static void test_file_link_information(void) HeapFree( GetProcessHeap(), 0, fli ); delete_object( oldpath ); delete_object( newpath ); + + /* oldpath == newpath */ + 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" ); + + pRtlDosPathNameToNtPathName_U( oldpath, &name_str, NULL, NULL ); + fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length ); + fli->ReplaceIfExists = FALSE; + fli->RootDirectory = NULL; + fli->FileNameLength = name_str.Length; + memcpy( fli->FileName, name_str.Buffer, name_str.Length ); + pRtlFreeUnicodeString( &name_str ); + + U(io).Status = 0xdeadbeef; + res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation ); + todo_wine ok( U(io).Status == 0xdeadbeef, "got io status %#x\n", U(io).Status ); + ok( res == STATUS_OBJECT_NAME_COLLISION, "got status %x\n", res ); + + fli->ReplaceIfExists = TRUE; + U(io).Status = 0xdeadbeef; + res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation ); + todo_wine ok( U(io).Status == STATUS_SUCCESS, "got io status %#x\n", U(io).Status ); + todo_wine ok( res == STATUS_SUCCESS, "got status %x\n", res ); + ok( GetFileAttributesW( oldpath ) != INVALID_FILE_ATTRIBUTES, "file should exist\n" ); + + CloseHandle( handle ); + HeapFree( GetProcessHeap(), 0, fli ); + delete_object( oldpath ); }
static void test_file_both_information(void)