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

Unified Diff: content/test/test_launcher.cc

Issue 8825010: Stop running tests if more than 5 time out. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_launcher.cc
diff --git a/content/test/test_launcher.cc b/content/test/test_launcher.cc
index 7d7df69146777c2667a356bc5cdc19ea32569694..e62caf3e8485eaf52916a1c8430c007963cac8af 100644
--- a/content/test/test_launcher.cc
+++ b/content/test/test_launcher.cc
@@ -38,20 +38,22 @@
namespace test_launcher {
-namespace {
-
// The environment variable name for the total number of test shards.
-static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
+const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
// The environment variable name for the test shard index.
-static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
+const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
// The default output file for XML output.
-static const FilePath::CharType kDefaultOutputFile[] = FILE_PATH_LITERAL(
+const FilePath::CharType kDefaultOutputFile[] = FILE_PATH_LITERAL(
"test_detail.xml");
// Name of the empty test below.
-static const char kEmptyTestName[] = "InProcessBrowserTest.Empty";
+const char kEmptyTestName[] = "InProcessBrowserTest.Empty";
+
+// Quit test execution after this number of tests has timed out.
+const int kMaxTimeouts = 5; // 45s timeout * 10 = 450s max run time.
+namespace {
Avi (use Gerrit) 2011/12/06 23:01:00 \n after this line
// An empty test (it starts up and shuts down the browser as part of its
// setup and teardown) used to prefetch all of the browser code into memory.
IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, Empty) {
@@ -302,7 +304,11 @@ int GetTestTerminationTimeout(const std::string& test_name,
// and returns the exit code.
int RunTest(TestLauncherDelegate* launcher_delegate,
const std::string& test_name,
- int default_timeout_ms) {
+ int default_timeout_ms,
+ bool* was_timeout) {
+ if (was_timeout)
+ *was_timeout = false;
+
#if defined(OS_MACOSX)
// Some of the below method calls will leak objects if there is no
// autorelease pool in place.
@@ -375,6 +381,8 @@ int RunTest(TestLauncherDelegate* launcher_delegate,
LOG(ERROR) << "Test timeout (" << timeout_ms
<< " ms) exceeded for " << test_name;
+ if (was_timeout)
+ *was_timeout = true;
exit_code = -1; // Set a non-zero exit code to signal a failure.
// Ensure that the process terminates.
@@ -421,6 +429,7 @@ bool RunTests(TestLauncherDelegate* launcher_delegate,
int num_runnable_tests = 0;
int test_run_count = 0;
int ignored_failure_count = 0;
+ int timeout_count = 0;
std::vector<std::string> failed_tests;
ResultsPrinter printer(*command_line);
@@ -470,9 +479,11 @@ bool RunTests(TestLauncherDelegate* launcher_delegate,
base::Time start_time = base::Time::Now();
++test_run_count;
+ bool was_timeout = false;
int exit_code = RunTest(launcher_delegate,
test_name,
- TestTimeouts::action_max_timeout_ms());
+ TestTimeouts::action_max_timeout_ms(),
+ &was_timeout);
if (exit_code == 0) {
// Test passed.
printer.OnTestEnd(test_info->name(), test_case->name(), true, false,
@@ -493,8 +504,20 @@ bool RunTests(TestLauncherDelegate* launcher_delegate,
(base::Time::Now() - start_time).InMillisecondsF());
if (ignore_failure)
++ignored_failure_count;
+
+ if (was_timeout)
+ ++timeout_count;
+ }
+
+ if (timeout_count > kMaxTimeouts) {
+ printf("More than %d timeouts, aborting test case\n", kMaxTimeouts);
+ break;
}
}
+ if (timeout_count > kMaxTimeouts) {
+ printf("More than %d timeouts, aborting test\n", kMaxTimeouts);
+ break;
+ }
}
printf("%d test%s run\n", test_run_count, test_run_count > 1 ? "s" : "");
@@ -615,7 +638,8 @@ int LaunchTests(TestLauncherDelegate* launcher_delegate,
// and closes a browser with a long timeout to avoid those problems.
int exit_code = RunTest(launcher_delegate,
kEmptyTestName,
- TestTimeouts::large_test_timeout_ms());
+ TestTimeouts::large_test_timeout_ms(),
+ NULL);
if (exit_code != 0)
return exit_code;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698