Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: base/test/launcher/unit_test_launcher.cc

Issue 476543004: Implement unit test specific test launcher timeout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: after disabling Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 GetCommandLineForChildGTestProcess(current_test_names, output_file)); 179 GetCommandLineForChildGTestProcess(current_test_names, output_file));
180 180
181 GTestCallbackState callback_state; 181 GTestCallbackState callback_state;
182 callback_state.test_launcher = test_launcher; 182 callback_state.test_launcher = test_launcher;
183 callback_state.test_names = current_test_names; 183 callback_state.test_names = current_test_names;
184 callback_state.output_file = output_file; 184 callback_state.output_file = output_file;
185 185
186 test_launcher->LaunchChildGTestProcess( 186 test_launcher->LaunchChildGTestProcess(
187 cmd_line, 187 cmd_line,
188 std::string(), 188 std::string(),
189 TestTimeouts::test_launcher_timeout(), 189 TestTimeouts::test_launcher_unit_timeout(),
190 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0, 190 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0,
191 Bind(&UnitTestLauncherDelegate::SerialGTestCallback, 191 Bind(&UnitTestLauncherDelegate::SerialGTestCallback,
192 Unretained(this), 192 Unretained(this),
193 callback_state, 193 callback_state,
194 new_test_names)); 194 new_test_names));
195 } 195 }
196 196
197 void RunBatch(TestLauncher* test_launcher, 197 void RunBatch(TestLauncher* test_launcher,
198 const std::vector<std::string>& test_names) { 198 const std::vector<std::string>& test_names) {
199 DCHECK(thread_checker_.CalledOnValidThread()); 199 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 11 matching lines...) Expand all
211 CommandLine cmd_line( 211 CommandLine cmd_line(
212 GetCommandLineForChildGTestProcess(test_names, output_file)); 212 GetCommandLineForChildGTestProcess(test_names, output_file));
213 213
214 // Adjust the timeout depending on how many tests we're running 214 // Adjust the timeout depending on how many tests we're running
215 // (note that e.g. the last batch of tests will be smaller). 215 // (note that e.g. the last batch of tests will be smaller).
216 // TODO(phajdan.jr): Consider an adaptive timeout, which can change 216 // TODO(phajdan.jr): Consider an adaptive timeout, which can change
217 // depending on how many tests ran and how many remain. 217 // depending on how many tests ran and how many remain.
218 // Note: do NOT parse child's stdout to do that, it's known to be 218 // Note: do NOT parse child's stdout to do that, it's known to be
219 // unreliable (e.g. buffering issues can mix up the output). 219 // unreliable (e.g. buffering issues can mix up the output).
220 base::TimeDelta timeout = 220 base::TimeDelta timeout =
221 test_names.size() * TestTimeouts::test_launcher_timeout(); 221 test_names.size() * TestTimeouts::test_launcher_unit_timeout();
222 222
223 GTestCallbackState callback_state; 223 GTestCallbackState callback_state;
224 callback_state.test_launcher = test_launcher; 224 callback_state.test_launcher = test_launcher;
225 callback_state.test_names = test_names; 225 callback_state.test_names = test_names;
226 callback_state.output_file = output_file; 226 callback_state.output_file = output_file;
227 227
228 test_launcher->LaunchChildGTestProcess( 228 test_launcher->LaunchChildGTestProcess(
229 cmd_line, 229 cmd_line,
230 std::string(), 230 std::string(),
231 timeout, 231 timeout,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 test_result.status = TestResult::TEST_TIMEOUT; 338 test_result.status = TestResult::TEST_TIMEOUT;
339 } 339 }
340 } else if (test_result.status == TestResult::TEST_SUCCESS || 340 } else if (test_result.status == TestResult::TEST_SUCCESS ||
341 test_result.status == TestResult::TEST_FAILURE) { 341 test_result.status == TestResult::TEST_FAILURE) {
342 // We run multiple tests in a batch with a timeout applied 342 // We run multiple tests in a batch with a timeout applied
343 // to the entire batch. It is possible that with other tests 343 // to the entire batch. It is possible that with other tests
344 // running quickly some tests take longer than the per-test timeout. 344 // running quickly some tests take longer than the per-test timeout.
345 // For consistent handling of tests independent of order and other 345 // For consistent handling of tests independent of order and other
346 // factors, mark them as timing out. 346 // factors, mark them as timing out.
347 if (test_result.elapsed_time > 347 if (test_result.elapsed_time >
348 TestTimeouts::test_launcher_timeout()) { 348 TestTimeouts::test_launcher_unit_timeout()) {
349 test_result.status = TestResult::TEST_TIMEOUT; 349 test_result.status = TestResult::TEST_TIMEOUT;
350 } 350 }
351 } 351 }
352 test_result.output_snippet = 352 test_result.output_snippet =
353 GetTestOutputSnippet(test_result, output); 353 GetTestOutputSnippet(test_result, output);
354 final_results.push_back(test_result); 354 final_results.push_back(test_result);
355 } else if (had_interrupted_test) { 355 } else if (had_interrupted_test) {
356 tests_to_relaunch->push_back(test_names[i]); 356 tests_to_relaunch->push_back(test_names[i]);
357 } else { 357 } else {
358 // TODO(phajdan.jr): Explicitly pass the info that the test didn't 358 // TODO(phajdan.jr): Explicitly pass the info that the test didn't
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 CommandLine::Init(argc, NULL); 577 CommandLine::Init(argc, NULL);
578 return LaunchUnitTestsInternal( 578 return LaunchUnitTestsInternal(
579 run_test_suite, 579 run_test_suite,
580 SysInfo::NumberOfProcessors(), 580 SysInfo::NumberOfProcessors(),
581 use_job_objects, 581 use_job_objects,
582 Bind(&InitGoogleTestWChar, &argc, argv)); 582 Bind(&InitGoogleTestWChar, &argc, argv));
583 } 583 }
584 #endif // defined(OS_WIN) 584 #endif // defined(OS_WIN)
585 585
586 } // namespace base 586 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698