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

Side by Side Diff: base/test_suite.h

Issue 18003: Call logging::InitLogging. The lack of this was causing some hangs (and poss... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/run_all_unittests.cc ('k') | chrome/common/ipc_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TEST_SUITE_H_ 5 #ifndef BASE_TEST_SUITE_H_
6 #define BASE_TEST_SUITE_H_ 6 #define BASE_TEST_SUITE_H_
7 7
8 // Defines a basic test suite framework for running gtest based tests. You can 8 // Defines a basic test suite framework for running gtest based tests. You can
9 // instantiate this class in your main function and call its Run method to run 9 // instantiate this class in your main function and call its Run method to run
10 // any gtest based tests that are linked into your executable. 10 // any gtest based tests that are linked into your executable.
11 11
12 #include "base/at_exit.h" 12 #include "base/at_exit.h"
13 #include "base/base_paths.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/debug_on_start.h" 15 #include "base/debug_on_start.h"
16 #include "base/file_path.h"
15 #include "base/icu_util.h" 17 #include "base/icu_util.h"
16 #include "base/logging.h" 18 #include "base/logging.h"
17 #include "base/multiprocess_test.h" 19 #include "base/multiprocess_test.h"
20 #include "base/scoped_nsautorelease_pool.h"
18 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
19 #include "testing/multiprocess_func_list.h" 22 #include "testing/multiprocess_func_list.h"
20 23
21 #if defined(OS_WIN) 24 #if defined(OS_WIN)
22 #include <windows.h> 25 #include <windows.h>
23 #elif defined(OS_LINUX) 26 #elif defined(OS_LINUX)
24 #include <gtk/gtk.h> 27 #include <gtk/gtk.h>
25 #endif 28 #endif
26 29
27 class TestSuite { 30 class TestSuite {
28 public: 31 public:
29 TestSuite(int argc, char** argv) { 32 TestSuite(int argc, char** argv) {
33 base::ScopedNSAutoreleasePool scoped_pool;
34
35 base::EnableTerminationOnHeapCorruption();
30 CommandLine::SetArgcArgv(argc, argv); 36 CommandLine::SetArgcArgv(argc, argv);
31 testing::InitGoogleTest(&argc, argv); 37 testing::InitGoogleTest(&argc, argv);
32 #if defined(OS_LINUX) 38 #if defined(OS_LINUX)
33 gtk_init_check(&argc, &argv); 39 gtk_init_check(&argc, &argv);
34 #endif 40 #endif
41
42 FilePath exe;
43 PathService::Get(base::FILE_EXE, &exe);
44 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
45 logging::InitLogging(log_filename.value().c_str(),
46 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG,
47 logging::LOCK_LOG_FILE,
48 logging::DELETE_OLD_LOG_FILE);
49 // we want process and thread IDs because we may have multiple processes
50 logging::SetLogItems(true, true, false, true);
35 } 51 }
36 52
37 virtual ~TestSuite() {} 53 virtual ~TestSuite() {}
38 54
39 int Run() { 55 int Run() {
56 base::ScopedNSAutoreleasePool scoped_pool;
57
40 Initialize(); 58 Initialize();
41 std::wstring client_func = CommandLine().GetSwitchValue(kRunClientProcess); 59 std::wstring client_func = CommandLine().GetSwitchValue(kRunClientProcess);
42 // Check to see if we are being run as a client process. 60 // Check to see if we are being run as a client process.
43 if (!client_func.empty()) { 61 if (!client_func.empty()) {
44 // Convert our function name to a usable string for GetProcAddress. 62 // Convert our function name to a usable string for GetProcAddress.
45 std::string func_name(client_func.begin(), client_func.end()); 63 std::string func_name(client_func.begin(), client_func.end());
46 64
47 return multi_process_function_list::InvokeChildProcessTest(func_name); 65 return multi_process_function_list::InvokeChildProcessTest(func_name);
48 } 66 }
49 int result = RUN_ALL_TESTS(); 67 int result = RUN_ALL_TESTS();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 virtual void Shutdown() { 109 virtual void Shutdown() {
92 } 110 }
93 111
94 // Make sure that we setup an AtExitManager so Singleton objects will be 112 // Make sure that we setup an AtExitManager so Singleton objects will be
95 // destroyed. 113 // destroyed.
96 base::AtExitManager at_exit_manager_; 114 base::AtExitManager at_exit_manager_;
97 }; 115 };
98 116
99 #endif // BASE_TEST_SUITE_H_ 117 #endif // BASE_TEST_SUITE_H_
100 118
OLDNEW
« no previous file with comments | « base/run_all_unittests.cc ('k') | chrome/common/ipc_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698