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

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

Issue 2692273008: Hacky slashy (Closed)
Patch Set: . Created 3 years, 10 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
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 #include <memory> 7 #include <memory>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Set of live launch test processes with corresponding lock (it is allowed 98 // Set of live launch test processes with corresponding lock (it is allowed
99 // for callers to launch processes on different threads). 99 // for callers to launch processes on different threads).
100 LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes 100 LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes
101 = LAZY_INSTANCE_INITIALIZER; 101 = LAZY_INSTANCE_INITIALIZER;
102 LazyInstance<Lock> g_live_processes_lock = LAZY_INSTANCE_INITIALIZER; 102 LazyInstance<Lock> g_live_processes_lock = LAZY_INSTANCE_INITIALIZER;
103 103
104 // Performance trace generator. 104 // Performance trace generator.
105 LazyInstance<TestLauncherTracer> g_tracer = LAZY_INSTANCE_INITIALIZER; 105 LazyInstance<TestLauncherTracer> g_tracer = LAZY_INSTANCE_INITIALIZER;
106 106
107 #if defined(OS_POSIX) 107 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
108 // Self-pipe that makes it possible to do complex shutdown handling 108 // Self-pipe that makes it possible to do complex shutdown handling
109 // outside of the signal handler. 109 // outside of the signal handler.
110 int g_shutdown_pipe[2] = { -1, -1 }; 110 int g_shutdown_pipe[2] = { -1, -1 };
111 111
112 void ShutdownPipeSignalHandler(int signal) { 112 void ShutdownPipeSignalHandler(int signal) {
113 HANDLE_EINTR(write(g_shutdown_pipe[1], "q", 1)); 113 HANDLE_EINTR(write(g_shutdown_pipe[1], "q", 1));
114 } 114 }
115 115
116 void KillSpawnedTestProcesses() { 116 void KillSpawnedTestProcesses() {
117 // Keep the lock until exiting the process to prevent further processes 117 // Keep the lock until exiting the process to prevent further processes
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 TestLauncher::~TestLauncher() {} 516 TestLauncher::~TestLauncher() {}
517 517
518 bool TestLauncher::Run() { 518 bool TestLauncher::Run() {
519 if (!Init()) 519 if (!Init())
520 return false; 520 return false;
521 521
522 // Value of |cycles_| changes after each iteration. Keep track of the 522 // Value of |cycles_| changes after each iteration. Keep track of the
523 // original value. 523 // original value.
524 int requested_cycles = cycles_; 524 int requested_cycles = cycles_;
525 525
526 #if defined(OS_POSIX) 526 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
527 CHECK_EQ(0, pipe(g_shutdown_pipe)); 527 CHECK_EQ(0, pipe(g_shutdown_pipe));
528 528
529 struct sigaction action; 529 struct sigaction action;
530 memset(&action, 0, sizeof(action)); 530 memset(&action, 0, sizeof(action));
531 sigemptyset(&action.sa_mask); 531 sigemptyset(&action.sa_mask);
532 action.sa_handler = &ShutdownPipeSignalHandler; 532 action.sa_handler = &ShutdownPipeSignalHandler;
533 533
534 CHECK_EQ(0, sigaction(SIGINT, &action, NULL)); 534 CHECK_EQ(0, sigaction(SIGINT, &action, NULL));
535 CHECK_EQ(0, sigaction(SIGQUIT, &action, NULL)); 535 CHECK_EQ(0, sigaction(SIGQUIT, &action, NULL));
536 CHECK_EQ(0, sigaction(SIGTERM, &action, NULL)); 536 CHECK_EQ(0, sigaction(SIGTERM, &action, NULL));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 result.status == TestResult::TEST_UNKNOWN) { 671 result.status == TestResult::TEST_UNKNOWN) {
672 test_broken_count_++; 672 test_broken_count_++;
673 } 673 }
674 size_t broken_threshold = 674 size_t broken_threshold =
675 std::max(static_cast<size_t>(20), test_found_count_ / 10); 675 std::max(static_cast<size_t>(20), test_found_count_ / 10);
676 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) { 676 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) {
677 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n", 677 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n",
678 test_broken_count_); 678 test_broken_count_);
679 fflush(stdout); 679 fflush(stdout);
680 680
681 #if defined(OS_POSIX) 681 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
682 KillSpawnedTestProcesses(); 682 KillSpawnedTestProcesses();
683 #endif // defined(OS_POSIX) 683 #endif // defined(OS_POSIX)
684 684
685 MaybeSaveSummaryAsJSON({"BROKEN_TEST_EARLY_EXIT", kUnreliableResultsTag}); 685 MaybeSaveSummaryAsJSON({"BROKEN_TEST_EARLY_EXIT", kUnreliableResultsTag});
686 686
687 exit(1); 687 exit(1);
688 } 688 }
689 689
690 if (test_finished_count_ != test_started_count_) 690 if (test_finished_count_ != test_started_count_)
691 return; 691 return;
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 } 1214 }
1215 1215
1216 std::string snippet(full_output.substr(run_pos)); 1216 std::string snippet(full_output.substr(run_pos));
1217 if (end_pos != std::string::npos) 1217 if (end_pos != std::string::npos)
1218 snippet = full_output.substr(run_pos, end_pos - run_pos); 1218 snippet = full_output.substr(run_pos, end_pos - run_pos);
1219 1219
1220 return snippet; 1220 return snippet;
1221 } 1221 }
1222 1222
1223 } // namespace base 1223 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698