diff options
author | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 14:43:55 +0000 |
---|---|---|
committer | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 14:43:55 +0000 |
commit | 1dda386456321a228cf7c0cbb39c2358539d6481 (patch) | |
tree | a3051b6e0fa77409a50595b27c8490f217246dfa /content | |
parent | f059c6946d6c3a29e8d7fc7435ec16a33110eefa (diff) | |
download | chromium_src-1dda386456321a228cf7c0cbb39c2358539d6481.zip chromium_src-1dda386456321a228cf7c0cbb39c2358539d6481.tar.gz chromium_src-1dda386456321a228cf7c0cbb39c2358539d6481.tar.bz2 |
Prevent loading libffmpegsumo.so to python (autotests) process.
This is needed for ASAN environment because libffmpegsumo.so, being
built with ASAN support, fails to load to python process (which is not
ASAN-ed currently). At the same time it loads file to chrome or to
gtest processes (like content_unittests) because they do have ASAN
runtime.
FYI: Alternative approach (https://chromiumcodereview.appspot.com/10692190/)
was skipped because it disallowed ASAN to test libffmpegsumo.so.
BUG=chromium-os:32259
TESTS=unit
Review URL: https://chromiumcodereview.appspot.com/10786038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/test/content_test_suite.cc | 25 | ||||
-rw-r--r-- | content/test/content_test_suite_base.cc | 2 |
2 files changed, 25 insertions, 2 deletions
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc index 1fc9d35..03d21db 100644 --- a/content/test/content_test_suite.cc +++ b/content/test/content_test_suite.cc @@ -4,9 +4,15 @@ #include "content/test/content_test_suite.h" +#if defined(OS_CHROMEOS) +#include <stdio.h> +#include <unistd.h> +#endif + #include "base/logging.h" #include "content/public/test/test_content_client_initializer.h" #include "content/test/test_content_client.h" +#include "media/base/media.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(USE_AURA) @@ -53,6 +59,19 @@ ContentTestSuite::ContentTestSuite(int argc, char** argv) ContentTestSuite::~ContentTestSuite() { } +static bool IsCrosPythonProcess() { +#if defined(OS_CHROMEOS) + char buf[80]; + int num_read = readlink("/proc/self/exe", buf, sizeof(buf) - 1); + if (num_read == -1) + return false; + buf[num_read] = 0; + const char kPythonPrefix[] = "/python"; + return !strncmp(strrchr(buf, '/'), kPythonPrefix, sizeof(kPythonPrefix) - 1); +#endif // defined(OS_CHROMEOS) + return false; +} + void ContentTestSuite::Initialize() { #if defined(OS_MACOSX) base::mac::ScopedNSAutoreleasePool autorelease_pool; @@ -60,6 +79,12 @@ void ContentTestSuite::Initialize() { ContentTestSuiteBase::Initialize(); + // Initialize media library for unit tests. If we are auto test + // (python process under chrome os), media library will be loaded to + // chrome directly so don't load it here. + if (!IsCrosPythonProcess()) + media::InitializeMediaLibraryForTesting(); + testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); listeners.Append(new TestInitializationListener); diff --git a/content/test/content_test_suite_base.cc b/content/test/content_test_suite_base.cc index 3274f1b..adf2079 100644 --- a/content/test/content_test_suite_base.cc +++ b/content/test/content_test_suite_base.cc @@ -11,7 +11,6 @@ #include "content/common/url_schemes.h" #include "content/public/common/content_client.h" #include "content/public/common/content_paths.h" -#include "media/base/media.h" #include "ui/base/ui_base_paths.h" #include "ui/compositor/compositor_setup.h" @@ -23,7 +22,6 @@ ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) void ContentTestSuiteBase::Initialize() { base::TestSuite::Initialize(); - media::InitializeMediaLibraryForTesting(); scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); SetContentClient(client_for_init.get()); |