diff options
author | Paweł Hajdan <phajdan.jr@chromium.org> | 2015-01-29 14:38:45 +0100 |
---|---|---|
committer | Paweł Hajdan <phajdan.jr@chromium.org> | 2015-01-29 13:40:08 +0000 |
commit | 5a34a29a62f5468d9de244bca3295347f7afbd56 (patch) | |
tree | d5f7d04850934c3b8006507a65bf42bde21d7a4b /base/test | |
parent | 0a0829f0f753a161b1b2371d818df94e532ac0eb (diff) | |
download | chromium_src-5a34a29a62f5468d9de244bca3295347f7afbd56.zip chromium_src-5a34a29a62f5468d9de244bca3295347f7afbd56.tar.gz chromium_src-5a34a29a62f5468d9de244bca3295347f7afbd56.tar.bz2 |
iOS gtest launcher: retry tests in one big batch
Without it the overhead of serialized ios simulator run is too big.
BUG=426870
R=sky@chromium.org, smut@google.com
Review URL: https://codereview.chromium.org/886463003
Cr-Commit-Position: refs/heads/master@{#313696}
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/launcher/test_launcher_ios.cc | 8 | ||||
-rw-r--r-- | base/test/launcher/unit_test_launcher.cc | 49 | ||||
-rw-r--r-- | base/test/launcher/unit_test_launcher.h | 5 |
3 files changed, 34 insertions, 28 deletions
diff --git a/base/test/launcher/test_launcher_ios.cc b/base/test/launcher/test_launcher_ios.cc index 7028133..ecd31ae 100644 --- a/base/test/launcher/test_launcher_ios.cc +++ b/base/test/launcher/test_launcher_ios.cc @@ -129,6 +129,14 @@ class IOSUnitTestPlatformDelegate : public base::UnitTestPlatformDelegate { return dir_exe_.AppendASCII("iossim").value(); } + void RelaunchTests(base::TestLauncher* test_launcher, + const std::vector<std::string>& test_names, + int launch_flags) override { + // Relaunch all tests in one big batch, since overhead of smaller batches + // is too big for serialized runs inside ios simulator. + RunUnitTestsBatch(test_launcher, this, test_names, launch_flags); + } + private: // Directory containing test launcher's executable. base::FilePath dir_exe_; diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc index 1ded464..1b3a162 100644 --- a/base/test/launcher/unit_test_launcher.cc +++ b/base/test/launcher/unit_test_launcher.cc @@ -121,6 +121,18 @@ class DefaultUnitTestPlatformDelegate : public UnitTestPlatformDelegate { return std::string(); } + void RelaunchTests(TestLauncher* test_launcher, + const std::vector<std::string>& test_names, + int launch_flags) override { + // Relaunch requested tests in parallel, but only use single + // test per batch for more precise results (crashes, etc). + for (const std::string& test_name : test_names) { + std::vector<std::string> batch; + batch.push_back(test_name); + RunUnitTestsBatch(test_launcher, this, batch, launch_flags); + } + } + DISALLOW_COPY_AND_ASSIGN(DefaultUnitTestPlatformDelegate); }; @@ -302,24 +314,10 @@ bool ProcessTestResults( if (!has_non_success_test && exit_code != 0) { // This is a bit surprising case: all tests are marked as successful, // but the exit code was not zero. This can happen e.g. under memory - // tools that report leaks this way. - - if (final_results.size() == 1) { - // Easy case. One test only so we know the non-zero exit code - // was caused by that one test. - final_results[0].status = TestResult::TEST_FAILURE_ON_EXIT; - } else { - // Harder case. Discard the results and request relaunching all - // tests without batching. This will trigger above branch on - // relaunch leading to more precise results. - LOG(WARNING) << "Not sure which test caused non-zero exit code, " - << "relaunching all of them without batching."; - - for (size_t i = 0; i < final_results.size(); i++) - tests_to_relaunch->push_back(final_results[i].full_name); - - return false; - } + // tools that report leaks this way. Mark all tests as a failure on exit, + // and for more precise info they'd need to be retried serially. + for (size_t i = 0; i < final_results.size(); i++) + final_results[i].status = TestResult::TEST_FAILURE_ON_EXIT; } for (size_t i = 0; i < final_results.size(); i++) { @@ -373,16 +371,11 @@ void GTestCallback( callback_state.output_file, output, exit_code, was_timeout, &tests_to_relaunch); - // Relaunch requested tests in parallel, but only use single - // test per batch for more precise results (crashes, test passes - // but non-zero exit codes etc). - for (size_t i = 0; i < tests_to_relaunch.size(); i++) { - std::vector<std::string> batch; - batch.push_back(tests_to_relaunch[i]); - RunUnitTestsBatch(callback_state.test_launcher, - callback_state.platform_delegate, - batch, - callback_state.launch_flags); + if (!tests_to_relaunch.empty()) { + callback_state.platform_delegate->RelaunchTests( + callback_state.test_launcher, + tests_to_relaunch, + callback_state.launch_flags); } // The temporary file's directory is also temporary. diff --git a/base/test/launcher/unit_test_launcher.h b/base/test/launcher/unit_test_launcher.h index 5b5f240..ca00f10 100644 --- a/base/test/launcher/unit_test_launcher.h +++ b/base/test/launcher/unit_test_launcher.h @@ -55,6 +55,11 @@ class UnitTestPlatformDelegate { // no wrapper. virtual std::string GetWrapperForChildGTestProcess() = 0; + // Relaunch tests, e.g. after a crash. + virtual void RelaunchTests(TestLauncher* test_launcher, + const std::vector<std::string>& test_names, + int launch_flags) = 0; + protected: ~UnitTestPlatformDelegate() {} }; |