ReactOS  0.4.14-dev-49-gfb4591c
NpfsFileInfo.c
Go to the documentation of this file.
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 file 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 #define PIPE_NAME L"\\KmtestNpfsFileInfoTestPipe"
15 
16 static
17 VOID
19  IN HANDLE ServerHandle)
20 {
23 
24  struct {
26  WCHAR PartialName[50];
27  } FileAllInfo;
28 
29  RtlFillMemory(&FileAllInfo, sizeof(FileAllInfo), 0xFF);
30  Status = ZwQueryInformationFile(ServerHandle,
32  &FileAllInfo,
33  sizeof(FileAllInfo),
37  ok_eq_longlong(FileAllInfo.BasicInformation.CreationTime.QuadPart, 0);
38  ok_eq_longlong(FileAllInfo.BasicInformation.LastAccessTime.QuadPart, 0);
39  ok_eq_longlong(FileAllInfo.BasicInformation.LastWriteTime.QuadPart, 0);
40  ok_eq_longlong(FileAllInfo.BasicInformation.ChangeTime.QuadPart, 0);
41  ok_eq_ulong(FileAllInfo.BasicInformation.FileAttributes, FILE_ATTRIBUTE_NORMAL);
42  ok_eq_longlong(FileAllInfo.StandardInformation.AllocationSize.QuadPart, 8192);
43  ok_eq_longlong(FileAllInfo.StandardInformation.EndOfFile.QuadPart, 0);
44  ok_eq_ulong(FileAllInfo.StandardInformation.NumberOfLinks, 1);
45  ok_bool_true(FileAllInfo.StandardInformation.DeletePending, "DeletePending");
46  ok_bool_false(FileAllInfo.StandardInformation.Directory, "Directory");
47  ok(FileAllInfo.InternalInformation.IndexNumber.QuadPart != 0xFFFFFFFFFFFFFFFF, "FileAllInfo.InternalInformation.IndexNumber = 0xFFFFFFFFFFFFFFFF, whereas it shouldn't\n");
48  ok(FileAllInfo.InternalInformation.IndexNumber.QuadPart != 0, "FileAllInfo.InternalInformation.IndexNumber = 0, whereas it shouldn't\n");
49  ok_eq_ulong(FileAllInfo.EaInformation.EaSize, 0);
50  ok_eq_ulong(FileAllInfo.AccessInformation.AccessFlags, (FILE_GENERIC_READ | FILE_GENERIC_WRITE));
51  ok_eq_longlong(FileAllInfo.PositionInformation.CurrentByteOffset.QuadPart, 0);
52  ok_eq_ulong(FileAllInfo.ModeInformation.Mode, FILE_SYNCHRONOUS_IO_NONALERT);
53  ok_eq_ulong(FileAllInfo.AlignmentInformation.AlignmentRequirement, 0);
54  ok_eq_ulong(FileAllInfo.NameInformation.FileNameLength, sizeof(PIPE_NAME) - sizeof(WCHAR));
55  ok_eq_size(RtlCompareMemory(FileAllInfo.NameInformation.FileName, PIPE_NAME, sizeof(PIPE_NAME) - sizeof(WCHAR)), (sizeof(PIPE_NAME) - sizeof(WCHAR)));
56  ok_eq_wchar(FileAllInfo.NameInformation.FileName[sizeof(PIPE_NAME) / sizeof(WCHAR) - 1], 0xFFFF);
57  ok_eq_ulong(IoStatusBlock.Information, (FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName) + sizeof(PIPE_NAME) - sizeof(WCHAR)));
58 
59  RtlFillMemory(&FileAllInfo, sizeof(FileAllInfo), 0xFF);
60  Status = ZwQueryInformationFile(ServerHandle,
62  &FileAllInfo,
63  sizeof(FILE_ALL_INFORMATION) + 4 * sizeof(WCHAR),
67  ok_eq_longlong(FileAllInfo.BasicInformation.CreationTime.QuadPart, 0);
68  ok_eq_longlong(FileAllInfo.BasicInformation.LastAccessTime.QuadPart, 0);
69  ok_eq_longlong(FileAllInfo.BasicInformation.LastWriteTime.QuadPart, 0);
70  ok_eq_longlong(FileAllInfo.BasicInformation.ChangeTime.QuadPart, 0);
71  ok_eq_ulong(FileAllInfo.BasicInformation.FileAttributes, FILE_ATTRIBUTE_NORMAL);
72  ok_eq_longlong(FileAllInfo.StandardInformation.AllocationSize.QuadPart, 8192);
73  ok_eq_longlong(FileAllInfo.StandardInformation.EndOfFile.QuadPart, 0);
74  ok_eq_ulong(FileAllInfo.StandardInformation.NumberOfLinks, 1);
75  ok_bool_true(FileAllInfo.StandardInformation.DeletePending, "DeletePending");
76  ok_bool_false(FileAllInfo.StandardInformation.Directory, "Directory");
77  ok(FileAllInfo.InternalInformation.IndexNumber.QuadPart != 0xFFFFFFFFFFFFFFFF, "FileAllInfo.InternalInformation.IndexNumber = 0xFFFFFFFFFFFFFFFF, whereas it shouldn't\n");
78  ok(FileAllInfo.InternalInformation.IndexNumber.QuadPart != 0, "FileAllInfo.InternalInformation.IndexNumber = 0, whereas it shouldn't\n");
79  ok_eq_ulong(FileAllInfo.EaInformation.EaSize, 0);
80  ok_eq_ulong(FileAllInfo.AccessInformation.AccessFlags, (FILE_GENERIC_READ | FILE_GENERIC_WRITE));
81  ok_eq_longlong(FileAllInfo.PositionInformation.CurrentByteOffset.QuadPart, 0);
82  ok_eq_ulong(FileAllInfo.ModeInformation.Mode, FILE_SYNCHRONOUS_IO_NONALERT);
83  ok_eq_ulong(FileAllInfo.AlignmentInformation.AlignmentRequirement, 0);
84  ok_eq_ulong(FileAllInfo.NameInformation.FileNameLength, sizeof(PIPE_NAME) - sizeof(WCHAR));
85  ok_eq_size(RtlCompareMemory(FileAllInfo.NameInformation.FileName, PIPE_NAME, 6 * sizeof(WCHAR)), (6 * sizeof(WCHAR)));
86  ok_eq_wchar(FileAllInfo.NameInformation.FileName[6], 0xFFFF);
87  ok_eq_ulong(IoStatusBlock.Information, (FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName) + 6 * sizeof(WCHAR)));
88 
89  RtlFillMemory(&FileAllInfo, sizeof(FileAllInfo), 0xFF);
90  Status = ZwQueryInformationFile(ServerHandle,
92  &FileAllInfo,
93  sizeof(FILE_ALL_INFORMATION) - 4,
97  ok_eq_longlong(FileAllInfo.BasicInformation.CreationTime.QuadPart, 0);
98  ok_eq_longlong(FileAllInfo.BasicInformation.LastAccessTime.QuadPart, 0);
99  ok_eq_longlong(FileAllInfo.BasicInformation.LastWriteTime.QuadPart, 0);
100  ok_eq_longlong(FileAllInfo.BasicInformation.ChangeTime.QuadPart, 0);
101  ok_eq_ulong(FileAllInfo.BasicInformation.FileAttributes, FILE_ATTRIBUTE_NORMAL);
102  ok_eq_longlong(FileAllInfo.StandardInformation.AllocationSize.QuadPart, 8192);
103  ok_eq_longlong(FileAllInfo.StandardInformation.EndOfFile.QuadPart, 0);
104  ok_eq_ulong(FileAllInfo.StandardInformation.NumberOfLinks, 1);
105  ok_bool_true(FileAllInfo.StandardInformation.DeletePending, "DeletePending");
106  ok_bool_false(FileAllInfo.StandardInformation.Directory, "Directory");
107  ok(FileAllInfo.InternalInformation.IndexNumber.QuadPart != 0xFFFFFFFFFFFFFFFF, "FileAllInfo.InternalInformation.IndexNumber = 0xFFFFFFFFFFFFFFFF, whereas it shouldn't\n");
108  ok(FileAllInfo.InternalInformation.IndexNumber.QuadPart != 0, "FileAllInfo.InternalInformation.IndexNumber = 0, whereas it shouldn't\n");
109  ok_eq_ulong(FileAllInfo.EaInformation.EaSize, 0);
110  ok_eq_ulong(FileAllInfo.AccessInformation.AccessFlags, (FILE_GENERIC_READ | FILE_GENERIC_WRITE));
111  ok_eq_longlong(FileAllInfo.PositionInformation.CurrentByteOffset.QuadPart, 0);
112  ok_eq_ulong(FileAllInfo.ModeInformation.Mode, FILE_SYNCHRONOUS_IO_NONALERT);
113  ok_eq_ulong(FileAllInfo.AlignmentInformation.AlignmentRequirement, 0);
114  ok_eq_ulong(FileAllInfo.NameInformation.FileNameLength, sizeof(PIPE_NAME) - sizeof(WCHAR));
115  ok_eq_wchar(FileAllInfo.NameInformation.FileName[0], 0xFFFF);
117 }
118 
119 static KSTART_ROUTINE RunTest;
120 static
121 VOID
122 NTAPI
124  IN PVOID Context)
125 {
127  HANDLE ServerHandle;
128 
130 
131  ServerHandle = INVALID_HANDLE_VALUE;
132  Status = NpCreatePipe(&ServerHandle,
136  IN_QUOTA,
137  OUT_QUOTA);
139  ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle);
140  if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n"))
141  {
142  TestFileInfo(ServerHandle);
143  ObCloseHandle(ServerHandle, KernelMode);
144  }
145 }
146 
147 START_TEST(NpfsFileInfo)
148 {
150 
153 }
NTSTATUS NpCreatePipe(OUT PHANDLE ServerHandle, IN PCWSTR PipePath, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota)
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define ok_eq_ulong(value, expected)
#define IN
Definition: typedefs.h:38
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
#define ok_eq_longlong(value, expected)
Definition: kmt_test.h:242
#define ok_eq_size(value, expected)
Definition: kmt_test.h:247
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
struct _FILE_ALL_INFORMATION FILE_ALL_INFORMATION
static VOID TestFileInfo(IN HANDLE ServerHandle)
Definition: NpfsFileInfo.c:18
LONG NTSTATUS
Definition: precomp.h:26
#define DEVICE_NAMED_PIPE
Definition: npfs.h:11
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ok_bool_false(value, desc)
Definition: kmt_test.h:257
#define ok_bool_true(value, desc)
Definition: kmt_test.h:256
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
smooth NULL
Definition: ftsmooth.c:416
#define ok_eq_wchar(value, expected)
Definition: kmt_test.h:245
#define PIPE_NAME
Definition: NpfsFileInfo.c:14
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OUT_QUOTA
Definition: NpfsFileInfo.c:13
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define DUPLEX
Definition: npfs.h:21
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define BYTE_STREAM
Definition: npfs.h:13
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
Status
Definition: gdiplustypes.h:24
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define IN_QUOTA
Definition: NpfsFileInfo.c:12
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define ok(value,...)
Definition: atltest.h:57
START_TEST(NpfsFileInfo)
Definition: NpfsFileInfo.c:147
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define QUEUE
Definition: npfs.h:17
#define skip(...)
Definition: atltest.h:64
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
static KSTART_ROUTINE RunTest
Definition: NpfsFileInfo.c:119
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define MAX_INSTANCES
Definition: NpfsFileInfo.c:11