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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "ui/aura/test/event_generator_delegate_aura.h" // nogncheck | 55 #include "ui/aura/test/event_generator_delegate_aura.h" // nogncheck |
56 #if defined(USE_X11) | 56 #if defined(USE_X11) |
57 #include "ui/aura/window_tree_host_x11.h" // nogncheck | 57 #include "ui/aura/window_tree_host_x11.h" // nogncheck |
58 #endif | 58 #endif |
59 #endif | 59 #endif |
60 | 60 |
61 namespace content { | 61 namespace content { |
62 namespace { | 62 namespace { |
63 | 63 |
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 SIGSEGV or SIGTERM (sent by the runner on timeouts), dump a stack trace |
66 // debugging easier) and also exit with a known error code (so that the test | 66 // (to make debugging easier) and also exit with a known error code (so that |
67 // framework considers this a failure -- http://crbug.com/57578). | 67 // the test 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 EXPECT_EQ(expected_exit_code_, ContentMain(*GetContentMainParams())); | 308 EXPECT_EQ(expected_exit_code_, ContentMain(*GetContentMainParams())); |
308 #endif | 309 #endif |
309 TearDownInProcessBrowserTestFixture(); | 310 TearDownInProcessBrowserTestFixture(); |
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 g_browser_process_pid = base::GetCurrentProcId(); |
318 g_browser_process_pid = base::GetCurrentProcId(); | 319 signal(SIGSEGV, DumpStackTraceSignalHandler); |
| 320 |
| 321 if (handle_sigterm_) |
319 signal(SIGTERM, DumpStackTraceSignalHandler); | 322 signal(SIGTERM, DumpStackTraceSignalHandler); |
320 } | |
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( |
330 trace_config, | 332 trace_config, |
(...skipping 55 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 |