Chromium Code Reviews| 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_suite.h" | 5 #include "chrome/test/base/chrome_test_suite.h" |
| 6 | 6 |
| 7 #if defined(OS_CHROMEOS) | |
| 8 #include <stdio.h> | |
| 9 #include <unistd.h> | |
| 10 #endif | |
| 11 | |
| 7 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 10 #include "base/metrics/stats_table.h" | 15 #include "base/metrics/stats_table.h" |
| 11 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 12 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 13 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 14 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_content_browser_client.h" | 21 #include "chrome/browser/chrome_content_browser_client.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 | 157 |
| 153 const char ChromeTestSuite::kLaunchAsBrowser[] = "as-browser"; | 158 const char ChromeTestSuite::kLaunchAsBrowser[] = "as-browser"; |
| 154 | 159 |
| 155 ChromeTestSuite::ChromeTestSuite(int argc, char** argv) | 160 ChromeTestSuite::ChromeTestSuite(int argc, char** argv) |
| 156 : content::ContentTestSuiteBase(argc, argv) { | 161 : content::ContentTestSuiteBase(argc, argv) { |
| 157 } | 162 } |
| 158 | 163 |
| 159 ChromeTestSuite::~ChromeTestSuite() { | 164 ChromeTestSuite::~ChromeTestSuite() { |
| 160 } | 165 } |
| 161 | 166 |
| 167 static bool IsCrosPythonProcess() { | |
|
jam
2012/07/24 15:32:19
nit: put static method in the annonymous namespace
glotov
2012/07/24 16:23:41
I'd leave it here: locality is more important for
jam
2012/07/24 16:27:55
it's chrome style to put static functions that are
glotov
2012/07/24 17:05:05
Done.
| |
| 168 #if defined(OS_CHROMEOS) | |
| 169 char buf[80]; | |
| 170 int num_read = readlink("/proc/self/exe", buf, sizeof(buf) - 1); | |
| 171 if (num_read == -1) | |
| 172 return false; | |
| 173 buf[num_read] = 0; | |
| 174 const char kPythonPrefix[] = "/python"; | |
| 175 return !strncmp(strrchr(buf, '/'), kPythonPrefix, sizeof(kPythonPrefix) - 1); | |
| 176 #endif // defined(OS_CHROMEOS) | |
| 177 return false; | |
| 178 } | |
| 179 | |
| 162 void ChromeTestSuite::Initialize() { | 180 void ChromeTestSuite::Initialize() { |
| 163 #if defined(OS_MACOSX) | 181 #if defined(OS_MACOSX) |
| 164 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 182 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 165 chrome_browser_application_mac::RegisterBrowserCrApp(); | 183 chrome_browser_application_mac::RegisterBrowserCrApp(); |
| 166 #endif | 184 #endif |
| 167 | 185 |
| 168 chrome::RegisterPathProvider(); | 186 chrome::RegisterPathProvider(); |
| 169 if (!browser_dir_.empty()) { | 187 if (!browser_dir_.empty()) { |
| 170 PathService::Override(base::DIR_EXE, browser_dir_); | 188 PathService::Override(base::DIR_EXE, browser_dir_); |
| 171 PathService::Override(base::DIR_MODULE, browser_dir_); | 189 PathService::Override(base::DIR_MODULE, browser_dir_); |
| 172 } | 190 } |
| 173 | 191 |
| 192 // Disable external libraries load if we are under python process in | |
| 193 // ChromeOS. That means we are autotest and, if ASAN is used, | |
| 194 // external libraries load crashes. | |
| 195 if (!IsCrosPythonProcess()) | |
| 196 content::ContentTestSuiteBase::DisableLoadingExternalLibraries(); | |
| 197 | |
| 174 // Initialize after overriding paths as some content paths depend on correct | 198 // Initialize after overriding paths as some content paths depend on correct |
| 175 // values for DIR_EXE and DIR_MODULE. | 199 // values for DIR_EXE and DIR_MODULE. |
| 176 content::ContentTestSuiteBase::Initialize(); | 200 content::ContentTestSuiteBase::Initialize(); |
| 177 | 201 |
| 178 #if defined(OS_MACOSX) | 202 #if defined(OS_MACOSX) |
| 179 // Look in the framework bundle for resources. | 203 // Look in the framework bundle for resources. |
| 180 FilePath path; | 204 FilePath path; |
| 181 PathService::Get(base::DIR_EXE, &path); | 205 PathService::Get(base::DIR_EXE, &path); |
| 182 path = path.Append(chrome::kFrameworkName); | 206 path = path.Append(chrome::kFrameworkName); |
| 183 base::mac::SetOverrideFrameworkBundlePath(path); | 207 base::mac::SetOverrideFrameworkBundlePath(path); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 214 #if defined(OS_MACOSX) | 238 #if defined(OS_MACOSX) |
| 215 base::mac::SetOverrideFrameworkBundle(NULL); | 239 base::mac::SetOverrideFrameworkBundle(NULL); |
| 216 #endif | 240 #endif |
| 217 | 241 |
| 218 base::StatsTable::set_current(NULL); | 242 base::StatsTable::set_current(NULL); |
| 219 stats_table_.reset(); | 243 stats_table_.reset(); |
| 220 RemoveSharedMemoryFile(stats_filename_); | 244 RemoveSharedMemoryFile(stats_filename_); |
| 221 | 245 |
| 222 base::TestSuite::Shutdown(); | 246 base::TestSuite::Shutdown(); |
| 223 } | 247 } |
| OLD | NEW |