[KMTESTS:NPFS]
[reactos.git] / rostests / kmtests / npfs / NpfsVolumeInfo.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite NPFS volume information test
5 * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
6 */
7
8 #include <kmt_test.h>
9 #include "npfs.h"
10
11 #define MAX_INSTANCES 1
12 #define IN_QUOTA 4096
13 #define OUT_QUOTA 4096
14
15 static
16 VOID
17 TestVolumeInfo(
18 IN HANDLE ServerHandle)
19 {
20 NTSTATUS Status;
21 IO_STATUS_BLOCK IoStatusBlock;
22 struct {
23 FILE_FS_VOLUME_INFORMATION;
24 WCHAR PartialName[2];
25 } PartialInfo;
26 struct {
27 FILE_FS_VOLUME_INFORMATION;
28 WCHAR PartialName[10];
29 } CompleteInfo;
30
31 Status = ZwQueryVolumeInformationFile(ServerHandle,
32 &IoStatusBlock,
33 &CompleteInfo,
34 sizeof(CompleteInfo),
35 FileFsVolumeInformation);
36 ok_eq_hex(Status, STATUS_SUCCESS);
37 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);
43 ok_eq_ulong(IoStatusBlock.Information, 36);
44 ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"NamedPipe", 18), 18);
45
46 Status = ZwQueryVolumeInformationFile(ServerHandle,
47 &IoStatusBlock,
48 &PartialInfo,
49 sizeof(PartialInfo),
50 FileFsVolumeInformation);
51 ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
52 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);
60 }
61
62 static KSTART_ROUTINE RunTest;
63 static
64 VOID
65 NTAPI
66 RunTest(
67 IN PVOID Context)
68 {
69 NTSTATUS Status;
70 HANDLE ServerHandle;
71
72 UNREFERENCED_PARAMETER(Context);
73
74 ServerHandle = INVALID_HANDLE_VALUE;
75 Status = NpCreatePipe(&ServerHandle,
76 DEVICE_NAMED_PIPE L"\\KmtestNpfsVolumeInfoTestPipe",
77 BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX,
78 MAX_INSTANCES,
79 IN_QUOTA,
80 OUT_QUOTA);
81 ok_eq_hex(Status, STATUS_SUCCESS);
82 ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle);
83 if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n"))
84 {
85 TestVolumeInfo(ServerHandle);
86 ObCloseHandle(ServerHandle, KernelMode);
87 }
88 }
89
90 START_TEST(NpfsVolumeInfo)
91 {
92 PKTHREAD Thread;
93
94 Thread = KmtStartThread(RunTest, NULL);
95 KmtFinishThread(Thread, NULL);
96 }