Title: [239401] trunk/Tools
- Revision
- 239401
- Author
- [email protected]
- Date
- 2018-12-19 15:44:48 -0800 (Wed, 19 Dec 2018)
Log Message
[GTK][WPE] Unify TestController::platformRunUntil() and honor condition flag
https://bugs.webkit.org/show_bug.cgi?id=192855
Reviewed by Michael Catanzaro.
* WebKitTestRunner/gtk/TestControllerGtk.cpp:
(WTR::TestController::notifyDone): Use the WPE implementation.
(WTR::TestController::platformRunUntil): Use the WPE implementation.
* WebKitTestRunner/wpe/TestControllerWPE.cpp:
(WTR::TestController::platformRunUntil): Honor the condition flag.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (239400 => 239401)
--- trunk/Tools/ChangeLog 2018-12-19 23:37:02 UTC (rev 239400)
+++ trunk/Tools/ChangeLog 2018-12-19 23:44:48 UTC (rev 239401)
@@ -1,3 +1,16 @@
+2018-12-19 Adrian Perez de Castro <[email protected]>
+
+ [GTK][WPE] Unify TestController::platformRunUntil() and honor condition flag
+ https://bugs.webkit.org/show_bug.cgi?id=192855
+
+ Reviewed by Michael Catanzaro.
+
+ * WebKitTestRunner/gtk/TestControllerGtk.cpp:
+ (WTR::TestController::notifyDone): Use the WPE implementation.
+ (WTR::TestController::platformRunUntil): Use the WPE implementation.
+ * WebKitTestRunner/wpe/TestControllerWPE.cpp:
+ (WTR::TestController::platformRunUntil): Honor the condition flag.
+
2018-12-19 Megan Gardner <[email protected]>
Allow clients to set the navigator platform
Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (239400 => 239401)
--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp 2018-12-19 23:37:02 UTC (rev 239400)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp 2018-12-19 23:44:48 UTC (rev 239401)
@@ -37,27 +37,8 @@
namespace WTR {
-static GSource* timeoutSource()
-{
- static GRefPtr<GSource> source = nullptr;
- if (!source) {
- source = adoptGRef(g_timeout_source_new(0));
- g_source_set_ready_time(source.get(), -1);
- g_source_set_name(source.get(), "[WTR] Test timeout source");
- g_source_set_callback(source.get(), [](gpointer userData) -> gboolean {
- g_source_set_ready_time(static_cast<GSource*>(userData), -1);
- fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
- RunLoop::main().stop();
- return G_SOURCE_REMOVE;
- }, source.get(), nullptr);
- g_source_attach(source.get(), nullptr);
- }
- return source.get();
-}
-
void TestController::notifyDone()
{
- g_source_set_ready_time(timeoutSource(), -1);
RunLoop::main().stop();
}
@@ -74,17 +55,31 @@
{
}
-void TestController::platformRunUntil(bool&, WTF::Seconds timeout)
+void TestController::platformRunUntil(bool& done, WTF::Seconds timeout)
{
- if (timeout > 0_s) {
- // FIXME: This conversion is now repeated in several places, it should be moved to a common place in WTF and used everywhere.
- gint64 currentTime = g_get_monotonic_time();
- gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeout.microsecondsAs<int64_t>());
- ASSERT(targetTime >= currentTime);
- g_source_set_ready_time(timeoutSource(), targetTime);
- } else
- g_source_set_ready_time(timeoutSource(), -1);
- RunLoop::main().run();
+ struct TimeoutTimer {
+ TimeoutTimer()
+ : timer(RunLoop::main(), this, &TimeoutTimer::fired)
+ { }
+
+ void fired()
+ {
+ timedOut = true;
+ RunLoop::main().stop();
+ }
+
+ RunLoop::Timer<TimeoutTimer> timer;
+ bool timedOut { false };
+ } timeoutTimer;
+
+ timeoutTimer.timer.setPriority(G_PRIORITY_DEFAULT_IDLE);
+ if (timeout >= 0_s)
+ timeoutTimer.timer.startOneShot(timeout);
+
+ while (!done && !timeoutTimer.timedOut)
+ RunLoop::main().run();
+
+ timeoutTimer.timer.stop();
}
static char* getEnvironmentVariableAsUTF8String(const char* variableName)
Modified: trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp (239400 => 239401)
--- trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp 2018-12-19 23:37:02 UTC (rev 239400)
+++ trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp 2018-12-19 23:44:48 UTC (rev 239401)
@@ -58,7 +58,7 @@
{
}
-void TestController::platformRunUntil(bool& condition, WTF::Seconds timeout)
+void TestController::platformRunUntil(bool& done, WTF::Seconds timeout)
{
struct TimeoutTimer {
TimeoutTimer()
@@ -65,8 +65,14 @@
: timer(RunLoop::main(), this, &TimeoutTimer::fired)
{ }
- void fired() { RunLoop::main().stop(); }
+ void fired()
+ {
+ timedOut = true;
+ RunLoop::main().stop();
+ }
+
RunLoop::Timer<TimeoutTimer> timer;
+ bool timedOut { false };
} timeoutTimer;
timeoutTimer.timer.setPriority(G_PRIORITY_DEFAULT_IDLE);
@@ -73,7 +79,8 @@
if (timeout >= 0_s)
timeoutTimer.timer.startOneShot(timeout);
- RunLoop::main().run();
+ while (!done && !timeoutTimer.timedOut)
+ RunLoop::main().run();
timeoutTimer.timer.stop();
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes