[libsoup/autobahn-integration-new: 23/23] autobahn-test.c: Implement timeout in main loop




commit e3217eb1ce7d1417d385fadccc5a9666b59d14c8
Author: Diego Pino Garcia <dpino igalia com>
Date:   Thu Mar 11 07:30:18 2021 +0000

    autobahn-test.c: Implement timeout in main loop

 tests/autobahn/autobahn-test.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/tests/autobahn/autobahn-test.c b/tests/autobahn/autobahn-test.c
index 81e4bb35..2c6ecfaa 100644
--- a/tests/autobahn/autobahn-test.c
+++ b/tests/autobahn/autobahn-test.c
@@ -116,8 +116,17 @@ connect_and_run (SoupSession *session, char *path, ConnectionFunc method, gpoint
         g_test_message ("Connecting to %s", uri);
         soup_session_websocket_connect_async (session, message, NULL, NULL, G_PRIORITY_DEFAULT, NULL, 
on_connect, ctx);
 
-        while (!ctx->done)
-               g_main_context_iteration (async_context, TRUE);
+        time_t now = time(NULL);
+        const int timeout = 30;
+        const time_t threshold = now + timeout;
+        while (!ctx->done) {
+                g_main_context_iteration (async_context, TRUE);
+                now = time(NULL);
+                if (now > threshold) {
+                        debug_printf (1, "Test timeout: %s\n", uri);
+                        ctx->done = TRUE;
+                }
+        }
 
         g_object_unref (message);
         g_free (uri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]