Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/test/browser_test_base.h" | 5 #include "content/public/test/browser_test_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 #if defined(OS_POSIX) | 64 #if defined(OS_POSIX) |
| 65 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 65 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 66 // debugging easier) and also exit with a known error code (so that the test | 66 // debugging easier) and also exit with a known error code (so that the test |
| 67 // framework considers this a failure -- http://crbug.com/57578). | 67 // framework considers this a failure -- http://crbug.com/57578). |
| 68 // Note: We only want to do this in the browser process, and not forked | 68 // Note: We only want to do this in the browser process, and not forked |
| 69 // processes. That might lead to hangs because of locks inside tcmalloc or the | 69 // processes. That might lead to hangs because of locks inside tcmalloc or the |
| 70 // OS. See http://crbug.com/141302. | 70 // OS. See http://crbug.com/141302. |
| 71 static int g_browser_process_pid; | 71 static int g_browser_process_pid; |
| 72 static void DumpStackTraceSignalHandler(int signal) { | 72 static void DumpStackTraceSignalHandler(int signal) { |
| 73 if (g_browser_process_pid == base::GetCurrentProcId()) { | 73 if (g_browser_process_pid == base::GetCurrentProcId()) { |
| 74 logging::RawLog(logging::LOG_ERROR, | 74 std::string message("BrowserTestBase received signal: "); |
| 75 "BrowserTestBase signal handler received SIGTERM. " | 75 message += strsignal(signal); |
| 76 "Backtrace:\n"); | 76 message += ". Backtrace:\n"; |
| 77 logging::RawLog(logging::LOG_ERROR, message.c_str()); | |
| 77 base::debug::StackTrace().Print(); | 78 base::debug::StackTrace().Print(); |
| 78 } | 79 } |
| 79 _exit(128 + signal); | 80 _exit(128 + signal); |
| 80 } | 81 } |
| 81 #endif // defined(OS_POSIX) | 82 #endif // defined(OS_POSIX) |
| 82 | 83 |
| 83 void RunTaskOnRendererThread(const base::Closure& task, | 84 void RunTaskOnRendererThread(const base::Closure& task, |
| 84 const base::Closure& quit_task) { | 85 const base::Closure& quit_task) { |
| 85 task.Run(); | 86 task.Run(); |
| 86 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); | 87 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 } | 311 } |
| 311 | 312 |
| 312 void BrowserTestBase::TearDown() { | 313 void BrowserTestBase::TearDown() { |
| 313 } | 314 } |
| 314 | 315 |
| 315 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { | 316 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { |
| 316 #if defined(OS_POSIX) | 317 #if defined(OS_POSIX) |
| 317 if (handle_sigterm_) { | 318 if (handle_sigterm_) { |
| 318 g_browser_process_pid = base::GetCurrentProcId(); | 319 g_browser_process_pid = base::GetCurrentProcId(); |
| 319 signal(SIGTERM, DumpStackTraceSignalHandler); | 320 signal(SIGTERM, DumpStackTraceSignalHandler); |
| 321 signal(SIGSEGV, DumpStackTraceSignalHandler); | |
|
Paweł Hajdan Jr.
2016/08/17 06:34:09
Could you just move this and g_browser_process_pid
michaelpg
2016/08/18 23:44:37
Done.
| |
| 320 } | 322 } |
| 321 #endif // defined(OS_POSIX) | 323 #endif // defined(OS_POSIX) |
| 322 | 324 |
| 323 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 325 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 324 switches::kEnableTracing)) { | 326 switches::kEnableTracing)) { |
| 325 base::trace_event::TraceConfig trace_config( | 327 base::trace_event::TraceConfig trace_config( |
| 326 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 328 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 327 switches::kEnableTracing), | 329 switches::kEnableTracing), |
| 328 base::trace_event::RECORD_CONTINUOUSLY); | 330 base::trace_event::RECORD_CONTINUOUSLY); |
| 329 TracingController::GetInstance()->StartTracing( | 331 TracingController::GetInstance()->StartTracing( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 use_software_compositing_ = true; | 388 use_software_compositing_ = true; |
| 387 } | 389 } |
| 388 | 390 |
| 389 bool BrowserTestBase::UsingOSMesa() const { | 391 bool BrowserTestBase::UsingOSMesa() const { |
| 390 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 392 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 391 return cmd->GetSwitchValueASCII(switches::kUseGL) == | 393 return cmd->GetSwitchValueASCII(switches::kUseGL) == |
| 392 gl::kGLImplementationOSMesaName; | 394 gl::kGLImplementationOSMesaName; |
| 393 } | 395 } |
| 394 | 396 |
| 395 } // namespace content | 397 } // namespace content |
| OLD | NEW |