[USP10_WINETEST] Sync with Wine Staging 2.9. CORE-13362
[reactos.git] / rostests / kmtests / npfs / NpfsCreate.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 Create test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8 #include <kmt_test.h>
9 #include "npfs.h"
10
11 static
12 VOID
13 TestCreateNamedPipe(VOID)
14 {
15 NTSTATUS Status;
16 HANDLE ServerHandle;
17 ULONG MaxInstances;
18 ULONG InQuota, OutQuota;
19 ULONG Quotas[] = { 0, 1, 2, 1024, PAGE_SIZE - 1, PAGE_SIZE, PAGE_SIZE + 1, 2 * PAGE_SIZE, 8 * PAGE_SIZE, 64 * PAGE_SIZE, 64 * PAGE_SIZE + 1, 128 * PAGE_SIZE };
20 ULONG i;
21 LARGE_INTEGER Timeout;
22
23 /* Invalid pipe name */
24 MaxInstances = 1;
25 InQuota = 4096;
26 OutQuota = 4096;
27 ServerHandle = INVALID_HANDLE_VALUE;
28 Status = NpCreatePipe(&ServerHandle,
29 DEVICE_NAMED_PIPE L"",
30 BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX,
31 MaxInstances,
32 InQuota,
33 OutQuota);
34 ok_eq_hex(Status, STATUS_OBJECT_NAME_INVALID);
35 ok_eq_pointer(ServerHandle, INVALID_HANDLE_VALUE);
36 if (ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE)
37 ObCloseHandle(ServerHandle, KernelMode);
38
39 ServerHandle = INVALID_HANDLE_VALUE;
40 Status = NpCreatePipe(&ServerHandle,
41 DEVICE_NAMED_PIPE L"\\",
42 BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX,
43 MaxInstances,
44 InQuota,
45 OutQuota);
46 ok_eq_hex(Status, STATUS_OBJECT_NAME_INVALID);
47 ok_eq_pointer(ServerHandle, INVALID_HANDLE_VALUE);
48 if (ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE)
49 ObCloseHandle(ServerHandle, KernelMode);
50
51 ServerHandle = INVALID_HANDLE_VALUE;
52 Status = NpCreatePipe(&ServerHandle,
53 DEVICE_NAMED_PIPE L"\\\\",
54 BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX,
55 MaxInstances,
56 InQuota,
57 OutQuota);
58 ok_eq_hex(Status, STATUS_OBJECT_NAME_INVALID);
59 ok_eq_pointer(ServerHandle, INVALID_HANDLE_VALUE);
60 if (ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE)
61 ObCloseHandle(ServerHandle, KernelMode);
62
63 /* Test in-quota */
64 MaxInstances = 1;
65 OutQuota = 4096;
66 for (i = 0; i < RTL_NUMBER_OF(Quotas); i++)
67 {
68 InQuota = Quotas[i];
69 ServerHandle = INVALID_HANDLE_VALUE;
70 Status = NpCreatePipe(&ServerHandle,
71 DEVICE_NAMED_PIPE L"\\KmtestNpfsCreateTestPipe",
72 BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX,
73 MaxInstances,
74 InQuota,
75 OutQuota);
76 ok_eq_hex(Status, STATUS_SUCCESS);
77 ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle);
78 if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n"))
79 {
80 NpCheckServerPipe(ServerHandle,
81 BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX,
82 MaxInstances, 1,
83 InQuota, 0,
84 OutQuota, OutQuota,
85 FILE_PIPE_LISTENING_STATE);
86 ObCloseHandle(ServerHandle, KernelMode);
87 Timeout.QuadPart = -100 * 1000 * 10;
88 Status = KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
89 ok_eq_hex(Status, STATUS_SUCCESS);
90 }
91 }
92 }
93
94 static
95 VOID
96 TestCreate(VOID)
97 {
98 }
99
100 static KSTART_ROUTINE RunTest;
101 static
102 VOID
103 NTAPI
104 RunTest(
105 IN PVOID Context)
106 {
107 UNREFERENCED_PARAMETER(Context);
108 TestCreateNamedPipe();
109 TestCreate();
110 }
111
112 START_TEST(NpfsCreate)
113 {
114 PKTHREAD Thread;
115
116 Thread = KmtStartThread(RunTest, NULL);
117 KmtFinishThread(Thread, NULL);
118 }