| 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() WARN_UNUSED_RESULT; | 78 bool Run(int argc, char** argv) 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. |use_job_objects| determines whether job objects are used | 90 // is terminated. After the child process finishes |callback| is called |
| 91 // on Windows (if unsure pass true). After the child process finishes | 91 // on the same thread this method was called. |
| 92 // |callback| is called on the same thread this method was called. | |
| 93 void LaunchChildGTestProcess(const CommandLine& command_line, | 92 void LaunchChildGTestProcess(const CommandLine& command_line, |
| 94 const std::string& wrapper, | 93 const std::string& wrapper, |
| 95 base::TimeDelta timeout, | 94 base::TimeDelta timeout, |
| 96 bool use_job_objects, | |
| 97 const LaunchChildGTestProcessCallback& callback); | 95 const LaunchChildGTestProcessCallback& callback); |
| 98 | 96 |
| 99 // Called when a test has finished running. | 97 // Called when a test has finished running. |
| 100 void OnTestFinished(const TestResult& result); | 98 void OnTestFinished(const TestResult& result); |
| 101 | 99 |
| 102 private: | 100 private: |
| 103 bool Init() WARN_UNUSED_RESULT; | 101 bool Init() WARN_UNUSED_RESULT; |
| 104 | 102 |
| 105 // Runs all tests in current iteration. Uses callbacks to communicate success. | 103 // Runs all tests in current iteration. Uses callbacks to communicate success. |
| 106 void RunTests(); | 104 void RunTests(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Worker pool used to launch processes in parallel. | 177 // Worker pool used to launch processes in parallel. |
| 180 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_; | 178 scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_; |
| 181 | 179 |
| 182 DISALLOW_COPY_AND_ASSIGN(TestLauncher); | 180 DISALLOW_COPY_AND_ASSIGN(TestLauncher); |
| 183 }; | 181 }; |
| 184 | 182 |
| 185 // Extract part from |full_output| that applies to |result|. | 183 // Extract part from |full_output| that applies to |result|. |
| 186 std::string GetTestOutputSnippet(const TestResult& result, | 184 std::string GetTestOutputSnippet(const TestResult& result, |
| 187 const std::string& full_output); | 185 const std::string& full_output); |
| 188 | 186 |
| 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 |
| 189 // Returns command line command line after gtest-specific processing | 196 // Returns command line command line after gtest-specific processing |
| 190 // and applying |wrapper|. | 197 // and applying |wrapper|. |
| 191 CommandLine PrepareCommandLineForGTest(const CommandLine& command_line, | 198 CommandLine PrepareCommandLineForGTest(const CommandLine& command_line, |
| 192 const std::string& wrapper); | 199 const std::string& wrapper); |
| 193 | 200 |
| 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 |
| 194 } // namespace base | 209 } // namespace base |
| 195 | 210 |
| 196 #endif // BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ | 211 #endif // BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ |
| OLD | NEW |