ReactOS 0.4.15-dev-7712-gbbbcd8e
NpfsFileInfo.c File Reference
#include <kmt_test.h>
#include "npfs.h"
Include dependency graph for NpfsFileInfo.c:

Go to the source code of this file.

Macros

#define MAX_INSTANCES   1
 
#define IN_QUOTA   4096
 
#define OUT_QUOTA   4096
 
#define PIPE_NAME   L"\\KmtestNpfsFileInfoTestPipe"
 

Functions

static VOID TestFileInfo (IN HANDLE ServerHandle)
 
static VOID NTAPI RunTest (IN PVOID Context)
 
 START_TEST (NpfsFileInfo)
 

Variables

static KSTART_ROUTINE RunTest
 

Macro Definition Documentation

◆ IN_QUOTA

#define IN_QUOTA   4096

Definition at line 12 of file NpfsFileInfo.c.

◆ MAX_INSTANCES

#define MAX_INSTANCES   1

Definition at line 11 of file NpfsFileInfo.c.

◆ OUT_QUOTA

#define OUT_QUOTA   4096

Definition at line 13 of file NpfsFileInfo.c.

◆ PIPE_NAME

#define PIPE_NAME   L"\\KmtestNpfsFileInfoTestPipe"

Definition at line 14 of file NpfsFileInfo.c.

Function Documentation

◆ RunTest()

static VOID NTAPI RunTest ( IN PVOID  Context)
static

Definition at line 123 of file NpfsFileInfo.c.

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}
#define OUT_QUOTA
Definition: NpfsFileInfo.c:13
static VOID TestFileInfo(IN HANDLE ServerHandle)
Definition: NpfsFileInfo.c:18
#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:76
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
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
Status
Definition: gdiplustypes.h:25
#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
#define KernelMode
Definition: asm.h:34
#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

◆ START_TEST()

START_TEST ( NpfsFileInfo  )

Definition at line 147 of file NpfsFileInfo.c.

148{
150
153}
static KSTART_ROUTINE RunTest
Definition: NpfsFileInfo.c:119
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)

◆ TestFileInfo()

static VOID TestFileInfo ( IN HANDLE  ServerHandle)
static

Definition at line 18 of file NpfsFileInfo.c.

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}
#define ok_eq_ulong(value, expected)
Definition: apitest.h:62
#define ok_eq_longlong(value, expected)
Definition: apitest.h:63
#define ok_bool_false(value, desc)
Definition: apitest.h:78
#define ok_bool_true(value, desc)
Definition: apitest.h:77
#define ok_eq_size(value, expected)
Definition: apitest.h:68
#define ok_eq_wchar(value, expected)
Definition: apitest.h:66
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
@ FileAllInformation
Definition: from_kernel.h:79
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
struct _FILE_ALL_INFORMATION FILE_ALL_INFORMATION
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by RunTest().

Variable Documentation

◆ RunTest

KSTART_ROUTINE RunTest
static

Definition at line 119 of file NpfsFileInfo.c.

Referenced by START_TEST().