[MOUNTMGR_APITEST] Add a test suite for the mount manager
authorPierre Schweitzer <pierre@reactos.org>
Thu, 5 Sep 2019 06:35:23 +0000 (08:35 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 5 Sep 2019 06:36:20 +0000 (08:36 +0200)
It only tests IOCTL_MOUNTMGR_QUERY_POINTS for now

modules/rostests/apitests/CMakeLists.txt
modules/rostests/apitests/mountmgr/CMakeLists.txt [new file with mode: 0644]
modules/rostests/apitests/mountmgr/QueryPoints.c [new file with mode: 0644]
modules/rostests/apitests/mountmgr/precomp.h [new file with mode: 0644]
modules/rostests/apitests/mountmgr/testlist.c [new file with mode: 0644]

index 5bff8ce..1d62310 100644 (file)
@@ -19,6 +19,7 @@ if(NOT ARCH STREQUAL "amd64")
     add_subdirectory(kernel32)
 endif()
 add_subdirectory(localspl)
+add_subdirectory(mountmgr)
 add_subdirectory(msgina)
 add_subdirectory(mspatcha)
 add_subdirectory(msvcrt)
diff --git a/modules/rostests/apitests/mountmgr/CMakeLists.txt b/modules/rostests/apitests/mountmgr/CMakeLists.txt
new file mode 100644 (file)
index 0000000..73317c6
--- /dev/null
@@ -0,0 +1,11 @@
+
+list(APPEND SOURCE
+    QueryPoints.c
+    precomp.h)
+
+add_executable(mountmgr_apitest ${SOURCE} testlist.c)
+target_link_libraries(mountmgr_apitest wine ${PSEH_LIB})
+set_module_type(mountmgr_apitest win32cui)
+add_importlibs(mountmgr_apitest msvcrt kernel32 ntdll)
+add_pch(mountmgr_apitest precomp.h SOURCE)
+add_rostests_file(TARGET mountmgr_apitest)
diff --git a/modules/rostests/apitests/mountmgr/QueryPoints.c b/modules/rostests/apitests/mountmgr/QueryPoints.c
new file mode 100644 (file)
index 0000000..b7e6bee
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPLv2+ - See COPYING in the top level directory
+ * PURPOSE:         Test for QueryPoints IOCTL
+ * PROGRAMMER:      Pierre Schweitzer
+ */
+
+#include "precomp.h"
+
+START_TEST(QueryPoints)
+{
+    BOOL Ret;
+    DWORD BytesReturned;
+    HANDLE MountMgrHandle;
+    MOUNTMGR_MOUNT_POINT SinglePoint;
+    MOUNTMGR_MOUNT_POINTS MountPoints;
+    PMOUNTMGR_MOUNT_POINTS AllocatedPoints;
+
+    MountMgrHandle = CreateFileW(MOUNTMGR_DOS_DEVICE_NAME, 0,
+                                 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+                                 INVALID_HANDLE_VALUE);
+    if (MountMgrHandle == INVALID_HANDLE_VALUE)
+    {
+        win_skip("MountMgr unavailable: %lx\n", GetLastError());
+        return;
+    }
+
+    ZeroMemory(&SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT));
+
+    Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
+                          &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
+                          &MountPoints, sizeof(MOUNTMGR_MOUNT_POINTS),
+                          &BytesReturned, NULL);
+    ok(Ret == FALSE, "IOCTL unexpectedly succeed\n");
+    ok(GetLastError() == ERROR_MORE_DATA, "Unexcepted failure: %lx\n", GetLastError());
+
+    AllocatedPoints = RtlAllocateHeap(RtlGetProcessHeap(), 0, MountPoints.Size);
+    if (AllocatedPoints == NULL)
+    {
+        win_skip("Insufficiant memory\n");
+        goto Done;
+    }
+
+    Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
+                          &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
+                          AllocatedPoints, MountPoints.Size,
+                          &BytesReturned, NULL);
+    ok(Ret == TRUE, "IOCTL unexpectedly failed %lx\n", GetLastError());
+
+    RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPoints);
+
+Done:
+    CloseHandle(MountMgrHandle);
+}
diff --git a/modules/rostests/apitests/mountmgr/precomp.h b/modules/rostests/apitests/mountmgr/precomp.h
new file mode 100644 (file)
index 0000000..33509fb
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _MOUNTMGR_APITEST_PRECOMP_H_
+#define _MOUNTMGR_APITEST_PRECOMP_H_
+
+#define WIN32_NO_STATUS
+
+#include <apitest.h>
+#include <strsafe.h>
+#include <ntstatus.h>
+#include <mountmgr.h>
+#include <ndk/rtlfuncs.h>
+
+#endif /* _MOUNTMGR_APITEST_PRECOMP_H_ */
diff --git a/modules/rostests/apitests/mountmgr/testlist.c b/modules/rostests/apitests/mountmgr/testlist.c
new file mode 100644 (file)
index 0000000..ab7c092
--- /dev/null
@@ -0,0 +1,11 @@
+#define STANDALONE
+#include <apitest.h>
+
+extern void func_QueryPoints(void);
+
+const struct test winetest_testlist[] =
+{
+    { "QueryPoints", func_QueryPoints },
+    { 0, 0 }
+};
+