summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 18:11:02 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 18:11:02 +0000
commit70b7447f624d02d4a62e6bc1a9ab9e105cd2be85 (patch)
treeb062ddd295ee3a67671403b060dcf164eabdf270 /base
parentc2e74fe834afaeed3bf8d21034bb995437518843 (diff)
downloadchromium_src-70b7447f624d02d4a62e6bc1a9ab9e105cd2be85.zip
chromium_src-70b7447f624d02d4a62e6bc1a9ab9e105cd2be85.tar.gz
chromium_src-70b7447f624d02d4a62e6bc1a9ab9e105cd2be85.tar.bz2
Print a backtrace when a test binary crashes.
For now only for POSIX, Windows to follow very soon. TEST=none http://crbug.com/20996 Review URL: http://codereview.chromium.org/200004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25330 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/test_suite.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/base/test_suite.h b/base/test_suite.h
index 236c3ed..e616b80 100644
--- a/base/test_suite.h
+++ b/base/test_suite.h
@@ -13,6 +13,7 @@
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/debug_on_start.h"
+#include "base/debug_util.h"
#include "base/file_path.h"
#include "base/icu_util.h"
#include "base/logging.h"
@@ -34,6 +35,13 @@
#include <gtk/gtk.h>
#endif
+#if defined(OS_POSIX)
+static void TestSuiteCrashHandler(int signal) {
+ StackTrace().PrintBacktrace();
+ _exit(1);
+}
+#endif
+
class TestSuite {
public:
TestSuite(int argc, char** argv) {
@@ -124,6 +132,12 @@ class TestSuite {
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
CHECK(sigaction(SIGPIPE, &action, NULL) == 0);
+
+ // TODO(phajdan.jr): Catch other crashy signals, like SIGABRT.
+ CHECK(signal(SIGSEGV, &TestSuiteCrashHandler) != SIG_ERR);
+ CHECK(signal(SIGILL, &TestSuiteCrashHandler) != SIG_ERR);
+ CHECK(signal(SIGBUS, &TestSuiteCrashHandler) != SIG_ERR);
+ CHECK(signal(SIGFPE, &TestSuiteCrashHandler) != SIG_ERR);
#endif // OS_POSIX
#if defined(OS_WIN)