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>
This commit is contained in:
Philip Withnall 2022-03-11 23:47:22 +00:00
parent 91411338dc
commit 404d5d40e0

View File

@ -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);