Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/test/base/chrome_test_launcher.cc

Issue 2897483003: Attempt #3 at registry outage: ShellExecute reg delete (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "base/test/test_file_util.h" 21 #include "base/test/test_file_util.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "chrome/app/chrome_main_delegate.h" 23 #include "chrome/app/chrome_main_delegate.h"
23 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/install_static/test/scoped_install_details.h" 26 #include "chrome/install_static/test/scoped_install_details.h"
26 #include "chrome/test/base/chrome_test_suite.h" 27 #include "chrome/test/base/chrome_test_suite.h"
27 #include "components/crash/content/app/crashpad.h" 28 #include "components/crash/content/app/crashpad.h"
28 #include "content/public/app/content_main.h" 29 #include "content/public/app/content_main.h"
(...skipping 16 matching lines...) Expand all
45 46
46 #if defined(OS_CHROMEOS) 47 #if defined(OS_CHROMEOS)
47 #include "ash/test/ui_controls_factory_ash.h" 48 #include "ash/test/ui_controls_factory_ash.h"
48 #endif 49 #endif
49 50
50 #if defined(OS_LINUX) || defined(OS_ANDROID) 51 #if defined(OS_LINUX) || defined(OS_ANDROID)
51 #include "chrome/app/chrome_crash_reporter_client.h" 52 #include "chrome/app/chrome_crash_reporter_client.h"
52 #endif 53 #endif
53 54
54 #if defined(OS_WIN) 55 #if defined(OS_WIN)
56 #include <shellapi.h>
55 #include "base/win/registry.h" 57 #include "base/win/registry.h"
56 #include "chrome/app/chrome_crash_reporter_client_win.h" 58 #include "chrome/app/chrome_crash_reporter_client_win.h"
57 #include "chrome/install_static/install_util.h" 59 #include "chrome/install_static/install_util.h"
58 #endif 60 #endif
59 61
60 ChromeTestSuiteRunner::ChromeTestSuiteRunner() {} 62 ChromeTestSuiteRunner::ChromeTestSuiteRunner() {}
61 ChromeTestSuiteRunner::~ChromeTestSuiteRunner() {} 63 ChromeTestSuiteRunner::~ChromeTestSuiteRunner() {}
62 64
63 int ChromeTestSuiteRunner::RunTestSuite(int argc, char** argv) { 65 int ChromeTestSuiteRunner::RunTestSuite(int argc, char** argv) {
64 return ChromeTestSuite(argc, argv).Run(); 66 return ChromeTestSuite(argc, argv).Run();
(...skipping 28 matching lines...) Expand all
93 return true; 95 return true;
94 } 96 }
95 97
96 content::ContentMainDelegate* 98 content::ContentMainDelegate*
97 ChromeTestLauncherDelegate::CreateContentMainDelegate() { 99 ChromeTestLauncherDelegate::CreateContentMainDelegate() {
98 return new ChromeMainDelegate(); 100 return new ChromeMainDelegate();
99 } 101 }
100 102
101 void ChromeTestLauncherDelegate::PreSharding() { 103 void ChromeTestLauncherDelegate::PreSharding() {
102 #if defined(OS_WIN) 104 #if defined(OS_WIN)
103 // Pre-test cleanup for registry state keyed off the profile dir (which can 105 // Construct the distribution specific equivalent of
104 // proliferate with the use of uniquely named scoped_dirs): 106 // "delete HKCU\\SOFTWARE\\Chromium\\PreferenceMACs /f".
105 // https://crbug.com/721245. This needs to be here in order not to be racy 107 base::string16 operation(L"delete HKCU\\");
106 // with any tests that will access that state. 108 operation.append(install_static::GetRegistryPath());
107 base::win::RegKey distrubution_key; 109 operation.append(L"\\PreferenceMACs /f");
108 LONG result = distrubution_key.Open(HKEY_CURRENT_USER, 110 // TODO(gab): This is a nuclear option while the cleanup below doesn't work as
109 install_static::GetRegistryPath().c_str(), 111 // the bots are in such bad shape per https://crbug.com/721245 that doing any
110 KEY_SET_VALUE); 112 // registry operations from C++ results in fatal error 1450 (insufficient
113 // resources). Hopefully ShellExecute works...
114 ::ShellExecute(NULL, NULL, L"reg.exe", operation.c_str(), NULL, 0);
111 115
112 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { 116 // // Pre-test cleanup for registry state keyed off the profile dir (which can
113 LOG(ERROR) << "Failed to open distribution key for cleanup: " << result; 117 // // proliferate with the use of uniquely named scoped_dirs):
114 return; 118 // // https://crbug.com/721245. This needs to be here in order not to be racy
115 } 119 // // with any tests that will access that state.
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);
116 124
117 result = distrubution_key.DeleteKey(L"PreferenceMACs"); 125 // if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
126 // LOG(ERROR) << "Failed to open distribution key for cleanup: " << result;
127 // return;
128 // }
118 129
119 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { 130 // result = distrubution_key.DeleteKey(L"PreferenceMACs");
120 LOG(ERROR) << "Failed to cleanup PreferenceMACs: " << result; 131
121 return; 132 // if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
122 } 133 // LOG(ERROR) << "Failed to cleanup PreferenceMACs: " << result;
134 // return;
135 // }
123 #endif 136 #endif
124 } 137 }
125 138
126 int LaunchChromeTests(int default_jobs, 139 int LaunchChromeTests(int default_jobs,
127 content::TestLauncherDelegate* delegate, 140 content::TestLauncherDelegate* delegate,
128 int argc, 141 int argc,
129 char** argv) { 142 char** argv) {
130 #if defined(OS_MACOSX) 143 #if defined(OS_MACOSX)
131 chrome_browser_application_mac::RegisterBrowserCrApp(); 144 chrome_browser_application_mac::RegisterBrowserCrApp();
132 #endif 145 #endif
133 146
134 #if defined(OS_WIN) 147 #if defined(OS_WIN)
135 // Create a primordial InstallDetails instance for the test. 148 // Create a primordial InstallDetails instance for the test.
136 install_static::ScopedInstallDetails install_details; 149 install_static::ScopedInstallDetails install_details;
137 #endif 150 #endif
138 151
139 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN) 152 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN)
140 // We leak this pointer intentionally. The crash client needs to outlive 153 // We leak this pointer intentionally. The crash client needs to outlive
141 // all other code. 154 // all other code.
142 ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient(); 155 ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient();
143 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); 156 ANNOTATE_LEAKING_OBJECT_PTR(crash_client);
144 crash_reporter::SetCrashReporterClient(crash_client); 157 crash_reporter::SetCrashReporterClient(crash_client);
145 #endif 158 #endif
146 159
147 return content::LaunchTests(delegate, default_jobs, argc, argv); 160 return content::LaunchTests(delegate, default_jobs, argc, argv);
148 } 161 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698