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

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

Issue 24892002: GTTF: Fix handling of PRE_ tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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/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
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 #ifndef BASE_TEST_PARALLEL_TEST_LAUNCHER_H_ 5 #ifndef BASE_TEST_PARALLEL_TEST_LAUNCHER_H_
6 #define BASE_TEST_PARALLEL_TEST_LAUNCHER_H_ 6 #define BASE_TEST_PARALLEL_TEST_LAUNCHER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/threading/sequenced_worker_pool.h"
13 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
15 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
16 15
17 class CommandLine; 16 class CommandLine;
18 17
19 namespace base { 18 namespace base {
20 19
21 class SequencedWorkerPoolOwner; 20 class SequencedWorkerPoolOwner;
22 class Timer;
23 21
24 // Launches child gtest process in parallel. Keeps track of running processes, 22 // Launches child gtest process in parallel. Keeps track of running processes,
25 // prints a message in case no output is produced for a while. 23 // prints a message in case no output is produced for a while.
26 class ParallelTestLauncher { 24 class ParallelTestLauncher {
27 public: 25 public:
28 // Constructor. |jobs| is the maximum number of tests launched in parallel. 26 // Constructor. |jobs| is the maximum number of tests launched in parallel.
29 explicit ParallelTestLauncher(size_t jobs); 27 explicit ParallelTestLauncher(size_t jobs);
30 ~ParallelTestLauncher(); 28 ~ParallelTestLauncher();
31 29
32 // Callback called after a child process finishes. First argument is the exit 30 // Callback called after a child process finishes. First argument is the exit
33 // code, second one is child process elapsed time, third one is true if 31 // code, second one is child process elapsed time, third one is true if
34 // the child process was terminated because of a timeout, and fourth one 32 // the child process was terminated because of a timeout, and fourth one
35 // contains output of the child (stdout and stderr together). 33 // contains output of the child (stdout and stderr together).
36 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)> 34 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)>
37 LaunchChildGTestProcessCallback; 35 LaunchChildGTestProcessCallback;
38 36
39 // Launches a child process (assumed to be gtest-based binary) using 37 // Launches a child process (assumed to be gtest-based binary) using
40 // |command_line|. If |wrapper| is not empty, it is prepended to the final 38 // |command_line|. If |wrapper| is not empty, it is prepended to the final
41 // command line. If the child process is still running after |timeout|, it 39 // command line. If the child process is still running after |timeout|, it
42 // is terminated. After the child process finishes |callback| is called 40 // is terminated. After the child process finishes |callback| is called
43 // on the same thread this method was called. 41 // on the same thread this method was called.
44 void LaunchChildGTestProcess(const CommandLine& command_line, 42 void LaunchChildGTestProcess(const CommandLine& command_line,
45 const std::string& wrapper, 43 const std::string& wrapper,
46 base::TimeDelta timeout, 44 base::TimeDelta timeout,
47 const LaunchChildGTestProcessCallback& callback); 45 const LaunchChildGTestProcessCallback& callback);
48 46
49 // Similar to above, but with processes sharing the same value of |token_name|
50 // being serialized, with order matching order of calls of this method.
51 void LaunchNamedSequencedChildGTestProcess(
52 const std::string& token_name,
53 const CommandLine& command_line,
54 const std::string& wrapper,
55 base::TimeDelta timeout,
56 const LaunchChildGTestProcessCallback& callback);
57
58 // Resets the output watchdog, indicating some test results have been printed 47 // Resets the output watchdog, indicating some test results have been printed
59 // out. If a pause between the calls exceeds an internal treshold, a message 48 // out. If a pause between the calls exceeds an internal treshold, a message
60 // will be printed listing all child processes we're still waiting for. 49 // will be printed listing all child processes we're still waiting for.
61 void ResetOutputWatchdog(); 50 void ResetOutputWatchdog();
62 51
63 private: 52 private:
64 void LaunchSequencedChildGTestProcess(
65 SequencedWorkerPool::SequenceToken sequence_token,
66 const CommandLine& command_line,
67 const std::string& wrapper,
68 base::TimeDelta timeout,
69 const LaunchChildGTestProcessCallback& callback);
70
71 // Called on a worker thread after a child process finishes. 53 // Called on a worker thread after a child process finishes.
72 void OnLaunchTestProcessFinished( 54 void OnLaunchTestProcessFinished(
73 size_t sequence_number, 55 size_t sequence_number,
74 const LaunchChildGTestProcessCallback& callback, 56 const LaunchChildGTestProcessCallback& callback,
75 int exit_code, 57 int exit_code,
76 const TimeDelta& elapsed_time, 58 const TimeDelta& elapsed_time,
77 bool was_timeout, 59 bool was_timeout,
78 const std::string& output); 60 const std::string& output);
79 61
80 // Called by the delay timer when no output was made for a while. 62 // Called by the delay timer when no output was made for a while.
(...skipping 19 matching lines...) Expand all
100 82
101 // Worker pool used to launch processes in parallel. 83 // Worker pool used to launch processes in parallel.
102 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_; 84 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_;
103 85
104 DISALLOW_COPY_AND_ASSIGN(ParallelTestLauncher); 86 DISALLOW_COPY_AND_ASSIGN(ParallelTestLauncher);
105 }; 87 };
106 88
107 } // namespace base 89 } // namespace base
108 90
109 #endif // BASE_TEST_PARALLEL_TEST_LAUNCHER_H_ 91 #endif // BASE_TEST_PARALLEL_TEST_LAUNCHER_H_
OLDNEW
« no previous file with comments | « no previous file | base/test/parallel_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698