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

Unified Diff: base/test/launcher/test_launcher.cc

Issue 2112253002: Add basic tracing support to the gtest launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sort Created 4 years, 6 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/BUILD.gn ('k') | base/test/launcher/test_launcher_tracer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/launcher/test_launcher.cc
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index cfd08fbc49ca6d89c121076eddc3c5d60b125550..c23dc8cb542a3bc4762eea7479d9ce38be3a7ae8 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -31,6 +31,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/gtest_util.h"
+#include "base/test/launcher/test_launcher_tracer.h"
#include "base/test/launcher/test_results_tracker.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/test/test_switches.h"
@@ -90,6 +91,9 @@ LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes
= LAZY_INSTANCE_INITIALIZER;
LazyInstance<Lock> g_live_processes_lock = LAZY_INSTANCE_INITIALIZER;
+// Performance trace generator.
+LazyInstance<TestLauncherTracer> g_tracer = LAZY_INSTANCE_INITIALIZER;
+
#if defined(OS_POSIX)
// Self-pipe that makes it possible to do complex shutdown handling
// outside of the signal handler.
@@ -253,6 +257,8 @@ int LaunchChildTestProcessWithOptions(
TimeDelta timeout,
const TestLauncher::GTestProcessLaunchedCallback& launched_callback,
bool* was_timeout) {
+ TimeTicks start_time(TimeTicks::Now());
+
#if defined(OS_POSIX)
// Make sure an option we rely on is present - see LaunchChildGTestProcess.
DCHECK(options.new_process_group);
@@ -344,6 +350,9 @@ int LaunchChildTestProcessWithOptions(
g_live_processes.Get().erase(process.Handle());
}
+ g_tracer.Get().RecordProcessExecution(start_time,
+ TimeTicks::Now() - start_time);
+
return exit_code;
}
@@ -1034,6 +1043,13 @@ void TestLauncher::MaybeSaveSummaryAsJSON() {
LOG(ERROR) << "Failed to save test launcher output summary.";
}
}
+ if (command_line->HasSwitch(switches::kTestLauncherTrace)) {
+ FilePath trace_path(
+ command_line->GetSwitchValuePath(switches::kTestLauncherTrace));
+ if (!g_tracer.Get().Dump(trace_path)) {
+ LOG(ERROR) << "Failed to save test launcher trace.";
+ }
+ }
}
void TestLauncher::OnLaunchTestProcessFinished(
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/launcher/test_launcher_tracer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698