mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 01:24:11 +00:00
[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:
parent
bf054095df
commit
8d003b1a1c
8 changed files with 67 additions and 7 deletions
|
@ -50,6 +50,9 @@ list(APPEND KMTEST_SOURCE
|
||||||
kmtest/service.c
|
kmtest/service.c
|
||||||
kmtest/support.c
|
kmtest/support.c
|
||||||
kmtest/testlist.c
|
kmtest/testlist.c
|
||||||
|
|
||||||
|
example/Example_user.c
|
||||||
|
|
||||||
kmtest/kmtest.rc)
|
kmtest/kmtest.rc)
|
||||||
|
|
||||||
add_executable(kmtest ${KMTEST_SOURCE})
|
add_executable(kmtest ${KMTEST_SOURCE})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS kernel-mode tests
|
* PROJECT: ReactOS kernel-mode tests
|
||||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
* 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>
|
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
26
kmtests/example/Example_user.c
Normal file
26
kmtests/example/Example_user.c
Normal 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");
|
||||||
|
}
|
|
@ -46,6 +46,8 @@ typedef struct
|
||||||
PMDL Mdl;
|
PMDL Mdl;
|
||||||
} KMT_DEVICE_EXTENSION, *PKMT_DEVICE_EXTENSION;
|
} KMT_DEVICE_EXTENSION, *PKMT_DEVICE_EXTENSION;
|
||||||
#elif defined KMT_USER_MODE
|
#elif defined KMT_USER_MODE
|
||||||
|
DWORD KmtRunKernelTest(IN PCSTR TestName);
|
||||||
|
|
||||||
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning);
|
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning);
|
||||||
VOID KmtUnloadDriver(VOID);
|
VOID KmtUnloadDriver(VOID);
|
||||||
VOID KmtOpenDriver(VOID);
|
VOID KmtOpenDriver(VOID);
|
||||||
|
|
|
@ -8,4 +8,7 @@
|
||||||
<file>support.c</file>
|
<file>support.c</file>
|
||||||
<file>testlist.c</file>
|
<file>testlist.c</file>
|
||||||
</directory>
|
</directory>
|
||||||
|
<directory name="example">
|
||||||
|
<file>Example_user.c</file>
|
||||||
|
</directory>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define LOGBUFFER_SIZE 65000
|
#define LOGBUFFER_SIZE 65000
|
||||||
#define RESULTBUFFER_SIZE FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer[LOGBUFFER_SIZE])
|
#define RESULTBUFFER_SIZE FIELD_OFFSET(KMT_RESULTBUFFER, LogBuffer[LOGBUFFER_SIZE])
|
||||||
|
|
||||||
static HANDLE KmtestHandle;
|
HANDLE KmtestHandle;
|
||||||
PCSTR ErrorFileAndLine = "No error";
|
PCSTR ErrorFileAndLine = "No error";
|
||||||
|
|
||||||
static void OutputError(DWORD Error);
|
static void OutputError(DWORD Error);
|
||||||
|
@ -225,12 +225,11 @@ RunTest(
|
||||||
}
|
}
|
||||||
|
|
||||||
// not found in user-mode test list, call driver
|
// 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 = KmtRunKernelTest(TestName);
|
||||||
error_goto(Error, cleanup);
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!Error)
|
if (!Error)
|
||||||
OutputResult(TestName);
|
Error = OutputResult(TestName);
|
||||||
|
|
||||||
KmtFreeResultBuffer(ResultBuffer);
|
KmtFreeResultBuffer(ResultBuffer);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,31 @@ START_TEST(Stop)
|
||||||
|
|
||||||
/* test support functions for special-purpose drivers */
|
/* 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 WCHAR TestServiceName[MAX_PATH];
|
||||||
static SC_HANDLE TestServiceHandle;
|
static SC_HANDLE TestServiceHandle;
|
||||||
static HANDLE TestDeviceHandle;
|
static HANDLE TestDeviceHandle;
|
||||||
|
|
|
@ -14,6 +14,7 @@ VOID Test_Create(VOID);
|
||||||
VOID Test_Delete(VOID);
|
VOID Test_Delete(VOID);
|
||||||
VOID Test_Start(VOID);
|
VOID Test_Start(VOID);
|
||||||
VOID Test_Stop(VOID);
|
VOID Test_Stop(VOID);
|
||||||
|
VOID Test_Example(VOID);
|
||||||
|
|
||||||
/* tests with a leading '-' will not be listed */
|
/* tests with a leading '-' will not be listed */
|
||||||
const KMT_TEST TestList[] =
|
const KMT_TEST TestList[] =
|
||||||
|
@ -22,5 +23,6 @@ const KMT_TEST TestList[] =
|
||||||
{ "-delete", Test_Delete },
|
{ "-delete", Test_Delete },
|
||||||
{ "-start", Test_Start },
|
{ "-start", Test_Start },
|
||||||
{ "-stop", Test_Stop, },
|
{ "-stop", Test_Stop, },
|
||||||
|
{ "Example", Test_Example },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue