| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/test/launcher/unit_test_launcher.h" | 5 #include "base/test/launcher/unit_test_launcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 (base::TimeTicks::Now() - start_time).InSeconds()); | 218 (base::TimeTicks::Now() - start_time).InSeconds()); |
| 219 fflush(stdout); | 219 fflush(stdout); |
| 220 | 220 |
| 221 return (success ? 0 : 1); | 221 return (success ? 0 : 1); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void InitGoogleTestChar(int* argc, char** argv) { | 224 void InitGoogleTestChar(int* argc, char** argv) { |
| 225 testing::InitGoogleTest(argc, argv); | 225 testing::InitGoogleTest(argc, argv); |
| 226 } | 226 } |
| 227 | 227 |
| 228 #if defined(OS_WIN) | |
| 229 void InitGoogleTestWChar(int* argc, wchar_t** argv) { | |
| 230 testing::InitGoogleTest(argc, argv); | |
| 231 } | |
| 232 #endif // defined(OS_WIN) | |
| 233 | |
| 234 // Interprets test results and reports to the test launcher. Returns true | 228 // Interprets test results and reports to the test launcher. Returns true |
| 235 // on success. | 229 // on success. |
| 236 bool ProcessTestResults( | 230 bool ProcessTestResults( |
| 237 TestLauncher* test_launcher, | 231 TestLauncher* test_launcher, |
| 238 const std::vector<std::string>& test_names, | 232 const std::vector<std::string>& test_names, |
| 239 const base::FilePath& output_file, | 233 const base::FilePath& output_file, |
| 240 const std::string& output, | 234 const std::string& output, |
| 241 int exit_code, | 235 int exit_code, |
| 242 bool was_timeout, | 236 bool was_timeout, |
| 243 std::vector<std::string>* tests_to_relaunch) { | 237 std::vector<std::string>* tests_to_relaunch) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 419 } |
| 426 | 420 |
| 427 int LaunchUnitTestsSerially(int argc, | 421 int LaunchUnitTestsSerially(int argc, |
| 428 char** argv, | 422 char** argv, |
| 429 const RunTestSuiteCallback& run_test_suite) { | 423 const RunTestSuiteCallback& run_test_suite) { |
| 430 CommandLine::Init(argc, argv); | 424 CommandLine::Init(argc, argv); |
| 431 return LaunchUnitTestsInternal(run_test_suite, 1, true, | 425 return LaunchUnitTestsInternal(run_test_suite, 1, true, |
| 432 Bind(&InitGoogleTestChar, &argc, argv)); | 426 Bind(&InitGoogleTestChar, &argc, argv)); |
| 433 } | 427 } |
| 434 | 428 |
| 435 #if defined(OS_WIN) | |
| 436 int LaunchUnitTests(int argc, | |
| 437 wchar_t** argv, | |
| 438 bool use_job_objects, | |
| 439 const RunTestSuiteCallback& run_test_suite) { | |
| 440 // Windows CommandLine::Init ignores argv anyway. | |
| 441 CommandLine::Init(argc, NULL); | |
| 442 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(), | |
| 443 use_job_objects, | |
| 444 Bind(&InitGoogleTestWChar, &argc, argv)); | |
| 445 } | |
| 446 #endif // defined(OS_WIN) | |
| 447 | |
| 448 void RunUnitTestsSerially( | 429 void RunUnitTestsSerially( |
| 449 TestLauncher* test_launcher, | 430 TestLauncher* test_launcher, |
| 450 UnitTestPlatformDelegate* platform_delegate, | 431 UnitTestPlatformDelegate* platform_delegate, |
| 451 const std::vector<std::string>& test_names, | 432 const std::vector<std::string>& test_names, |
| 452 int launch_flags) { | 433 int launch_flags) { |
| 453 if (test_names.empty()) | 434 if (test_names.empty()) |
| 454 return; | 435 return; |
| 455 | 436 |
| 456 std::vector<std::string> new_test_names(test_names); | 437 std::vector<std::string> new_test_names(test_names); |
| 457 std::string test_name(new_test_names.back()); | 438 std::string test_name(new_test_names.back()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 TestLauncher* test_launcher, | 558 TestLauncher* test_launcher, |
| 578 const std::vector<std::string>& test_names) { | 559 const std::vector<std::string>& test_names) { |
| 579 ThreadTaskRunnerHandle::Get()->PostTask( | 560 ThreadTaskRunnerHandle::Get()->PostTask( |
| 580 FROM_HERE, | 561 FROM_HERE, |
| 581 Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names, | 562 Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names, |
| 582 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0)); | 563 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0)); |
| 583 return test_names.size(); | 564 return test_names.size(); |
| 584 } | 565 } |
| 585 | 566 |
| 586 } // namespace base | 567 } // namespace base |
| OLD | NEW |