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

Side by Side Diff: content/test/content_test_suite_base.cc

Issue 10786038: Prevent loading libffmpegsumo.so to python (autotests) process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: restrict to OS_CHROMEOS Created 8 years, 5 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 | 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 "content/public/test/content_test_suite_base.h" 5 #include "content/public/test/content_test_suite_base.h"
6 6
7 #include <fcntl.h>
8 #include <stdio.h>
9
7 #include "base/basictypes.h" 10 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/eintr_wrapper.h"
9 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
10 #include "base/test/test_suite.h" 14 #include "base/test/test_suite.h"
11 #include "content/common/url_schemes.h" 15 #include "content/common/url_schemes.h"
12 #include "content/public/common/content_client.h" 16 #include "content/public/common/content_client.h"
13 #include "content/public/common/content_paths.h" 17 #include "content/public/common/content_paths.h"
14 #include "media/base/media.h" 18 #include "media/base/media.h"
15 #include "ui/base/ui_base_paths.h" 19 #include "ui/base/ui_base_paths.h"
16 #include "ui/compositor/compositor_setup.h" 20 #include "ui/compositor/compositor_setup.h"
17 21
18 namespace content { 22 namespace content {
19 23
20 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) 24 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv)
21 : base::TestSuite(argc, argv) { 25 : base::TestSuite(argc, argv) {
22 } 26 }
23 27
28 static bool IsAutotestProcess() {
29 #ifdef OS_CHROMEOS
scherkus (not reviewing) 2012/07/18 17:40:02 #if defined(OS_CHROMEOS)
glotov 2012/07/19 20:12:40 Done.
30 int status_fd = open("/proc/self/cmdline", O_RDONLY);
31 if (status_fd == -1)
32 return false;
33 const char kPythonPrefix[] = "/usr/bin/python";
scherkus (not reviewing) 2012/07/18 17:40:02 would this catch processes started with /usr/bin/e
glotov 2012/07/19 20:12:40 Done.
34 const size_t kPythonPrefixLength = sizeof(kPythonPrefix) - 1;
35 char cmdline_prefix[kPythonPrefixLength];
36 ssize_t num_read =
37 HANDLE_EINTR(read(status_fd, cmdline_prefix, sizeof(cmdline_prefix)));
38 if (HANDLE_EINTR(close(status_fd)) < 0)
39 return false;
40 if (num_read == sizeof(cmdline_prefix) &&
41 !memcmp(kPythonPrefix, cmdline_prefix, sizeof(cmdline_prefix)))
42 return true;
43 #endif
44 return false;
45 }
46
24 void ContentTestSuiteBase::Initialize() { 47 void ContentTestSuiteBase::Initialize() {
25 base::TestSuite::Initialize(); 48 base::TestSuite::Initialize();
26 media::InitializeMediaLibraryForTesting(); 49
50 // Initialize media library for unit tests. If we are auto test
51 // (python process), media library will be loaded to chrome directly
52 // so don't load it here.
53 if (!IsAutotestProcess())
54 media::InitializeMediaLibraryForTesting();
27 55
28 scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); 56 scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization());
29 SetContentClient(client_for_init.get()); 57 SetContentClient(client_for_init.get());
30 RegisterContentSchemes(false); 58 RegisterContentSchemes(false);
31 SetContentClient(NULL); 59 SetContentClient(NULL);
32 60
33 RegisterPathProvider(); 61 RegisterPathProvider();
34 ui::RegisterPathProvider(); 62 ui::RegisterPathProvider();
35 63
36 // Mock out the compositor on platforms that use it. 64 // Mock out the compositor on platforms that use it.
37 ui::SetupTestCompositor(); 65 ui::SetupTestCompositor();
38 } 66 }
39 67
40 } // namespace content 68 } // namespace content
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