Skip to content

Commit ffd100f

Browse files
committed
[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
1 parent f5431ba commit ffd100f

File tree

2 files changed

+145
-22
lines changed

2 files changed

+145
-22
lines changed

rostests/kmtests/include/kmt_test.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ VOID KmtFreeGuarded(PVOID Pointer);
190190
#define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu")
191191
#define ok_eq_longlong(value, expected) ok_eq_print(value, expected, "%I64d")
192192
#define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected, "%I64u")
193+
#define ok_eq_char(value, expected) ok_eq_print(value, expected, "%c")
194+
#define ok_eq_wchar(value, expected) ok_eq_print(value, expected, "%C")
193195
#ifndef _WIN64
194196
#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected), "%lu")
195197
#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected), "%ld")

rostests/kmtests/npfs/NpfsVolumeInfo.c

Lines changed: 143 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,165 @@ TestVolumeInfo(
1919
{
2020
NTSTATUS Status;
2121
IO_STATUS_BLOCK IoStatusBlock;
22-
struct {
23-
FILE_FS_VOLUME_INFORMATION;
24-
WCHAR PartialName[2];
25-
} PartialInfo;
22+
FILE_FS_SIZE_INFORMATION FileFsSizeInfo;
23+
FILE_FS_DEVICE_INFORMATION FileFsDeviceInfo;
24+
FILE_FS_FULL_SIZE_INFORMATION FileFsFullSizeInfo;
25+
2626
struct {
2727
FILE_FS_VOLUME_INFORMATION;
2828
WCHAR PartialName[10];
29-
} CompleteInfo;
29+
} VolumeInfo;
3030

31+
struct {
32+
FILE_FS_ATTRIBUTE_INFORMATION;
33+
WCHAR PartialName[6];
34+
} AttributeInfo;
35+
36+
RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
3137
Status = ZwQueryVolumeInformationFile(ServerHandle,
3238
&IoStatusBlock,
33-
&CompleteInfo,
34-
sizeof(CompleteInfo),
39+
&VolumeInfo,
40+
sizeof(VolumeInfo),
3541
FileFsVolumeInformation);
3642
ok_eq_hex(Status, STATUS_SUCCESS);
3743
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
38-
ok_eq_long(CompleteInfo.VolumeCreationTime.LowPart, 0);
39-
ok_eq_long(CompleteInfo.VolumeCreationTime.HighPart, 0);
40-
ok_eq_ulong(CompleteInfo.VolumeSerialNumber, 0);
41-
ok_bool_false(CompleteInfo.SupportsObjects, "CompleteInfo.SupportsObjects");
42-
ok_eq_ulong(CompleteInfo.VolumeLabelLength, 18);
44+
ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
45+
ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
46+
ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
47+
ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
48+
ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
49+
ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedPipe", 18), 18);
50+
ok_eq_wchar(VolumeInfo.VolumeLabel[9], 0xFFFF);
4351
ok_eq_ulong(IoStatusBlock.Information, 36);
44-
ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"NamedPipe", 18), 18);
4552

53+
RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
4654
Status = ZwQueryVolumeInformationFile(ServerHandle,
4755
&IoStatusBlock,
48-
&PartialInfo,
49-
sizeof(PartialInfo),
56+
&VolumeInfo,
57+
sizeof(FILE_FS_VOLUME_INFORMATION) + 2 * sizeof(WCHAR),
5058
FileFsVolumeInformation);
5159
ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
5260
ok_eq_hex(IoStatusBlock.Status, STATUS_BUFFER_OVERFLOW);
53-
ok_eq_long(CompleteInfo.VolumeCreationTime.LowPart, 0);
54-
ok_eq_long(CompleteInfo.VolumeCreationTime.HighPart, 0);
55-
ok_eq_ulong(CompleteInfo.VolumeSerialNumber, 0);
56-
ok_bool_false(CompleteInfo.SupportsObjects, "CompleteInfo.SupportsObjects");
57-
ok_eq_ulong(CompleteInfo.VolumeLabelLength, 18);
58-
ok_eq_ulong(IoStatusBlock.Information, 32);
59-
ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"Na", 4), 4);
61+
ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
62+
ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
63+
ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
64+
ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
65+
ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
66+
ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedP", 10), 10);
67+
ok_eq_wchar(VolumeInfo.VolumeLabel[5], 0xFFFF);
68+
ok_eq_ulong(IoStatusBlock.Information, 28);
69+
70+
RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
71+
Status = ZwQueryVolumeInformationFile(ServerHandle,
72+
&IoStatusBlock,
73+
&FileFsSizeInfo,
74+
sizeof(FileFsSizeInfo),
75+
FileFsSizeInformation);
76+
ok_eq_hex(Status, STATUS_SUCCESS);
77+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
78+
ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
79+
ok_eq_longlong(FileFsSizeInfo.AvailableAllocationUnits.QuadPart, 0);
80+
ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
81+
ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
82+
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));
83+
84+
RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
85+
Status = ZwQueryVolumeInformationFile(ServerHandle,
86+
&IoStatusBlock,
87+
&FileFsSizeInfo,
88+
sizeof(FileFsSizeInfo) - 4,
89+
FileFsSizeInformation);
90+
ok_eq_hex(Status, STATUS_SUCCESS);
91+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
92+
ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
93+
ok_eq_longlong(FileFsSizeInfo.AvailableAllocationUnits.QuadPart, 0);
94+
ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
95+
ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
96+
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));
97+
98+
RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
99+
Status = ZwQueryVolumeInformationFile(ServerHandle,
100+
&IoStatusBlock,
101+
&FileFsDeviceInfo,
102+
sizeof(FileFsDeviceInfo),
103+
FileFsDeviceInformation);
104+
ok_eq_hex(Status, STATUS_SUCCESS);
105+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
106+
ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
107+
ok_eq_ulong(FileFsDeviceInfo.DeviceType, FILE_DEVICE_NAMED_PIPE);
108+
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));
109+
110+
RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
111+
Status = ZwQueryVolumeInformationFile(ServerHandle,
112+
&IoStatusBlock,
113+
&FileFsDeviceInfo,
114+
sizeof(FileFsDeviceInfo) - 4,
115+
FileFsDeviceInformation);
116+
ok_eq_hex(Status, STATUS_SUCCESS);
117+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
118+
ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
119+
ok_eq_ulong(FileFsDeviceInfo.DeviceType, FILE_DEVICE_NAMED_PIPE);
120+
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));
121+
122+
RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
123+
Status = ZwQueryVolumeInformationFile(ServerHandle,
124+
&IoStatusBlock,
125+
&AttributeInfo,
126+
sizeof(AttributeInfo),
127+
FileFsAttributeInformation);
128+
ok_eq_hex(Status, STATUS_SUCCESS);
129+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
130+
ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
131+
ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
132+
ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
133+
ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
134+
ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
135+
ok_eq_ulong(IoStatusBlock.Information, 20);
136+
137+
RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
138+
Status = ZwQueryVolumeInformationFile(ServerHandle,
139+
&IoStatusBlock,
140+
&AttributeInfo,
141+
sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 2 * sizeof(WCHAR),
142+
FileFsAttributeInformation);
143+
ok_eq_hex(Status, STATUS_SUCCESS);
144+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
145+
ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
146+
ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
147+
ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
148+
ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
149+
ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
150+
ok_eq_ulong(IoStatusBlock.Information, 20);
151+
152+
RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
153+
Status = ZwQueryVolumeInformationFile(ServerHandle,
154+
&IoStatusBlock,
155+
&FileFsFullSizeInfo,
156+
sizeof(FileFsFullSizeInfo),
157+
FileFsFullSizeInformation);
158+
ok_eq_hex(Status, STATUS_SUCCESS);
159+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
160+
ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
161+
ok_eq_longlong(FileFsFullSizeInfo.CallerAvailableAllocationUnits.QuadPart, 0);
162+
ok_eq_longlong(FileFsFullSizeInfo.ActualAvailableAllocationUnits.QuadPart, 0);
163+
ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
164+
ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
165+
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));
166+
167+
RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
168+
Status = ZwQueryVolumeInformationFile(ServerHandle,
169+
&IoStatusBlock,
170+
&FileFsFullSizeInfo,
171+
sizeof(FileFsFullSizeInfo) - 4,
172+
FileFsFullSizeInformation);
173+
ok_eq_hex(Status, STATUS_SUCCESS);
174+
ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
175+
ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
176+
ok_eq_longlong(FileFsFullSizeInfo.CallerAvailableAllocationUnits.QuadPart, 0);
177+
ok_eq_longlong(FileFsFullSizeInfo.ActualAvailableAllocationUnits.QuadPart, 0);
178+
ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
179+
ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
180+
ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));
60181
}
61182

62183
static KSTART_ROUTINE RunTest;

0 commit comments

Comments
 (0)