[glib: 1/12] tests: Ensure timeout source is removed in gdbus-auth test




commit 404d5d40e05354a2483c88122478e046be389996
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Mar 11 23:47:22 2022 +0000

    tests: Ensure timeout source is removed in gdbus-auth test
    
    If the whole set of tests takes more than 5 seconds, the failure timeout
    from the first test could still trigger, causing an incorrect failure.
    
    Ensure the timeout is removed at the end of each test.i
    
    This will hopefully fix the CI failure seen here:
    https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
    ```
    204/266 glib:gio / gdbus-auth                   FAIL     9.21 s (killed by signal 5 SIGTRAP)
    …
    ok 1 /gdbus/auth/client/EXTERNAL
    Bail out! GLib-GIO-FATAL-ERROR: Timeout waiting for client
    ```
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/tests/gdbus-auth.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gio/tests/gdbus-auth.c b/gio/tests/gdbus-auth.c
index 18288f36d..eabfdd331 100644
--- a/gio/tests/gdbus-auth.c
+++ b/gio/tests/gdbus-auth.c
@@ -167,6 +167,7 @@ test_auth_mechanism (const gchar *allowed_client_mechanism,
   GMainLoop *loop;
   GThread *client_thread;
   TestAuthData data;
+  guint timeout_id;
 
   server = server_new_for_mechanism (allowed_server_mechanism);
 
@@ -177,7 +178,7 @@ test_auth_mechanism (const gchar *allowed_client_mechanism,
                     G_CALLBACK (test_auth_on_new_connection),
                     loop);
 
-  g_timeout_add_seconds (5, test_auth_on_timeout, NULL);
+  timeout_id = g_timeout_add_seconds (5, test_auth_on_timeout, NULL);
 
   data.allowed_client_mechanism = allowed_client_mechanism;
   data.allowed_server_mechanism = allowed_server_mechanism;
@@ -195,6 +196,7 @@ test_auth_mechanism (const gchar *allowed_client_mechanism,
   g_dbus_server_stop (server);
 
   g_thread_join (client_thread);
+  g_source_remove (timeout_id);
 
   while (g_main_context_iteration (NULL, FALSE));
   g_main_loop_unref (loop);


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