| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <inttypes.h> | 5 #include <inttypes.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 17 #include "base/strings/string_tokenizer.h" | 17 #include "base/strings/string_tokenizer.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| 20 #include "base/test/launcher/test_launcher.h" | 20 #include "base/test/launcher/test_launcher.h" |
| 21 #include "base/test/launcher/unit_test_launcher.h" | 21 #include "base/test/launcher/unit_test_launcher.h" |
| 22 #include "base/test/test_switches.h" | 22 #include "base/test/test_switches.h" |
| 23 #include "base/test/test_timeouts.h" | 23 #include "base/test/test_timeouts.h" |
| 24 #include "build/build_config.h" |
| 25 |
| 26 #if defined(OS_POSIX) |
| 27 #include "base/files/file_descriptor_watcher_posix.h" |
| 28 #endif |
| 24 | 29 |
| 25 namespace base { | 30 namespace base { |
| 26 | 31 |
| 27 namespace { | 32 namespace { |
| 28 | 33 |
| 29 const char kHelpFlag[] = "help"; | 34 const char kHelpFlag[] = "help"; |
| 30 | 35 |
| 31 void PrintUsage() { | 36 void PrintUsage() { |
| 32 fprintf(stdout, | 37 fprintf(stdout, |
| 33 "Runs tests using the gtest framework, each batch of tests being\n" | 38 "Runs tests using the gtest framework, each batch of tests being\n" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) { | 137 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) { |
| 133 PrintUsage(); | 138 PrintUsage(); |
| 134 return 0; | 139 return 0; |
| 135 } | 140 } |
| 136 | 141 |
| 137 base::TimeTicks start_time(base::TimeTicks::Now()); | 142 base::TimeTicks start_time(base::TimeTicks::Now()); |
| 138 | 143 |
| 139 TestTimeouts::Initialize(); | 144 TestTimeouts::Initialize(); |
| 140 | 145 |
| 141 base::MessageLoopForIO message_loop; | 146 base::MessageLoopForIO message_loop; |
| 147 #if defined(OS_POSIX) |
| 148 FileDescriptorWatcher file_descriptor_watcher(&message_loop); |
| 149 #endif |
| 142 | 150 |
| 143 NonSfiUnitTestPlatformDelegate platform_delegate; | 151 NonSfiUnitTestPlatformDelegate platform_delegate; |
| 144 if (!platform_delegate.Init(test_binary)) { | 152 if (!platform_delegate.Init(test_binary)) { |
| 145 fprintf(stderr, "Failed to initialize test launcher.\n"); | 153 fprintf(stderr, "Failed to initialize test launcher.\n"); |
| 146 fflush(stderr); | 154 fflush(stderr); |
| 147 return 1; | 155 return 1; |
| 148 } | 156 } |
| 149 | 157 |
| 150 base::UnitTestLauncherDelegate delegate(&platform_delegate, 10, true); | 158 base::UnitTestLauncherDelegate delegate(&platform_delegate, 10, true); |
| 151 base::TestLauncher launcher(&delegate, base::SysInfo::NumberOfProcessors()); | 159 base::TestLauncher launcher(&delegate, base::SysInfo::NumberOfProcessors()); |
| 152 bool success = launcher.Run(); | 160 bool success = launcher.Run(); |
| 153 | 161 |
| 154 fprintf(stdout, "Tests took %" PRId64 " seconds.\n", | 162 fprintf(stdout, "Tests took %" PRId64 " seconds.\n", |
| 155 (base::TimeTicks::Now() - start_time).InSeconds()); | 163 (base::TimeTicks::Now() - start_time).InSeconds()); |
| 156 fflush(stdout); | 164 fflush(stdout); |
| 157 return success ? 0 : 1; | 165 return success ? 0 : 1; |
| 158 } | 166 } |
| 159 | 167 |
| 160 } // namespace base | 168 } // namespace base |
| OLD | NEW |