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

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

Issue 10786038: Prevent loading libffmpegsumo.so to python (autotests) process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/public/test/content_test_suite_base.h » ('j') | 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_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 24 matching lines...) Expand all
41 46
42 void RemoveSharedMemoryFile(const std::string& filename) { 47 void RemoveSharedMemoryFile(const std::string& filename) {
43 // Stats uses SharedMemory under the hood. On posix, this results in a file 48 // Stats uses SharedMemory under the hood. On posix, this results in a file
44 // on disk. 49 // on disk.
45 #if defined(OS_POSIX) 50 #if defined(OS_POSIX)
46 base::SharedMemory memory; 51 base::SharedMemory memory;
47 memory.Delete(filename); 52 memory.Delete(filename);
48 #endif 53 #endif
49 } 54 }
50 55
56 bool IsCrosPythonProcess() {
57 #if defined(OS_CHROMEOS)
58 char buf[80];
59 int num_read = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
60 if (num_read == -1)
61 return false;
62 buf[num_read] = 0;
63 const char kPythonPrefix[] = "/python";
64 return !strncmp(strrchr(buf, '/'), kPythonPrefix, sizeof(kPythonPrefix) - 1);
65 #endif // defined(OS_CHROMEOS)
66 return false;
67 }
68
51 // In many cases it may be not obvious that a test makes a real DNS lookup. 69 // In many cases it may be not obvious that a test makes a real DNS lookup.
52 // We generally don't want to rely on external DNS servers for our tests, 70 // We generally don't want to rely on external DNS servers for our tests,
53 // so this host resolver procedure catches external queries and returns a failed 71 // so this host resolver procedure catches external queries and returns a failed
54 // lookup result. 72 // lookup result.
55 class LocalHostResolverProc : public net::HostResolverProc { 73 class LocalHostResolverProc : public net::HostResolverProc {
56 public: 74 public:
57 LocalHostResolverProc() : HostResolverProc(NULL) {} 75 LocalHostResolverProc() : HostResolverProc(NULL) {}
58 76
59 virtual int Resolve(const std::string& host, 77 virtual int Resolve(const std::string& host,
60 net::AddressFamily address_family, 78 net::AddressFamily address_family,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 content::ContentTestSuiteBase::set_external_libraries_enabled(
196 !IsCrosPythonProcess());
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
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 }
OLDNEW
« no previous file with comments | « no previous file | content/public/test/content_test_suite_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698