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

Unified Diff: base/test/launcher/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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/launcher/parallel_test_launcher.cc ('k') | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/launcher/test_launcher.h
diff --git a/base/test/launcher/test_launcher.h b/base/test/launcher/test_launcher.h
index 177d12d934b381eaadcebd9d779fd81475218b33..1ff1c05ea4706f457fc6cdcb7d3c729e63066dc0 100644
--- a/base/test/launcher/test_launcher.h
+++ b/base/test/launcher/test_launcher.h
@@ -14,6 +14,7 @@
#include "base/test/launcher/test_result.h"
#include "base/test/launcher/test_results_tracker.h"
#include "base/time/time.h"
+#include "base/timer/timer.h"
class CommandLine;
@@ -25,6 +26,7 @@ class TestInfo;
namespace base {
struct LaunchOptions;
+class SequencedWorkerPoolOwner;
class TestLauncher;
// Constants for GTest command-line flags.
@@ -80,12 +82,31 @@ class TestLauncherDelegate {
// Launches tests using a TestLauncherDelegate.
class TestLauncher {
public:
- explicit TestLauncher(TestLauncherDelegate* launcher_delegate);
+ // Constructor. |parallel_jobs| is the limit of simultaneous parallel test
+ // jobs.
+ TestLauncher(TestLauncherDelegate* launcher_delegate, size_t parallel_jobs);
~TestLauncher();
// Runs the launcher. Must be called at most once.
bool Run(int argc, char** argv) WARN_UNUSED_RESULT;
+ // Callback called after a child process finishes. First argument is the exit
+ // code, second one is child process elapsed time, third one is true if
+ // the child process was terminated because of a timeout, and fourth one
+ // contains output of the child (stdout and stderr together).
+ typedef Callback<void(int, const TimeDelta&, bool, const std::string&)>
+ LaunchChildGTestProcessCallback;
+
+ // Launches a child process (assumed to be gtest-based binary) using
+ // |command_line|. If |wrapper| is not empty, it is prepended to the final
+ // command line. If the child process is still running after |timeout|, it
+ // is terminated. After the child process finishes |callback| is called
+ // on the same thread this method was called.
+ void LaunchChildGTestProcess(const CommandLine& command_line,
+ const std::string& wrapper,
+ base::TimeDelta timeout,
+ const LaunchChildGTestProcessCallback& callback);
+
// Called when a test has finished running.
void OnTestFinished(const TestResult& result);
@@ -97,11 +118,27 @@ class TestLauncher {
void RunTestIteration();
- void OnAllTestsStarted();
-
// Saves test results summary as JSON if requested from command line.
void MaybeSaveSummaryAsJSON();
+ // Called on a worker thread after a child process finishes.
+ void OnLaunchTestProcessFinished(
+ const LaunchChildGTestProcessCallback& callback,
+ int exit_code,
+ const TimeDelta& elapsed_time,
+ bool was_timeout,
+ const std::string& output);
+
+ // Called by the delay timer when no output was made for a while.
+ void OnOutputTimeout();
+
+ // Make sure we don't accidentally call the wrong methods e.g. on the worker
+ // pool thread. With lots of callbacks used this is non-trivial.
+ // Should be the first member so that it's destroyed last: when destroying
+ // other members, especially the worker pool, we may check the code is running
+ // on the correct thread.
+ ThreadChecker thread_checker_;
+
TestLauncherDelegate* launcher_delegate_;
// Support for outer sharding, just like gtest does.
@@ -141,6 +178,12 @@ class TestLauncher {
TestResultsTracker results_tracker_;
+ // Watchdog timer to make sure we do not go without output for too long.
+ DelayTimer<TestLauncher> watchdog_timer_;
+
+ // Worker pool used to launch processes in parallel.
+ scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_;
+
DISALLOW_COPY_AND_ASSIGN(TestLauncher);
};
« no previous file with comments | « base/test/launcher/parallel_test_launcher.cc ('k') | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698