Author: tfaber Date: Wed Jul 6 18:55:21 2011 New Revision: 52549
URL: http://svn.reactos.org/svn/reactos?rev=52549&view=rev Log: [KMTESTS] - add a user-mode part to the example testlist.c - misc fixes
Added: branches/GSoC_2011/KMTestSuite/kmtests/example/Example_user.c (with props) Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c branches/GSoC_2011/KMTestSuite/kmtests/kmtest/support.c branches/GSoC_2011/KMTestSuite/kmtests/kmtest/testlist.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/CM... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] Wed Jul 6 18:55:21 2011 @@ -50,6 +50,9 @@ kmtest/service.c kmtest/support.c kmtest/testlist.c + + example/Example_user.c + kmtest/kmtest.rc)
add_executable(kmtest ${KMTEST_SOURCE})
Modified: branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/ex... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c [iso-8859-1] Wed Jul 6 18:55:21 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 kernel-mode part + * PURPOSE: Kernel-Mode Test Suite Example kernel-mode test part * PROGRAMMER: Thomas Faber thfabba@gmx.de */
Added: branches/GSoC_2011/KMTestSuite/kmtests/example/Example_user.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/ex... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/example/Example_user.c (added) +++ branches/GSoC_2011/KMTestSuite/kmtests/example/Example_user.c [iso-8859-1] Wed Jul 6 18:55:21 2011 @@ -1,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"); +}
Propchange: branches/GSoC_2011/KMTestSuite/kmtests/example/Example_user.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/in... ============================================================================== --- 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] Wed Jul 6 18:55:21 2011 @@ -46,6 +46,8 @@ 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);
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/km... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild [iso-8859-1] Wed Jul 6 18:55:21 2011 @@ -8,4 +8,7 @@ <file>support.c</file> <file>testlist.c</file> </directory> + <directory name="example"> + <file>Example_user.c</file> + </directory> </module>
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/km... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest/kmtest.c [iso-8859-1] Wed Jul 6 18:55:21 2011 @@ -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 @@ 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;
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest/support.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/km... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest/support.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest/support.c [iso-8859-1] Wed Jul 6 18:55:21 2011 @@ -50,6 +50,31 @@
/* 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;
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest/testlist.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/km... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest/testlist.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest/testlist.c [iso-8859-1] Wed Jul 6 18:55:21 2011 @@ -14,6 +14,7 @@ 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 @@ { "-delete", Test_Delete }, { "-start", Test_Start }, { "-stop", Test_Stop, }, + { "Example", Test_Example }, { NULL, NULL }, };