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

Side by Side Diff: base/test/launcher/parallel_test_launcher.h

Issue 55473002: GTTF: Unify parallel test launching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reupload Created 7 years, 1 month 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/base.gyp ('k') | base/test/launcher/parallel_test_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_TEST_LAUNCHER_PARALLEL_TEST_LAUNCHER_H_
6 #define BASE_TEST_LAUNCHER_PARALLEL_TEST_LAUNCHER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/threading/thread_checker.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
15
16 class CommandLine;
17
18 namespace base {
19
20 class SequencedWorkerPoolOwner;
21
22 // Launches child gtest process in parallel. Keeps track of running processes,
23 // prints a message in case no output is produced for a while.
24 class ParallelTestLauncher {
25 public:
26 // Constructor. |jobs| is the maximum number of tests launched in parallel.
27 explicit ParallelTestLauncher(size_t jobs);
28 ~ParallelTestLauncher();
29
30 // Callback called after a child process finishes. First argument is the exit
31 // code, second one is child process elapsed time, third one is true if
32 // the child process was terminated because of a timeout, and fourth one
33 // contains output of the child (stdout and stderr together).
34 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)>
35 LaunchChildGTestProcessCallback;
36
37 // Launches a child process (assumed to be gtest-based binary) using
38 // |command_line|. If |wrapper| is not empty, it is prepended to the final
39 // command line. If the child process is still running after |timeout|, it
40 // is terminated. After the child process finishes |callback| is called
41 // on the same thread this method was called.
42 void LaunchChildGTestProcess(const CommandLine& command_line,
43 const std::string& wrapper,
44 base::TimeDelta timeout,
45 const LaunchChildGTestProcessCallback& callback);
46
47 // Resets the output watchdog, indicating some test results have been printed
48 // out. If a pause between the calls exceeds an internal treshold, a message
49 // will be printed listing all child processes we're still waiting for.
50 void ResetOutputWatchdog();
51
52 private:
53 // Called on a worker thread after a child process finishes.
54 void OnLaunchTestProcessFinished(
55 size_t sequence_number,
56 const LaunchChildGTestProcessCallback& callback,
57 int exit_code,
58 const TimeDelta& elapsed_time,
59 bool was_timeout,
60 const std::string& output);
61
62 // Called by the delay timer when no output was made for a while.
63 void OnOutputTimeout();
64
65 // Make sure we don't accidentally call the wrong methods e.g. on the worker
66 // pool thread. With lots of callbacks used this is non-trivial.
67 // Should be the first member so that it's destroyed last: when destroying
68 // other members, especially the worker pool, we may check the code is running
69 // on the correct thread.
70 ThreadChecker thread_checker_;
71
72 // Watchdog timer to make sure we do not go without output for too long.
73 DelayTimer<ParallelTestLauncher> timer_;
74
75 // Monotonically increasing sequence number to uniquely identify each
76 // launched child process.
77 size_t launch_sequence_number_;
78
79 // Map of currently running child processes, keyed by the sequence number.
80 typedef std::map<size_t, CommandLine> RunningProcessesMap;
81 RunningProcessesMap running_processes_map_;
82
83 // Worker pool used to launch processes in parallel.
84 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_;
85
86 DISALLOW_COPY_AND_ASSIGN(ParallelTestLauncher);
87 };
88
89 } // namespace base
90
91 #endif // BASE_TEST_LAUNCHER_PARALLEL_TEST_LAUNCHER_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/test/launcher/parallel_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698