Chromium Code Reviews| 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()); |