Author: tfaber
Date: Sat May 6 15:29:56 2017
New Revision: 74489
URL:
http://svn.reactos.org/svn/reactos?rev=74489&view=rev
Log:
[KMTESTS:RTL]
- Add a test for RtlWalkFrameChain and RtlCaptureStackBackTrace
Added:
trunk/rostests/kmtests/rtl/RtlStack.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?re…
==============================================================================
--- trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] Sat May 6 15:29:56 2017
@@ -20,6 +20,7 @@
rtl/RtlMemory.c
rtl/RtlRegistry.c
rtl/RtlSplayTree.c
+ rtl/RtlStack.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] Sat May 6 15:29:56 2017
@@ -21,6 +21,7 @@
KMT_TESTFUNC Test_RtlMemory;
KMT_TESTFUNC Test_RtlRegistry;
KMT_TESTFUNC Test_RtlSplayTree;
+KMT_TESTFUNC Test_RtlStack;
KMT_TESTFUNC Test_RtlUnicodeString;
KMT_TESTFUNC Test_TcpIpIoctl;
KMT_TESTFUNC Test_TcpIpTdi;
@@ -43,6 +44,7 @@
{ "RtlMemory", Test_RtlMemory },
{ "RtlRegistry", Test_RtlRegistry },
{ "RtlSplayTree", Test_RtlSplayTree },
+ { "RtlStack", Test_RtlStack },
{ "RtlUnicodeString", Test_RtlUnicodeString },
{ "TcpIpTdi", Test_TcpIpTdi },
{ "TcpIpConnect", Test_TcpIpConnect },
Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testli…
==============================================================================
--- trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] Sat May 6 15:29:56 2017
@@ -70,6 +70,7 @@
KMT_TESTFUNC Test_RtlMemory;
KMT_TESTFUNC Test_RtlRegistry;
KMT_TESTFUNC Test_RtlSplayTree;
+KMT_TESTFUNC Test_RtlStack;
KMT_TESTFUNC Test_RtlUnicodeString;
KMT_TESTFUNC Test_ZwAllocateVirtualMemory;
KMT_TESTFUNC Test_ZwCreateSection;
@@ -139,6 +140,7 @@
{ "RtlMemoryKM", Test_RtlMemory },
{ "RtlRegistryKM", Test_RtlRegistry },
{ "RtlSplayTreeKM", Test_RtlSplayTree },
+ { "RtlStackKM", Test_RtlStack },
{ "RtlUnicodeStringKM", Test_RtlUnicodeString },
{ "SeInheritance", Test_SeInheritance },
{ "SeQueryInfoToken", Test_SeQueryInfoToken },
Added: trunk/rostests/kmtests/rtl/RtlStack.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/rtl/RtlStack.c?re…
==============================================================================
--- trunk/rostests/kmtests/rtl/RtlStack.c (added)
+++ trunk/rostests/kmtests/rtl/RtlStack.c [iso-8859-1] Sat May 6 15:29:56 2017
@@ -0,0 +1,136 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Kernel-Mode Test Suite Runtime library stack trace test
+ * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ */
+
+#define KMT_EMULATE_KERNEL
+#include <kmt_test.h>
+
+static PVOID ReturnAddresses[4];
+
+static
+VOID
+TestStackWalk3(VOID);
+
+DECLSPEC_NOINLINE
+static
+VOID
+TestStackWalk4(VOID)
+{
+ PVOID Frames[5];
+ ULONG Ret;
+ ULONG Hash;
+ ULONG ExpectedHash;
+ ULONG i;
+ const ULONG FunctionSizeGuess = 0x1000;
+
+ ReturnAddresses[3] = _ReturnAddress();
+
+ Ret = RtlWalkFrameChain(NULL, 5, 0);
+ ok_eq_ulong(Ret, 0);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Ret = RtlWalkFrameChain(Frames, 0, 0);
+ ok_eq_ulong(Ret, 0);
+ ok_eq_pointer(Frames[0], (PVOID)(ULONG_PTR)0x5555555555555555);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Ret = RtlWalkFrameChain(Frames, 5, 0);
+ ok_eq_ulong(Ret, 5);
+ ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function
is %p\n", Frames[0], TestStackWalk4);
+ ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess,
"Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
+ ok_eq_pointer(Frames[1], ReturnAddresses[3]);
+ ok_eq_pointer(Frames[2], ReturnAddresses[2]);
+ ok_eq_pointer(Frames[3], ReturnAddresses[1]);
+ ok_eq_pointer(Frames[4], ReturnAddresses[0]);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Ret = RtlWalkFrameChain(Frames, 4, 0);
+ ok_eq_ulong(Ret, 4);
+ ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function
is %p\n", Frames[0], TestStackWalk4);
+ ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess,
"Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
+ ok_eq_pointer(Frames[1], ReturnAddresses[3]);
+ ok_eq_pointer(Frames[2], ReturnAddresses[2]);
+ ok_eq_pointer(Frames[3], ReturnAddresses[1]);
+ ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555);
+
+ KmtStartSeh()
+ RtlCaptureStackBackTrace(0, 5, NULL, NULL);
+ KmtEndSeh(STATUS_ACCESS_VIOLATION);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Hash = 0x55555555;
+ Ret = RtlCaptureStackBackTrace(0, 0, Frames, &Hash);
+ ok_eq_ulong(Ret, 0);
+ ok_eq_hex(Hash, 0x55555555);
+ ok_eq_pointer(Frames[0], (PVOID)(ULONG_PTR)0x5555555555555555);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Hash = 0x55555555;
+ Ret = RtlCaptureStackBackTrace(0, 1, Frames, NULL);
+ ok_eq_ulong(Ret, 1);
+ ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function
is %p\n", Frames[0], TestStackWalk4);
+ ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess,
"Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
+ ok_eq_pointer(Frames[1], (PVOID)(ULONG_PTR)0x5555555555555555);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Ret = RtlCaptureStackBackTrace(0, 5, Frames, &Hash);
+ ok_eq_ulong(Ret, 5);
+ ExpectedHash = 0;
+ for (i = 0; i < 5; i++)
+ ExpectedHash += (ULONG)(ULONG_PTR)Frames[i];
+ ok_eq_hex(Hash, ExpectedHash);
+ ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function
is %p\n", Frames[0], TestStackWalk4);
+ ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess,
"Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
+ ok_eq_pointer(Frames[1], ReturnAddresses[3]);
+ ok_eq_pointer(Frames[2], ReturnAddresses[2]);
+ ok_eq_pointer(Frames[3], ReturnAddresses[1]);
+ ok_eq_pointer(Frames[4], ReturnAddresses[0]);
+
+ RtlFillMemory(Frames, sizeof(Frames), 0x55);
+ Ret = RtlCaptureStackBackTrace(1, 4, Frames, &Hash);
+ ok_eq_ulong(Ret, 4);
+ ExpectedHash = 0;
+ for (i = 0; i < 4; i++)
+ ExpectedHash += (ULONG)(ULONG_PTR)Frames[i];
+ ok_eq_hex(Hash, ExpectedHash);
+ ok_eq_pointer(Frames[0], ReturnAddresses[3]);
+ ok_eq_pointer(Frames[1], ReturnAddresses[2]);
+ ok_eq_pointer(Frames[2], ReturnAddresses[1]);
+ ok_eq_pointer(Frames[3], ReturnAddresses[0]);
+ ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555);
+}
+
+DECLSPEC_NOINLINE
+static
+VOID
+TestStackWalk3(VOID)
+{
+ ReturnAddresses[2] = _ReturnAddress();
+ TestStackWalk4();
+}
+
+DECLSPEC_NOINLINE
+static
+VOID
+TestStackWalk2(VOID)
+{
+ ReturnAddresses[1] = _ReturnAddress();
+ TestStackWalk3();
+}
+
+DECLSPEC_NOINLINE
+static
+VOID
+TestStackWalk1(VOID)
+{
+ ReturnAddresses[0] = _ReturnAddress();
+ TestStackWalk2();
+}
+
+START_TEST(RtlStack)
+{
+ TestStackWalk1();
+}
Propchange: trunk/rostests/kmtests/rtl/RtlStack.c
------------------------------------------------------------------------------
svn:eol-style = native