Author: tfaber Date: Fri Apr 27 08:36:58 2012 New Revision: 56434
URL: http://svn.reactos.org/svn/reactos?rev=56434&view=rev Log: [KMTESTS/RTL] - Add a small RtlException test, mainly to check that a stack overflow really throws STATUS_STACK_OVERFLOW, not STATUS_ACCESS_VIOLATION.
Added: trunk/rostests/kmtests/rtl/RtlException.c (with props) Modified: trunk/rostests/kmtests/CMakeLists.txt trunk/rostests/kmtests/kmtest/testlist.c trunk/rostests/kmtests/kmtest_drv/testlist.c
Modified: trunk/rostests/kmtests/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/CMakeLists.txt?rev... ============================================================================== --- trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] Fri Apr 27 08:36:58 2012 @@ -10,6 +10,7 @@ list(APPEND COMMON_SOURCE example/GuardedMemory.c rtl/RtlAvlTree.c + rtl/RtlException.c rtl/RtlMemory.c rtl/RtlSplayTree.c rtl/RtlUnicodeString.c)
Modified: trunk/rostests/kmtests/kmtest/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest/testlist.c?... ============================================================================== --- trunk/rostests/kmtests/kmtest/testlist.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/kmtest/testlist.c [iso-8859-1] Fri Apr 27 08:36:58 2012 @@ -10,6 +10,7 @@ KMT_TESTFUNC Test_Example; KMT_TESTFUNC Test_IoDeviceObject; KMT_TESTFUNC Test_RtlAvlTree; +KMT_TESTFUNC Test_RtlException; KMT_TESTFUNC Test_RtlMemory; KMT_TESTFUNC Test_RtlSplayTree; KMT_TESTFUNC Test_RtlUnicodeString; @@ -20,6 +21,7 @@ { "Example", Test_Example }, { "IoDeviceObject", Test_IoDeviceObject }, { "RtlAvlTree", Test_RtlAvlTree }, + { "RtlException", Test_RtlException }, { "RtlMemory", Test_RtlMemory }, { "RtlSplayTree", Test_RtlSplayTree }, { "RtlUnicodeString", Test_RtlUnicodeString },
Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testlis... ============================================================================== --- trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] Fri Apr 27 08:36:58 2012 @@ -38,6 +38,7 @@ KMT_TESTFUNC Test_ObTypeNoClean; KMT_TESTFUNC Test_ObTypes; KMT_TESTFUNC Test_RtlAvlTree; +KMT_TESTFUNC Test_RtlException; KMT_TESTFUNC Test_RtlMemory; KMT_TESTFUNC Test_RtlSplayTree;
@@ -74,6 +75,7 @@ { "-ObTypeNoClean", Test_ObTypeNoClean }, { "ObTypes", Test_ObTypes }, { "RtlAvlTreeKM", Test_RtlAvlTree }, + { "RtlExceptionKM", Test_RtlException }, { "RtlMemoryKM", Test_RtlMemory }, { "RtlSplayTreeKM", Test_RtlSplayTree }, { NULL, NULL }
Added: trunk/rostests/kmtests/rtl/RtlException.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/rtl/RtlException.c... ============================================================================== --- trunk/rostests/kmtests/rtl/RtlException.c (added) +++ trunk/rostests/kmtests/rtl/RtlException.c [iso-8859-1] Fri Apr 27 08:36:58 2012 @@ -1,0 +1,61 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Kernel-Mode Test Suite Exception test + * PROGRAMMER: Thomas Faber thfabba@gmx.de + */ + +#include <kmt_test.h> + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok_eq_hex(ExceptionStatus, ExpectedStatus) + +START_TEST(RtlException) +{ + NTSTATUS ExceptionStatus; + PCHAR Buffer[128]; + CHAR Value; + + /* Access a valid pointer - must not trigger SEH */ + StartSeh() + RtlFillMemory(Buffer, sizeof(Buffer), 0x12); + EndSeh(STATUS_SUCCESS); + + /* Read from a NULL pointer - must cause an access violation */ + StartSeh() + Value = *(volatile CHAR *)NULL; + EndSeh(STATUS_ACCESS_VIOLATION); + + /* Write to a NULL pointer - must cause an access violation */ + StartSeh() + *(volatile CHAR *)NULL = 5; + EndSeh(STATUS_ACCESS_VIOLATION); + + /* TODO: Find where MmBadPointer is defined - gives an unresolved external */ +#if 0 //def KMT_KERNEL_MODE + /* Read from MmBadPointer - must cause an access violation */ + StartSeh() + Value = *(volatile CHAR *)MmBadPointer; + EndSeh(STATUS_ACCESS_VIOLATION); + + /* Write to MmBadPointer - must cause an access violation */ + StartSeh() + *(volatile CHAR *)MmBadPointer = 5; + EndSeh(STATUS_ACCESS_VIOLATION); +#endif + + /* We cannot test this in kernel mode easily - the stack is just "somewhere" + * in system space, and there's no guard page below it */ +#ifdef KMT_USER_MODE + /* Overflow the stack - must cause a special exception */ + StartSeh() + PCHAR Pointer; + + while (1) + { + Pointer = _alloca(1024); + *Pointer = 5; + } + EndSeh(STATUS_STACK_OVERFLOW); +#endif +}
Propchange: trunk/rostests/kmtests/rtl/RtlException.c ------------------------------------------------------------------------------ svn:eol-style = native