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

Side by Side Diff: base/test/parallel_test_launcher.cc

Issue 23754019: Use SequencedWorkerPoolOwner in ParallelTestLauncher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « base/test/parallel_test_launcher.h ('k') | no next file » | 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/parallel_test_launcher.h" 5 #include "base/test/parallel_test_launcher.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 #endif 11 #endif
12 12
13 #if defined(OS_WIN) 13 #if defined(OS_WIN)
14 #include <windows.h> 14 #include <windows.h>
15 #endif 15 #endif
16 16
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/location.h" 20 #include "base/location.h"
21 #include "base/message_loop/message_loop_proxy.h" 21 #include "base/message_loop/message_loop_proxy.h"
22 #include "base/process/launch.h" 22 #include "base/process/launch.h"
23 #include "base/run_loop.h"
23 #include "base/test/test_launcher.h" 24 #include "base/test/test_launcher.h"
24 #include "base/threading/sequenced_worker_pool.h" 25 #include "base/test/sequenced_worker_pool_owner.h"
25 26
26 #if defined(OS_WIN) 27 #if defined(OS_WIN)
27 #include "base/win/scoped_handle.h" 28 #include "base/win/scoped_handle.h"
28 #endif 29 #endif
29 30
30 namespace base { 31 namespace base {
31 32
32 namespace { 33 namespace {
33 34
34 // Maximum time of no output after which we print list of processes still 35 // Maximum time of no output after which we print list of processes still
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 121 }
121 122
122 } // namespace 123 } // namespace
123 124
124 ParallelTestLauncher::ParallelTestLauncher(size_t jobs) 125 ParallelTestLauncher::ParallelTestLauncher(size_t jobs)
125 : timer_(FROM_HERE, 126 : timer_(FROM_HERE,
126 TimeDelta::FromSeconds(kOutputTimeoutSeconds), 127 TimeDelta::FromSeconds(kOutputTimeoutSeconds),
127 this, 128 this,
128 &ParallelTestLauncher::OnOutputTimeout), 129 &ParallelTestLauncher::OnOutputTimeout),
129 launch_sequence_number_(0), 130 launch_sequence_number_(0),
130 worker_pool_(new SequencedWorkerPool(jobs, "parallel_test_launcher")) { 131 worker_pool_owner_(
132 new SequencedWorkerPoolOwner(jobs, "parallel_test_launcher")) {
131 // Start the watchdog timer. 133 // Start the watchdog timer.
132 timer_.Reset(); 134 timer_.Reset();
133 } 135 }
134 136
135 ParallelTestLauncher::~ParallelTestLauncher() { 137 ParallelTestLauncher::~ParallelTestLauncher() {
136 DCHECK(thread_checker_.CalledOnValidThread()); 138 DCHECK(thread_checker_.CalledOnValidThread());
137 139
138 worker_pool_->Shutdown(); 140 worker_pool_owner_->pool()->Shutdown();
139 } 141 }
140 142
141 void ParallelTestLauncher::LaunchChildGTestProcess( 143 void ParallelTestLauncher::LaunchChildGTestProcess(
142 const CommandLine& command_line, 144 const CommandLine& command_line,
143 const std::string& wrapper, 145 const std::string& wrapper,
144 base::TimeDelta timeout, 146 base::TimeDelta timeout,
145 const LaunchChildGTestProcessCallback& callback) { 147 const LaunchChildGTestProcessCallback& callback) {
146 DCHECK(thread_checker_.CalledOnValidThread()); 148 DCHECK(thread_checker_.CalledOnValidThread());
147 149
148 // Record the exact command line used to launch the child. 150 // Record the exact command line used to launch the child.
149 CommandLine new_command_line( 151 CommandLine new_command_line(
150 PrepareCommandLineForGTest(command_line, wrapper)); 152 PrepareCommandLineForGTest(command_line, wrapper));
151 launch_sequence_number_++; 153 launch_sequence_number_++;
152 running_processes_map_.insert( 154 running_processes_map_.insert(
153 std::make_pair(launch_sequence_number_, new_command_line)); 155 std::make_pair(launch_sequence_number_, new_command_line));
154 156
155 worker_pool_->PostWorkerTask( 157 worker_pool_owner_->pool()->PostWorkerTask(
156 FROM_HERE, 158 FROM_HERE,
157 Bind(&DoLaunchChildTestProcess, 159 Bind(&DoLaunchChildTestProcess,
158 new_command_line, 160 new_command_line,
159 timeout, 161 timeout,
160 MessageLoopProxy::current(), 162 MessageLoopProxy::current(),
161 Bind(&ParallelTestLauncher::OnLaunchTestProcessFinished, 163 Bind(&ParallelTestLauncher::OnLaunchTestProcessFinished,
162 Unretained(this), 164 Unretained(this),
163 launch_sequence_number_, 165 launch_sequence_number_,
164 callback))); 166 callback)));
165 } 167 }
(...skipping 29 matching lines...) Expand all
195 #endif 197 #endif
196 } 198 }
197 199
198 fflush(stdout); 200 fflush(stdout);
199 201
200 // Arm the timer again - otherwise it would fire only once. 202 // Arm the timer again - otherwise it would fire only once.
201 timer_.Reset(); 203 timer_.Reset();
202 } 204 }
203 205
204 } // namespace base 206 } // namespace base
OLDNEW
« no previous file with comments | « base/test/parallel_test_launcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698