From 302831b6e4e9d8a700ecbea7616f1879898bbfb9 Mon Sep 17 00:00:00 2001 From: "erikkay@google.com" Date: Tue, 13 Jan 2009 22:35:10 +0000 Subject: Call logging::InitLogging. The lack of this was causing some hangs (and possibly crashes) in ObserverListTest.BUG=6286 This CL has expanded to include some cleanup and refactoring of test_suite and related files, so that this logging change (and other improvements) are applied to all unit tests. Review URL: http://codereview.chromium.org/18003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7977 0039d316-1c4b-4281-b951-d872f2087c98 --- base/test_suite.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'base/test_suite.h') diff --git a/base/test_suite.h b/base/test_suite.h index 1c0a785..a9f05b2 100644 --- a/base/test_suite.h +++ b/base/test_suite.h @@ -10,11 +10,14 @@ // any gtest based tests that are linked into your executable. #include "base/at_exit.h" +#include "base/base_paths.h" #include "base/command_line.h" #include "base/debug_on_start.h" +#include "base/file_path.h" #include "base/icu_util.h" #include "base/logging.h" #include "base/multiprocess_test.h" +#include "base/scoped_nsautorelease_pool.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/multiprocess_func_list.h" @@ -27,16 +30,31 @@ class TestSuite { public: TestSuite(int argc, char** argv) { + base::ScopedNSAutoreleasePool scoped_pool; + + base::EnableTerminationOnHeapCorruption(); CommandLine::SetArgcArgv(argc, argv); testing::InitGoogleTest(&argc, argv); #if defined(OS_LINUX) gtk_init_check(&argc, &argv); #endif + + FilePath exe; + PathService::Get(base::FILE_EXE, &exe); + FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); + logging::InitLogging(log_filename.value().c_str(), + logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE); + // we want process and thread IDs because we may have multiple processes + logging::SetLogItems(true, true, false, true); } virtual ~TestSuite() {} int Run() { + base::ScopedNSAutoreleasePool scoped_pool; + Initialize(); std::wstring client_func = CommandLine().GetSwitchValue(kRunClientProcess); // Check to see if we are being run as a client process. -- cgit v1.1