Changeset 239401 in webkit
- Timestamp:
- Dec 19, 2018 3:44:48 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r239384 r239401 1 2018-12-19 Adrian Perez de Castro <aperez@igalia.com> 2 3 [GTK][WPE] Unify TestController::platformRunUntil() and honor condition flag 4 https://bugs.webkit.org/show_bug.cgi?id=192855 5 6 Reviewed by Michael Catanzaro. 7 8 * WebKitTestRunner/gtk/TestControllerGtk.cpp: 9 (WTR::TestController::notifyDone): Use the WPE implementation. 10 (WTR::TestController::platformRunUntil): Use the WPE implementation. 11 * WebKitTestRunner/wpe/TestControllerWPE.cpp: 12 (WTR::TestController::platformRunUntil): Honor the condition flag. 13 1 14 2018-12-19 Megan Gardner <megan_gardner@apple.com> 2 15 -
trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp
r235399 r239401 38 38 namespace WTR { 39 39 40 static GSource* timeoutSource()41 {42 static GRefPtr<GSource> source = nullptr;43 if (!source) {44 source = adoptGRef(g_timeout_source_new(0));45 g_source_set_ready_time(source.get(), -1);46 g_source_set_name(source.get(), "[WTR] Test timeout source");47 g_source_set_callback(source.get(), [](gpointer userData) -> gboolean {48 g_source_set_ready_time(static_cast<GSource*>(userData), -1);49 fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");50 RunLoop::main().stop();51 return G_SOURCE_REMOVE;52 }, source.get(), nullptr);53 g_source_attach(source.get(), nullptr);54 }55 return source.get();56 }57 58 40 void TestController::notifyDone() 59 41 { 60 g_source_set_ready_time(timeoutSource(), -1);61 42 RunLoop::main().stop(); 62 43 } … … 75 56 } 76 57 77 void TestController::platformRunUntil(bool& , WTF::Seconds timeout)58 void TestController::platformRunUntil(bool& done, WTF::Seconds timeout) 78 59 { 79 if (timeout > 0_s) { 80 // FIXME: This conversion is now repeated in several places, it should be moved to a common place in WTF and used everywhere. 81 gint64 currentTime = g_get_monotonic_time(); 82 gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeout.microsecondsAs<int64_t>()); 83 ASSERT(targetTime >= currentTime); 84 g_source_set_ready_time(timeoutSource(), targetTime); 85 } else 86 g_source_set_ready_time(timeoutSource(), -1); 87 RunLoop::main().run(); 60 struct TimeoutTimer { 61 TimeoutTimer() 62 : timer(RunLoop::main(), this, &TimeoutTimer::fired) 63 { } 64 65 void fired() 66 { 67 timedOut = true; 68 RunLoop::main().stop(); 69 } 70 71 RunLoop::Timer<TimeoutTimer> timer; 72 bool timedOut { false }; 73 } timeoutTimer; 74 75 timeoutTimer.timer.setPriority(G_PRIORITY_DEFAULT_IDLE); 76 if (timeout >= 0_s) 77 timeoutTimer.timer.startOneShot(timeout); 78 79 while (!done && !timeoutTimer.timedOut) 80 RunLoop::main().run(); 81 82 timeoutTimer.timer.stop(); 88 83 } 89 84 -
trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp
r235399 r239401 59 59 } 60 60 61 void TestController::platformRunUntil(bool& condition, WTF::Seconds timeout)61 void TestController::platformRunUntil(bool& done, WTF::Seconds timeout) 62 62 { 63 63 struct TimeoutTimer { … … 66 66 { } 67 67 68 void fired() { RunLoop::main().stop(); } 68 void fired() 69 { 70 timedOut = true; 71 RunLoop::main().stop(); 72 } 73 69 74 RunLoop::Timer<TimeoutTimer> timer; 75 bool timedOut { false }; 70 76 } timeoutTimer; 71 77 … … 74 80 timeoutTimer.timer.startOneShot(timeout); 75 81 76 RunLoop::main().run(); 82 while (!done && !timeoutTimer.timedOut) 83 RunLoop::main().run(); 77 84 78 85 timeoutTimer.timer.stop();
Note: See TracChangeset
for help on using the changeset viewer.