Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Unified Diff: base/test_suite.h

Issue 200004: Print a backtrace when a test binary crashes. (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test_suite.h
diff --git a/base/test_suite.h b/base/test_suite.h
index 236c3edcbc98ac223e2dd72ebe6ad2da8a20ba5d..80f11009e344137339c554b14a97fdd3c3976841 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();
agl 2009/09/03 17:36:33 Note that, if the crash happens at certain points,
+ _exit(1);
+}
+#endif
+
class TestSuite {
public:
TestSuite(int argc, char** argv) {
@@ -124,6 +132,11 @@ 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);
agl 2009/09/03 17:36:33 SIGFPE is probably good too.
#endif // OS_POSIX
#if defined(OS_WIN)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698