summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-05-20 21:50:28 +0100
committerColin Walters <walters@verbum.org>2013-05-20 21:50:28 +0100
commit3d7fcc23c154824a0377ceea07a1d3b18bcd3874 (patch)
treea2d84d93e3ef469408fb526db599597443d080b5
parent7ee44da5cf7fc5c7bee18c29287d8f062f045c67 (diff)
downloadglib-wip/installed-tests.tar.gz
gio/tests: Make gdbus-peer work in installed modewip/installed-tests
There's no /etc/hosts in gnome-ostree...
-rw-r--r--gio/tests/gdbus-peer.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index 799c6730c..f85a055cd 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -62,6 +62,8 @@ static gboolean is_unix = TRUE;
static gboolean is_unix = FALSE;
#endif
+static const gchar *datapath;
+
static gchar *tmp_address = NULL;
static gchar *test_guid = NULL;
static GMainLoop *service_loop = NULL;
@@ -186,6 +188,7 @@ test_interface_method_call (GDBusConnection *connection,
error = NULL;
fd = g_open (path, O_RDONLY, 0);
+ g_assert (fd != -1);
g_unix_fd_list_append (fd_list, fd, &error);
g_assert_no_error (error);
close (fd);
@@ -759,12 +762,13 @@ test_peer (void)
gsize len;
gchar *buf2;
gsize len2;
+ char *testfile = g_build_filename (datapath, "file.c", NULL);
method_call_message = g_dbus_message_new_method_call (NULL, /* name */
"/org/gtk/GDBus/PeerTestObject",
"org.gtk.GDBus.PeerTestInterface",
"OpenFile");
- g_dbus_message_set_body (method_call_message, g_variant_new ("(s)", "/etc/hosts"));
+ g_dbus_message_set_body (method_call_message, g_variant_new ("(s)", testfile));
error = NULL;
method_reply_message = g_dbus_connection_send_message_with_reply_sync (c,
method_call_message,
@@ -792,7 +796,7 @@ test_peer (void)
close (fd);
error = NULL;
- g_file_get_contents ("/etc/hosts",
+ g_file_get_contents (testfile,
&buf2,
&len2,
&error);
@@ -801,6 +805,7 @@ test_peer (void)
g_assert (memcmp (buf, buf2, len) == 0);
g_free (buf2);
g_free (buf);
+ g_free (testfile);
}
#else
error = NULL;
@@ -1822,6 +1827,11 @@ main (int argc,
GDBusNodeInfo *introspection_data = NULL;
gchar *tmpdir = NULL;
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (test_interface_introspection_xml, NULL);