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 namespace { | 19 namespace { |
20 | 20 |
21 #if defined(OS_POSIX) | 21 #if defined(OS_POSIX) |
22 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 22 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
23 // debugging easier) and also exit with a known error code (so that the test | 23 // debugging easier) and also exit with a known error code (so that the test |
24 // framework considers this a failure -- http://crbug.com/57578). | 24 // framework considers this a failure -- http://crbug.com/57578). |
25 // Note: We only want to do this in the browser process, and not forked | 25 // Note: We only want to do this in the browser process, and not forked |
26 // processes. That might lead to hangs because of locks inside tcmalloc or the | 26 // processes. That might lead to hangs because of locks inside tcmalloc or the |
27 // OS. See http://crbug.com/141302. | 27 // OS. See http://crbug.com/141302. |
28 static int g_browser_process_pid; | 28 static int g_browser_process_pid; |
29 static void DumpStackTraceSignalHandler(int signal) { | 29 static void DumpStackTraceSignalHandler(int signal) { |
30 if (g_browser_process_pid == base::GetCurrentProcId()) | 30 if (g_browser_process_pid == base::GetCurrentProcId()) |
31 base::debug::StackTrace().PrintBacktrace(); | 31 base::debug::StackTrace().PrintBacktrace(); |
32 _exit(128 + signal); | 32 _exit(128 + signal); |
33 } | 33 } |
34 #endif // defined(OS_POSIX) | 34 #endif // defined(OS_POSIX) |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 namespace content { | 38 namespace content { |
39 | 39 |
40 extern int BrowserMain(const content::MainFunctionParams&); | 40 extern int BrowserMain(const content::MainFunctionParams&); |
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 FilePath& test_server_base) { | 87 void BrowserTestBase::CreateTestServer(const FilePath& 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 test_server_base)); | 92 test_server_base)); |
93 } | 93 } |
94 | 94 |
95 } // namespace content | 95 } // namespace content |
OLD | NEW |