summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/test/in_process_browser_test.cc31
-rw-r--r--chrome/test/in_process_browser_test.h9
-rw-r--r--chrome/test/live_sync/live_sync_test.h4
-rw-r--r--chrome/test/test_launcher/out_of_proc_test_runner.cc27
-rw-r--r--chrome/test/test_switches.cc4
-rw-r--r--chrome/test/test_switches.h1
-rw-r--r--chrome/test/test_timeouts.cc5
-rw-r--r--chrome/test/test_timeouts.h4
9 files changed, 65 insertions, 21 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 96b2fae..a1718f2 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2337,6 +2337,7 @@
'<(INTERMEDIATE_DIR)',
'<(protoc_out_dir)',
],
+ # TODO(phajdan.jr): Only temporary, to make transition easier.
'defines': [ 'ALLOW_IN_PROC_BROWSER_TEST' ],
'sources': [
'app/chrome_dll.rc',
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 276556d..870cf95 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -69,6 +69,13 @@ const wchar_t kUnitTestShowWindows[] = L"show-windows";
// Passed as value of kTestType.
static const char kBrowserTestType[] = "browser";
+// Default delay for the time-out at which we stop the
+// inner-message loop the first time.
+const int kInitialTimeoutInMS = 30000;
+
+// Delay for sub-sequent time-outs once the initial time-out happened.
+const int kSubsequentTimeoutInMS = 5000;
+
InProcessBrowserTest::InProcessBrowserTest()
: browser_(NULL),
test_server_(net::TestServer::TYPE_HTTP,
@@ -76,7 +83,8 @@ InProcessBrowserTest::InProcessBrowserTest()
show_window_(false),
dom_automation_enabled_(false),
tab_closeable_state_watcher_enabled_(false),
- original_single_process_(false) {
+ original_single_process_(false),
+ initial_timeout_(kInitialTimeoutInMS) {
}
InProcessBrowserTest::~InProcessBrowserTest() {
@@ -294,6 +302,11 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
browser_ = CreateBrowser(profile);
pool.Recycle();
+ // Start the timeout timer to prevent hangs.
+ MessageLoopForUI::current()->PostDelayedTask(FROM_HERE,
+ NewRunnableMethod(this, &InProcessBrowserTest::TimedOut),
+ initial_timeout_);
+
// Pump any pending events that were created as a result of creating a
// browser.
MessageLoopForUI::current()->RunAllPending();
@@ -320,3 +333,19 @@ void InProcessBrowserTest::QuitBrowsers() {
NewRunnableFunction(&BrowserList::CloseAllBrowsersAndExit));
ui_test_utils::RunMessageLoop();
}
+
+void InProcessBrowserTest::TimedOut() {
+ std::string error_message = "Test timed out. Each test runs for a max of ";
+ error_message += base::IntToString(initial_timeout_);
+ error_message += " ms (kInitialTimeoutInMS).";
+
+ MessageLoopForUI::current()->Quit();
+
+ // WARNING: This must be after Quit as it returns.
+ FAIL() << error_message;
+}
+
+void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) {
+ DCHECK_GT(timeout_value, 0);
+ initial_timeout_ = timeout_value;
+}
diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h
index 347d19c..0af1877 100644
--- a/chrome/test/in_process_browser_test.h
+++ b/chrome/test/in_process_browser_test.h
@@ -95,6 +95,12 @@ class InProcessBrowserTest : public testing::Test {
// main thread before the browser is torn down.
virtual void CleanUpOnMainThread() {}
+ // Invoked when a test is not finishing in a timely manner.
+ void TimedOut();
+
+ // Sets Initial Timeout value.
+ void SetInitialTimeoutInMS(int initial_timeout);
+
// Returns the testing server. Guaranteed to be non-NULL.
net::TestServer* test_server() { return &test_server_; }
@@ -152,6 +158,9 @@ class InProcessBrowserTest : public testing::Test {
// Saved to restore the value of RenderProcessHost::run_renderer_in_process.
bool original_single_process_;
+ // Initial timeout value in ms.
+ int initial_timeout_;
+
// Host resolver to use during the test.
scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_;
diff --git a/chrome/test/live_sync/live_sync_test.h b/chrome/test/live_sync/live_sync_test.h
index db5ee0b0..134b200 100644
--- a/chrome/test/live_sync/live_sync_test.h
+++ b/chrome/test/live_sync/live_sync_test.h
@@ -28,6 +28,9 @@ class ProxyConfig;
class ScopedDefaultHostResolverProc;
}
+// Live sync tests are allowed to run for up to 5 minutes.
+const int kTestTimeoutInMS = 300000;
+
// This is the base class for integration tests for all sync data types. Derived
// classes must be defined for each sync data type. Individual tests are defined
// using the IN_PROC_BROWSER_TEST_F macro.
@@ -60,6 +63,7 @@ class LiveSyncTest : public InProcessBrowserTest {
test_server_(net::TestServer::TYPE_HTTP, FilePath()),
started_local_test_server_(false) {
InProcessBrowserTest::set_show_window(true);
+ InProcessBrowserTest::SetInitialTimeoutInMS(kTestTimeoutInMS);
switch (test_type_) {
case SINGLE_CLIENT: {
num_clients_ = 1;
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc
index 49da2f6..47be495 100644
--- a/chrome/test/test_launcher/out_of_proc_test_runner.cc
+++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc
@@ -10,7 +10,6 @@
#include "base/string_number_conversions.h"
#include "base/test/test_suite.h"
#include "chrome/test/test_launcher/test_runner.h"
-#include "chrome/test/test_timeouts.h"
#include "chrome/test/unit/chrome_test_suite.h"
#if defined(OS_WIN)
@@ -36,11 +35,16 @@ const char kGTestOutputFlag[] = "gtest_output";
const char kGTestRepeatFlag[] = "gtest_repeat";
const char kSingleProcessTestsFlag[] = "single_process";
const char kSingleProcessTestsAndChromeFlag[] = "single-process";
+const char kTestTerminateTimeoutFlag[] = "test-terminate-timeout";
// The following is kept for historical reasons (so people that are used to
// using it don't get surprised).
const char kChildProcessFlag[] = "child";
const char kHelpFlag[] = "help";
+// This value was changed from 30000 (30sec) to 45000 due to
+// http://crbug.com/43862.
+const int64 kDefaultTestTimeoutMs = 45000;
+
class OutOfProcTestRunner : public tests::TestRunner {
public:
OutOfProcTestRunner() {
@@ -88,11 +92,19 @@ class OutOfProcTestRunner : public tests::TestRunner {
if (!base::LaunchApp(new_cmd_line, false, false, &process_handle))
return false;
+ int test_terminate_timeout_ms = kDefaultTestTimeoutMs;
+ if (cmd_line->HasSwitch(kTestTerminateTimeoutFlag)) {
+ std::string timeout_str =
+ cmd_line->GetSwitchValueASCII(kTestTerminateTimeoutFlag);
+ int timeout;
+ base::StringToInt(timeout_str, &timeout);
+ test_terminate_timeout_ms = std::max(test_terminate_timeout_ms, timeout);
+ }
+
int exit_code = 0;
- if (!base::WaitForExitCodeWithTimeout(
- process_handle, &exit_code,
- TestTimeouts::medium_test_timeout_ms())) {
- LOG(ERROR) << "Test timeout (" << TestTimeouts::medium_test_timeout_ms()
+ if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code,
+ test_terminate_timeout_ms)) {
+ LOG(ERROR) << "Test timeout (" << test_terminate_timeout_ms
<< " ms) exceeded for " << test_name;
exit_code = -1; // Set a non-zero exit code to signal a failure.
@@ -129,6 +141,9 @@ void PrintUsage() {
" debugging a specific test in a debugger.\n"
" --single-process\n"
" Same as above, and also runs Chrome in single-process mode.\n"
+ " --test-terminate-timeout\n"
+ " Specifies a timeout (in milliseconds) after which a running test\n"
+ " will be forcefully terminated.\n"
" --help\n"
" Shows this message.\n"
" --gtest_help\n"
@@ -192,8 +207,6 @@ int main(int argc, char** argv) {
}
#endif
- TestTimeouts::Initialize();
-
fprintf(stdout,
"Starting tests...\n"
"IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n"
diff --git a/chrome/test/test_switches.cc b/chrome/test/test_switches.cc
index 3349019..9fbf153 100644
--- a/chrome/test/test_switches.cc
+++ b/chrome/test/test_switches.cc
@@ -10,10 +10,6 @@ const char switches::kExtraChromeFlags[] = "extra-chrome-flags";
// Enable displaying error dialogs (for debugging).
const char switches::kEnableErrorDialogs[] = "enable-errdialogs";
-// Timeout for medium tests, like browser_tests.
-// TODO(phajdan.jr): Clean up the switch name.
-const char switches::kMediumTestTimeout[] = "test-terminate-timeout";
-
// Number of iterations that page cycler tests will run.
const char switches::kPageCyclerIterations[] = "page-cycler-iterations";
diff --git a/chrome/test/test_switches.h b/chrome/test/test_switches.h
index c5d1901..4497d1a 100644
--- a/chrome/test/test_switches.h
+++ b/chrome/test/test_switches.h
@@ -11,7 +11,6 @@ namespace switches {
// alongside the definition of their values in the .cc file.
extern const char kExtraChromeFlags[];
extern const char kEnableErrorDialogs[];
-extern const char kMediumTestTimeout[];
extern const char kPageCyclerIterations[];
extern const char kUiTestActionTimeout[];
extern const char kUiTestActionMaxTimeout[];
diff --git a/chrome/test/test_timeouts.cc b/chrome/test/test_timeouts.cc
index b1a608a..245f148 100644
--- a/chrome/test/test_timeouts.cc
+++ b/chrome/test/test_timeouts.cc
@@ -31,7 +31,6 @@ bool TestTimeouts::initialized_ = false;
// static
int TestTimeouts::action_timeout_ms_ = 2000;
int TestTimeouts::action_max_timeout_ms_ = 15000;
-int TestTimeouts::medium_test_timeout_ms_ = 30 * 1000;
int TestTimeouts::large_test_timeout_ms_ = 10 * 60 * 1000;
// static
@@ -54,13 +53,11 @@ void TestTimeouts::Initialize() {
InitializeTimeout(switches::kUiTestActionTimeout, &action_timeout_ms_);
InitializeTimeout(switches::kUiTestActionMaxTimeout,
&action_max_timeout_ms_);
- InitializeTimeout(switches::kMediumTestTimeout, &medium_test_timeout_ms_);
InitializeTimeout(switches::kUiTestTimeout, &large_test_timeout_ms_);
// The timeout values should be increasing in the right order.
CHECK(action_timeout_ms_ <= action_max_timeout_ms_);
- CHECK(action_max_timeout_ms_ <= medium_test_timeout_ms_);
- CHECK(medium_test_timeout_ms_ <= large_test_timeout_ms_);
+ CHECK(action_max_timeout_ms_ <= large_test_timeout_ms_);
InitializeTimeout(switches::kUiTestSleepTimeout, &sleep_timeout_ms_);
InitializeTimeout(switches::kUiTestCommandExecutionTimeout,
diff --git a/chrome/test/test_timeouts.h b/chrome/test/test_timeouts.h
index ef4a200c..8405a51 100644
--- a/chrome/test/test_timeouts.h
+++ b/chrome/test/test_timeouts.h
@@ -24,9 +24,6 @@ class TestTimeouts {
// is not sufficient.
static int action_max_timeout_ms() { return action_max_timeout_ms_; }
- // Timeout for a medium test (like one test inside browser_tests).
- static int medium_test_timeout_ms() { return medium_test_timeout_ms_; }
-
// Timeout for a large test (like running a layout test inside the browser).
// Do not use unless absolutely necessary - try to make the test smaller.
// Do not use multiple times in a single test.
@@ -53,7 +50,6 @@ class TestTimeouts {
static int action_timeout_ms_;
static int action_max_timeout_ms_;
- static int medium_test_timeout_ms_;
static int large_test_timeout_ms_;
static int sleep_timeout_ms_;
static int command_execution_timeout_ms_;