Skip to content

Commit

Permalink
[Qt][NRWT] Pass --timeout to DRT/WTR if a test is marked as SLOW.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=90968.

Reviewed by Csaba Osztrogonác.

Added functionality in DRT and WTR to use any timeout value while running
slow tests (eventually, any test). Now NRWT --time-out-ms determines the
timeout value for the test. Added a flag in NRWT (supports_per_test_timeout)
to indicate whether the current port supports setting timeout value
per test (it's False by default; I enabled it only on Qt).
Also corrected a typo in driver.py

* DumpRenderTree/DumpRenderTree.h:
(TestCommand::TestCommand):
(TestCommand):
* DumpRenderTree/DumpRenderTreeCommon.cpp:
(parseInputLine):
* DumpRenderTree/qt/DumpRenderTreeQt.cpp:
(WebCore::DumpRenderTree::processLine):
* Scripts/webkitpy/layout_tests/port/base.py:
(Port.supports_per_test_timeout):
* Scripts/webkitpy/layout_tests/port/driver.py:
(Driver.run_test):
(Driver._command_from_driver_input):
* Scripts/webkitpy/layout_tests/port/qt.py:
(QtPort.supports_per_test_timeout):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::InjectedBundle):
(WTR::InjectedBundle::didReceiveMessage):
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setCustomTimeout):
(WTR):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/InjectedBundle/qt/TestRunnerQt.cpp:
(WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::getCustomTimeout):
(WTR):
(WTR::TestCommand::TestCommand):
(TestCommand):
(WTR::parseInputLine):
(WTR::TestController::runTest):
(WTR::TestController::runUntil):
* WebKitTestRunner/TestController.h:
(TestController):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::TestInvocation):
(WTR::TestInvocation::setCustomTimeout):
(WTR):
(WTR::TestInvocation::invoke):
* WebKitTestRunner/TestInvocation.h:
(TestInvocation):


Canonical link: https://commits.webkit.org/124643@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139194 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Dicska committed Jan 9, 2013
1 parent 92b25d7 commit 385df79
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 27 deletions.
59 changes: 59 additions & 0 deletions Tools/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
2013-01-09 János Badics <[email protected]>

[Qt][NRWT] Pass --timeout to DRT/WTR if a test is marked as SLOW.
https://bugs.webkit.org/show_bug.cgi?id=90968.

Reviewed by Csaba Osztrogonác.

Added functionality in DRT and WTR to use any timeout value while running
slow tests (eventually, any test). Now NRWT --time-out-ms determines the
timeout value for the test. Added a flag in NRWT (supports_per_test_timeout)
to indicate whether the current port supports setting timeout value
per test (it's False by default; I enabled it only on Qt).
Also corrected a typo in driver.py

* DumpRenderTree/DumpRenderTree.h:
(TestCommand::TestCommand):
(TestCommand):
* DumpRenderTree/DumpRenderTreeCommon.cpp:
(parseInputLine):
* DumpRenderTree/qt/DumpRenderTreeQt.cpp:
(WebCore::DumpRenderTree::processLine):
* Scripts/webkitpy/layout_tests/port/base.py:
(Port.supports_per_test_timeout):
* Scripts/webkitpy/layout_tests/port/driver.py:
(Driver.run_test):
(Driver._command_from_driver_input):
* Scripts/webkitpy/layout_tests/port/qt.py:
(QtPort.supports_per_test_timeout):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::InjectedBundle):
(WTR::InjectedBundle::didReceiveMessage):
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setCustomTimeout):
(WTR):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/InjectedBundle/qt/TestRunnerQt.cpp:
(WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::getCustomTimeout):
(WTR):
(WTR::TestCommand::TestCommand):
(TestCommand):
(WTR::parseInputLine):
(WTR::TestController::runTest):
(WTR::TestController::runUntil):
* WebKitTestRunner/TestController.h:
(TestController):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::TestInvocation):
(WTR::TestInvocation::setCustomTimeout):
(WTR):
(WTR::TestInvocation::invoke):
* WebKitTestRunner/TestInvocation.h:
(TestInvocation):

2013-01-08 Gyuyoung Kim <[email protected]>

Regression(r138681): Add HAVE(ACCESSIBILITY) guard to atk files
Expand Down
3 changes: 2 additions & 1 deletion Tools/DumpRenderTree/DumpRenderTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ void dump();
void displayWebView();

struct TestCommand {
TestCommand() : shouldDumpPixels(false) { }
TestCommand() : shouldDumpPixels(false), timeout(30000) { }

std::string pathOrURL;
bool shouldDumpPixels;
std::string expectedPixelHash;
int timeout; // in ms
};

TestCommand parseInputLine(const std::string&);
Expand Down
23 changes: 13 additions & 10 deletions Tools/DumpRenderTree/DumpRenderTreeCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ TestCommand parseInputLine(const std::string& inputLine)
if (!tokenizer.hasNext())
die(inputLine);

result.pathOrURL = tokenizer.next();
if (!tokenizer.hasNext())
return result;

std::string arg = tokenizer.next();
if (arg != std::string("-p") && arg != std::string("--pixel-test"))
die(inputLine);
result.shouldDumpPixels = true;

if (tokenizer.hasNext())
result.expectedPixelHash = tokenizer.next();
result.pathOrURL = arg;
while (tokenizer.hasNext()) {
arg = tokenizer.next();
if (arg == std::string("--timeout")) {
std::string timeoutToken = tokenizer.next();
result.timeout = atoi(timeoutToken.c_str());
} else if (arg == std::string("-p") || arg == std::string("--pixel-test")) {
result.shouldDumpPixels = true;
if (tokenizer.hasNext())
result.expectedPixelHash = tokenizer.next();
} else
die(inputLine);
}

return result;
}
2 changes: 2 additions & 0 deletions Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ void DumpRenderTree::processLine(const QString &input)
open(QUrl::fromLocalFile(fi.absoluteFilePath()));
}

if (command.timeout > 0)
setTimeout(command.timeout);
fflush(stdout);
}

Expand Down
3 changes: 3 additions & 0 deletions Tools/Scripts/webkitpy/layout_tests/port/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def __init__(self, host, port_name, options=None, **kwargs):
def additional_drt_flag(self):
return []

def supports_per_test_timeout(self):
return False

def default_pixel_tests(self):
# FIXME: Disable until they are run by default on build.webkit.org.
return False
Expand Down
4 changes: 3 additions & 1 deletion Tools/Scripts/webkitpy/layout_tests/port/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def run_test(self, driver_input, stop_when_done):
the driver in an indeterminate state. The upper layers of the program
are responsible for cleaning up and ensuring things are okay.
Returns a DriverOuput object.
Returns a DriverOutput object.
"""
start_time = time.time()
self.start(driver_input.should_run_pixel_test, driver_input.args)
Expand Down Expand Up @@ -381,6 +381,8 @@ def _command_from_driver_input(self, driver_input):
assert not driver_input.image_hash or driver_input.should_run_pixel_test

# ' is the separator between arguments.
if self._port.supports_per_test_timeout():
command += "'--timeout'%s" % driver_input.timeout
if driver_input.should_run_pixel_test:
command += "'--pixel-test"
if driver_input.image_hash:
Expand Down
3 changes: 3 additions & 0 deletions Tools/Scripts/webkitpy/layout_tests/port/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def _build_driver(self):
# The Qt port builds DRT as part of the main build step
return True

def supports_per_test_timeout(self):
return True

def _path_to_driver(self):
return self._build_path('bin/%s' % self.driver_name())

Expand Down
6 changes: 6 additions & 0 deletions Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ InjectedBundle::InjectedBundle()
, m_dumpPixels(false)
, m_useWaitToDumpWatchdogTimer(true)
, m_useWorkQueue(false)
, m_timeout(0)
{
}

Expand Down Expand Up @@ -153,6 +154,9 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey(AdoptWK, WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer"));
m_useWaitToDumpWatchdogTimer = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, useWaitToDumpWatchdogTimerKey.get())));

WKRetainPtr<WKStringRef> timeoutKey(AdoptWK, WKStringCreateWithUTF8CString("Timeout"));
m_timeout = (int)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get())));

WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack"));
WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest"));
WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
Expand Down Expand Up @@ -266,6 +270,8 @@ void InjectedBundle::beginTesting(WKDictionaryRef settings)
m_testRunner->setAcceptsEditing(true);
m_testRunner->setTabKeyCyclesThroughElements(true);

m_testRunner->setCustomTimeout(m_timeout);

page()->prepare();

WKBundleClearAllDatabases(m_bundle);
Expand Down
1 change: 1 addition & 0 deletions Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class InjectedBundle {
bool m_dumpPixels;
bool m_useWaitToDumpWatchdogTimer;
bool m_useWorkQueue;
int m_timeout;

WKRetainPtr<WKDataRef> m_audioResult;
WKRetainPtr<WKImageRef> m_pixelResult;
Expand Down
5 changes: 5 additions & 0 deletions Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ void TestRunner::notifyDone()
m_waitToDump = false;
}

void TestRunner::setCustomTimeout(int timeout)
{
m_timeout = timeout;
}

unsigned TestRunner::numberOfActiveAnimations() const
{
// FIXME: Is it OK this works only for the main frame?
Expand Down
4 changes: 4 additions & 0 deletions Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ class TestRunner : public JSWrappable {

bool callShouldCloseOnWebView();

void setCustomTimeout(int duration);

// Work queue.
void queueBackNavigation(unsigned howFarBackward);
void queueForwardNavigation(unsigned howFarForward);
Expand Down Expand Up @@ -327,6 +329,8 @@ class TestRunner : public JSWrappable {
bool m_globalFlag;
bool m_customFullScreenBehavior;

int m_timeout;

bool m_userStyleSheetEnabled;
WKRetainPtr<WKStringRef> m_userStyleSheetLocation;

Expand Down
7 changes: 6 additions & 1 deletion Tools/WebKitTestRunner/InjectedBundle/qt/TestRunnerQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@ void TestRunner::invalidateWaitToDumpWatchdogTimer()

void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()
{
int timerInterval;
if (qgetenv("QT_WEBKIT2_DEBUG") == "1")
return;

if (m_waitToDumpWatchdogTimer.isActive())
return;
if (m_timeout > 0)
timerInterval = m_timeout;
else
timerInterval = waitToDumpWatchdogTimerInterval * 1000;

m_waitToDumpWatchdogTimer.start(waitToDumpWatchdogTimerInterval * 1000);
m_waitToDumpWatchdogTimer.start(timerInterval);
}

JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)
Expand Down
38 changes: 26 additions & 12 deletions Tools/WebKitTestRunner/TestController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ TestController::TestController(int argc, const char* argv[])
, m_noTimeout(defaultNoTimeout)
, m_useWaitToDumpWatchdogTimer(true)
, m_forceNoTimeout(false)
, m_timeout(0)
, m_didPrintWebProcessCrashedMessage(false)
, m_shouldExitWhenWebProcessCrashes(true)
, m_beforeUnloadReturnValue(true)
Expand Down Expand Up @@ -174,6 +175,11 @@ static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, W
TestController::shared().handleGeolocationPermissionRequest(permissionRequest);
}

int TestController::getCustomTimeout()
{
return m_timeout;
}

WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*)
{
PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage));
Expand Down Expand Up @@ -601,11 +607,12 @@ bool TestController::resetStateToConsistentValues()
}

struct TestCommand {
TestCommand() : shouldDumpPixels(false) { }
TestCommand() : shouldDumpPixels(false), timeout(0) { }

std::string pathOrURL;
bool shouldDumpPixels;
std::string expectedPixelHash;
int timeout;
};

class CommandTokenizer {
Expand Down Expand Up @@ -667,18 +674,20 @@ TestCommand parseInputLine(const std::string& inputLine)
if (!tokenizer.hasNext())
die(inputLine);

result.pathOrURL = tokenizer.next();
if (!tokenizer.hasNext())
return result;

std::string arg = tokenizer.next();
if (arg != std::string("-p") && arg != std::string("--pixel-test"))
die(inputLine);
result.shouldDumpPixels = true;

if (tokenizer.hasNext())
result.expectedPixelHash = tokenizer.next();

result.pathOrURL = arg;
while (tokenizer.hasNext()) {
arg = tokenizer.next();
if (arg == std::string("--timeout")) {
std::string timeoutToken = tokenizer.next();
result.timeout = atoi(timeoutToken.c_str());
} else if (arg == std::string("-p") || arg == std::string("--pixel-test")) {
result.shouldDumpPixels = true;
if (tokenizer.hasNext())
result.expectedPixelHash = tokenizer.next();
} else
die(inputLine);
}
return result;
}

Expand All @@ -691,6 +700,8 @@ bool TestController::runTest(const char* inputLine)
m_currentInvocation = adoptPtr(new TestInvocation(command.pathOrURL));
if (command.shouldDumpPixels || m_shouldDumpPixelsForAllTests)
m_currentInvocation->setIsPixelTest(command.expectedPixelHash);
if (command.timeout > 0)
m_currentInvocation->setCustomTimeout(command.timeout);

m_currentInvocation->invoke();
m_currentInvocation.clear();
Expand Down Expand Up @@ -742,6 +753,9 @@ void TestController::runUntil(bool& done, TimeoutDuration timeoutDuration)
case LongTimeout:
timeout = m_longTimeout;
break;
case CustomTimeout:
timeout = m_timeout;
break;
case NoTimeout:
default:
timeout = m_noTimeout;
Expand Down
6 changes: 5 additions & 1 deletion Tools/WebKitTestRunner/TestController.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ class TestController {
void ensureViewSupportsOptions(WKDictionaryRef options);

// Runs the run loop until `done` is true or the timeout elapses.
enum TimeoutDuration { ShortTimeout, LongTimeout, NoTimeout };
enum TimeoutDuration { ShortTimeout, LongTimeout, NoTimeout, CustomTimeout };
bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
void runUntil(bool& done, TimeoutDuration);
void notifyDone();

int getCustomTimeout();

bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; }
Expand Down Expand Up @@ -175,6 +177,8 @@ class TestController {
bool m_useWaitToDumpWatchdogTimer;
bool m_forceNoTimeout;

int m_timeout;

bool m_didPrintWebProcessCrashedMessage;
bool m_shouldExitWhenWebProcessCrashes;

Expand Down
Loading

0 comments on commit 385df79

Please sign in to comment.