Alexandre Julliard : ntdll/tests: Add some tests for opening files by file id.
Alexandre Julliard
julliard at winehq.org
Thu Dec 3 10:29:50 CST 2009
Module: wine
Branch: master
Commit: 8115c6243b0111728cc1538eaac7ae832c7a7b6a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8115c6243b0111728cc1538eaac7ae832c7a7b6a
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Dec 2 17:36:58 2009 +0100
ntdll/tests: Add some tests for opening files by file id.
---
dlls/ntdll/tests/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index ca0ef28..aeb8cc7 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -72,6 +72,8 @@ static NTSTATUS (WINAPI *pNtRemoveIoCompletion)(HANDLE, PULONG_PTR, PULONG_PTR,
static NTSTATUS (WINAPI *pNtSetIoCompletion)(HANDLE, ULONG_PTR, ULONG_PTR, NTSTATUS, ULONG);
static NTSTATUS (WINAPI *pNtSetInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FILE_INFORMATION_CLASS);
static NTSTATUS (WINAPI *pNtQueryInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FILE_INFORMATION_CLASS);
+static NTSTATUS (WINAPI *pNtQueryDirectoryFile)(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,
+ PVOID,ULONG,FILE_INFORMATION_CLASS,BOOLEAN,PUNICODE_STRING,BOOLEAN);
static inline BOOL is_signaled( HANDLE obj )
{
@@ -155,10 +157,12 @@ static void open_file_test(void)
NTSTATUS status;
HANDLE dir, handle;
WCHAR path[MAX_PATH];
+ BYTE data[8192];
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
UNICODE_STRING nameW;
UINT i, len;
+ BOOL restart = TRUE;
len = GetWindowsDirectoryW( path, MAX_PATH );
pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
@@ -206,6 +210,46 @@ static void open_file_test(void)
ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
CloseHandle( handle );
+ /* try open by file id */
+
+ while (!pNtQueryDirectoryFile( dir, NULL, NULL, NULL, &io, data, sizeof(data),
+ FileIdBothDirectoryInformation, FALSE, NULL, restart ))
+ {
+ FILE_ID_BOTH_DIRECTORY_INFORMATION *info = (FILE_ID_BOTH_DIRECTORY_INFORMATION *)data;
+
+ restart = FALSE;
+ for (;;)
+ {
+ if (!info->FileId.QuadPart) goto next;
+ nameW.Buffer = (WCHAR *)&info->FileId;
+ nameW.Length = sizeof(info->FileId);
+ info->FileName[info->FileNameLength/sizeof(WCHAR)] = 0;
+ status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OPEN_BY_FILE_ID |
+ ((info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FILE_DIRECTORY_FILE : 0) );
+ ok( status == STATUS_SUCCESS || status == STATUS_ACCESS_DENIED,
+ "open %s failed %x\n", wine_dbgstr_w(info->FileName), status );
+ if (!status)
+ {
+ FILE_ALL_INFORMATION all_info;
+
+ if (!pNtQueryInformationFile( handle, &io, &all_info, sizeof(all_info), FileAllInformation ))
+ {
+ /* check that it's the same file */
+ ok( info->EndOfFile.QuadPart == all_info.StandardInformation.EndOfFile.QuadPart,
+ "mismatched file size for %s\n", wine_dbgstr_w(info->FileName));
+ ok( info->LastWriteTime.QuadPart == all_info.BasicInformation.LastWriteTime.QuadPart,
+ "mismatched write time for %s\n", wine_dbgstr_w(info->FileName));
+ }
+ CloseHandle( handle );
+ }
+ next:
+ if (!info->NextEntryOffset) break;
+ info = (FILE_ID_BOTH_DIRECTORY_INFORMATION *)((char *)info + info->NextEntryOffset);
+ }
+ }
+
CloseHandle( dir );
}
@@ -1307,6 +1351,7 @@ START_TEST(file)
pNtSetIoCompletion = (void *)GetProcAddress(hntdll, "NtSetIoCompletion");
pNtSetInformationFile = (void *)GetProcAddress(hntdll, "NtSetInformationFile");
pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile");
+ pNtQueryDirectoryFile = (void *)GetProcAddress(hntdll, "NtQueryDirectoryFile");
open_file_test();
delete_file_test();
More information about the wine-cvs
mailing list