diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 23:53:53 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 23:53:53 +0000 |
commit | 0fe31f2ba217cceb277b670e2812667c3aee8e80 (patch) | |
tree | 3d2adea86b5d61d297318ea60c3faf1b1636c996 /base/test_suite.h | |
parent | 2f66ed584522a2383f0f7193b264b3da7928eb82 (diff) | |
download | chromium_src-0fe31f2ba217cceb277b670e2812667c3aee8e80.zip chromium_src-0fe31f2ba217cceb277b670e2812667c3aee8e80.tar.gz chromium_src-0fe31f2ba217cceb277b670e2812667c3aee8e80.tar.bz2 |
Print stack trace on exception in unit tests on Windows.
Also remove std::vector<> from StackTrace to reduce heap usage during potential unstable execution.
TEST=none
BUG=http://crbug.com/20996
Review URL: http://codereview.chromium.org/201050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test_suite.h')
-rw-r--r-- | base/test_suite.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/base/test_suite.h b/base/test_suite.h index e616b80..4a90a23 100644 --- a/base/test_suite.h +++ b/base/test_suite.h @@ -40,7 +40,22 @@ static void TestSuiteCrashHandler(int signal) { StackTrace().PrintBacktrace(); _exit(1); } -#endif +#endif // OS_POSIX + +#if defined(OS_WIN) +// Previous unhandled filter. Will be called if not NULL when we intercept an +// exception. +__declspec(selectany) LPTOP_LEVEL_EXCEPTION_FILTER g_previous_filter = NULL; + +// Prints the exception call stack. +// This is the unit tests exception filter. +inline long WINAPI UnitTestExceptionFilter(EXCEPTION_POINTERS* info) { + StackTrace(info).PrintBacktrace(); + if (g_previous_filter) + return g_previous_filter(info); + return EXCEPTION_EXECUTE_HANDLER; +} +#endif // OS_WIN class TestSuite { public: @@ -155,6 +170,9 @@ class TestSuite { // As a hack workaround, just #ifdef out this code for Purify builds. logging::SetLogAssertHandler(UnitTestAssertHandler); #endif // !defined(PURIFY) + // Add stack dumping support on exception on windows. Similar to OS_POSIX + // signal() handling above. + g_previous_filter = SetUnhandledExceptionFilter(&UnitTestExceptionFilter); } #endif // defined(OS_WIN) |