Tools/ChangeLog

 12012-11-30 János Badics <[email protected]>
 2
 3 [Qt][NRWT] Pass --timeout to DRT/WTR if a test is marked as SLOW.
 4 https://bugs.webkit.org/show_bug.cgi?id=90968.
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added functionality in DRT and WTR to use any timeout value while running
 9 slow tests (eventually, any test). Now NRWT --time-out-ms determines the
 10 timeout value for the test. Added a flag in NRWT (supports_per_test_timeout)
 11 to indicate whether the current port supports setting timeout value
 12 per test (it's False by default; I enabled it only on Qt).
 13 Also corrected a typo in driver.py
 14
 15 * DumpRenderTree/DumpRenderTree.h:
 16 (TestCommand::TestCommand):
 17 (TestCommand):
 18 * DumpRenderTree/DumpRenderTreeCommon.cpp:
 19 (parseInputLine):
 20 * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
 21 (WebCore::DumpRenderTree::processLine):
 22 * Scripts/webkitpy/layout_tests/port/base.py:
 23 (Port.supports_per_test_timeout):
 24 * Scripts/webkitpy/layout_tests/port/driver.py:
 25 (Driver.run_test):
 26 (Driver._command_from_driver_input):
 27 * Scripts/webkitpy/layout_tests/port/qt.py:
 28 (QtPort.supports_per_test_timeout):
 29 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
 30 (WTR::InjectedBundle::InjectedBundle):
 31 (WTR::InjectedBundle::didReceiveMessage):
 32 (WTR::InjectedBundle::beginTesting):
 33 * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
 34 * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
 35 (WTR::TestRunner::setCustomTimeout):
 36 (WTR):
 37 * WebKitTestRunner/InjectedBundle/TestRunner.h:
 38 (TestRunner):
 39 * WebKitTestRunner/InjectedBundle/qt/TestRunnerQt.cpp:
 40 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
 41 * WebKitTestRunner/TestController.cpp:
 42 (WTR::TestController::TestController):
 43 (WTR::TestController::getCustomTimeout):
 44 (WTR):
 45 (WTR::TestCommand::TestCommand):
 46 (TestCommand):
 47 (WTR::parseInputLine):
 48 (WTR::TestController::runTest):
 49 (WTR::TestController::runUntil):
 50 * WebKitTestRunner/TestController.h:
 51 (TestController):
 52 * WebKitTestRunner/TestInvocation.cpp:
 53 (WTR::TestInvocation::TestInvocation):
 54 (WTR::TestInvocation::setCustomTimeout):
 55 (WTR):
 56 (WTR::TestInvocation::invoke):
 57 * WebKitTestRunner/TestInvocation.h:
 58 (TestInvocation):
 59
1602012-11-29 Rafael Weinstein <[email protected]>
261
362 [HTMLTemplateElement] Add feature flag

Tools/DumpRenderTree/DumpRenderTree.h

@@void dump();
6666void displayWebView();
6767
6868struct TestCommand {
69  TestCommand() : shouldDumpPixels(false) { }
 69 TestCommand() : shouldDumpPixels(false), timeout(30000) { }
7070
7171 std::string pathOrURL;
7272 bool shouldDumpPixels;
7373 std::string expectedPixelHash;
 74 int timeout; // in ms
7475};
7576
7677TestCommand parseInputLine(const std::string&);

Tools/DumpRenderTree/DumpRenderTreeCommon.cpp

@@TestCommand parseInputLine(const std::string& inputLine)
6666 if (!tokenizer.hasNext())
6767 die(inputLine);
6868
69  result.pathOrURL = tokenizer.next();
70  if (!tokenizer.hasNext())
71  return result;
72 
7369 std::string arg = tokenizer.next();
74  if (arg != std::string("-p") && arg != std::string("--pixel-test"))
75  die(inputLine);
76  result.shouldDumpPixels = true;
77 
78  if (tokenizer.hasNext())
79  result.expectedPixelHash = tokenizer.next();
 70 result.pathOrURL = arg;
 71 while (tokenizer.hasNext()) {
 72 arg = tokenizer.next();
 73 if (arg == std::string("--timeout")) {
 74 std::string timeoutToken = tokenizer.next();
 75 result.timeout = atoi(timeoutToken.c_str());
 76 } else if (arg == std::string("-p") || arg == std::string("--pixel-test")) {
 77 result.shouldDumpPixels = true;
 78 if (tokenizer.hasNext())
 79 result.expectedPixelHash = tokenizer.next();
 80 } else
 81 die(inputLine);
 82 }
8083
8184 return result;
8285}

Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp

@@void DumpRenderTree::processLine(const QString &input)
720720 open(QUrl::fromLocalFile(fi.absoluteFilePath()));
721721 }
722722
 723 if (command.timeout > 0)
 724 setTimeout(command.timeout);
723725 fflush(stdout);
724726}
725727

Tools/Scripts/webkitpy/layout_tests/port/base.py

@@class Port(object):
150150 def additional_drt_flag(self):
151151 return []
152152
 153 def supports_per_test_timeout(self):
 154 return False
 155
153156 def default_pixel_tests(self):
154157 # FIXME: Disable until they are run by default on build.webkit.org.
155158 return False

Tools/Scripts/webkitpy/layout_tests/port/driver.py

@@class Driver(object):
156156 the driver in an indeterminate state. The upper layers of the program
157157 are responsible for cleaning up and ensuring things are okay.
158158
159  Returns a DriverOuput object.
 159 Returns a DriverOutput object.
160160 """
161161 start_time = time.time()
162162 self.start(driver_input.should_run_pixel_test, driver_input.args)

@@class Driver(object):
365365 assert not driver_input.image_hash or driver_input.should_run_pixel_test
366366
367367 # ' is the separator between arguments.
 368 if self._port.supports_per_test_timeout():
 369 command += "'--timeout'%s" % driver_input.timeout
368370 if driver_input.should_run_pixel_test:
369371 command += "'--pixel-test"
370372 if driver_input.image_hash:

Tools/Scripts/webkitpy/layout_tests/port/qt.py

@@class QtPort(Port):
8080 # The Qt port builds DRT as part of the main build step
8181 return True
8282
 83 def supports_per_test_timeout(self):
 84 return True
 85
8386 def _path_to_driver(self):
8487 return self._build_path('bin/%s' % self.driver_name())
8588

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

@@InjectedBundle::InjectedBundle()
5555 , m_dumpPixels(false)
5656 , m_useWaitToDumpWatchdogTimer(true)
5757 , m_useWorkQueue(false)
 58 , m_timeout(0)
5859{
5960}
6061

@@void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
154155 WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey(AdoptWK, WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer"));
155156 m_useWaitToDumpWatchdogTimer = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, useWaitToDumpWatchdogTimerKey.get())));
156157
 158 WKRetainPtr<WKStringRef> timeoutKey(AdoptWK, WKStringCreateWithUTF8CString("Timeout"));
 159 m_timeout = (int)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get())));
 160
157161 WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack"));
158162 WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest"));
159163 WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());

@@void InjectedBundle::beginTesting(WKDictionaryRef settings)
267271 m_testRunner->setAcceptsEditing(true);
268272 m_testRunner->setTabKeyCyclesThroughElements(true);
269273
 274 m_testRunner->setCustomTimeout(m_timeout);
 275
270276 page()->prepare();
271277
272278 WKBundleClearAllDatabases(m_bundle);

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

@@private:
156156 bool m_dumpPixels;
157157 bool m_useWaitToDumpWatchdogTimer;
158158 bool m_useWorkQueue;
 159 int m_timeout;
159160
160161 WKRetainPtr<WKImageRef> m_pixelResult;
161162 WKRetainPtr<WKArrayRef> m_repaintRects;

Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

@@void TestRunner::notifyDone()
166166 m_waitToDump = false;
167167}
168168
 169void TestRunner::setCustomTimeout(int timeout)
 170{
 171 m_timeout = timeout;
 172}
 173
169174unsigned TestRunner::numberOfActiveAnimations() const
170175{
171176 // FIXME: Is it OK this works only for the main frame?

Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

@@public:
262262
263263 bool callShouldCloseOnWebView();
264264
 265 void setCustomTimeout(int duration);
 266
265267 // Work queue.
266268 void queueBackNavigation(unsigned howFarBackward);
267269 void queueForwardNavigation(unsigned howFarForward);

@@private:
314316 bool m_globalFlag;
315317 bool m_customFullScreenBehavior;
316318
 319 int m_timeout;
 320
317321 bool m_userStyleSheetEnabled;
318322 WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
319323

Tools/WebKitTestRunner/InjectedBundle/qt/TestRunnerQt.cpp

@@void TestRunner::invalidateWaitToDumpWatchdogTimer()
7474
7575void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()
7676{
 77 int timerInterval;
7778 if (qgetenv("QT_WEBKIT2_DEBUG") == "1")
7879 return;
7980
8081 if (m_waitToDumpWatchdogTimer.isActive())
8182 return;
 83 if (m_timeout > 0)
 84 timerInterval = m_timeout;
 85 else
 86 timerInterval = waitToDumpWatchdogTimerInterval * 1000;
8287
83  m_waitToDumpWatchdogTimer.start(waitToDumpWatchdogTimerInterval * 1000);
 88 m_waitToDumpWatchdogTimer.start(timerInterval);
8489}
8590
8691JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)

Tools/WebKitTestRunner/TestController.cpp

@@TestController::TestController(int argc, const char* argv[])
9393 , m_noTimeout(defaultNoTimeout)
9494 , m_useWaitToDumpWatchdogTimer(true)
9595 , m_forceNoTimeout(false)
 96 , m_timeout(0)
9697 , m_didPrintWebProcessCrashedMessage(false)
9798 , m_shouldExitWhenWebProcessCrashes(true)
9899 , m_beforeUnloadReturnValue(true)

@@static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, W
170171 TestController::shared().handleGeolocationPermissionRequest(permissionRequest);
171172}
172173
 174int TestController::getCustomTimeout()
 175{
 176 return m_timeout;
 177}
 178
173179WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*)
174180{
175181 PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage));

@@bool TestController::resetStateToConsistentValues()
586592}
587593
588594struct TestCommand {
589  TestCommand() : shouldDumpPixels(false) { }
 595 TestCommand() : shouldDumpPixels(false), timeout(0) { }
590596
591597 std::string pathOrURL;
592598 bool shouldDumpPixels;
593599 std::string expectedPixelHash;
 600 int timeout;
594601};
595602
596603class CommandTokenizer {

@@TestCommand parseInputLine(const std::string& inputLine)
652659 if (!tokenizer.hasNext())
653660 die(inputLine);
654661
655  result.pathOrURL = tokenizer.next();
656  if (!tokenizer.hasNext())
657  return result;
658 
659662 std::string arg = tokenizer.next();
660  if (arg != std::string("-p") && arg != std::string("--pixel-test"))
661  die(inputLine);
662  result.shouldDumpPixels = true;
663 
664  if (tokenizer.hasNext())
665  result.expectedPixelHash = tokenizer.next();
666 
 663 result.pathOrURL = arg;
 664 while (tokenizer.hasNext()) {
 665 arg = tokenizer.next();
 666 if (arg == std::string("--timeout")) {
 667 std::string timeoutToken = tokenizer.next();
 668 result.timeout = atoi(timeoutToken.c_str());
 669 } else if (arg == std::string("-p") || arg == std::string("--pixel-test")) {
 670 result.shouldDumpPixels = true;
 671 if (tokenizer.hasNext())
 672 result.expectedPixelHash = tokenizer.next();
 673 } else
 674 die(inputLine);
 675 }
667676 return result;
668677}
669678

@@bool TestController::runTest(const char* inputLine)
676685 m_currentInvocation = adoptPtr(new TestInvocation(command.pathOrURL));
677686 if (command.shouldDumpPixels || m_shouldDumpPixelsForAllTests)
678687 m_currentInvocation->setIsPixelTest(command.expectedPixelHash);
 688 if (command.timeout > 0)
 689 m_currentInvocation->setCustomTimeout(command.timeout);
679690
680691 m_currentInvocation->invoke();
681692 m_currentInvocation.clear();

@@void TestController::runUntil(bool& done, TimeoutDuration timeoutDuration)
727738 case LongTimeout:
728739 timeout = m_longTimeout;
729740 break;
 741 case CustomTimeout:
 742 timeout = m_timeout;
 743 break;
730744 case NoTimeout:
731745 default:
732746 timeout = m_noTimeout;

Tools/WebKitTestRunner/TestController.h

@@public:
6060 void ensureViewSupportsOptions(WKDictionaryRef options);
6161
6262 // Runs the run loop until `done` is true or the timeout elapses.
63  enum TimeoutDuration { ShortTimeout, LongTimeout, NoTimeout };
 63 enum TimeoutDuration { ShortTimeout, LongTimeout, NoTimeout, CustomTimeout };
6464 bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
6565 void runUntil(bool& done, TimeoutDuration);
6666 void notifyDone();
 67
 68 int getCustomTimeout();
6769
6870 bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
6971 void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; }

@@private:
166168 bool m_useWaitToDumpWatchdogTimer;
167169 bool m_forceNoTimeout;
168170
 171 int m_timeout;
 172
169173 bool m_didPrintWebProcessCrashedMessage;
170174 bool m_shouldExitWhenWebProcessCrashes;
171175

Tools/WebKitTestRunner/TestInvocation.cpp

@@TestInvocation::TestInvocation(const std::string& pathOrURL)
101101 : m_url(AdoptWK, createWKURL(pathOrURL.c_str()))
102102 , m_pathOrURL(pathOrURL)
103103 , m_dumpPixels(false)
 104 , m_timeout(0)
104105 , m_gotInitialResponse(false)
105106 , m_gotFinalMessage(false)
106107 , m_gotRepaint(false)

@@void TestInvocation::setIsPixelTest(const std::string& expectedPixelHash)
119120 m_expectedPixelHash = expectedPixelHash;
120121}
121122
 123void TestInvocation::setCustomTimeout(int timeout)
 124{
 125 m_timeout = timeout;
 126}
 127
122128static const unsigned w3cSVGWidth = 480;
123129static const unsigned w3cSVGHeight = 360;
124130static const unsigned normalWidth = 800;

@@static void updateLayoutType(const char* pathOrURL)
189195
190196void TestInvocation::invoke()
191197{
 198 TestController::TimeoutDuration timeoutToUse = TestController::LongTimeout;
192199 sizeWebViewForCurrentTest(m_pathOrURL.c_str());
193200 updateLayoutType(m_pathOrURL.c_str());
194201 updateTiledDrawingForCurrentTest(m_pathOrURL.c_str());

@@void TestInvocation::invoke()
208215 WKRetainPtr<WKBooleanRef> useWaitToDumpWatchdogTimerValue = adoptWK(WKBooleanCreate(TestController::shared().useWaitToDumpWatchdogTimer()));
209216 WKDictionaryAddItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get());
210217
 218 WKRetainPtr<WKStringRef> timeoutKey = adoptWK(WKStringCreateWithUTF8CString("Timeout"));
 219 WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout));
 220 WKDictionaryAddItem(beginTestMessageBody.get(), timeoutKey.get(), timeoutValue.get());
 221
211222 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), beginTestMessageBody.get());
212223
213224 TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout);

@@void TestInvocation::invoke()
226237
227238 WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get());
228239
229  TestController::shared().runUntil(m_gotFinalMessage, TestController::shared().useWaitToDumpWatchdogTimer() ? TestController::LongTimeout : TestController::NoTimeout);
 240 if (TestController::shared().useWaitToDumpWatchdogTimer()) {
 241 if (m_timeout > 0)
 242 timeoutToUse = TestController::CustomTimeout;
 243 } else
 244 timeoutToUse = TestController::NoTimeout;
 245 TestController::shared().runUntil(m_gotFinalMessage, timeoutToUse);
 246
230247 if (!m_gotFinalMessage) {
231248 m_errorMessage = "Timed out waiting for final message from web process\n";
232249 m_webProcessIsUnresponsive = true;

Tools/WebKitTestRunner/TestInvocation.h

@@public:
4040
4141 void setIsPixelTest(const std::string& expectedPixelHash);
4242
 43 void setCustomTimeout(int duration);
 44
4345 void invoke();
4446 void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
4547 WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);

@@private:
6163 bool m_dumpPixels;
6264 std::string m_expectedPixelHash;
6365
 66 int m_timeout;
 67
6468 // Invocation state
6569 bool m_gotInitialResponse;
6670 bool m_gotFinalMessage;