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

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

Issue 131663002: Only print summary of all test iterations if there is more than one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/launcher/test_results_tracker.cc » ('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/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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 TestLauncher::~TestLauncher() { 336 TestLauncher::~TestLauncher() {
337 if (worker_pool_owner_) 337 if (worker_pool_owner_)
338 worker_pool_owner_->pool()->Shutdown(); 338 worker_pool_owner_->pool()->Shutdown();
339 } 339 }
340 340
341 bool TestLauncher::Run(int argc, char** argv) { 341 bool TestLauncher::Run(int argc, char** argv) {
342 if (!Init()) 342 if (!Init())
343 return false; 343 return false;
344 344
345 // Value of |cycles_| changes after each iteration. Keep track of the
346 // original value.
347 int requested_cycles = cycles_;
348
345 #if defined(OS_POSIX) 349 #if defined(OS_POSIX)
346 CHECK_EQ(0, pipe(g_shutdown_pipe)); 350 CHECK_EQ(0, pipe(g_shutdown_pipe));
347 351
348 struct sigaction action; 352 struct sigaction action;
349 memset(&action, 0, sizeof(action)); 353 memset(&action, 0, sizeof(action));
350 sigemptyset(&action.sa_mask); 354 sigemptyset(&action.sa_mask);
351 action.sa_handler = &ShutdownPipeSignalHandler; 355 action.sa_handler = &ShutdownPipeSignalHandler;
352 356
353 CHECK_EQ(0, sigaction(SIGINT, &action, NULL)); 357 CHECK_EQ(0, sigaction(SIGINT, &action, NULL));
354 CHECK_EQ(0, sigaction(SIGQUIT, &action, NULL)); 358 CHECK_EQ(0, sigaction(SIGQUIT, &action, NULL));
(...skipping 12 matching lines...) Expand all
367 371
368 // Start the watchdog timer. 372 // Start the watchdog timer.
369 watchdog_timer_.Reset(); 373 watchdog_timer_.Reset();
370 374
371 MessageLoop::current()->PostTask( 375 MessageLoop::current()->PostTask(
372 FROM_HERE, 376 FROM_HERE,
373 Bind(&TestLauncher::RunTestIteration, Unretained(this))); 377 Bind(&TestLauncher::RunTestIteration, Unretained(this)));
374 378
375 MessageLoop::current()->Run(); 379 MessageLoop::current()->Run();
376 380
377 if (cycles_ != 1) 381 if (requested_cycles != 1)
378 results_tracker_.PrintSummaryOfAllIterations(); 382 results_tracker_.PrintSummaryOfAllIterations();
379 383
380 MaybeSaveSummaryAsJSON(); 384 MaybeSaveSummaryAsJSON();
381 385
382 return run_result_; 386 return run_result_;
383 } 387 }
384 388
385 void TestLauncher::LaunchChildGTestProcess( 389 void TestLauncher::LaunchChildGTestProcess(
386 const CommandLine& command_line, 390 const CommandLine& command_line,
387 const std::string& wrapper, 391 const std::string& wrapper,
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 int exit_code, 857 int exit_code,
854 const TimeDelta& elapsed_time, 858 const TimeDelta& elapsed_time,
855 bool was_timeout, 859 bool was_timeout,
856 const std::string& output) { 860 const std::string& output) {
857 DCHECK(thread_checker_.CalledOnValidThread()); 861 DCHECK(thread_checker_.CalledOnValidThread());
858 862
859 callback.Run(exit_code, elapsed_time, was_timeout, output); 863 callback.Run(exit_code, elapsed_time, was_timeout, output);
860 } 864 }
861 865
862 void TestLauncher::OnTestIterationFinished() { 866 void TestLauncher::OnTestIterationFinished() {
863 // The current iteration is done.
864 fprintf(stdout, "%" PRIuS " test%s run\n",
865 test_finished_count_,
866 test_finished_count_ > 1 ? "s" : "");
867 fflush(stdout);
868
869 results_tracker_.PrintSummaryOfCurrentIteration();
870
871 // When we retry tests, success is determined by having nothing more 867 // When we retry tests, success is determined by having nothing more
872 // to retry (everything eventually passed), as opposed to having 868 // to retry (everything eventually passed), as opposed to having
873 // no failures at all. 869 // no failures at all.
874 if (!tests_to_retry_.empty()) { 870 if (tests_to_retry_.empty()) {
871 fprintf(stdout, "SUCCESS: all tests passed.\n");
872 fflush(stdout);
873 } else {
875 // Signal failure, but continue to run all requested test iterations. 874 // Signal failure, but continue to run all requested test iterations.
876 // With the summary of all iterations at the end this is a good default. 875 // With the summary of all iterations at the end this is a good default.
877 run_result_ = false; 876 run_result_ = false;
878 } 877 }
879 878
879 results_tracker_.PrintSummaryOfCurrentIteration();
880
880 // Kick off the next iteration. 881 // Kick off the next iteration.
881 MessageLoop::current()->PostTask( 882 MessageLoop::current()->PostTask(
882 FROM_HERE, 883 FROM_HERE,
883 Bind(&TestLauncher::RunTestIteration, Unretained(this))); 884 Bind(&TestLauncher::RunTestIteration, Unretained(this)));
884 } 885 }
885 886
886 void TestLauncher::OnOutputTimeout() { 887 void TestLauncher::OnOutputTimeout() {
887 DCHECK(thread_checker_.CalledOnValidThread()); 888 DCHECK(thread_checker_.CalledOnValidThread());
888 889
889 AutoLock lock(g_live_processes_lock.Get()); 890 AutoLock lock(g_live_processes_lock.Get());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1062
1062 g_live_processes.Get().erase(process_handle); 1063 g_live_processes.Get().erase(process_handle);
1063 } 1064 }
1064 1065
1065 base::CloseProcessHandle(process_handle); 1066 base::CloseProcessHandle(process_handle);
1066 1067
1067 return exit_code; 1068 return exit_code;
1068 } 1069 }
1069 1070
1070 } // namespace base 1071 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/test/launcher/test_results_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698