[KMTESTS]

- add a user-mode part to the example testlist.c
- misc fixes

svn path=/branches/GSoC_2011/KMTestSuite/; revision=52549
This commit is contained in:
Thomas Faber 2011-07-06 18:55:21 +00:00
parent bf054095df
commit 8d003b1a1c
8 changed files with 67 additions and 7 deletions

View file

@ -50,6 +50,9 @@ list(APPEND KMTEST_SOURCE
kmtest/service.c
kmtest/support.c
kmtest/testlist.c
example/Example_user.c
kmtest/kmtest.rc)
add_executable(kmtest ${KMTEST_SOURCE})

View file

@ -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 kernel-mode part
* PURPOSE: Kernel-Mode Test Suite Example kernel-mode test part
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
*/

View file

@ -0,0 +1,26 @@
/*
* PROJECT: ReactOS kernel-mode tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
* PURPOSE: Kernel-Mode Test Suite Example user-mode test part
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
*/
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <kmt_test.h>
START_TEST(Example)
{
/* do some user-mode stuff */
SYSTEM_INFO SystemInfo;
trace("Message from user-mode\n");
GetSystemInfo(&SystemInfo);
ok(SystemInfo.dwActiveProcessorMask != 0, "No active processors?!\n");
/* now run the kernel-mode part (see Example.c).
* If no user-mode part exists, this is what's done automatically */
KmtRunKernelTest("Example");
}

View file

@ -46,6 +46,8 @@ typedef struct
PMDL Mdl;
} KMT_DEVICE_EXTENSION, *PKMT_DEVICE_EXTENSION;
#elif defined KMT_USER_MODE
DWORD KmtRunKernelTest(IN PCSTR TestName);
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning);
VOID KmtUnloadDriver(VOID);
VOID KmtOpenDriver(VOID);

View file

@ -8,4 +8,7 @@
<file>support.c</file>
<file>testlist.c</file>
</directory>
<directory name="example">
<file>Example_user.c</file>
</directory>
</module>

View file

@ -26,7 +26,7 @@
#define LOGBUFFER_SIZE 65000
#define RESULTBUFFER_SIZE FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer[LOGBUFFER_SIZE])
static HANDLE KmtestHandle;
HANDLE KmtestHandle;
PCSTR ErrorFileAndLine = "No error";
static void OutputError(DWORD Error);
@ -223,15 +223,14 @@ RunTest(
TestFunction();
goto cleanup;
}
// not found in user-mode test list, call driver
if (!DeviceIoControl(KmtestHandle, IOCTL_KMTEST_RUN_TEST, (PVOID)TestName, strlen(TestName), NULL, 0, &BytesRead, NULL))
error_goto(Error, cleanup);
Error = KmtRunKernelTest(TestName);
cleanup:
if (!Error)
OutputResult(TestName);
Error = OutputResult(TestName);
KmtFreeResultBuffer(ResultBuffer);
return Error;

View file

@ -50,6 +50,31 @@ START_TEST(Stop)
/* test support functions for special-purpose drivers */
extern HANDLE KmtestHandle;
/**
* @name KmtRunKernelTest
*
* Run the specified kernel-mode test part
*
* @param TestName
* Name of the test to run
*
* @return Win32 error code as returned by DeviceIoControl
*/
DWORD
KmtRunKernelTest(
IN PCSTR TestName)
{
DWORD Error = ERROR_SUCCESS;
DWORD BytesRead;
if (!DeviceIoControl(KmtestHandle, IOCTL_KMTEST_RUN_TEST, (PVOID)TestName, strlen(TestName), NULL, 0, &BytesRead, NULL))
error(Error);
return Error;
}
static WCHAR TestServiceName[MAX_PATH];
static SC_HANDLE TestServiceHandle;
static HANDLE TestDeviceHandle;

View file

@ -14,6 +14,7 @@ VOID Test_Create(VOID);
VOID Test_Delete(VOID);
VOID Test_Start(VOID);
VOID Test_Stop(VOID);
VOID Test_Example(VOID);
/* tests with a leading '-' will not be listed */
const KMT_TEST TestList[] =
@ -22,5 +23,6 @@ const KMT_TEST TestList[] =
{ "-delete", Test_Delete },
{ "-start", Test_Start },
{ "-stop", Test_Stop, },
{ "Example", Test_Example },
{ NULL, NULL },
};