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

Unified Diff: base/test/test_suite.cc

Issue 2494133002: Fix a data race in multiple unit tests processes. (Closed)
Patch Set: fix logger test Created 4 years, 1 month 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 | base/test/test_support_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_suite.cc
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index a56dc59fecceff86f96180938be3049414e62c32..1e55e973eea49df429d0dc229d0bb33345f64449 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -108,6 +108,24 @@ std::string GetProfileName() {
return profile_name;
}
+void InitializeLogging() {
+#if defined(OS_ANDROID)
+ InitAndroidTestLogging();
+#else
+ FilePath exe;
+ PathService::Get(FILE_EXE, &exe);
+ FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_ALL;
+ settings.log_file = log_filename.value().c_str();
+ settings.delete_old = logging::DELETE_OLD_LOG_FILE;
+ logging::InitLogging(settings);
+ // We want process and thread IDs because we may have multiple processes.
+ // Note: temporarily enabled timestamps in an effort to catch bug 6361.
+ logging::SetLogItems(true, true, true, true);
+#endif // !defined(OS_ANDROID)
+}
+
} // namespace
int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) {
@@ -120,6 +138,9 @@ TestSuite::TestSuite(int argc, char** argv)
: initialized_command_line_(false), created_feature_list_(false) {
PreInitialize();
InitializeFromCommandLine(argc, argv);
+ // Logging must be initialized before any thread has a chance to call logging
+ // functions.
+ InitializeLogging();
}
#if defined(OS_WIN)
@@ -127,6 +148,9 @@ TestSuite::TestSuite(int argc, wchar_t** argv)
: initialized_command_line_(false), created_feature_list_(false) {
PreInitialize();
InitializeFromCommandLine(argc, argv);
+ // Logging must be initialized before any thread has a chance to call logging
+ // functions.
+ InitializeLogging();
}
#endif // defined(OS_WIN)
@@ -318,20 +342,7 @@ void TestSuite::Initialize() {
#endif // OS_IOS
#if defined(OS_ANDROID)
- InitAndroidTest();
-#else
- // Initialize logging.
- FilePath exe;
- PathService::Get(FILE_EXE, &exe);
- FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
- logging::LoggingSettings settings;
- settings.logging_dest = logging::LOG_TO_ALL;
- settings.log_file = log_filename.value().c_str();
- settings.delete_old = logging::DELETE_OLD_LOG_FILE;
- logging::InitLogging(settings);
- // We want process and thread IDs because we may have multiple processes.
- // Note: temporarily enabled timestamps in an effort to catch bug 6361.
- logging::SetLogItems(true, true, true, true);
+ InitAndroidTestMessageLoop();
#endif // else defined(OS_ANDROID)
CHECK(debug::EnableInProcessStackDumping());
« no previous file with comments | « no previous file | base/test/test_support_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698