ntdll/tests: Test hard linking a file to a different casing of itself or existing target.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
01283ec6a6
commit
ec20f767fb
|
@ -2176,6 +2176,7 @@ static void test_file_link_information(void)
|
||||||
WCHAR tmp_path[MAX_PATH], oldpath[MAX_PATH + 16], newpath[MAX_PATH + 16], *filename, *p;
|
WCHAR tmp_path[MAX_PATH], oldpath[MAX_PATH + 16], newpath[MAX_PATH + 16], *filename, *p;
|
||||||
FILE_LINK_INFORMATION *fli;
|
FILE_LINK_INFORMATION *fli;
|
||||||
FILE_NAME_INFORMATION *fni;
|
FILE_NAME_INFORMATION *fni;
|
||||||
|
WIN32_FIND_DATAW find_data;
|
||||||
BOOL success, fileDeleted;
|
BOOL success, fileDeleted;
|
||||||
UNICODE_STRING name_str;
|
UNICODE_STRING name_str;
|
||||||
HANDLE handle, handle2;
|
HANDLE handle, handle2;
|
||||||
|
@ -2283,6 +2284,46 @@ static void test_file_link_information(void)
|
||||||
delete_object( oldpath );
|
delete_object( oldpath );
|
||||||
delete_object( newpath );
|
delete_object( newpath );
|
||||||
|
|
||||||
|
/* oldpath is a file, newpath is a file, ReplaceIfExists = TRUE, different casing on link */
|
||||||
|
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" );
|
||||||
|
wcsrchr( newpath, '\\' )[1] = 'F';
|
||||||
|
pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
|
||||||
|
fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
|
||||||
|
fli->ReplaceIfExists = TRUE;
|
||||||
|
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 );
|
||||||
|
ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
|
||||||
|
ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, 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 );
|
||||||
|
handle = FindFirstFileW( newpath, &find_data );
|
||||||
|
ok(handle != INVALID_HANDLE_VALUE, "FindFirstFileW: failed, error %d\n", GetLastError());
|
||||||
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
todo_wine ok(!lstrcmpW(wcsrchr(newpath, '\\') + 1, find_data.cFileName),
|
||||||
|
"Link did not change casing on existing target file: got %s\n", wine_dbgstr_w(find_data.cFileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle( handle );
|
||||||
|
HeapFree( GetProcessHeap(), 0, fli );
|
||||||
|
delete_object( oldpath );
|
||||||
|
delete_object( newpath );
|
||||||
|
|
||||||
/* oldpath is a file, newpath is a file, ReplaceIfExists = FALSE, target file opened */
|
/* oldpath is a file, newpath is a file, ReplaceIfExists = FALSE, target file opened */
|
||||||
res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
|
res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
|
||||||
ok( res != 0, "failed to create temp file\n" );
|
ok( res != 0, "failed to create temp file\n" );
|
||||||
|
@ -2826,6 +2867,46 @@ static void test_file_link_information(void)
|
||||||
CloseHandle( handle );
|
CloseHandle( handle );
|
||||||
HeapFree( GetProcessHeap(), 0, fli );
|
HeapFree( GetProcessHeap(), 0, fli );
|
||||||
delete_object( oldpath );
|
delete_object( oldpath );
|
||||||
|
|
||||||
|
/* oldpath == newpath, different casing on link */
|
||||||
|
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" );
|
||||||
|
|
||||||
|
wcsrchr( oldpath, '\\' )[1] = 'F';
|
||||||
|
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 );
|
||||||
|
ok( U(io).Status == STATUS_SUCCESS, "got io status %#x\n", U(io).Status );
|
||||||
|
ok( res == STATUS_SUCCESS, "got status %x\n", res );
|
||||||
|
ok( GetFileAttributesW( oldpath ) != INVALID_FILE_ATTRIBUTES, "file should exist\n" );
|
||||||
|
|
||||||
|
CloseHandle( handle );
|
||||||
|
handle = FindFirstFileW( oldpath, &find_data );
|
||||||
|
ok(handle != INVALID_HANDLE_VALUE, "FindFirstFileW: failed, error %d\n", GetLastError());
|
||||||
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
todo_wine ok(!lstrcmpW(wcsrchr(oldpath, '\\') + 1, find_data.cFileName),
|
||||||
|
"Link did not change casing on same file: got %s\n", wine_dbgstr_w(find_data.cFileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle( handle );
|
||||||
|
HeapFree( GetProcessHeap(), 0, fli );
|
||||||
|
delete_object( oldpath );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_file_both_information(void)
|
static void test_file_both_information(void)
|
||||||
|
|
Loading…
Reference in New Issue