Changeset 71263 in webkit


Ignore:
Timestamp:
Nov 3, 2010 1:51:16 PM (13 years ago)
Author:
Adam Roben
Message:

Stop waiting for messages from the web process after a timeout elapses

TestController::runUntil now takes a timeout parameter that specifies
how long to wait for the condition to become true. WebKitTestRunner
takes a --timeout flag that specifies how long the timeout should be.
run-webkit-tests passes this flag to WebKitTestRunner so its timeout
will be similar to run-webkit-tests.

Fixes <http://webkit.org/b/43047> <rdar://problem/8365833>
WebKitTestRunner waits forever if the web process crashes

Reviewed by Darin Adler and Anders Carlsson.

  • Scripts/old-run-webkit-tests:

(top level): Moved the GuardMalloc timeout adjustment here from
readFromDumpToolWithTimer.
(openDumpTool): Make WTR use a timeout similar to but slightly shorter
than the one that was specified on the command line.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::TestController): Initialize our timeout values.
(WTR::TestController::initialize): Parse the --timeout flag and use it
to modify our timeout values.
(WTR::TestController::resetStateToConsistentValues): Changed to use a
short timeout while waiting for the web process to reset and to return
a boolean indicating whether we were able to reset the web process.
Uses a 5-second timeout while waiting for the process to be reset.
(WTR::TestController::runTest): Changed to return a boolean indicating
whether we were able to reset the web process (and thus run the test).
(WTR::TestController::runUntil): Call through to platformRunUntil.

(WTR::TestController::runTestingServerLoop):
(WTR::TestController::run):
Changed to bail if any test can't be run. This will cause the process
to exit. (Unfortunately this will make run-webkit-tests think we
crashed; see <http://webkit.org/b/48943>.)

  • WebKitTestRunner/TestController.h: Added platformRunUntil,

m_longTimeout, and m_shortTimeout.

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::invoke): Use a short timeout when waiting for the
initial response and a long timeout when waiting for the test to
complete. Check whether runUntil timed out and print an error message
if so.

  • WebKitTestRunner/mac/TestControllerMac.mm:

(WTR::TestController::platformRunUntil): Renamed from runUntil. Pass
[NSDate distantPast] to -[NSRunLoop runMode:beforeDate:] so that we
won't block waiting for the run loop. Only loop until the timeout
elapses.

  • WebKitTestRunner/qt/TestControllerQt.cpp:

(WTR::TestController::platformRunUntil): Renamed from runUntil. Added a
FIXME about honoring the timeout.

  • WebKitTestRunner/win/TestControllerWin.cpp:

(WTR::TestController::platformRunUntil): Renamed from runUntil. Use
::MsgWaitForMultipleObjectsEx to implement the timeout. Changed to use
::PeekMessageW so that we don't block waiting for messages to become
available.

Location:
trunk/WebKitTools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r71249 r71263  
     12010-11-03  Adam Roben  <aroben@apple.com>
     2
     3        Stop waiting for messages from the web process after a timeout elapses
     4
     5        TestController::runUntil now takes a timeout parameter that specifies
     6        how long to wait for the condition to become true. WebKitTestRunner
     7        takes a --timeout flag that specifies how long the timeout should be.
     8        run-webkit-tests passes this flag to WebKitTestRunner so its timeout
     9        will be similar to run-webkit-tests.
     10
     11        Fixes <http://webkit.org/b/43047> <rdar://problem/8365833>
     12        WebKitTestRunner waits forever if the web process crashes
     13
     14        Reviewed by Darin Adler and Anders Carlsson.
     15
     16        * Scripts/old-run-webkit-tests:
     17        (top level): Moved the GuardMalloc timeout adjustment here from
     18        readFromDumpToolWithTimer.
     19        (openDumpTool): Make WTR use a timeout similar to but slightly shorter
     20        than the one that was specified on the command line.
     21
     22        * WebKitTestRunner/TestController.cpp:
     23        (WTR::TestController::TestController): Initialize our timeout values.
     24        (WTR::TestController::initialize): Parse the --timeout flag and use it
     25        to modify our timeout values.
     26        (WTR::TestController::resetStateToConsistentValues): Changed to use a
     27        short timeout while waiting for the web process to reset and to return
     28        a boolean indicating whether we were able to reset the web process.
     29        Uses a 5-second timeout while waiting for the process to be reset.
     30        (WTR::TestController::runTest): Changed to return a boolean indicating
     31        whether we were able to reset the web process (and thus run the test).
     32        (WTR::TestController::runUntil): Call through to platformRunUntil.
     33
     34        (WTR::TestController::runTestingServerLoop):
     35        (WTR::TestController::run):
     36        Changed to bail if any test can't be run. This will cause the process
     37        to exit. (Unfortunately this will make run-webkit-tests think we
     38        crashed; see <http://webkit.org/b/48943>.)
     39
     40        * WebKitTestRunner/TestController.h: Added platformRunUntil,
     41        m_longTimeout, and m_shortTimeout.
     42
     43        * WebKitTestRunner/TestInvocation.cpp:
     44        (WTR::TestInvocation::invoke): Use a short timeout when waiting for the
     45        initial response and a long timeout when waiting for the test to
     46        complete. Check whether runUntil timed out and print an error message
     47        if so.
     48
     49        * WebKitTestRunner/mac/TestControllerMac.mm:
     50        (WTR::TestController::platformRunUntil): Renamed from runUntil. Pass
     51        [NSDate distantPast] to -[NSRunLoop runMode:beforeDate:] so that we
     52        won't block waiting for the run loop. Only loop until the timeout
     53        elapses.
     54
     55        * WebKitTestRunner/qt/TestControllerQt.cpp:
     56        (WTR::TestController::platformRunUntil): Renamed from runUntil. Added a
     57        FIXME about honoring the timeout.
     58
     59        * WebKitTestRunner/win/TestControllerWin.cpp:
     60        (WTR::TestController::platformRunUntil): Renamed from runUntil. Use
     61        ::MsgWaitForMultipleObjectsEx to implement the timeout. Changed to use
     62        ::PeekMessageW so that we don't block waiting for messages to become
     63        available.
     64
    1652010-11-03  Adam Roben  <aroben@apple.com>
    266
  • trunk/WebKitTools/Scripts/old-run-webkit-tests

    r70773 r71263  
    374374}
    375375
     376$timeoutSeconds *= 10 if $guardMalloc;
     377
    376378$stripEditingCallbacks = isCygwin() unless defined $stripEditingCallbacks;
    377379
     
    14841486    }
    14851487
     1488    if ($useWebKitTestRunner) {
     1489        # Make WebKitTestRunner use a similar timeout. We don't use the exact same timeout to avoid
     1490        # race conditions.
     1491        push @args, "--timeout", $timeoutSeconds - 5;
     1492    }
     1493
    14861494    $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
    14871495
     
    20902098
    20912099    my $maximumSecondsWithoutOutput = $timeoutSeconds;
    2092     $maximumSecondsWithoutOutput *= 10 if $guardMalloc;
    20932100    my $microsecondsToWaitBeforeReadingAgain = 1000;
    20942101
  • trunk/WebKitTools/WebKitTestRunner/TestController.cpp

    r70790 r71263  
    3636namespace WTR {
    3737
     38static const double defaultLongTimeout = 30;
     39static const double defaultShortTimeout = 5;
     40
    3841static WKURLRef blankURL()
    3942{
     
    5760    , m_state(Initial)
    5861    , m_doneResetting(false)
     62    , m_longTimeout(defaultLongTimeout)
     63    , m_shortTimeout(defaultShortTimeout)
    5964{
    6065    initialize(argc, argv);
     
    147152        std::string argument(argv[i]);
    148153
     154        if (argument == "--timeout" && i + 1 < argc) {
     155            m_longTimeout = atoi(argv[++i]);
     156            // Scale up the short timeout to match.
     157            m_shortTimeout = defaultShortTimeout * m_longTimeout / defaultLongTimeout;
     158            continue;
     159        }
    149160        if (argument == "--pixel-tests") {
    150161            m_dumpPixels = true;
     
    254265}
    255266
    256 void TestController::resetStateToConsistentValues()
     267bool TestController::resetStateToConsistentValues()
    257268{
    258269    m_state = Resetting;
     
    286297
    287298    WKPageLoadURL(m_mainWebView->page(), blankURL());
    288     TestController::runUntil(m_doneResetting);
    289 }
    290 
    291 void TestController::runTest(const char* test)
    292 {
    293     resetStateToConsistentValues();
     299    runUntil(m_doneResetting, ShortTimeout);
     300    return m_doneResetting;
     301}
     302
     303bool TestController::runTest(const char* test)
     304{
     305    if (!resetStateToConsistentValues())
     306        return false;
    294307
    295308    m_state = RunningTest;
     
    297310    m_currentInvocation->invoke();
    298311    m_currentInvocation.clear();
     312
     313    return true;
    299314}
    300315
     
    310325            continue;
    311326
    312         runTest(filenameBuffer);
     327        if (!runTest(filenameBuffer))
     328            break;
    313329    }
    314330}
     
    319335        runTestingServerLoop();
    320336    else {
    321         for (size_t i = 0; i < m_paths.size(); ++i)
    322             runTest(m_paths[i].c_str());
     337        for (size_t i = 0; i < m_paths.size(); ++i) {
     338            if (!runTest(m_paths[i].c_str()))
     339                break;
     340        }
    323341    }
     342}
     343
     344void TestController::runUntil(bool& done, TimeoutDuration timeoutDuration)
     345{
     346    platformRunUntil(done, timeoutDuration == ShortTimeout ? m_shortTimeout : m_longTimeout);
    324347}
    325348
  • trunk/WebKitTools/WebKitTestRunner/TestController.h

    r70723 r71263  
    5454    WKContextRef context() { return m_context.get(); }
    5555
    56     // Helper
    57     static void runUntil(bool& done);
     56    // Runs the run loop until `done` is true or the timeout elapses.
     57    enum TimeoutDuration { ShortTimeout, LongTimeout };
     58    void runUntil(bool& done, TimeoutDuration);
    5859
    5960private:
     
    6263
    6364    void runTestingServerLoop();
    64     void runTest(const char* pathOrURL);
     65    bool runTest(const char* pathOrURL);
    6566
    6667    void platformInitialize();
    6768    void platformInitializeContext();
     69    void platformRunUntil(bool& done, double timeout);
    6870    void initializeInjectedBundlePath();
    6971    void initializeTestPluginDirectory();
    7072
    71     void resetStateToConsistentValues();
     73    bool resetStateToConsistentValues();
    7274
    7375    // WKContextInjectedBundleClient
     
    103105    State m_state;
    104106    bool m_doneResetting;
     107
     108    double m_longTimeout;
     109    double m_shortTimeout;
    105110};
    106111
  • trunk/WebKitTools/WebKitTestRunner/TestInvocation.cpp

    r70723 r71263  
    121121    WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
    122122
    123     TestController::runUntil(m_gotInitialResponse);
     123    TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout);
     124    if (!m_gotInitialResponse) {
     125        dump("Timed out waiting for initial response from web process\n");
     126        return;
     127    }
    124128    if (m_error) {
    125129        dump("FAIL\n");
     
    129133    WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get());
    130134
    131     TestController::runUntil(m_gotFinalMessage);
     135    TestController::shared().runUntil(m_gotFinalMessage, TestController::LongTimeout);
     136    if (!m_gotFinalMessage) {
     137        dump("Timed out waiting for final message from web process\n");
     138        return;
     139    }
    132140    if (m_error) {
    133141        dump("FAIL\n");
  • trunk/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm

    r70723 r71263  
    4646}
    4747
    48 void TestController::runUntil(bool& done)
     48void TestController::platformRunUntil(bool& done, double timeout)
    4949{
    50     while (!done)
    51         [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
     50    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent() + timeout;
     51    while (!done && CFAbsoluteTimeGetCurrent() < end)
     52        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
    5253}
    5354
  • trunk/WebKitTools/WebKitTestRunner/qt/TestControllerQt.cpp

    r70060 r71263  
    8484}
    8585
    86 void TestController::runUntil(bool& done)
     86void TestController::platformRunUntil(bool& done, double)
    8787{
     88    // FIXME: Honor the timeout parameter <http://webkit.org/b/48941>.
    8889    RunUntilConditionLoop::start(done);
    8990    ASSERT(done);
  • trunk/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp

    r65831 r71263  
    121121}
    122122
    123 void TestController::runUntil(bool& done)
     123void TestController::platformRunUntil(bool& done, double timeout)
    124124{
     125    DWORD end = ::GetTickCount() + timeout * 1000;
    125126    while (!done) {
     127        DWORD now = ::GetTickCount();
     128        if (now > end)
     129            return;
     130
     131        DWORD result = ::MsgWaitForMultipleObjectsEx(0, 0, end - now, QS_ALLINPUT, 0);
     132        if (result == WAIT_TIMEOUT)
     133            return;
     134
     135        ASSERT(result == WAIT_OBJECT_0);
     136        // There are messages in the queue. Process them.
    126137        MSG msg;
    127         BOOL result = GetMessage(&msg, 0, 0, 0);
    128         if (result == -1)
    129             return;
    130         TranslateMessage(&msg);
    131         DispatchMessage(&msg);
     138        while (::PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) {
     139            ::TranslateMessage(&msg);
     140            ::DispatchMessageW(&msg);
     141        }
    132142    }
    133143}
Note: See TracChangeset for help on using the changeset viewer.