From 5832b9c9647b618c424f0b67cd7a5d2b3243ab4f Mon Sep 17 00:00:00 2001 From: Jianqiu Zhang Date: Tue, 7 Apr 2015 18:35:56 +0800 Subject: [PATCH 2/3] ntdll/tests: Add test for FileFsFullSizeInformation --- dlls/ntdll/tests/file.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index d70ed6b..7710b99 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -84,6 +84,25 @@ static inline BOOL is_signaled( HANDLE obj ) return WaitForSingleObject( obj, 0 ) == WAIT_OBJECT_0; } +static inline const char* debugstr_longlong(LONGLONG ll) +{ + static char str[17]; + BOOL isneg = 0; + BOOL carry = 0; + + /* Print correct value if ll is an negative value */ + + if ((long)ll == 0) carry = 1; + if ((long)(ll >> 32) & 0x80000000) + isneg = 1; + + if (sizeof(ll) > sizeof(long) && ll >> 32) + sprintf(str, "%lx%08lx%s", isneg?(long)(~(ll >> 32) + carry):(long)(ll >> 32), isneg?(long)(~ll + 1):(long)ll,isneg?"(NEG)":""); + else + sprintf(str, "%lx", (long)ll); + return str; +} + #define PIPENAME "\\\\.\\pipe\\ntdll_tests_file.c" #define TEST_BUF_LEN 3 @@ -1205,6 +1224,37 @@ static void test_iocp_fileio(HANDLE h) CloseHandle( hPipeClt ); } +static void test_file_full_size_information(void) +{ + IO_STATUS_BLOCK io; + FILE_FS_FULL_SIZE_INFORMATION ffsi; + FILE_FS_SIZE_INFORMATION fsi; + HANDLE h; + NTSTATUS res; + + if(!(h = create_temp_file(0))) return ; + + memset(&ffsi,0,sizeof(ffsi)); + memset(&fsi,0,sizeof(fsi)); + res = pNtQueryVolumeInformationFile(h, &io, &ffsi, sizeof ffsi, FileFsFullSizeInformation); + ok(res == STATUS_SUCCESS, "cannot get attributes, res %x\n", res); + res = pNtQueryVolumeInformationFile(h, &io, &fsi, sizeof fsi, FileFsSizeInformation); + ok(res == STATUS_SUCCESS, "cannot get attributes, res %x\n", res); + ok(ffsi.TotalAllocationUnits.QuadPart == fsi.TotalAllocationUnits.QuadPart,"TotalAllocationUnits expected 0x%s, go 0x%s\n", + debugstr_longlong(fsi.TotalAllocationUnits.QuadPart), debugstr_longlong(ffsi.TotalAllocationUnits.QuadPart)); + ok(ffsi.CallerAvailableAllocationUnits.QuadPart == fsi.AvailableAllocationUnits.QuadPart, "CallerAvailableAllocationUnits \ + expected 0x%s, got 0x%s\n", debugstr_longlong(fsi.AvailableAllocationUnits.QuadPart), + debugstr_longlong(ffsi.CallerAvailableAllocationUnits.QuadPart)); + ok(ffsi.SectorsPerAllocationUnit == fsi.SectorsPerAllocationUnit, "SectorsPerAllocationUnit is incorrect\n"); + ok(ffsi.BytesPerSector == fsi.BytesPerSector, "BytesPerSector is incorrect\n"); + + /* Assume file system is NTFS*/ + ok(ffsi.BytesPerSector == 512, "BytesPerSector expected 512, got %d\n",ffsi.BytesPerSector); + ok(ffsi.SectorsPerAllocationUnit == 8, "SectorsPerAllocationUnit expected 8, got %d\n",ffsi.SectorsPerAllocationUnit); + + CloseHandle( h ); +} + static void test_file_basic_information(void) { IO_STATUS_BLOCK io; @@ -2732,6 +2782,7 @@ START_TEST(file) test_file_all_information(); test_file_both_information(); test_file_name_information(); + test_file_full_size_information(); test_file_all_name_information(); test_file_disposition_information(); test_query_volume_information_file(); -- 1.9.1