[KMTESTS:NPFS]

- Add more tests for volume info
- Fix previous tests
- Add two helper macros

Tested by Thomas.

CORE-7451

svn path=/trunk/; revision=62721
This commit is contained in:
Pierre Schweitzer 2014-04-12 18:37:44 +00:00
parent f5431ba0ec
commit ffd100f622
2 changed files with 145 additions and 22 deletions

View file

@ -190,6 +190,8 @@ VOID KmtFreeGuarded(PVOID Pointer);
#define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu")
#define ok_eq_longlong(value, expected) ok_eq_print(value, expected, "%I64d")
#define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected, "%I64u")
#define ok_eq_char(value, expected) ok_eq_print(value, expected, "%c")
#define ok_eq_wchar(value, expected) ok_eq_print(value, expected, "%C")
#ifndef _WIN64
#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected), "%lu")
#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected), "%ld")

View file

@ -19,44 +19,165 @@ TestVolumeInfo(
{
NTSTATUS Status;
IO_STATUS_BLOCK IoStatusBlock;
struct {
FILE_FS_VOLUME_INFORMATION;
WCHAR PartialName[2];
} PartialInfo;
FILE_FS_SIZE_INFORMATION FileFsSizeInfo;
FILE_FS_DEVICE_INFORMATION FileFsDeviceInfo;
FILE_FS_FULL_SIZE_INFORMATION FileFsFullSizeInfo;
struct {
FILE_FS_VOLUME_INFORMATION;
WCHAR PartialName[10];
} CompleteInfo;
} VolumeInfo;
struct {
FILE_FS_ATTRIBUTE_INFORMATION;
WCHAR PartialName[6];
} AttributeInfo;
RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&CompleteInfo,
sizeof(CompleteInfo),
&VolumeInfo,
sizeof(VolumeInfo),
FileFsVolumeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_long(CompleteInfo.VolumeCreationTime.LowPart, 0);
ok_eq_long(CompleteInfo.VolumeCreationTime.HighPart, 0);
ok_eq_ulong(CompleteInfo.VolumeSerialNumber, 0);
ok_bool_false(CompleteInfo.SupportsObjects, "CompleteInfo.SupportsObjects");
ok_eq_ulong(CompleteInfo.VolumeLabelLength, 18);
ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedPipe", 18), 18);
ok_eq_wchar(VolumeInfo.VolumeLabel[9], 0xFFFF);
ok_eq_ulong(IoStatusBlock.Information, 36);
ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"NamedPipe", 18), 18);
RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&PartialInfo,
sizeof(PartialInfo),
&VolumeInfo,
sizeof(FILE_FS_VOLUME_INFORMATION) + 2 * sizeof(WCHAR),
FileFsVolumeInformation);
ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
ok_eq_hex(IoStatusBlock.Status, STATUS_BUFFER_OVERFLOW);
ok_eq_long(CompleteInfo.VolumeCreationTime.LowPart, 0);
ok_eq_long(CompleteInfo.VolumeCreationTime.HighPart, 0);
ok_eq_ulong(CompleteInfo.VolumeSerialNumber, 0);
ok_bool_false(CompleteInfo.SupportsObjects, "CompleteInfo.SupportsObjects");
ok_eq_ulong(CompleteInfo.VolumeLabelLength, 18);
ok_eq_ulong(IoStatusBlock.Information, 32);
ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"Na", 4), 4);
ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedP", 10), 10);
ok_eq_wchar(VolumeInfo.VolumeLabel[5], 0xFFFF);
ok_eq_ulong(IoStatusBlock.Information, 28);
RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&FileFsSizeInfo,
sizeof(FileFsSizeInfo),
FileFsSizeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
ok_eq_longlong(FileFsSizeInfo.AvailableAllocationUnits.QuadPart, 0);
ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));
RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&FileFsSizeInfo,
sizeof(FileFsSizeInfo) - 4,
FileFsSizeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
ok_eq_longlong(FileFsSizeInfo.AvailableAllocationUnits.QuadPart, 0);
ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));
RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&FileFsDeviceInfo,
sizeof(FileFsDeviceInfo),
FileFsDeviceInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
ok_eq_ulong(FileFsDeviceInfo.DeviceType, FILE_DEVICE_NAMED_PIPE);
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));
RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&FileFsDeviceInfo,
sizeof(FileFsDeviceInfo) - 4,
FileFsDeviceInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
ok_eq_ulong(FileFsDeviceInfo.DeviceType, FILE_DEVICE_NAMED_PIPE);
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));
RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&AttributeInfo,
sizeof(AttributeInfo),
FileFsAttributeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
ok_eq_ulong(IoStatusBlock.Information, 20);
RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&AttributeInfo,
sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 2 * sizeof(WCHAR),
FileFsAttributeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
ok_eq_ulong(IoStatusBlock.Information, 20);
RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&FileFsFullSizeInfo,
sizeof(FileFsFullSizeInfo),
FileFsFullSizeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
ok_eq_longlong(FileFsFullSizeInfo.CallerAvailableAllocationUnits.QuadPart, 0);
ok_eq_longlong(FileFsFullSizeInfo.ActualAvailableAllocationUnits.QuadPart, 0);
ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));
RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
Status = ZwQueryVolumeInformationFile(ServerHandle,
&IoStatusBlock,
&FileFsFullSizeInfo,
sizeof(FileFsFullSizeInfo) - 4,
FileFsFullSizeInformation);
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
ok_eq_longlong(FileFsFullSizeInfo.CallerAvailableAllocationUnits.QuadPart, 0);
ok_eq_longlong(FileFsFullSizeInfo.ActualAvailableAllocationUnits.QuadPart, 0);
ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));
}
static KSTART_ROUTINE RunTest;