From 1dda386456321a228cf7c0cbb39c2358539d6481 Mon Sep 17 00:00:00 2001 From: "glotov@google.com" Date: Sat, 21 Jul 2012 14:43:55 +0000 Subject: 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 --- content/test/content_test_suite.cc | 25 +++++++++++++++++++++++++ content/test/content_test_suite_base.cc | 2 -- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'content') 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 +#include +#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 client_for_init(CreateClientForInitialization()); SetContentClient(client_for_init.get()); -- cgit v1.1