https://git.reactos.org/?p=reactos.git;a=commitdiff;h=16ec2e2aa53b403a9e59ffd7c9db09ce356335e3

commit 16ec2e2aa53b403a9e59ffd7c9db09ce356335e3
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Thu Sep 5 08:35:23 2019 +0200
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Thu Sep 5 08:36:20 2019 +0200

    [MOUNTMGR_APITEST] Add a test suite for the mount manager
    
    It only tests IOCTL_MOUNTMGR_QUERY_POINTS for now
---
 modules/rostests/apitests/CMakeLists.txt          |  1 +
 modules/rostests/apitests/mountmgr/CMakeLists.txt | 11 +++++
 modules/rostests/apitests/mountmgr/QueryPoints.c  | 55 +++++++++++++++++++++++
 modules/rostests/apitests/mountmgr/precomp.h      | 12 +++++
 modules/rostests/apitests/mountmgr/testlist.c     | 11 +++++
 5 files changed, 90 insertions(+)

diff --git a/modules/rostests/apitests/CMakeLists.txt 
b/modules/rostests/apitests/CMakeLists.txt
index 5bff8ce7604..1d623104fc7 100644
--- a/modules/rostests/apitests/CMakeLists.txt
+++ b/modules/rostests/apitests/CMakeLists.txt
@@ -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
index 00000000000..73317c628b6
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/CMakeLists.txt
@@ -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
index 00000000000..b7e6bee3250
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/QueryPoints.c
@@ -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
index 00000000000..33509fb8083
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/precomp.h
@@ -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
index 00000000000..ab7c0921a26
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/testlist.c
@@ -0,0 +1,11 @@
+#define STANDALONE
+#include <apitest.h>
+
+extern void func_QueryPoints(void);
+
+const struct test winetest_testlist[] =
+{
+    { "QueryPoints", func_QueryPoints },
+    { 0, 0 }
+};
+

Reply via email to