| 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/unit_test_launcher.h" | 5 #include "base/test/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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 CommandLine cmd_line( | 152 CommandLine cmd_line( |
| 153 GetCommandLineForChildGTestProcess(test_names, output_file)); | 153 GetCommandLineForChildGTestProcess(test_names, output_file)); |
| 154 | 154 |
| 155 // Adjust the timeout depending on how many tests we're running | 155 // Adjust the timeout depending on how many tests we're running |
| 156 // (note that e.g. the last batch of tests will be smaller). | 156 // (note that e.g. the last batch of tests will be smaller). |
| 157 // TODO(phajdan.jr): Consider an adaptive timeout, which can change | 157 // TODO(phajdan.jr): Consider an adaptive timeout, which can change |
| 158 // depending on how many tests ran and how many remain. | 158 // depending on how many tests ran and how many remain. |
| 159 // Note: do NOT parse child's stdout to do that, it's known to be | 159 // Note: do NOT parse child's stdout to do that, it's known to be |
| 160 // unreliable (e.g. buffering issues can mix up the output). | 160 // unreliable (e.g. buffering issues can mix up the output). |
| 161 base::TimeDelta timeout = | 161 base::TimeDelta timeout = |
| 162 test_names.size() * TestTimeouts::action_timeout(); | 162 test_names.size() * TestTimeouts::test_launcher_timeout(); |
| 163 | 163 |
| 164 parallel_launcher_.LaunchChildGTestProcess( | 164 parallel_launcher_.LaunchChildGTestProcess( |
| 165 cmd_line, | 165 cmd_line, |
| 166 std::string(), | 166 std::string(), |
| 167 timeout, | 167 timeout, |
| 168 Bind(&UnitTestLauncherDelegate::GTestCallback, | 168 Bind(&UnitTestLauncherDelegate::GTestCallback, |
| 169 base::Unretained(this), | 169 base::Unretained(this), |
| 170 tests_, | 170 tests_, |
| 171 output_file)); | 171 output_file)); |
| 172 tests_.clear(); | 172 tests_.clear(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 TestResult test_result = results_map[tests[i].GetFullName()]; | 227 TestResult test_result = results_map[tests[i].GetFullName()]; |
| 228 if (test_result.status == TestResult::TEST_CRASH) { | 228 if (test_result.status == TestResult::TEST_CRASH) { |
| 229 had_interrupted_test = true; | 229 had_interrupted_test = true; |
| 230 | 230 |
| 231 if (was_timeout) { | 231 if (was_timeout) { |
| 232 // Fix up the test status: we forcibly kill the child process | 232 // Fix up the test status: we forcibly kill the child process |
| 233 // after the timeout, so from XML results it looks just like | 233 // after the timeout, so from XML results it looks just like |
| 234 // a crash. | 234 // a crash. |
| 235 test_result.status = TestResult::TEST_TIMEOUT; | 235 test_result.status = TestResult::TEST_TIMEOUT; |
| 236 } | 236 } |
| 237 } else if (test_result.status == TestResult::TEST_SUCCESS || |
| 238 test_result.status == TestResult::TEST_FAILURE) { |
| 239 // We run multiple tests in a batch with a timeout applied |
| 240 // to the entire batch. It is possible that with other tests |
| 241 // running quickly some tests take longer than the per-test timeout. |
| 242 // For consistent handling of tests independent of order and other |
| 243 // factors, mark them as timing out. |
| 244 if (test_result.elapsed_time > |
| 245 TestTimeouts::test_launcher_timeout()) { |
| 246 test_result.status = TestResult::TEST_TIMEOUT; |
| 247 } |
| 237 } | 248 } |
| 238 PrintTestOutputSnippetOnFailure(test_result, output); | 249 PrintTestOutputSnippetOnFailure(test_result, output); |
| 239 tests[i].callback.Run(test_result); | 250 tests[i].callback.Run(test_result); |
| 240 called_any_callback = true; | 251 called_any_callback = true; |
| 241 } else if (had_interrupted_test) { | 252 } else if (had_interrupted_test) { |
| 242 tests_to_relaunch_after_interruption->push_back(tests[i]); | 253 tests_to_relaunch_after_interruption->push_back(tests[i]); |
| 243 } else { | 254 } else { |
| 244 // TODO(phajdan.jr): Explicitly pass the info that the test didn't | 255 // TODO(phajdan.jr): Explicitly pass the info that the test didn't |
| 245 // run for a mysterious reason. | 256 // run for a mysterious reason. |
| 246 LOG(ERROR) << "no test result for " << tests[i].GetFullName(); | 257 LOG(ERROR) << "no test result for " << tests[i].GetFullName(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 365 |
| 355 fprintf(stdout, | 366 fprintf(stdout, |
| 356 "Tests took %" PRId64 " seconds.\n", | 367 "Tests took %" PRId64 " seconds.\n", |
| 357 (base::TimeTicks::Now() - start_time).InSeconds()); | 368 (base::TimeTicks::Now() - start_time).InSeconds()); |
| 358 fflush(stdout); | 369 fflush(stdout); |
| 359 | 370 |
| 360 return exit_code; | 371 return exit_code; |
| 361 } | 372 } |
| 362 | 373 |
| 363 } // namespace base | 374 } // namespace base |
| OLD | NEW |