diff options
-rw-r--r-- | chrome/test/base/chrome_test_suite.cc | 24 | ||||
-rw-r--r-- | content/public/test/content_test_suite_base.h | 7 | ||||
-rw-r--r-- | content/test/content_test_suite_base.cc | 7 |
3 files changed, 36 insertions, 2 deletions
diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc index 5ef7802..72b1fba 100644 --- a/chrome/test/base/chrome_test_suite.cc +++ b/chrome/test/base/chrome_test_suite.cc @@ -4,6 +4,11 @@ #include "chrome/test/base/chrome_test_suite.h" +#if defined(OS_CHROMEOS) +#include <stdio.h> +#include <unistd.h> +#endif + #include "base/command_line.h" #include "base/file_util.h" #include "base/memory/ref_counted.h" @@ -48,6 +53,19 @@ void RemoveSharedMemoryFile(const std::string& filename) { #endif } +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; +} + // In many cases it may be not obvious that a test makes a real DNS lookup. // We generally don't want to rely on external DNS servers for our tests, // so this host resolver procedure catches external queries and returns a failed @@ -171,6 +189,12 @@ void ChromeTestSuite::Initialize() { PathService::Override(base::DIR_MODULE, browser_dir_); } + // Disable external libraries load if we are under python process in + // ChromeOS. That means we are autotest and, if ASAN is used, + // external libraries load crashes. + content::ContentTestSuiteBase::set_external_libraries_enabled( + !IsCrosPythonProcess()); + // Initialize after overriding paths as some content paths depend on correct // values for DIR_EXE and DIR_MODULE. content::ContentTestSuiteBase::Initialize(); diff --git a/content/public/test/content_test_suite_base.h b/content/public/test/content_test_suite_base.h index 7d011a6..7887cc3 100644 --- a/content/public/test/content_test_suite_base.h +++ b/content/public/test/content_test_suite_base.h @@ -25,7 +25,14 @@ class ContentTestSuiteBase : public base::TestSuite { // Creates a ContentClient for use during test suite initialization. virtual ContentClient* CreateClientForInitialization() = 0; + // If set to false, prevents Initialize() to load external libraries + // to the process. By default loading is enabled. + void set_external_libraries_enabled(bool val) { + external_libraries_enabled_ = val; + } + private: + bool external_libraries_enabled_; DISALLOW_COPY_AND_ASSIGN(ContentTestSuiteBase); }; diff --git a/content/test/content_test_suite_base.cc b/content/test/content_test_suite_base.cc index 3274f1b..0c32858 100644 --- a/content/test/content_test_suite_base.cc +++ b/content/test/content_test_suite_base.cc @@ -18,12 +18,15 @@ namespace content { ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) - : base::TestSuite(argc, argv) { + : base::TestSuite(argc, argv), + external_libraries_enabled_(true) { } void ContentTestSuiteBase::Initialize() { base::TestSuite::Initialize(); - media::InitializeMediaLibraryForTesting(); + + if (external_libraries_enabled_) + media::InitializeMediaLibraryForTesting(); scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); SetContentClient(client_for_init.get()); |