OLD | NEW |
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_LAUNCHER_TEST_LAUNCHER_H_ | 5 #ifndef BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ |
6 #define BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ | 6 #define BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 // Launches tests using a TestLauncherDelegate. | 69 // Launches tests using a TestLauncherDelegate. |
70 class TestLauncher { | 70 class TestLauncher { |
71 public: | 71 public: |
72 // Constructor. |parallel_jobs| is the limit of simultaneous parallel test | 72 // Constructor. |parallel_jobs| is the limit of simultaneous parallel test |
73 // jobs. | 73 // jobs. |
74 TestLauncher(TestLauncherDelegate* launcher_delegate, size_t parallel_jobs); | 74 TestLauncher(TestLauncherDelegate* launcher_delegate, size_t parallel_jobs); |
75 ~TestLauncher(); | 75 ~TestLauncher(); |
76 | 76 |
77 // Runs the launcher. Must be called at most once. | 77 // Runs the launcher. Must be called at most once. |
78 bool Run(int argc, char** argv) WARN_UNUSED_RESULT; | 78 bool Run() WARN_UNUSED_RESULT; |
79 | 79 |
80 // Callback called after a child process finishes. First argument is the exit | 80 // Callback called after a child process finishes. First argument is the exit |
81 // code, second one is child process elapsed time, third one is true if | 81 // code, second one is child process elapsed time, third one is true if |
82 // the child process was terminated because of a timeout, and fourth one | 82 // the child process was terminated because of a timeout, and fourth one |
83 // contains output of the child (stdout and stderr together). | 83 // contains output of the child (stdout and stderr together). |
84 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)> | 84 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)> |
85 LaunchChildGTestProcessCallback; | 85 LaunchChildGTestProcessCallback; |
86 | 86 |
87 // Launches a child process (assumed to be gtest-based binary) using | 87 // Launches a child process (assumed to be gtest-based binary) using |
88 // |command_line|. If |wrapper| is not empty, it is prepended to the final | 88 // |command_line|. If |wrapper| is not empty, it is prepended to the final |
89 // command line. If the child process is still running after |timeout|, it | 89 // command line. If the child process is still running after |timeout|, it |
90 // is terminated. After the child process finishes |callback| is called | 90 // is terminated. |use_job_objects| determines whether job objects are used |
91 // on the same thread this method was called. | 91 // on Windows (if unsure pass true). After the child process finishes |
| 92 // |callback| is called on the same thread this method was called. |
92 void LaunchChildGTestProcess(const CommandLine& command_line, | 93 void LaunchChildGTestProcess(const CommandLine& command_line, |
93 const std::string& wrapper, | 94 const std::string& wrapper, |
94 base::TimeDelta timeout, | 95 base::TimeDelta timeout, |
| 96 bool use_job_objects, |
95 const LaunchChildGTestProcessCallback& callback); | 97 const LaunchChildGTestProcessCallback& callback); |
96 | 98 |
97 // Called when a test has finished running. | 99 // Called when a test has finished running. |
98 void OnTestFinished(const TestResult& result); | 100 void OnTestFinished(const TestResult& result); |
99 | 101 |
100 private: | 102 private: |
101 bool Init() WARN_UNUSED_RESULT; | 103 bool Init() WARN_UNUSED_RESULT; |
102 | 104 |
103 // Runs all tests in current iteration. Uses callbacks to communicate success. | 105 // Runs all tests in current iteration. Uses callbacks to communicate success. |
104 void RunTests(); | 106 void RunTests(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Worker pool used to launch processes in parallel. | 179 // Worker pool used to launch processes in parallel. |
178 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_; | 180 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_; |
179 | 181 |
180 DISALLOW_COPY_AND_ASSIGN(TestLauncher); | 182 DISALLOW_COPY_AND_ASSIGN(TestLauncher); |
181 }; | 183 }; |
182 | 184 |
183 // Extract part from |full_output| that applies to |result|. | 185 // Extract part from |full_output| that applies to |result|. |
184 std::string GetTestOutputSnippet(const TestResult& result, | 186 std::string GetTestOutputSnippet(const TestResult& result, |
185 const std::string& full_output); | 187 const std::string& full_output); |
186 | 188 |
187 // Launches a child process (assumed to be gtest-based binary) | |
188 // using |command_line|. If |wrapper| is not empty, it is prepended | |
189 // to the final command line. If the child process is still running | |
190 // after |timeout|, it is terminated and |*was_timeout| is set to true. | |
191 int LaunchChildGTestProcess(const CommandLine& command_line, | |
192 const std::string& wrapper, | |
193 base::TimeDelta timeout, | |
194 bool* was_timeout); | |
195 | |
196 // Returns command line command line after gtest-specific processing | 189 // Returns command line command line after gtest-specific processing |
197 // and applying |wrapper|. | 190 // and applying |wrapper|. |
198 CommandLine PrepareCommandLineForGTest(const CommandLine& command_line, | 191 CommandLine PrepareCommandLineForGTest(const CommandLine& command_line, |
199 const std::string& wrapper); | 192 const std::string& wrapper); |
200 | 193 |
201 // Launches a child process using |command_line|. If the child process is still | |
202 // running after |timeout|, it is terminated and |*was_timeout| is set to true. | |
203 // Returns exit code of the process. | |
204 int LaunchChildTestProcessWithOptions(const CommandLine& command_line, | |
205 const LaunchOptions& options, | |
206 base::TimeDelta timeout, | |
207 bool* was_timeout); | |
208 | |
209 } // namespace base | 194 } // namespace base |
210 | 195 |
211 #endif // BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ | 196 #endif // BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ |
OLD | NEW |