| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/common/main_function_params.h" | 12 #include "content/public/common/main_function_params.h" |
| 13 | 13 |
| 14 #if defined(OS_MACOSX) | 14 #if defined(OS_MACOSX) |
| 15 #include "base/mac/mac_util.h" | 15 #include "base/mac/mac_util.h" |
| 16 #include "base/system_monitor/system_monitor.h" | 16 #include "base/power_monitor/power_monitor.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 extern int BrowserMain(const content::MainFunctionParams&); | 19 extern int BrowserMain(const content::MainFunctionParams&); |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 #if defined(OS_POSIX) | 23 #if defined(OS_POSIX) |
| 24 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 24 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 25 // debugging easier) and also exit with a known error code (so that the test | 25 // debugging easier) and also exit with a known error code (so that the test |
| 26 // framework considers this a failure -- http://crbug.com/57578). | 26 // framework considers this a failure -- http://crbug.com/57578). |
| 27 // Note: We only want to do this in the browser process, and not forked | 27 // Note: We only want to do this in the browser process, and not forked |
| 28 // processes. That might lead to hangs because of locks inside tcmalloc or the | 28 // processes. That might lead to hangs because of locks inside tcmalloc or the |
| 29 // OS. See http://crbug.com/141302. | 29 // OS. See http://crbug.com/141302. |
| 30 static int g_browser_process_pid; | 30 static int g_browser_process_pid; |
| 31 static void DumpStackTraceSignalHandler(int signal) { | 31 static void DumpStackTraceSignalHandler(int signal) { |
| 32 if (g_browser_process_pid == base::GetCurrentProcId()) | 32 if (g_browser_process_pid == base::GetCurrentProcId()) |
| 33 base::debug::StackTrace().PrintBacktrace(); | 33 base::debug::StackTrace().PrintBacktrace(); |
| 34 _exit(128 + signal); | 34 _exit(128 + signal); |
| 35 } | 35 } |
| 36 #endif // defined(OS_POSIX) | 36 #endif // defined(OS_POSIX) |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 namespace content { | 40 namespace content { |
| 41 | 41 |
| 42 BrowserTestBase::BrowserTestBase() { | 42 BrowserTestBase::BrowserTestBase() { |
| 43 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
| 44 base::mac::SetOverrideAmIBundled(true); | 44 base::mac::SetOverrideAmIBundled(true); |
| 45 base::SystemMonitor::AllocateSystemIOPorts(); | 45 base::PowerMonitor::AllocateSystemIOPorts(); |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if defined(OS_POSIX) | 48 #if defined(OS_POSIX) |
| 49 handle_sigterm_ = true; | 49 handle_sigterm_ = true; |
| 50 #endif | 50 #endif |
| 51 } | 51 } |
| 52 | 52 |
| 53 BrowserTestBase::~BrowserTestBase() { | 53 BrowserTestBase::~BrowserTestBase() { |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 | 86 |
| 87 void BrowserTestBase::CreateTestServer(const char* test_server_base) { | 87 void BrowserTestBase::CreateTestServer(const char* test_server_base) { |
| 88 CHECK(!test_server_.get()); | 88 CHECK(!test_server_.get()); |
| 89 test_server_.reset(new net::TestServer( | 89 test_server_.reset(new net::TestServer( |
| 90 net::TestServer::TYPE_HTTP, | 90 net::TestServer::TYPE_HTTP, |
| 91 net::TestServer::kLocalhost, | 91 net::TestServer::kLocalhost, |
| 92 FilePath().AppendASCII(test_server_base))); | 92 FilePath().AppendASCII(test_server_base))); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace content | 95 } // namespace content |
| OLD | NEW |