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

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

Issue 441333002: Disallow breakaway from job for unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 4 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/launcher/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_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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 virtual size_t RetryTests(TestLauncher* test_launcher, 62 virtual size_t RetryTests(TestLauncher* test_launcher,
63 const std::vector<std::string>& test_names) = 0; 63 const std::vector<std::string>& test_names) = 0;
64 64
65 protected: 65 protected:
66 virtual ~TestLauncherDelegate(); 66 virtual ~TestLauncherDelegate();
67 }; 67 };
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 // Flags controlling behavior of LaunchChildGTestProcess.
73 enum LaunchChildGTestProcessFlags {
74 // Allows usage of job objects on Windows. Helps properly clean up child
75 // processes.
76 USE_JOB_OBJECTS = (1 << 0),
77
78 // Allows breakaway from job on Windows. May result in some child processes
79 // not being properly terminated after launcher dies if these processes
80 // fail to cooperate.
81 ALLOW_BREAKAWAY_FROM_JOB = (1 << 1),
82 };
83
72 // Constructor. |parallel_jobs| is the limit of simultaneous parallel test 84 // Constructor. |parallel_jobs| is the limit of simultaneous parallel test
73 // jobs. 85 // jobs.
74 TestLauncher(TestLauncherDelegate* launcher_delegate, size_t parallel_jobs); 86 TestLauncher(TestLauncherDelegate* launcher_delegate, size_t parallel_jobs);
75 ~TestLauncher(); 87 ~TestLauncher();
76 88
77 // Runs the launcher. Must be called at most once. 89 // Runs the launcher. Must be called at most once.
78 bool Run() WARN_UNUSED_RESULT; 90 bool Run() WARN_UNUSED_RESULT;
79 91
80 // Callback called after a child process finishes. First argument is the exit 92 // 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 93 // 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 94 // the child process was terminated because of a timeout, and fourth one
83 // contains output of the child (stdout and stderr together). 95 // contains output of the child (stdout and stderr together).
84 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)> 96 typedef Callback<void(int, const TimeDelta&, bool, const std::string&)>
85 LaunchChildGTestProcessCallback; 97 LaunchChildGTestProcessCallback;
86 98
87 // Launches a child process (assumed to be gtest-based binary) using 99 // 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 100 // |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 101 // command line. If the child process is still running after |timeout|, it
90 // is terminated. |use_job_objects| determines whether job objects are used 102 // is terminated. After the child process finishes |callback| is called
91 // on Windows (if unsure pass true). After the child process finishes 103 // 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, 104 void LaunchChildGTestProcess(const CommandLine& command_line,
94 const std::string& wrapper, 105 const std::string& wrapper,
95 base::TimeDelta timeout, 106 base::TimeDelta timeout,
96 bool use_job_objects, 107 int flags,
97 const LaunchChildGTestProcessCallback& callback); 108 const LaunchChildGTestProcessCallback& callback);
98 109
99 // Called when a test has finished running. 110 // Called when a test has finished running.
100 void OnTestFinished(const TestResult& result); 111 void OnTestFinished(const TestResult& result);
101 112
102 // Constructs a full test name given a test case name and a test name. 113 // Constructs a full test name given a test case name and a test name.
103 static std::string FormatFullTestName(const std::string& test_case_name, 114 static std::string FormatFullTestName(const std::string& test_case_name,
104 const std::string& test_name); 115 const std::string& test_name);
105 116
106 private: 117 private:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 const std::string& full_output); 202 const std::string& full_output);
192 203
193 // Returns command line command line after gtest-specific processing 204 // Returns command line command line after gtest-specific processing
194 // and applying |wrapper|. 205 // and applying |wrapper|.
195 CommandLine PrepareCommandLineForGTest(const CommandLine& command_line, 206 CommandLine PrepareCommandLineForGTest(const CommandLine& command_line,
196 const std::string& wrapper); 207 const std::string& wrapper);
197 208
198 } // namespace base 209 } // namespace base
199 210
200 #endif // BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_ 211 #endif // BASE_TEST_LAUNCHER_TEST_LAUNCHER_H_
OLDNEW
« no previous file with comments | « no previous file | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698