summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/test_shell_gtk.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-18 22:57:09 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-18 22:57:09 +0000
commitaa71474ec26b3fd6fa264f6fa85d4c9397a245ac (patch)
tree0bb85725de8e4140b99bfd9002f4747cd0c07414 /webkit/tools/test_shell/test_shell_gtk.cc
parentfbb2b7a4d30adc149b23ceb03e66cffd9a1265ff (diff)
downloadchromium_src-aa71474ec26b3fd6fa264f6fa85d4c9397a245ac.zip
chromium_src-aa71474ec26b3fd6fa264f6fa85d4c9397a245ac.tar.gz
chromium_src-aa71474ec26b3fd6fa264f6fa85d4c9397a245ac.tar.bz2
Implement layout test timeouts under the GTK test shell.
Review URL: http://codereview.chromium.org/11455 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/test_shell_gtk.cc')
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 5972367..f11b357 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -8,6 +8,7 @@
#include <fcntl.h>
#include <fontconfig/fontconfig.h>
#include <gtk/gtk.h>
+#include <signal.h>
#include <unistd.h>
#include "base/file_path.h"
@@ -27,6 +28,10 @@
#include "webkit/tools/test_shell/test_navigation_controller.h"
#include "webkit/tools/test_shell/test_webview_delegate.h"
+// Default timeout for page load when running non-interactive file
+// tests, in ms.
+const int kDefaultFileTestTimeoutSeconds = 10;
+
// static
void TestShell::InitializeTestShell(bool interactive) {
window_list_ = new WindowList;
@@ -210,19 +215,31 @@ void TestShell::SizeTo(int width, int height) {
gtk_window_resize(GTK_WINDOW(m_mainWnd), width, height + toolbar_height_);
}
+static void AlarmHandler(int signatl) {
+ // If the alarm alarmed, kill the process since we have a really bad hang.
+ puts("#TEST_TIMED_OUT\n");
+ puts("#EOF\n");
+ fflush(stdout);
+ exit(0);
+}
+
void TestShell::WaitTestFinished() {
DCHECK(!test_is_pending_) << "cannot be used recursively";
test_is_pending_ = true;
- // TODO(agl): Here windows forks a watchdog thread, but I'm punting on that
- // for the moment. On POSIX systems we probably want to install a signal
- // handler and use alarm(2).
+ // Install an alarm signal handler that will kill us if we time out.
+ signal(SIGALRM, AlarmHandler);
+ alarm(kDefaultFileTestTimeoutSeconds);
// TestFinished() will post a quit message to break this loop when the page
// finishes loading.
while (test_is_pending_)
MessageLoop::current()->Run();
+
+ // Remove the alarm.
+ alarm(0);
+ signal(SIGALRM, SIG_DFL);
}
void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) {