Author: tfaber
Date: Fri Jul 22 11:51:18 2011
New Revision: 52781
URL:
http://svn.reactos.org/svn/reactos?rev=52781&view=rev
Log:
[KMTESTS]
- small structure improvement in kmt_test.h
- add globals to allow easy checking for UP/MP & Free/Checked builds, as that is
required for some tests
- add KernelType example test demonstrating the above
- add a function to restore the irql (allows some failing tests to exit gracefully)
Added:
branches/GSoC_2011/KMTestSuite/kmtests/example/KernelType.c (with props)
Modified:
branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt
branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h
branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild
branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c
branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_standalone.c
branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.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] Fri Jul 22 11:51:18
2011
@@ -14,6 +14,7 @@
kmtest_drv/testlist.c
example/Example.c
+ example/KernelType.c
ntos_ex/ExHardError.c
ntos_ex/ExInterlocked.c
ntos_ex/ExPools.c
Added: branches/GSoC_2011/KMTestSuite/kmtests/example/KernelType.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/e…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/example/KernelType.c (added)
+++ branches/GSoC_2011/KMTestSuite/kmtests/example/KernelType.c [iso-8859-1] Fri Jul 22
11:51:18 2011
@@ -1,0 +1,21 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Kernel-Mode Test Suite Kernel Type example test
+ * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de>
+ */
+
+#include <ntddk.h>
+#include <kmt_test.h>
+
+START_TEST(KernelType)
+{
+ if (KmtIsMultiProcessorBuild)
+ trace("This is a MultiProcessor kernel\n");
+ else
+ trace("This is a Uniprocessor kernel\n");
+ if (KmtIsCheckedBuild)
+ trace("This is a Checked kernel\n");
+ else
+ trace("This is a Free kernel\n");
+}
Propchange: branches/GSoC_2011/KMTestSuite/kmtests/example/KernelType.c
------------------------------------------------------------------------------
svn:eol-style = native
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] Fri Jul 22
11:51:18 2011
@@ -79,6 +79,11 @@
PKMT_RESULTBUFFER ResultBuffer;
PMDL Mdl;
} KMT_DEVICE_EXTENSION, *PKMT_DEVICE_EXTENSION;
+
+extern BOOLEAN KmtIsCheckedBuild;
+extern BOOLEAN KmtIsMultiProcessorBuild;
+
+VOID KmtSetIrql(IN KIRQL NewIrql);
#elif defined KMT_USER_MODE
DWORD KmtRunKernelTest(IN PCSTR TestName);
@@ -146,9 +151,22 @@
FILE_ANY_ACCESS)
#if defined KMT_DEFINE_TEST_FUNCTIONS
-PKMT_RESULTBUFFER ResultBuffer = NULL;
-
-#if defined KMT_USER_MODE
+
+#if defined KMT_KERNEL_MODE
+BOOLEAN KmtIsCheckedBuild;
+BOOLEAN KmtIsMultiProcessorBuild;
+
+VOID KmtSetIrql(IN KIRQL NewIrql)
+{
+ KIRQL Irql = KeGetCurrentIrql();
+ if (Irql > NewIrql)
+ KeLowerIrql(NewIrql);
+ else if (Irql < NewIrql)
+ KeRaiseIrql(NewIrql, &Irql);
+}
+
+INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list
Arguments) KMT_FORMAT(ms_printf, 3, 0);
+#elif defined KMT_USER_MODE
static PKMT_RESULTBUFFER KmtAllocateResultBuffer(SIZE_T LogBufferMaxLength)
{
PKMT_RESULTBUFFER Buffer = HeapAlloc(GetProcessHeap(), 0,
FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer[LogBufferMaxLength]));
@@ -166,7 +184,11 @@
{
HeapFree(GetProcessHeap(), 0, Buffer);
}
+
+#define KmtVSNPrintF vsnprintf
#endif /* defined KMT_USER_MODE */
+
+PKMT_RESULTBUFFER ResultBuffer = NULL;
static VOID KmtAddToLogBuffer(PKMT_RESULTBUFFER Buffer, PCSTR String, SIZE_T Length)
{
@@ -191,12 +213,6 @@
memcpy(&Buffer->LogBuffer[OldLength], String, Length);
}
-#ifdef KMT_KERNEL_MODE
-INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list
Arguments) KMT_FORMAT(ms_printf, 3, 0);
-#elif defined KMT_USER_MODE
-#define KmtVSNPrintF vsnprintf
-#endif /* defined KMT_USER_MODE */
-
KMT_FORMAT(ms_printf, 5, 0)
static SIZE_T KmtXVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR
Prepend, PCSTR Format, va_list Arguments)
{
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild [iso-8859-1] Fri Jul 22
11:51:18 2011
@@ -12,6 +12,7 @@
</directory>
<directory name="example">
<file>Example.c</file>
+ <file>KernelType.c</file>
</directory>
<directory name="ntos_ex">
<file>ExHardError.c</file>
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_drv.c [iso-8859-1] Fri Jul 22
11:51:18 2011
@@ -6,6 +6,8 @@
*/
#include <ntddk.h>
+#include <ntifs.h>
+#include <ndk/ketypes.h>
#include <ntstrsafe.h>
#include <limits.h>
#include <pseh/pseh2.h>
@@ -49,12 +51,17 @@
NTSTATUS Status = STATUS_SUCCESS;
UNICODE_STRING DeviceName;
PKMT_DEVICE_EXTENSION DeviceExtension;
+ PKPRCB Prcb;
PAGED_CODE();
UNREFERENCED_PARAMETER(RegistryPath);
DPRINT("DriverEntry\n");
+
+ Prcb = KeGetCurrentPrcb();
+ KmtIsCheckedBuild = (Prcb->BuildType & PRCB_BUILD_DEBUG) != 0;
+ KmtIsMultiProcessorBuild = (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR) == 0;
RtlInitUnicodeString(&DeviceName, KMTEST_DEVICE_DRIVER_PATH);
Status = IoCreateDevice(DriverObject, sizeof(KMT_DEVICE_EXTENSION),
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_standalone.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_standalone.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/kmtest_standalone.c [iso-8859-1] Fri
Jul 22 11:51:18 2011
@@ -6,6 +6,8 @@
*/
#include <ntddk.h>
+#include <ntifs.h>
+#include <ndk/ketypes.h>
#define KMT_DEFINE_TEST_FUNCTIONS
#include <kmt_test.h>
@@ -104,10 +106,15 @@
PCWSTR DeviceNameSuffix;
INT Flags = 0;
int i;
+ PKPRCB Prcb;
PAGED_CODE();
DPRINT("DriverEntry\n");
+
+ Prcb = KeGetCurrentPrcb();
+ KmtIsCheckedBuild = (Prcb->BuildType & PRCB_BUILD_DEBUG) != 0;
+ KmtIsMultiProcessorBuild = (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR) == 0;
/* get the Kmtest device, so that we get a ResultBuffer pointer */
RtlInitUnicodeString(&KmtestDeviceName, KMTEST_DEVICE_DRIVER_PATH);
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c [iso-8859-1] Fri Jul 22
11:51:18 2011
@@ -23,6 +23,7 @@
KMT_TESTFUNC Test_KeDpc;
KMT_TESTFUNC Test_KeIrql;
KMT_TESTFUNC Test_KeProcessor;
+KMT_TESTFUNC Test_KernelType;
KMT_TESTFUNC Test_ObCreate;
const KMT_TEST TestList[] =
@@ -42,6 +43,7 @@
{ "KeDpc", Test_KeDpc },
{ "KeIrql", Test_KeIrql },
{ "KeProcessor", Test_KeProcessor },
+ { "KernelType", Test_KernelType },
{ "ObCreate", Test_ObCreate },
{ NULL, NULL }
};