| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 : launcher_delegate_(launcher_delegate), | 449 : launcher_delegate_(launcher_delegate), |
| 450 total_shards_(1), | 450 total_shards_(1), |
| 451 shard_index_(0), | 451 shard_index_(0), |
| 452 cycles_(1), | 452 cycles_(1), |
| 453 test_started_count_(0), | 453 test_started_count_(0), |
| 454 test_finished_count_(0), | 454 test_finished_count_(0), |
| 455 test_success_count_(0), | 455 test_success_count_(0), |
| 456 test_broken_count_(0), | 456 test_broken_count_(0), |
| 457 retry_count_(0), | 457 retry_count_(0), |
| 458 retry_limit_(0), | 458 retry_limit_(0), |
| 459 force_run_broken_tests_(false), |
| 459 run_result_(true), | 460 run_result_(true), |
| 460 watchdog_timer_(FROM_HERE, | 461 watchdog_timer_(FROM_HERE, |
| 461 TimeDelta::FromSeconds(kOutputTimeoutSeconds), | 462 TimeDelta::FromSeconds(kOutputTimeoutSeconds), |
| 462 this, | 463 this, |
| 463 &TestLauncher::OnOutputTimeout), | 464 &TestLauncher::OnOutputTimeout), |
| 464 parallel_jobs_(parallel_jobs) { | 465 parallel_jobs_(parallel_jobs) {} |
| 465 } | |
| 466 | 466 |
| 467 TestLauncher::~TestLauncher() { | 467 TestLauncher::~TestLauncher() { |
| 468 if (worker_pool_owner_) | 468 if (worker_pool_owner_) |
| 469 worker_pool_owner_->pool()->Shutdown(); | 469 worker_pool_owner_->pool()->Shutdown(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 bool TestLauncher::Run() { | 472 bool TestLauncher::Run() { |
| 473 if (!Init()) | 473 if (!Init()) |
| 474 return false; | 474 return false; |
| 475 | 475 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 612 |
| 613 // Do not waste time on timeouts. We include tests with unknown results here | 613 // Do not waste time on timeouts. We include tests with unknown results here |
| 614 // because sometimes (e.g. hang in between unit tests) that's how a timeout | 614 // because sometimes (e.g. hang in between unit tests) that's how a timeout |
| 615 // gets reported. | 615 // gets reported. |
| 616 if (result.status == TestResult::TEST_TIMEOUT || | 616 if (result.status == TestResult::TEST_TIMEOUT || |
| 617 result.status == TestResult::TEST_UNKNOWN) { | 617 result.status == TestResult::TEST_UNKNOWN) { |
| 618 test_broken_count_++; | 618 test_broken_count_++; |
| 619 } | 619 } |
| 620 size_t broken_threshold = | 620 size_t broken_threshold = |
| 621 std::max(static_cast<size_t>(20), test_started_count_ / 10); | 621 std::max(static_cast<size_t>(20), test_started_count_ / 10); |
| 622 if (test_broken_count_ >= broken_threshold) { | 622 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) { |
| 623 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n", | 623 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n", |
| 624 test_broken_count_); | 624 test_broken_count_); |
| 625 fflush(stdout); | 625 fflush(stdout); |
| 626 | 626 |
| 627 #if defined(OS_POSIX) | 627 #if defined(OS_POSIX) |
| 628 KillSpawnedTestProcesses(); | 628 KillSpawnedTestProcesses(); |
| 629 #endif // defined(OS_POSIX) | 629 #endif // defined(OS_POSIX) |
| 630 | 630 |
| 631 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT"); | 631 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT"); |
| 632 results_tracker_.AddGlobalTag(kUnreliableResultsTag); | 632 results_tracker_.AddGlobalTag(kUnreliableResultsTag); |
| 633 MaybeSaveSummaryAsJSON(); | 633 MaybeSaveSummaryAsJSON(); |
| 634 | 634 |
| 635 exit(1); | 635 exit(1); |
| 636 } | 636 } |
| 637 | 637 |
| 638 if (test_finished_count_ != test_started_count_) | 638 if (test_finished_count_ != test_started_count_) |
| 639 return; | 639 return; |
| 640 | 640 |
| 641 if (tests_to_retry_.empty() || retry_count_ >= retry_limit_) { | 641 if (tests_to_retry_.empty() || retry_count_ >= retry_limit_) { |
| 642 OnTestIterationFinished(); | 642 OnTestIterationFinished(); |
| 643 return; | 643 return; |
| 644 } | 644 } |
| 645 | 645 |
| 646 if (tests_to_retry_.size() >= broken_threshold) { | 646 if (!force_run_broken_tests_ && tests_to_retry_.size() >= broken_threshold) { |
| 647 fprintf(stdout, | 647 fprintf(stdout, |
| 648 "Too many failing tests (%" PRIuS "), skipping retries.\n", | 648 "Too many failing tests (%" PRIuS "), skipping retries.\n", |
| 649 tests_to_retry_.size()); | 649 tests_to_retry_.size()); |
| 650 fflush(stdout); | 650 fflush(stdout); |
| 651 | 651 |
| 652 results_tracker_.AddGlobalTag("BROKEN_TEST_SKIPPED_RETRIES"); | 652 results_tracker_.AddGlobalTag("BROKEN_TEST_SKIPPED_RETRIES"); |
| 653 results_tracker_.AddGlobalTag(kUnreliableResultsTag); | 653 results_tracker_.AddGlobalTag(kUnreliableResultsTag); |
| 654 | 654 |
| 655 OnTestIterationFinished(); | 655 OnTestIterationFinished(); |
| 656 return; | 656 return; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 return false; | 748 return false; |
| 749 } | 749 } |
| 750 | 750 |
| 751 retry_limit_ = retry_limit; | 751 retry_limit_ = retry_limit; |
| 752 } else if (!command_line->HasSwitch(kGTestFilterFlag) || BotModeEnabled()) { | 752 } else if (!command_line->HasSwitch(kGTestFilterFlag) || BotModeEnabled()) { |
| 753 // Retry failures 3 times by default if we are running all of the tests or | 753 // Retry failures 3 times by default if we are running all of the tests or |
| 754 // in bot mode. | 754 // in bot mode. |
| 755 retry_limit_ = 3; | 755 retry_limit_ = 3; |
| 756 } | 756 } |
| 757 | 757 |
| 758 if (command_line->HasSwitch(switches::kTestLauncherForceRunBrokenTests)) |
| 759 force_run_broken_tests_ = true; |
| 760 |
| 758 if (command_line->HasSwitch(switches::kTestLauncherJobs)) { | 761 if (command_line->HasSwitch(switches::kTestLauncherJobs)) { |
| 759 int jobs = -1; | 762 int jobs = -1; |
| 760 if (!StringToInt(command_line->GetSwitchValueASCII( | 763 if (!StringToInt(command_line->GetSwitchValueASCII( |
| 761 switches::kTestLauncherJobs), &jobs) || | 764 switches::kTestLauncherJobs), &jobs) || |
| 762 jobs < 0) { | 765 jobs < 0) { |
| 763 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; | 766 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; |
| 764 return false; | 767 return false; |
| 765 } | 768 } |
| 766 | 769 |
| 767 parallel_jobs_ = jobs; | 770 parallel_jobs_ = jobs; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 } | 1082 } |
| 1080 | 1083 |
| 1081 std::string snippet(full_output.substr(run_pos)); | 1084 std::string snippet(full_output.substr(run_pos)); |
| 1082 if (end_pos != std::string::npos) | 1085 if (end_pos != std::string::npos) |
| 1083 snippet = full_output.substr(run_pos, end_pos - run_pos); | 1086 snippet = full_output.substr(run_pos, end_pos - run_pos); |
| 1084 | 1087 |
| 1085 return snippet; | 1088 return snippet; |
| 1086 } | 1089 } |
| 1087 | 1090 |
| 1088 } // namespace base | 1091 } // namespace base |
| OLD | NEW |