From d79cf4b9009a9bae73523f5ac6f9e4154cbb3c6c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 15 Sep 2020 17:20:59 +0100 Subject: gdbus-server-auth: Don't usually test non-EXTERNAL repeatedly Even after changing the timeouts for #2164, DBUS_COOKIE_SHA1 doesn't seem to be 100% reliable. EXTERNAL is what we actually hope to be using on practical Unix systems (notably Linux and several flavours of BSD), so let's test that thoroughly by default, and just do a relatively cursory check on DBUS_COOKIE_SHA1 and ANONYMOUS. In particular, the original purpose of this test was to make sure that EXTERNAL authentication over AF_UNIX sockets interoperated with libdbus reliably; it only tests DBUS_COOKIE_SHA1, ANONYMOUS and TCP out of a sense of completeness. Signed-off-by: Simon McVittie --- gio/tests/gdbus-server-auth.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gio/tests/gdbus-server-auth.c b/gio/tests/gdbus-server-auth.c index b3ee8aab2..b349d5586 100644 --- a/gio/tests/gdbus-server-auth.c +++ b/gio/tests/gdbus-server-auth.c @@ -273,10 +273,23 @@ do_test_server_auth (InteropFlags flags) GVariant *tuple = NULL; gint64 uid, pid; #ifdef HAVE_DBUS1 - /* GNOME/glib#1831 seems to involve a race condition, so try a few times - * to see if we can trigger it. */ gsize i; - gsize n = 20; + gsize n; + + /* GNOME/glib#1831 and GNOME/glib#2164 involve race conditions, so + * try a few times to see if we can trigger them. DBUS_COOKIE_SHA1 + * is still not entirely reliable, so for now we only do this in + * situations where we expect to be able to use EXTERNAL auth, + * unless asked to be particularly thorough. */ + if (g_test_thorough () +#if defined(G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED) || \ + defined(G_CREDENTIALS_SOCKET_GET_CREDENTIALS_SUPPORTED) + || !(flags & (INTEROP_FLAGS_ANONYMOUS | INTEROP_FLAGS_SHA1 | INTEROP_FLAGS_TCP)) +#endif + ) + n = 20; + else + n = 1; #endif if (flags & INTEROP_FLAGS_TCP) -- cgit v1.2.1