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/test_launcher.h" | 5 #include "base/test/launcher/test_launcher.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 test_success_count_(0), | 329 test_success_count_(0), |
330 test_broken_count_(0), | 330 test_broken_count_(0), |
331 retry_count_(0), | 331 retry_count_(0), |
332 retry_limit_(0), | 332 retry_limit_(0), |
333 run_result_(true), | 333 run_result_(true), |
334 watchdog_timer_(FROM_HERE, | 334 watchdog_timer_(FROM_HERE, |
335 TimeDelta::FromSeconds(kOutputTimeoutSeconds), | 335 TimeDelta::FromSeconds(kOutputTimeoutSeconds), |
336 this, | 336 this, |
337 &TestLauncher::OnOutputTimeout), | 337 &TestLauncher::OnOutputTimeout), |
338 parallel_jobs_(parallel_jobs) { | 338 parallel_jobs_(parallel_jobs) { |
339 if (BotModeEnabled()) { | |
340 fprintf(stdout, | |
341 "Enabling defaults optimized for continuous integration bots.\n"); | |
342 fflush(stdout); | |
343 | |
344 // Enable test retries by default for bots. This can be still overridden | |
345 // from command line using --test-launcher-retry-limit flag. | |
346 retry_limit_ = 3; | |
347 } else { | |
348 // Default to serial test execution if not running on a bot. This makes it | |
349 // possible to disable stdio redirection and can still be overridden with | |
350 // --test-launcher-jobs flag. | |
351 parallel_jobs_ = 1; | |
352 } | |
353 } | 339 } |
354 | 340 |
355 TestLauncher::~TestLauncher() { | 341 TestLauncher::~TestLauncher() { |
356 if (worker_pool_owner_) | 342 if (worker_pool_owner_) |
357 worker_pool_owner_->pool()->Shutdown(); | 343 worker_pool_owner_->pool()->Shutdown(); |
358 } | 344 } |
359 | 345 |
360 bool TestLauncher::Run() { | 346 bool TestLauncher::Run() { |
361 if (!Init()) | 347 if (!Init()) |
362 return false; | 348 return false; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 switches::kTestLauncherRetryLimit)) { | 629 switches::kTestLauncherRetryLimit)) { |
644 int retry_limit = -1; | 630 int retry_limit = -1; |
645 if (!StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 631 if (!StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
646 switches::kTestLauncherRetryLimit), &retry_limit) || | 632 switches::kTestLauncherRetryLimit), &retry_limit) || |
647 retry_limit < 0) { | 633 retry_limit < 0) { |
648 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherRetryLimit; | 634 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherRetryLimit; |
649 return false; | 635 return false; |
650 } | 636 } |
651 | 637 |
652 retry_limit_ = retry_limit; | 638 retry_limit_ = retry_limit; |
| 639 } else if (!CommandLine::ForCurrentProcess()->HasSwitch(kGTestFilterFlag)) { |
| 640 // Retry failures 3 times by default if we are running all of the tests. |
| 641 retry_limit_ = 3; |
653 } | 642 } |
654 | 643 |
655 if (CommandLine::ForCurrentProcess()->HasSwitch( | 644 if (CommandLine::ForCurrentProcess()->HasSwitch( |
656 switches::kTestLauncherJobs)) { | 645 switches::kTestLauncherJobs)) { |
657 int jobs = -1; | 646 int jobs = -1; |
658 if (!StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 647 if (!StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
659 switches::kTestLauncherJobs), &jobs) || | 648 switches::kTestLauncherJobs), &jobs) || |
660 jobs < 0) { | 649 jobs < 0) { |
661 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; | 650 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; |
662 return false; | 651 return false; |
663 } | 652 } |
664 | 653 |
665 parallel_jobs_ = jobs; | 654 parallel_jobs_ = jobs; |
| 655 } else if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestFilterFlag)) { |
| 656 // Do not run jobs in parallel by default if we are running a subset of |
| 657 // the tests. |
| 658 parallel_jobs_ = 1; |
666 } | 659 } |
| 660 |
667 fprintf(stdout, "Using %" PRIuS " parallel jobs.\n", parallel_jobs_); | 661 fprintf(stdout, "Using %" PRIuS " parallel jobs.\n", parallel_jobs_); |
668 fflush(stdout); | 662 fflush(stdout); |
669 worker_pool_owner_.reset( | 663 worker_pool_owner_.reset( |
670 new SequencedWorkerPoolOwner(parallel_jobs_, "test_launcher")); | 664 new SequencedWorkerPoolOwner(parallel_jobs_, "test_launcher")); |
671 | 665 |
672 if (command_line->HasSwitch(switches::kTestLauncherFilterFile) && | 666 if (command_line->HasSwitch(switches::kTestLauncherFilterFile) && |
673 command_line->HasSwitch(kGTestFilterFlag)) { | 667 command_line->HasSwitch(kGTestFilterFlag)) { |
674 LOG(ERROR) << "Only one of --test-launcher-filter-file and --gtest_filter " | 668 LOG(ERROR) << "Only one of --test-launcher-filter-file and --gtest_filter " |
675 << "at a time is allowed."; | 669 << "at a time is allowed."; |
676 return false; | 670 return false; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 | 1091 |
1098 g_live_processes.Get().erase(process_handle); | 1092 g_live_processes.Get().erase(process_handle); |
1099 } | 1093 } |
1100 | 1094 |
1101 base::CloseProcessHandle(process_handle); | 1095 base::CloseProcessHandle(process_handle); |
1102 | 1096 |
1103 return exit_code; | 1097 return exit_code; |
1104 } | 1098 } |
1105 | 1099 |
1106 } // namespace base | 1100 } // namespace base |
OLD | NEW |