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

Unified Diff: content/test/browser_test_base.cc

Issue 10836148: Don't print the callstack in forked browser test processes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify Created 8 years, 4 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 | « content/test/browser_test_base.h ('k') | content/test/content_browser_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/browser_test_base.cc
===================================================================
--- content/test/browser_test_base.cc (revision 150562)
+++ content/test/browser_test_base.cc (working copy)
@@ -6,6 +6,8 @@
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/debug/stack_trace.h"
+#include "base/process_util.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "sandbox/win/src/dep.h"
@@ -17,11 +19,34 @@
extern int BrowserMain(const content::MainFunctionParams&);
+namespace {
+
+#if defined(OS_POSIX)
+// On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
+// debugging easier) and also exit with a known error code (so that the test
+// framework considers this a failure -- http://crbug.com/57578).
+// Note: We only want to do this in the browser process, and not forked
+// processes. That might lead to hangs because of locks inside tcmalloc or the
+// OS. See http://crbug.com/141302.
+static int g_browser_process_pid;
+static void DumpStackTraceSignalHandler(int signal) {
+ if (g_browser_process_pid == base::GetCurrentProcId())
+ base::debug::StackTrace().PrintBacktrace();
+ _exit(128 + signal);
+}
+#endif // defined(OS_POSIX)
+
+} // namespace
+
BrowserTestBase::BrowserTestBase() {
#if defined(OS_MACOSX)
base::mac::SetOverrideAmIBundled(true);
base::SystemMonitor::AllocateSystemIOPorts();
#endif
+
+#if defined(OS_POSIX)
+ handle_sigterm_ = true;
+#endif
}
BrowserTestBase::~BrowserTestBase() {
@@ -49,6 +74,12 @@
}
void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
+#if defined(OS_POSIX)
+ if (handle_sigterm_) {
+ g_browser_process_pid = base::GetCurrentProcId();
+ signal(SIGTERM, DumpStackTraceSignalHandler);
+ }
+#endif // defined(OS_POSIX)
RunTestOnMainThreadLoop();
}
« no previous file with comments | « content/test/browser_test_base.h ('k') | content/test/content_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698