Author: tfaber
Date: Thu Aug 11 11:37:50 2011
New Revision: 53177
URL:
http://svn.reactos.org/svn/reactos?rev=53177&view=rev
Log:
[KMTESTS]
- Add a dummy IoHelper driver that can be loaded by driver/device tests
- Minor changes to other standalone drivers
Added:
branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoHelper_drv.c
- copied, changed from r53083,
branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c
branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoHelper_drv.rbuild
- copied, changed from r53083,
branches/GSoC_2011/KMTestSuite/kmtests/example/example_drv.rbuild
Modified:
branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt
branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c
branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h
branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/CMakeLists.txt
branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoDriverObject_drv.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/C…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] Thu Aug 11 11:37:50
2011
@@ -87,7 +87,11 @@
# 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)
Modified: branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/e…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c [iso-8859-1] Thu Aug 11
11:37:50 2011
@@ -49,13 +49,14 @@
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");
Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/i…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] Thu Aug 11
11:37:50 2011
@@ -68,7 +68,7 @@
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 */
Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/CMakeLists.txt [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/CMakeLists.txt [iso-8859-1] Thu Aug 11
11:37:50 2011
@@ -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 @@
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)
Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoDriverObject_drv.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoDriverObject_drv.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoDriverObject_drv.c [iso-8859-1] Thu
Aug 11 11:37:50 2011
@@ -26,13 +26,14 @@
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";
@@ -61,6 +62,8 @@
IN PIO_STACK_LOCATION IoStackLocation)
{
NTSTATUS Status = STATUS_SUCCESS;
+
+ UNREFERENCED_PARAMETER(IoStackLocation);
TestDriverObject(DeviceObject->DriverObject, DriverIrp);
Copied: branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoHelper_drv.c (from r53083,
branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c)
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/example/Example_drv.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoHelper_drv.c [iso-8859-1] Thu Aug 11
11:37:50 2011
@@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS kernel-mode tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
- * PURPOSE: Kernel-Mode Test Suite Example Test Driver
+ * PURPOSE: Kernel-Mode Test Suite I/O Test Helper driver
* PROGRAMMER: Thomas Faber <thfabba(a)gmx.de>
*/
@@ -10,210 +10,40 @@
//#define NDEBUG
#include <debug.h>
-#include "Example.h"
-
-/* prototypes */
-static KMT_MESSAGE_HANDLER TestMessageHandler;
static KMT_IRP_HANDLER TestIrpHandler;
-/* globals */
-static PDRIVER_OBJECT TestDriverObject;
-
-/**
- * @name TestEntry
- *
- * Test entry point.
- * This is called by DriverEntry as early as possible, but with ResultBuffer
- * initialized, so that test macros work correctly
- *
- * @param DriverObject
- * Driver Object.
- * This is guaranteed not to have been touched by DriverEntry before
- * the call to TestEntry
- * @param RegistryPath
- * Driver Registry Path
- * This is guaranteed not to have been touched by DriverEntry before
- * the call to TestEntry
- * @param DeviceName
- * Pointer to receive a test-specific name for the device to create
- * @param Flags
- * Pointer to a flags variable instructing DriverEntry how to proceed.
- * See the KMT_TESTENTRY_FLAGS enumeration for possible values
- * Initialized to zero on entry
- *
- * @return Status.
- * DriverEntry will fail if this is a failure status
- */
NTSTATUS
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(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
+ UNREFERENCED_PARAMETER(Flags);
- DPRINT("Entry!\n");
-
- ok_irql(PASSIVE_LEVEL);
- TestDriverObject = DriverObject;
-
- *DeviceName = L"Example";
-
- trace("Hi, this is the example driver\n");
+ *DeviceName = L"IoHelper";
KmtRegisterIrpHandler(IRP_MJ_CREATE, NULL, TestIrpHandler);
KmtRegisterIrpHandler(IRP_MJ_CLOSE, NULL, TestIrpHandler);
- KmtRegisterMessageHandler(0, NULL, TestMessageHandler);
return Status;
}
-/**
- * @name TestUnload
- *
- * Test unload routine.
- * This is called by the driver's Unload routine as early as possible, with
- * ResultBuffer and the test device object still valid, so that test macros
- * work correctly
- *
- * @param DriverObject
- * Driver Object.
- * This is guaranteed not to have been touched by Unload before the call
- * to TestEntry
- *
- * @return Status
- */
VOID
TestUnload(
IN PDRIVER_OBJECT DriverObject)
{
PAGED_CODE();
- DPRINT("Unload!\n");
-
- ok_irql(PASSIVE_LEVEL);
- ok_eq_pointer(DriverObject, TestDriverObject);
-
- trace("Unloading example driver\n");
+ UNREFERENCED_PARAMETER(DriverObject);
}
-/**
- * @name TestMessageHandler
- *
- * Test message handler routine
- *
- * @param DeviceObject
- * Device Object.
- * This is guaranteed not to have been touched by the dispatch function
- * before the call to the IRP handler
- * @param Irp
- * Device Object.
- * This is guaranteed not to have been touched by the dispatch function
- * before the call to the IRP handler, except for passing it to
- * IoGetCurrentStackLocation
- * @param IoStackLocation
- * Device Object.
- * This is guaranteed not to have been touched by the dispatch function
- * before the call to the IRP handler
- *
- * @return Status
- */
-static
-NTSTATUS
-TestMessageHandler(
- IN PDEVICE_OBJECT DeviceObject,
- IN ULONG ControlCode,
- IN PVOID Buffer OPTIONAL,
- IN SIZE_T InLength,
- IN OUT PSIZE_T OutLength)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- switch (ControlCode)
- {
- case IOCTL_NOTIFY:
- {
- static int TimesReceived = 0;
-
- ++TimesReceived;
- ok(TimesReceived == 1, "Received control code 1 %d times\n",
TimesReceived);
- ok_eq_pointer(Buffer, NULL);
- ok_eq_ulong((ULONG)InLength, 0LU);
- ok_eq_ulong((ULONG)*OutLength, 0LU);
- break;
- }
- case IOCTL_SEND_STRING:
- {
- static int TimesReceived = 0;
- ANSI_STRING ExpectedString = RTL_CONSTANT_STRING("yay");
- ANSI_STRING ReceivedString;
-
- ++TimesReceived;
- ok(TimesReceived == 1, "Received control code 2 %d times\n",
TimesReceived);
- ok(Buffer != NULL, "Buffer is NULL\n");
- ok_eq_ulong((ULONG)InLength, (ULONG)ExpectedString.Length);
- ok_eq_ulong((ULONG)*OutLength, 0LU);
- ReceivedString.MaximumLength = ReceivedString.Length = (USHORT)InLength;
- ReceivedString.Buffer = Buffer;
- ok(RtlCompareString(&ExpectedString, &ReceivedString, FALSE) == 0,
"Received string: %Z\n", &ReceivedString);
- break;
- }
- case IOCTL_SEND_MYSTRUCT:
- {
- static int TimesReceived = 0;
- MY_STRUCT ExpectedStruct = { 123, ":D" };
- MY_STRUCT ResultStruct = { 456, "!!!" };
-
- ++TimesReceived;
- ok(TimesReceived == 1, "Received control code 3 %d times\n",
TimesReceived);
- ok(Buffer != NULL, "Buffer is NULL\n");
- ok_eq_ulong((ULONG)InLength, (ULONG)sizeof ExpectedStruct);
- ok_eq_ulong((ULONG)*OutLength, 2LU * sizeof ExpectedStruct);
- if (!skip(Buffer && InLength >= sizeof ExpectedStruct,
"Cannot read from buffer!\n"))
- ok(RtlCompareMemory(&ExpectedStruct, Buffer, sizeof ExpectedStruct)
== sizeof ExpectedStruct, "Buffer does not contain expected values\n");
-
- if (!skip(Buffer && *OutLength >= 2 * sizeof ExpectedStruct,
"Cannot write to buffer!\n"))
- {
- RtlCopyMemory((PCHAR)Buffer + sizeof ExpectedStruct, &ResultStruct,
sizeof ResultStruct);
- *OutLength = 2 * sizeof ExpectedStruct;
- }
- break;
- }
- default:
- ok(0, "Got an unknown message! DeviceObject=%p, ControlCode=%lu,
Buffer=%p, In=%lu, Out=%lu bytes\n",
- DeviceObject, ControlCode, Buffer, InLength, *OutLength);
- break;
- }
-
- return Status;
-}
-
-/**
- * @name TestIrpHandler
- *
- * Test IRP handler routine
- *
- * @param DeviceObject
- * Device Object.
- * This is guaranteed not to have been touched by the dispatch function
- * before the call to the IRP handler
- * @param Irp
- * Device Object.
- * This is guaranteed not to have been touched by the dispatch function
- * before the call to the IRP handler, except for passing it to
- * IoGetCurrentStackLocation
- * @param IoStackLocation
- * Device Object.
- * This is guaranteed not to have been touched by the dispatch function
- * before the call to the IRP handler
- *
- * @return Status
- */
static
NTSTATUS
TestIrpHandler(
@@ -223,17 +53,10 @@
{
NTSTATUS Status = STATUS_SUCCESS;
- DPRINT("IRP!\n");
-
- ok_irql(PASSIVE_LEVEL);
- ok_eq_pointer(DeviceObject->DriverObject, TestDriverObject);
-
if (IoStackLocation->MajorFunction == IRP_MJ_CREATE)
- trace("Got IRP_MJ_CREATE!\n");
+ DPRINT("Helper Driver: Create Device %p", DeviceObject);
else if (IoStackLocation->MajorFunction == IRP_MJ_CLOSE)
- trace("Got IRP_MJ_CLOSE!\n");
- else
- trace("Got an IRP!\n");
+ DPRINT("Helper Driver: Close Device %p", DeviceObject);
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
Copied: branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoHelper_drv.rbuild (from r53083,
branches/GSoC_2011/KMTestSuite/kmtests/example/example_drv.rbuild)
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/example/example_drv.rbuild [iso-8859-1]
(original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoHelper_drv.rbuild [iso-8859-1] Thu
Aug 11 11:37:50 2011
@@ -1,11 +1,11 @@
-<module name="example_drv" type="kernelmodedriver"
installbase="bin" installname="example_drv.sys">
+<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>Example_drv.c</file>
+ <file>IoHelper_drv.c</file>
<directory name="..">
<directory name="kmtest_drv">
<file>kmtest_standalone.c</file>