[KMTESTS]
authorThomas Faber <thomas.faber@reactos.org>
Thu, 11 Aug 2011 11:37:50 +0000 (11:37 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 11 Aug 2011 11:37:50 +0000 (11:37 +0000)
- Add a dummy IoHelper driver that can be loaded by driver/device tests
- Minor changes to other standalone drivers

svn path=/branches/GSoC_2011/KMTestSuite/; revision=53177

kmtests/CMakeLists.txt
kmtests/example/Example_drv.c
kmtests/include/kmt_test.h
kmtests/ntos_io/CMakeLists.txt
kmtests/ntos_io/IoDriverObject_drv.c
kmtests/ntos_io/IoHelper_drv.c [new file with mode: 0644]
kmtests/ntos_io/IoHelper_drv.rbuild [new file with mode: 0644]

index 63f86c2..b4bd26d 100644 (file)
@@ -87,7 +87,11 @@ add_cd_file(TARGET kmtest DESTINATION reactos/bin FOR all)
 # Group targets
 #
 add_custom_target(kmtest_drivers)
-add_dependencies(kmtest_drivers kmtest_drv example_drv iodriverobject_drv)
+add_dependencies(kmtest_drivers
+    kmtest_drv
+    example_drv
+    iodriverobject_drv
+    iohelper_drv)
 
 add_custom_target(kmtest_all)
 add_dependencies(kmtest_all kmtest_drivers kmtest)
index 5a2a62e..641c71a 100644 (file)
@@ -49,13 +49,14 @@ TestEntry(
     IN PDRIVER_OBJECT DriverObject,
     IN PCUNICODE_STRING RegistryPath,
     OUT PCWSTR *DeviceName,
-    OUT INT *Flags)
+    IN OUT INT *Flags)
 {
     NTSTATUS Status = STATUS_SUCCESS;
 
     PAGED_CODE();
 
     UNREFERENCED_PARAMETER(RegistryPath);
+    UNREFERENCED_PARAMETER(Flags);
 
     DPRINT("Entry!\n");
 
index 838d397..7b8f837 100644 (file)
@@ -68,7 +68,7 @@ typedef enum
     TESTENTRY_NO_REGISTER_UNLOAD = 4,
 } KMT_TESTENTRY_FLAGS;
 
-NTSTATUS TestEntry(IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT PCWSTR *DeviceName, OUT INT *Flags);
+NTSTATUS TestEntry(IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT PCWSTR *DeviceName, IN OUT INT *Flags);
 VOID TestUnload(IN PDRIVER_OBJECT DriverObject);
 #endif /* defined KMT_STANDALONE_DRIVER */
 
index 8559c43..9d1f5e0 100644 (file)
@@ -1,11 +1,14 @@
 include_directories(
     ../include)
 
-list(APPEND EXAMPLE_DRV_SOURCE
+#
+# IoDriverObject
+#
+list(APPEND IODRIVEROBJECT_DRV_SOURCE
     ../kmtest_drv/kmtest_standalone.c
     IoDriverObject_drv.c)
 
-add_library(iodriverobject_drv SHARED ${EXAMPLE_DRV_SOURCE})
+add_library(iodriverobject_drv SHARED ${IODRIVEROBJECT_DRV_SOURCE})
 
 set_module_type(iodriverobject_drv kernelmodedriver)
 target_link_libraries(iodriverobject_drv kmtest_printf ${PSEH_LIB})
@@ -13,3 +16,19 @@ add_importlibs(iodriverobject_drv ntoskrnl hal)
 set_property(TARGET iodriverobject_drv PROPERTY COMPILE_DEFINITIONS KMT_STANDALONE_DRIVER)
 
 add_cd_file(TARGET iodriverobject_drv DESTINATION reactos/bin FOR all)
+
+#
+# IoHelper
+#
+list(APPEND IOHELPER_DRV_SOURCE
+    ../kmtest_drv/kmtest_standalone.c
+    IoHelper_drv.c)
+
+add_library(iohelper_drv SHARED ${IOHELPER_DRV_SOURCE})
+
+set_module_type(iohelper_drv kernelmodedriver)
+target_link_libraries(iohelper_drv kmtest_printf ${PSEH_LIB})
+add_importlibs(iohelper_drv ntoskrnl hal)
+set_property(TARGET iohelper_drv PROPERTY COMPILE_DEFINITIONS KMT_STANDALONE_DRIVER)
+
+add_cd_file(TARGET iohelper_drv DESTINATION reactos/bin FOR all)
index 5c34eb7..99ae3b5 100644 (file)
@@ -26,13 +26,14 @@ TestEntry(
     IN PDRIVER_OBJECT DriverObject,
     IN PCUNICODE_STRING RegistryPath,
     OUT PCWSTR *DeviceName,
-    OUT INT *Flags)
+    IN OUT INT *Flags)
 {
     NTSTATUS Status = STATUS_SUCCESS;
 
     PAGED_CODE();
 
     UNREFERENCED_PARAMETER(RegistryPath);
+    UNREFERENCED_PARAMETER(Flags);
 
     *DeviceName = L"IoDriverObject";
 
@@ -62,6 +63,8 @@ TestIrpHandler(
 {
     NTSTATUS Status = STATUS_SUCCESS;
 
+    UNREFERENCED_PARAMETER(IoStackLocation);
+
     TestDriverObject(DeviceObject->DriverObject, DriverIrp);
 
     Irp->IoStatus.Status = Status;
diff --git a/kmtests/ntos_io/IoHelper_drv.c b/kmtests/ntos_io/IoHelper_drv.c
new file mode 100644 (file)
index 0000000..79fba76
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * PROJECT:         ReactOS kernel-mode tests
+ * LICENSE:         GPLv2+ - See COPYING in the top level directory
+ * PURPOSE:         Kernel-Mode Test Suite I/O Test Helper driver
+ * PROGRAMMER:      Thomas Faber <thfabba@gmx.de>
+ */
+
+#include <kmt_test.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+static KMT_IRP_HANDLER TestIrpHandler;
+
+NTSTATUS
+TestEntry(
+    IN PDRIVER_OBJECT DriverObject,
+    IN PCUNICODE_STRING RegistryPath,
+    OUT PCWSTR *DeviceName,
+    IN OUT INT *Flags)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    PAGED_CODE();
+
+    UNREFERENCED_PARAMETER(DriverObject);
+    UNREFERENCED_PARAMETER(RegistryPath);
+    UNREFERENCED_PARAMETER(Flags);
+
+    *DeviceName = L"IoHelper";
+
+    KmtRegisterIrpHandler(IRP_MJ_CREATE, NULL, TestIrpHandler);
+    KmtRegisterIrpHandler(IRP_MJ_CLOSE, NULL, TestIrpHandler);
+
+    return Status;
+}
+
+VOID
+TestUnload(
+    IN PDRIVER_OBJECT DriverObject)
+{
+    PAGED_CODE();
+
+    UNREFERENCED_PARAMETER(DriverObject);
+}
+
+static
+NTSTATUS
+TestIrpHandler(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    IN PIO_STACK_LOCATION IoStackLocation)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    if (IoStackLocation->MajorFunction == IRP_MJ_CREATE)
+        DPRINT("Helper Driver: Create Device %p", DeviceObject);
+    else if (IoStackLocation->MajorFunction == IRP_MJ_CLOSE)
+        DPRINT("Helper Driver: Close Device %p", DeviceObject);
+
+    Irp->IoStatus.Status = Status;
+    Irp->IoStatus.Information = 0;
+
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return Status;
+}
diff --git a/kmtests/ntos_io/IoHelper_drv.rbuild b/kmtests/ntos_io/IoHelper_drv.rbuild
new file mode 100644 (file)
index 0000000..5d0b554
--- /dev/null
@@ -0,0 +1,14 @@
+<module name="iohelper_drv" type="kernelmodedriver" installbase="bin" installname="iohelper_drv.sys">
+       <include base="kmtest_drv">include</include>
+       <library>ntoskrnl</library>
+       <library>hal</library>
+       <library>pseh</library>
+       <library>kmtest_printf</library>
+       <define name="KMT_STANDALONE_DRIVER" />
+       <file>IoHelper_drv.c</file>
+       <directory name="..">
+               <directory name="kmtest_drv">
+                       <file>kmtest_standalone.c</file>
+               </directory>
+       </directory>
+</module>