[NTDLL_APITEST] Add tests for zero and negative information class values. CORE-15651 1269/head
authorThomas Faber <thomas.faber@reactos.org>
Sat, 2 Feb 2019 20:37:08 +0000 (21:37 +0100)
committerThomas Faber <thomas.faber@reactos.org>
Sat, 2 Feb 2019 21:50:19 +0000 (22:50 +0100)
modules/rostests/apitests/ntdll/CMakeLists.txt
modules/rostests/apitests/ntdll/NtQueryInformationFile.c [new file with mode: 0644]
modules/rostests/apitests/ntdll/NtQuerySystemInformation.c [new file with mode: 0644]
modules/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c
modules/rostests/apitests/ntdll/NtSetInformationFile.c [new file with mode: 0644]
modules/rostests/apitests/ntdll/NtSetVolumeInformationFile.c [new file with mode: 0644]
modules/rostests/apitests/ntdll/testlist.c

index 768a522..4860cd2 100644 (file)
@@ -23,13 +23,17 @@ list(APPEND SOURCE
     NtOpenProcessToken.c
     NtOpenThreadToken.c
     NtProtectVirtualMemory.c
+    NtQueryInformationFile.c
     NtQueryInformationProcess.c
     NtQueryKey.c
     NtQuerySystemEnvironmentValue.c
+    NtQuerySystemInformation.c
     NtQueryVolumeInformationFile.c
     NtReadFile.c
     NtSaveKey.c
+    NtSetInformationFile.c
     NtSetValueKey.c
+    NtSetVolumeInformationFile.c
     NtWriteFile.c
     RtlAllocateHeap.c
     RtlBitmap.c
diff --git a/modules/rostests/apitests/ntdll/NtQueryInformationFile.c b/modules/rostests/apitests/ntdll/NtQueryInformationFile.c
new file mode 100644 (file)
index 0000000..74739bb
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     Test for NtQueryInformationFile
+ * COPYRIGHT:   Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
+ */
+
+#include "precomp.h"
+
+#define ntv6(x) (LOBYTE(LOWORD(GetVersion())) >= 6 ? (x) : 0)
+
+START_TEST(NtQueryInformationFile)
+{
+    NTSTATUS Status;
+
+    Status = NtQueryInformationFile(NULL, NULL, NULL, 0, 0);
+    ok(Status == STATUS_INVALID_INFO_CLASS ||
+       ntv6(Status == STATUS_NOT_IMPLEMENTED), "Status = %lx\n", Status);
+
+    Status = NtQueryInformationFile(NULL, NULL, NULL, 0, 0x80000000);
+    ok(Status == STATUS_INVALID_INFO_CLASS ||
+       ntv6(Status == STATUS_NOT_IMPLEMENTED), "Status = %lx\n", Status);
+}
diff --git a/modules/rostests/apitests/ntdll/NtQuerySystemInformation.c b/modules/rostests/apitests/ntdll/NtQuerySystemInformation.c
new file mode 100644 (file)
index 0000000..0ecd91d
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     Test for NtQuerySystemInformation
+ * COPYRIGHT:   Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
+ */
+
+#include "precomp.h"
+
+START_TEST(NtQuerySystemInformation)
+{
+    NTSTATUS Status;
+
+    Status = NtQuerySystemInformation(0, NULL, 0, NULL);
+    ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
+    
+    Status = NtQuerySystemInformation(0x80000000, NULL, 0, NULL);
+    ok_hex(Status, STATUS_INVALID_INFO_CLASS);
+}
index b361d26..c6fb6eb 100644 (file)
@@ -278,6 +278,9 @@ START_TEST(NtQueryVolumeInformationFile)
     ok(status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got 0x%lx\n", status);
     ok(GetLastError() == 0xcacacaca, "Expected 0xcacacaca, got %lx\n", GetLastError());
 
+    status = NtQueryVolumeInformationFile(NULL, NULL, NULL, 0, 0x80000000);
+    ok(status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got 0x%lx\n", status);
+
     TestFileFsDeviceInformation(handle);
     TestFileFsVolumeInformation(handle);
     TestFileFsAttributeInformation(handle);
diff --git a/modules/rostests/apitests/ntdll/NtSetInformationFile.c b/modules/rostests/apitests/ntdll/NtSetInformationFile.c
new file mode 100644 (file)
index 0000000..27afa45
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     Test for NtSetInformationFile
+ * COPYRIGHT:   Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
+ */
+
+#include "precomp.h"
+
+START_TEST(NtSetInformationFile)
+{
+    NTSTATUS Status;
+
+    Status = NtSetInformationFile(NULL, NULL, NULL, 0, 0);
+    ok(Status == STATUS_INVALID_INFO_CLASS, "Status = %lx\n", Status);
+
+    Status = NtSetInformationFile(NULL, NULL, NULL, 0, 0x80000000);
+    ok(Status == STATUS_INVALID_INFO_CLASS, "Status = %lx\n", Status);
+}
diff --git a/modules/rostests/apitests/ntdll/NtSetVolumeInformationFile.c b/modules/rostests/apitests/ntdll/NtSetVolumeInformationFile.c
new file mode 100644 (file)
index 0000000..7d75367
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     Test for NtSetVolumeInformationFile
+ * COPYRIGHT:   Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
+ */
+
+#include "precomp.h"
+
+START_TEST(NtSetVolumeInformationFile)
+{
+    NTSTATUS Status;
+
+    Status = NtSetVolumeInformationFile(NULL, NULL, NULL, 0, 0);
+    ok(Status == STATUS_INVALID_INFO_CLASS, "Status = %lx\n", Status);
+
+    Status = NtSetVolumeInformationFile(NULL, NULL, NULL, 0, 0x80000000);
+    ok(Status == STATUS_INVALID_INFO_CLASS, "Status = %lx\n", Status);
+}
index cd96ef8..e627634 100644 (file)
@@ -21,13 +21,17 @@ extern void func_NtOpenKey(void);
 extern void func_NtOpenProcessToken(void);
 extern void func_NtOpenThreadToken(void);
 extern void func_NtProtectVirtualMemory(void);
+extern void func_NtQueryInformationFile(void);
 extern void func_NtQueryInformationProcess(void);
 extern void func_NtQueryKey(void);
 extern void func_NtQuerySystemEnvironmentValue(void);
+extern void func_NtQuerySystemInformation(void);
 extern void func_NtQueryVolumeInformationFile(void);
 extern void func_NtReadFile(void);
 extern void func_NtSaveKey(void);
+extern void func_NtSetInformationFile(void);
 extern void func_NtSetValueKey(void);
+extern void func_NtSetVolumeInformationFile(void);
 extern void func_NtSystemInformation(void);
 extern void func_NtWriteFile(void);
 extern void func_RtlAllocateHeap(void);
@@ -81,13 +85,17 @@ const struct test winetest_testlist[] =
     { "NtOpenProcessToken",             func_NtOpenProcessToken },
     { "NtOpenThreadToken",              func_NtOpenThreadToken },
     { "NtProtectVirtualMemory",         func_NtProtectVirtualMemory },
+    { "NtQueryInformationFile",         func_NtQueryInformationFile },
     { "NtQueryInformationProcess",      func_NtQueryInformationProcess },
     { "NtQueryKey",                     func_NtQueryKey },
     { "NtQuerySystemEnvironmentValue",  func_NtQuerySystemEnvironmentValue },
+    { "NtQuerySystemInformation",       func_NtQuerySystemInformation },
     { "NtQueryVolumeInformationFile",   func_NtQueryVolumeInformationFile },
     { "NtReadFile",                     func_NtReadFile },
     { "NtSaveKey",                      func_NtSaveKey},
+    { "NtSetInformationFile",           func_NtSetInformationFile },
     { "NtSetValueKey",                  func_NtSetValueKey},
+    { "NtSetVolumeInformationFile",     func_NtSetVolumeInformationFile },
     { "NtSystemInformation",            func_NtSystemInformation },
     { "NtWriteFile",                    func_NtWriteFile },
     { "RtlAllocateHeap",                func_RtlAllocateHeap },