Module: wine Branch: master Commit: d89ee7c030afb0eb8be72625763f4a8c3158372c URL: https://gitlab.winehq.org/wine/wine/-/commit/d89ee7c030afb0eb8be72625763f4a8...
Author: Joel Holdsworth joel@airwebreathe.org.uk Date: Tue Jun 20 15:33:48 2023 +0100
ntdll/tests: Add tests for FILE_DISPOSITION_ON_CLOSE.
Signed-off-by: Joel Holdsworth joel@airwebreathe.org.uk
---
dlls/ntdll/tests/file.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 10d66ff201a..f76448659e2 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -3150,6 +3150,24 @@ static void test_file_disposition_information(void) fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND; ok( fileDeleted, "File should have been deleted\n" );
+ /* can reset delete-on-close flag through FileDispositionInformationEx */ + /* FileDispositionInformationEx is only supported on Windows 10 build 1809 and later */ + GetTempFileNameA( tmp_path, "dis", 0, buffer ); + handle = CreateFileA(buffer, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0); + ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" ); + fdie.Flags = FILE_DISPOSITION_ON_CLOSE; + res = pNtSetInformationFile( handle, &io, &fdie, sizeof fdie, FileDispositionInformationEx ); + ok( res == STATUS_INVALID_INFO_CLASS || res == STATUS_SUCCESS, + "unexpected FileDispositionInformationEx result (expected STATUS_SUCCESS or SSTATUS_INVALID_INFO_CLASS, got %lx)\n", res ); + CloseHandle( handle ); + if ( res == STATUS_SUCCESS ) + { + fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND; + todo_wine + ok( !fileDeleted, "File shouldn't have been deleted\n" ); + DeleteFileA( buffer ); + } + /* DeleteFile fails for wrong sharing mode */ GetTempFileNameA( tmp_path, "dis", 0, buffer ); handle = CreateFileA(buffer, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0);