OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/chrome_test_launcher.h" | 5 #include "chrome/test/base/chrome_test_launcher.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/leak_annotations.h" | 11 #include "base/debug/leak_annotations.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/process/process_metrics.h" | 17 #include "base/process/process_metrics.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/strings/string16.h" | |
20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
21 #include "base/test/test_file_util.h" | 20 #include "base/test/test_file_util.h" |
22 #include "build/build_config.h" | 21 #include "build/build_config.h" |
23 #include "chrome/app/chrome_main_delegate.h" | 22 #include "chrome/app/chrome_main_delegate.h" |
24 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/install_static/test/scoped_install_details.h" | 25 #include "chrome/install_static/test/scoped_install_details.h" |
27 #include "chrome/test/base/chrome_test_suite.h" | 26 #include "chrome/test/base/chrome_test_suite.h" |
28 #include "components/crash/content/app/crashpad.h" | 27 #include "components/crash/content/app/crashpad.h" |
29 #include "content/public/app/content_main.h" | 28 #include "content/public/app/content_main.h" |
(...skipping 16 matching lines...) Expand all Loading... |
46 | 45 |
47 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
48 #include "ash/test/ui_controls_factory_ash.h" | 47 #include "ash/test/ui_controls_factory_ash.h" |
49 #endif | 48 #endif |
50 | 49 |
51 #if defined(OS_LINUX) || defined(OS_ANDROID) | 50 #if defined(OS_LINUX) || defined(OS_ANDROID) |
52 #include "chrome/app/chrome_crash_reporter_client.h" | 51 #include "chrome/app/chrome_crash_reporter_client.h" |
53 #endif | 52 #endif |
54 | 53 |
55 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
56 #include <shellapi.h> | |
57 #include "base/win/registry.h" | 55 #include "base/win/registry.h" |
58 #include "chrome/app/chrome_crash_reporter_client_win.h" | 56 #include "chrome/app/chrome_crash_reporter_client_win.h" |
59 #include "chrome/install_static/install_util.h" | 57 #include "chrome/install_static/install_util.h" |
60 #endif | 58 #endif |
61 | 59 |
62 ChromeTestSuiteRunner::ChromeTestSuiteRunner() {} | 60 ChromeTestSuiteRunner::ChromeTestSuiteRunner() {} |
63 ChromeTestSuiteRunner::~ChromeTestSuiteRunner() {} | 61 ChromeTestSuiteRunner::~ChromeTestSuiteRunner() {} |
64 | 62 |
65 int ChromeTestSuiteRunner::RunTestSuite(int argc, char** argv) { | 63 int ChromeTestSuiteRunner::RunTestSuite(int argc, char** argv) { |
66 return ChromeTestSuite(argc, argv).Run(); | 64 return ChromeTestSuite(argc, argv).Run(); |
(...skipping 28 matching lines...) Expand all Loading... |
95 return true; | 93 return true; |
96 } | 94 } |
97 | 95 |
98 content::ContentMainDelegate* | 96 content::ContentMainDelegate* |
99 ChromeTestLauncherDelegate::CreateContentMainDelegate() { | 97 ChromeTestLauncherDelegate::CreateContentMainDelegate() { |
100 return new ChromeMainDelegate(); | 98 return new ChromeMainDelegate(); |
101 } | 99 } |
102 | 100 |
103 void ChromeTestLauncherDelegate::PreSharding() { | 101 void ChromeTestLauncherDelegate::PreSharding() { |
104 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
105 // Construct the distribution specific equivalent of | 103 // Pre-test cleanup for registry state keyed off the profile dir (which can |
106 // "delete HKCU\\SOFTWARE\\Chromium\\PreferenceMACs /f". | 104 // proliferate with the use of uniquely named scoped_dirs): |
107 base::string16 operation(L"delete HKCU\\"); | 105 // https://crbug.com/721245. This needs to be here in order not to be racy |
108 operation.append(install_static::GetRegistryPath()); | 106 // with any tests that will access that state. |
109 operation.append(L"\\PreferenceMACs /f"); | 107 base::win::RegKey distrubution_key; |
110 // TODO(gab): This is a nuclear option while the cleanup below doesn't work as | 108 LONG result = distrubution_key.Open(HKEY_CURRENT_USER, |
111 // the bots are in such bad shape per https://crbug.com/721245 that doing any | 109 install_static::GetRegistryPath().c_str(), |
112 // registry operations from C++ results in fatal error 1450 (insufficient | 110 KEY_SET_VALUE); |
113 // resources). Hopefully ShellExecute works... | |
114 ::ShellExecute(NULL, NULL, L"reg.exe", operation.c_str(), NULL, 0); | |
115 | 111 |
116 // // Pre-test cleanup for registry state keyed off the profile dir (which can | 112 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { |
117 // // proliferate with the use of uniquely named scoped_dirs): | 113 LOG(ERROR) << "Failed to open distribution key for cleanup: " << result; |
118 // // https://crbug.com/721245. This needs to be here in order not to be racy | 114 return; |
119 // // with any tests that will access that state. | 115 } |
120 // base::win::RegKey distrubution_key; | |
121 // LONG result = distrubution_key.Open( | |
122 // HKEY_CURRENT_USER, install_static::GetRegistryPath().c_str(), | |
123 // KEY_SET_VALUE); | |
124 | 116 |
125 // if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { | 117 result = distrubution_key.DeleteKey(L"PreferenceMACs"); |
126 // LOG(ERROR) << "Failed to open distribution key for cleanup: " << result; | |
127 // return; | |
128 // } | |
129 | 118 |
130 // result = distrubution_key.DeleteKey(L"PreferenceMACs"); | 119 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { |
131 | 120 LOG(ERROR) << "Failed to cleanup PreferenceMACs: " << result; |
132 // if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { | 121 return; |
133 // LOG(ERROR) << "Failed to cleanup PreferenceMACs: " << result; | 122 } |
134 // return; | |
135 // } | |
136 #endif | 123 #endif |
137 } | 124 } |
138 | 125 |
139 int LaunchChromeTests(int default_jobs, | 126 int LaunchChromeTests(int default_jobs, |
140 content::TestLauncherDelegate* delegate, | 127 content::TestLauncherDelegate* delegate, |
141 int argc, | 128 int argc, |
142 char** argv) { | 129 char** argv) { |
143 #if defined(OS_MACOSX) | 130 #if defined(OS_MACOSX) |
144 chrome_browser_application_mac::RegisterBrowserCrApp(); | 131 chrome_browser_application_mac::RegisterBrowserCrApp(); |
145 #endif | 132 #endif |
146 | 133 |
147 #if defined(OS_WIN) | 134 #if defined(OS_WIN) |
148 // Create a primordial InstallDetails instance for the test. | 135 // Create a primordial InstallDetails instance for the test. |
149 install_static::ScopedInstallDetails install_details; | 136 install_static::ScopedInstallDetails install_details; |
150 #endif | 137 #endif |
151 | 138 |
152 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN) | 139 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN) |
153 // We leak this pointer intentionally. The crash client needs to outlive | 140 // We leak this pointer intentionally. The crash client needs to outlive |
154 // all other code. | 141 // all other code. |
155 ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient(); | 142 ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient(); |
156 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); | 143 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); |
157 crash_reporter::SetCrashReporterClient(crash_client); | 144 crash_reporter::SetCrashReporterClient(crash_client); |
158 #endif | 145 #endif |
159 | 146 |
160 return content::LaunchTests(delegate, default_jobs, argc, argv); | 147 return content::LaunchTests(delegate, default_jobs, argc, argv); |
161 } | 148 } |
OLD | NEW |