ReactOS 0.4.15-dev-7942-gd23573b
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
16static
17VOID
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
119static KSTART_ROUTINE RunTest;
120static
121VOID
122NTAPI
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
147START_TEST(NpfsFileInfo)
148{
150
153}
#define OUT_QUOTA
Definition: NpfsFileInfo.c:13
static VOID TestFileInfo(IN HANDLE ServerHandle)
Definition: NpfsFileInfo.c:18
static KSTART_ROUTINE RunTest
Definition: NpfsFileInfo.c:119
#define PIPE_NAME
Definition: NpfsFileInfo.c:14
#define IN_QUOTA
Definition: NpfsFileInfo.c:12
#define MAX_INSTANCES
Definition: NpfsFileInfo.c:11
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok_eq_longlong(value, expected)
Definition: apitest.h:64
#define ok_bool_false(value, desc)
Definition: apitest.h:79
#define ok_bool_true(value, desc)
Definition: apitest.h:78
#define ok_eq_size(value, expected)
Definition: apitest.h:69
#define ok_eq_wchar(value, expected)
Definition: apitest.h:67
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
@ FileAllInformation
Definition: from_kernel.h:79
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
struct _FILE_ALL_INFORMATION FILE_ALL_INFORMATION
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
#define BYTE_STREAM
Definition: npfs.h:13
#define DUPLEX
Definition: npfs.h:21
#define DEVICE_NAMED_PIPE
Definition: npfs.h:11
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 QUEUE
Definition: npfs.h:17
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KernelMode
Definition: asm.h:34
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
__wchar_t WCHAR
Definition: xmlstorage.h:180