From a769d111600b58452622279128f040f50ebe48f6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 12 Apr 2012 14:01:40 +0100 Subject: dbus-tube-chan test: listen on a random address appropriate for the OS Instead of hard-coding the abstract Unix socket '\000dbus-tube-test', listen on a random (abstract or real) Unix socket in /tmp if on Unix, or a random port on 127.0.0.1 if not. These are the same listening addresses I used in test/loopback.c in libdbus. The Unix version also matches what the session bus normally uses. This fixes the test on non-Linux Unix (not insisting on abstract-namespace sockets working), when run twice in parallel on Linux (not insisting on using a particular hard-coded name), and in theory also on Windows (not trying to use Unix sockets). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48600 Signed-off-by: Simon McVittie Reviewed-by: Guillaume Desmottes --- tests/lib/dbus-tube-chan.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/lib/dbus-tube-chan.c b/tests/lib/dbus-tube-chan.c index 7c615c86e..8af4a1687 100644 --- a/tests/lib/dbus-tube-chan.c +++ b/tests/lib/dbus-tube-chan.c @@ -18,6 +18,12 @@ #include #include +#if defined(G_OS_UNIX) +# define LISTEN_ADDRESS "unix:tmpdir=/tmp" +#else +# define LISTEN_ADDRESS "tcp:host=127.0.0.1" +#endif + enum { PROP_SERVICE_NAME = 1, @@ -323,8 +329,7 @@ open_tube (TpTestsDBusTubeChannel *self) guid = g_dbus_generate_guid (); - self->priv->dbus_server = g_dbus_server_new_sync ( - "unix:abstract=dbus-tube-test", + self->priv->dbus_server = g_dbus_server_new_sync (LISTEN_ADDRESS, G_DBUS_SERVER_FLAGS_NONE, guid, NULL, NULL, &error); g_assert_no_error (error); -- cgit v1.2.1