summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2008-05-28 04:25:57 (GMT)
committerColin Walters <walters@verbum.org>2008-05-28 04:25:57 (GMT)
commita94e11973467e1b2cc43ba1e77b7413655b1dff7 (patch)
tree1268383d58a13c32c585ab939a548d0dac3d057e
parentdceee795d0cdc5889701064ac38d3c64451b02ec (diff)
downloaddbus-glib-a94e11973467e1b2cc43ba1e77b7413655b1dff7.tar.gz
dbus-glib-a94e11973467e1b2cc43ba1e77b7413655b1dff7.tar.xz
Bug 11671: Don't use well known name in /tmp
This as a side effect fixes the test suite on Solaris.
-rw-r--r--test/core/peer-client.c13
-rw-r--r--test/core/peer-server.c26
-rwxr-xr-xtest/core/run-peer-test.sh9
3 files changed, 29 insertions, 19 deletions
diff --git a/test/core/peer-client.c b/test/core/peer-client.c
index 4eb4c96..b3f9874 100644
--- a/test/core/peer-client.c
+++ b/test/core/peer-client.c
@@ -1,5 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
@@ -69,13 +71,22 @@ main (int argc, char **argv)
DBusGConnection *conn;
DBusGProxy *proxy;
guint32 v_UINT32_2;
+ char *addrbuf;
+ gsize lineoffset;
+ GIOChannel *io;
g_thread_init (NULL); dbus_g_thread_init ();
g_type_init ();
+ io = g_io_channel_unix_new (0);
+ if (!g_io_channel_read_line (io, &addrbuf, NULL, &lineoffset, &error))
+ lose_gerror ("failed to read address from stdin", error);
+ /* trim newline */
+ addrbuf[lineoffset] = '\0';
+
loop = g_main_loop_new (NULL, TRUE);
- conn = dbus_g_connection_open ("unix:abstract=/tmp/dbus-glib-peer.sock", &error);
+ conn = dbus_g_connection_open (addrbuf, &error);
if (!conn)
g_error ("Cannot open connection: %s", error->message);
diff --git a/test/core/peer-server.c b/test/core/peer-server.c
index f7dff6b..f1aa860 100644
--- a/test/core/peer-server.c
+++ b/test/core/peer-server.c
@@ -1,3 +1,6 @@
+#include <stdio.h>
+#include <stdlib.h>
+
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -6,13 +9,6 @@
GMainLoop *loop;
-static const char*
-make_path (void)
-{
- /* TODO: not this */
- return "unix:abstract=/tmp/dbus-glib-peer.sock";
-}
-
static void
new_connection_func (DBusServer *server, DBusConnection *conn, gpointer user_data)
{
@@ -32,6 +28,7 @@ main (int argc, char **argv)
{
DBusError error;
DBusServer *server;
+ char *addr;
dbus_error_init (&error);
@@ -40,11 +37,16 @@ main (int argc, char **argv)
loop = g_main_loop_new (NULL, TRUE);
- server = dbus_server_listen (make_path (), &error);
- if (!server) {
- g_warning ("Cannot create server: %s", error.message);
- return 1;
- }
+ server = dbus_server_listen ("unix:tmpdir=/tmp", &error);
+ if (!server)
+ {
+ g_warning ("Cannot create server: %s", error.message);
+ return 1;
+ }
+ addr = dbus_server_get_address (server);
+ fprintf (stdout, "%s\n", addr);
+ fflush (stdout);
+ free (addr);
dbus_server_setup_with_g_main (server, NULL);
dbus_server_set_new_connection_function (server, new_connection_func, NULL, NULL);
diff --git a/test/core/run-peer-test.sh b/test/core/run-peer-test.sh
index a779edd..10d9528 100755
--- a/test/core/run-peer-test.sh
+++ b/test/core/run-peer-test.sh
@@ -1,9 +1,6 @@
-#! /bin/sh
+#!/bin/sh
set -e
-${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-server &
-
-sleep 1
-
-${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-client
+# The peer server writes its address over stdout, which the client reads
+${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-server | ${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-client