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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/content_test_suite_base.cc
diff --git a/content/test/content_test_suite_base.cc b/content/test/content_test_suite_base.cc
index 3274f1bc3c77988a51ba1a63b789d64ecded4be3..c5466261c7aa8c1b3ae7781ffd010a848a565063 100644
--- a/content/test/content_test_suite_base.cc
+++ b/content/test/content_test_suite_base.cc
@@ -4,8 +4,12 @@
#include "content/public/test/content_test_suite_base.h"
+#include <fcntl.h>
+#include <stdio.h>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/eintr_wrapper.h"
#include "base/memory/scoped_ptr.h"
#include "base/test/test_suite.h"
#include "content/common/url_schemes.h"
@@ -21,9 +25,33 @@ ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv)
: base::TestSuite(argc, argv) {
}
+static bool IsAutotestProcess() {
+#ifdef OS_CHROMEOS
scherkus (not reviewing) 2012/07/18 17:40:02 #if defined(OS_CHROMEOS)
glotov 2012/07/19 20:12:40 Done.
+ int status_fd = open("/proc/self/cmdline", O_RDONLY);
+ if (status_fd == -1)
+ return false;
+ 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.
+ const size_t kPythonPrefixLength = sizeof(kPythonPrefix) - 1;
+ char cmdline_prefix[kPythonPrefixLength];
+ ssize_t num_read =
+ HANDLE_EINTR(read(status_fd, cmdline_prefix, sizeof(cmdline_prefix)));
+ if (HANDLE_EINTR(close(status_fd)) < 0)
+ return false;
+ if (num_read == sizeof(cmdline_prefix) &&
+ !memcmp(kPythonPrefix, cmdline_prefix, sizeof(cmdline_prefix)))
+ return true;
+#endif
+ return false;
+}
+
void ContentTestSuiteBase::Initialize() {
base::TestSuite::Initialize();
- media::InitializeMediaLibraryForTesting();
+
+ // Initialize media library for unit tests. If we are auto test
+ // (python process), media library will be loaded to chrome directly
+ // so don't load it here.
+ if (!IsAutotestProcess())
+ media::InitializeMediaLibraryForTesting();
scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization());
SetContentClient(client_for_init.get());
« 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