From: Eugene McArdle eugene@tensorworks.com.au
--- dlls/ntdll/tests/directory.c | 41 +++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/tests/directory.c b/dlls/ntdll/tests/directory.c index 27027d41d9d..b07654ee1ff 100644 --- a/dlls/ntdll/tests/directory.c +++ b/dlls/ntdll/tests/directory.c @@ -1025,8 +1025,8 @@ static BOOL test_NtQueryDirectoryFile_mask(HANDLE handle, BOOL restart_scan, UNI { if (validate_only && status != STATUS_SUCCESS) return FALSE;
- ok( status == STATUS_SUCCESS, "could not find file mask: '%s', restart: %d, error %ld\n", - wine_dbgstr_wn(mask.Buffer, mask_len), restart_scan, GetLastError() ); + ok( status == STATUS_SUCCESS, "could not find file mask: '%s', restart: %d, status 0x%lx\n", + wine_dbgstr_wn(mask.Buffer, mask_len), restart_scan, status ); /* Print the query parameters and the result */ if (status == 0) { dir_info = (FILE_DIRECTORY_INFORMATION *)data; @@ -1058,6 +1058,7 @@ static void test_NtQueryDirectoryFile_change_mask(void) { NTSTATUS status; HANDLE dirh; + HANDLE dirh_alt; char testdir[MAX_PATH]; OBJECT_ATTRIBUTES attr; IO_STATUS_BLOCK io; @@ -1068,8 +1069,6 @@ static void test_NtQueryDirectoryFile_change_mask(void) UNICODE_STRING anothertestfile; UNICODE_STRING notatestfile;
- BOOL run_updated_tests = TRUE; - pRtlInitUnicodeString(&atestfile, L"a-file.h"); pRtlInitUnicodeString(&anothertestfile, L"another-file.h"); pRtlInitUnicodeString(¬atestfile, L"not-a-file.h"); @@ -1098,19 +1097,34 @@ static void test_NtQueryDirectoryFile_change_mask(void) goto done; }
+ /* Open a second handle for our test directory */ + status = pNtOpenFile(&dirh_alt, SYNCHRONIZE | FILE_LIST_DIRECTORY, &attr, &io, FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_BACKUP_INTENT | FILE_DIRECTORY_FILE); + ok( status == STATUS_SUCCESS, "failed to open second handle to dir '%s', ret 0x%lx, error %ld\n", testdir, status, GetLastError() ); + if (status != STATUS_SUCCESS) + { + skip("can't test if we can't open a second handle to the directory\n"); + goto done; + } + /* Verify that updated windows 8 and higher behaviour is supported */ - if (!winetest_platform_is_wine && !test_NtQueryDirectoryFile_mask(dirh, TRUE, atestfile, TRUE, TRUE)) - run_updated_tests = FALSE; + test_NtQueryDirectoryFile_mask(dirh, TRUE, atestfile, TRUE, TRUE); if (!winetest_platform_is_wine && !test_NtQueryDirectoryFile_mask(dirh, TRUE, notatestfile, FALSE, TRUE)) - run_updated_tests = FALSE; - - if (!run_updated_tests) { - skip("Win8+ NtQueryDirectoryMask behaviour not supported"); + skip("Win8+ NtQueryDirectoryMask behaviour not supported\n"); goto done; }
- /* Run tests - all searches for `notatestfile` are expected to fail */ + /* Test that caches for two handles to a single directory do not interfere with each other*/ + /* Use dirh to search for a non-existent file, putting it into a state with an empty cache */ + test_NtQueryDirectoryFile_mask(dirh, TRUE, notatestfile, FALSE, FALSE); + /* Confirm that dirh is in a state where it fails to find atestfile */ + test_NtQueryDirectoryFile_mask(dirh, FALSE, atestfile, FALSE, FALSE); + /* Confirm that dirh_alt is able to find atestfile */ + test_NtQueryDirectoryFile_mask(dirh_alt, FALSE, atestfile, TRUE, FALSE); + + /* All searches for `notatestfile` are expected to fail */ + /* Tests should also fail if the scan is not reset, and the mask changes to an incompatible one */ test_NtQueryDirectoryFile_mask(dirh, TRUE, atestfile, TRUE, FALSE); test_NtQueryDirectoryFile_mask(dirh, TRUE, anothertestfile, TRUE, FALSE); test_NtQueryDirectoryFile_mask(dirh, TRUE, notatestfile, FALSE, FALSE); @@ -1119,12 +1133,15 @@ static void test_NtQueryDirectoryFile_change_mask(void) test_NtQueryDirectoryFile_mask(dirh, FALSE, notatestfile, FALSE, FALSE);
test_NtQueryDirectoryFile_mask(dirh, TRUE, atestfile, TRUE, FALSE); - /* Since we are not resetting the scan, and are using an incompatible mask, this should also fail */ test_NtQueryDirectoryFile_mask(dirh, FALSE, anothertestfile, FALSE, FALSE);
/* Cleanup */ done: tear_down_mask_test(testdir); + pRtlFreeUnicodeString(&ntdirname); + pRtlFreeUnicodeString(&atestfile); + pRtlFreeUnicodeString(&anothertestfile); + pRtlFreeUnicodeString(¬atestfile); }
static NTSTATUS get_file_id( FILE_INTERNAL_INFORMATION *info, const WCHAR *root, const WCHAR *name )