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

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

Issue 2406243004: Introduce test output snippet byte limit (Closed)
Patch Set: 2.5 MB Created 4 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 | « no previous file | base/test/launcher/test_result.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 e6880fa54f5f462acb4c3050e78b2f3f143a8885..1e2a95b0daa7a6813d8a844d7a46885a2ded8a03 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -90,6 +90,10 @@ const int kOutputTimeoutSeconds = 15;
// the infrastructure.
const size_t kOutputSnippetLinesLimit = 5000;
+// Limit of output snippet size. Exceeding this limit
+// results in truncating the output and failing the test.
+const size_t kOutputSnippetBytesLimit = 2.5 * 1024 * 1024;
+
// Set of live launch test processes with corresponding lock (it is allowed
// for callers to launch processes on different threads).
LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes
@@ -568,9 +572,21 @@ void TestLauncher::LaunchChildGTestProcess(
launched_callback));
}
-void TestLauncher::OnTestFinished(const TestResult& result) {
+void TestLauncher::OnTestFinished(const TestResult& original_result) {
++test_finished_count_;
+ TestResult result(original_result);
+
+ if (result.output_snippet.length() > kOutputSnippetBytesLimit) {
+ if (result.status == TestResult::TEST_SUCCESS)
+ result.status = TestResult::TEST_EXCESSIVE_OUTPUT;
+ result.output_snippet = StringPrintf(
+ "<truncated (%" PRIuS " bytes)>\n", result.output_snippet.length()) +
+ result.output_snippet.substr(
+ result.output_snippet.length() - kOutputSnippetLinesLimit) +
+ "\n";
+ }
+
bool print_snippet = false;
std::string print_test_stdio("auto");
if (CommandLine::ForCurrentProcess()->HasSwitch(
« no previous file with comments | « no previous file | base/test/launcher/test_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698