summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2011-08-27 11:33:43 -0400
committerDan Winship <danw@gnome.org>2011-08-30 09:52:46 -0400
commit302a5072c915fc95e187e733acab139bca692e0b (patch)
treedfc39dabb3411829283112674a52dc4ea3f02a30 /gio
parentd156492c8333097d969e933abbde2cab6011b321 (diff)
gio/tests/gdbus-peer: make this work on non-Linux unixes
The test was using a socket in a temporary directory, but not actually creating that temporary directory. This worked fine on Linux since it actually ended up using an abstract socket instead, but failed on unixes without abstract sockets. https://bugzilla.gnome.org/show_bug.cgi?id=657517
Diffstat (limited to 'gio')
-rw-r--r--gio/tests/gdbus-peer.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index af2feca41..444066516 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -53,6 +53,7 @@ static gboolean is_unix = TRUE;
static gboolean is_unix = FALSE;
#endif
+static gchar *tmp_address = NULL;
static gchar *test_guid = NULL;
static GMainLoop *service_loop = NULL;
static GDBusServer *server = NULL;
@@ -330,7 +331,7 @@ service_thread_func (gpointer user_data)
error = NULL;
observer = g_dbus_auth_observer_new ();
- server = g_dbus_server_new_sync (is_unix ? "unix:tmpdir=/tmp/gdbus-test-" : "nonce-tcp:",
+ server = g_dbus_server_new_sync (tmp_address,
G_DBUS_SERVER_FLAGS_NONE,
test_guid,
observer,
@@ -1004,7 +1005,7 @@ dmp_thread_func (gpointer user_data)
error = NULL;
guid = g_dbus_generate_guid ();
- data->server = g_dbus_server_new_sync ("unix:tmpdir=/tmp/gdbus-test-",
+ data->server = g_dbus_server_new_sync (tmp_address,
G_DBUS_SERVER_FLAGS_NONE,
guid,
NULL, /* GDBusAuthObserver */
@@ -1533,6 +1534,7 @@ main (int argc,
{
gint ret;
GDBusNodeInfo *introspection_data = NULL;
+ gchar *tmpdir = NULL;
g_type_init ();
g_thread_init (NULL);
@@ -1546,6 +1548,19 @@ main (int argc,
test_guid = g_dbus_generate_guid ();
+ if (is_unix)
+ {
+ if (g_unix_socket_address_abstract_names_supported ())
+ tmp_address = g_strdup ("unix:tmpdir=/tmp/gdbus-test-");
+ else
+ {
+ tmpdir = g_dir_make_tmp ("gdbus-test-XXXXXX", NULL);
+ tmp_address = g_strdup_printf ("unix:tmpdir=%s", tmpdir);
+ }
+ }
+ else
+ tmp_address = g_strdup ("nonce-tcp:");
+
/* all the tests rely on a shared main loop */
loop = g_main_loop_new (NULL, FALSE);
@@ -1561,6 +1576,13 @@ main (int argc,
g_main_loop_unref (loop);
g_free (test_guid);
g_dbus_node_info_unref (introspection_data);
+ if (is_unix)
+ g_free (tmp_address);
+ if (tmpdir)
+ {
+ g_rmdir (tmpdir);
+ g_free (tmpdir);
+ }
return ret;
}