diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am index b877577c1..3423d19d8 100644 --- a/gio/tests/Makefile.am +++ b/gio/tests/Makefile.am @@ -72,10 +72,8 @@ test_progs = \ credentials \ $(NULL) -TEST_PROGS += $(test_progs) - if HAVE_DBUS_DAEMON -TEST_PROGS += \ +test_progs += \ actions \ gdbus-connection \ gdbus-connection-loss \ @@ -93,9 +91,8 @@ TEST_PROGS += \ $(NULL) endif - if OS_UNIX -TEST_PROGS += \ +test_progs += \ gdbus-close-pending \ gdbus-connection-flush \ gdbus-peer \ @@ -125,7 +122,6 @@ SAMPLE_PROGS = \ gdbus-example-subtree \ gdbus-example-peer \ gdbus-example-proxy-subclass \ - gdbus-connection-flush-helper \ proxy \ gapplication-example-open \ gapplication-example-cmdline \ @@ -134,11 +130,15 @@ SAMPLE_PROGS = \ gapplication-example-actions \ gapplication-example-dbushooks \ gdbus-daemon \ + $(NULL) + +other_progs = \ gdbus-testserver \ + gdbus-connection-flush-helper \ $(NULL) if OS_UNIX -TEST_PROGS += \ +test_progs += \ live-g-file \ desktop-app-info \ unix-fd \ @@ -148,12 +148,16 @@ TEST_PROGS += \ gdbus-test-codegen \ socket-address \ $(NULL) + +other_progs += \ + appinfo-test \ + $(NULL) + SAMPLE_PROGS += \ gdbus-example-unix-fd-client \ gdbus-example-objectmanager-server \ gdbus-example-objectmanager-client \ gdbus-test-fixture \ - appinfo-test \ $(NULL) endif @@ -202,13 +206,13 @@ gdbus_daemon_SOURCES = gdbus-daemon.c $(top_srcdir)/gio/gdbusdaemon.c $(top_buil gdbus_testserver_SOURCES = gdbus-testserver.c if HAVE_DBUS1 -TEST_PROGS += gdbus-serialization +test_progs += gdbus-serialization gdbus_serialization_SOURCES = gdbus-serialization.c gdbus-tests.h gdbus-tests.c gdbus_serialization_CFLAGS = $(AM_CFLAGS) $(DBUS1_CFLAGS) gdbus_serialization_LDADD = $(LDADD) $(DBUS1_LIBS) endif -TEST_PROGS += gdbus-auth +test_progs += gdbus-auth gdbus_auth_SOURCES = gdbus-auth.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c gdbus_auth_LDADD = $(LDADD) @@ -293,6 +297,8 @@ gapplication_SOURCES = gapplication.c gdbus-sessionbus.h gdbus-sessionbus.c gdbu gmenumodel_SOURCES = gmenumodel.c gdbus-sessionbus.h gdbus-sessionbus.c +TEST_PROGS += $(test_progs) + TESTS_ENVIRONMENT = \ GLIB_MKENUMS=../../gobject/glib-mkenums \ GLIB_COMPILE_SCHEMAS=../glib-compile-schemas @@ -497,10 +503,14 @@ test_files = \ org.gtk.test.gschema.xml \ org.gtk.schemasourcecheck.gschema.xml \ test.gresource \ + appinfo-test.desktop \ + appinfo-test2.desktop \ + appinfo-test-gnome.desktop \ + appinfo-test-notgnome.desktop \ $(NULL) if BUILDOPT_INSTALL_TESTS -insttest_PROGRAMS = $(test_progs) +insttest_PROGRAMS = $(test_progs) $(other_progs) schematestdir = $(insttestdir)/schema-tests schematest_DATA = $(schema_test_files) diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c index 5b10fc8b4..4a7042fc8 100644 --- a/gio/tests/appinfo.c +++ b/gio/tests/appinfo.c @@ -4,6 +4,8 @@ #include #include +static const gchar *datapath; + static void test_launch (void) { @@ -11,9 +13,12 @@ test_launch (void) GError *error; GFile *file; GList *l; + gchar *path; - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (appinfo != NULL); + g_free (path); error = NULL; g_assert (g_app_info_launch (appinfo, NULL, NULL, &error)); @@ -22,7 +27,9 @@ test_launch (void) g_assert (g_app_info_launch_uris (appinfo, NULL, NULL, &error)); g_assert_no_error (error); - file = g_file_new_for_path (SRCDIR "/appinfo-test.desktop"); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + file = g_file_new_for_path (path); + g_free (path); l = NULL; l = g_list_append (l, file); @@ -32,12 +39,14 @@ test_launch (void) g_object_unref (file); l = NULL; - l = g_list_append (l, "file://" SRCDIR "/appinfo-test.desktop"); + path = g_strconcat ("file://", datapath, "/appinfo-test.desktop", NULL); + l = g_list_append (l, path); l = g_list_append (l, "file:///etc/group#adm"); g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error)); g_assert_no_error (error); g_list_free (l); + g_free (path); g_object_unref (appinfo); } @@ -47,12 +56,15 @@ test_locale (const char *locale) { GAppInfo *appinfo; const gchar *orig; + gchar *path; orig = setlocale (LC_ALL, NULL); g_setenv ("LANGUAGE", locale, TRUE); setlocale (LC_ALL, ""); - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); + g_free (path); if (g_strcmp0 (locale, "C") == 0) { @@ -94,8 +106,11 @@ test_basic (void) GAppInfo *appinfo; GAppInfo *appinfo2; GIcon *icon, *icon2; + gchar *path; - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); + g_free (path); g_assert_cmpstr (g_app_info_get_id (appinfo), ==, "appinfo-test.desktop"); g_assert_cmpstr (g_app_info_get_executable (appinfo), ==, "./appinfo-test"); @@ -118,20 +133,27 @@ static void test_show_in (void) { GAppInfo *appinfo; + gchar *path; g_desktop_app_info_set_desktop_env ("GNOME"); - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (g_app_info_should_show (appinfo)); g_object_unref (appinfo); + g_free (path); - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-gnome.desktop"); + path = g_build_filename (datapath, "appinfo-test-gnome.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (g_app_info_should_show (appinfo)); g_object_unref (appinfo); + g_free (path); - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-notgnome.desktop"); + path = g_build_filename (datapath, "appinfo-test-notgnome.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (!g_app_info_should_show (appinfo)); g_object_unref (appinfo); + g_free (path); } static void @@ -139,34 +161,45 @@ test_commandline (void) { GAppInfo *appinfo; GError *error; + gchar *cmdline; + gchar *cmdline_out; + + cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL); + cmdline_out = g_strconcat (cmdline, " %u", NULL); error = NULL; - appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", + appinfo = g_app_info_create_from_commandline (cmdline, "cmdline-app-test", G_APP_INFO_CREATE_SUPPORTS_URIS, &error); g_assert (appinfo != NULL); g_assert_no_error (error); g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test"); - g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %u"); + g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, cmdline_out); g_assert (g_app_info_supports_uris (appinfo)); g_assert (!g_app_info_supports_files (appinfo)); g_object_unref (appinfo); + g_free (cmdline_out); + cmdline_out = g_strconcat (cmdline, " %f", NULL); + error = NULL; - appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", + appinfo = g_app_info_create_from_commandline (cmdline, "cmdline-app-test", G_APP_INFO_CREATE_NONE, &error); g_assert (appinfo != NULL); g_assert_no_error (error); g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test"); - g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %f"); + g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, cmdline_out); g_assert (!g_app_info_supports_uris (appinfo)); g_assert (g_app_info_supports_files (appinfo)); g_object_unref (appinfo); + + g_free (cmdline); + g_free (cmdline_out); } static void @@ -175,9 +208,12 @@ test_launch_context (void) GAppLaunchContext *context; GAppInfo *appinfo; gchar *str; + gchar *cmdline; + + cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL); context = g_app_launch_context_new (); - appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", + appinfo = g_app_info_create_from_commandline (cmdline, "cmdline-app-test", G_APP_INFO_CREATE_SUPPORTS_URIS, NULL); @@ -190,6 +226,8 @@ test_launch_context (void) g_object_unref (appinfo); g_object_unref (context); + + g_free (cmdline); } static gboolean launched_reached; @@ -222,11 +260,14 @@ test_launch_context_signals (void) GAppLaunchContext *context; GAppInfo *appinfo; GError *error = NULL; + gchar *cmdline; + + cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL); context = g_app_launch_context_new (); g_signal_connect (context, "launched", G_CALLBACK (launched), NULL); g_signal_connect (context, "launch_failed", G_CALLBACK (launch_failed), NULL); - appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", + appinfo = g_app_info_create_from_commandline (cmdline, "cmdline-app-test", G_APP_INFO_CREATE_SUPPORTS_URIS, NULL); @@ -239,16 +280,22 @@ test_launch_context_signals (void) g_object_unref (appinfo); g_object_unref (context); + + g_free (cmdline); } static void test_tryexec (void) { GAppInfo *appinfo; + gchar *path; - appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test2.desktop"); + path = g_build_filename (datapath, "appinfo-test2.desktop", NULL); + appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (appinfo == NULL); + + g_free (path); } /* Test that we can set an appinfo as default for a mime type or @@ -262,8 +309,10 @@ test_associations (void) GError *error; gboolean result; GList *list; + gchar *cmdline; - appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", + cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL); + appinfo = g_app_info_create_from_commandline (cmdline, "cmdline-app-test", G_APP_INFO_CREATE_SUPPORTS_URIS, NULL); @@ -362,13 +411,16 @@ test_startup_wm_class (void) { GDesktopAppInfo *appinfo; const char *wm_class; + gchar *path; - appinfo = g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + appinfo = g_desktop_app_info_new_from_filename (path); wm_class = g_desktop_app_info_get_startup_wm_class (appinfo); g_assert_cmpstr (wm_class, ==, "appinfo-class"); g_object_unref (appinfo); + g_free (path); } static void @@ -376,14 +428,17 @@ test_supported_types (void) { GAppInfo *appinfo; const char * const *content_types; + gchar *path; - appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop")); + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); + appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (path)); content_types = g_app_info_get_supported_types (appinfo); g_assert_cmpint (g_strv_length ((char**)content_types), ==, 2); g_assert_cmpstr (content_types[0], ==, "image/png"); g_object_unref (appinfo); + g_free (path); } static void @@ -396,16 +451,16 @@ test_from_keyfile (void) gchar **keywords; const gchar *file; const gchar *name; + gchar *path; + path = g_build_filename (datapath, "appinfo-test.desktop", NULL); kf = g_key_file_new (); - g_key_file_load_from_file (kf, - SRCDIR "/appinfo-test.desktop", - G_KEY_FILE_NONE, - &error); + g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, &error); g_assert_no_error (error); info = g_desktop_app_info_new_from_keyfile (kf); g_key_file_free (kf); g_assert (info != NULL); + g_free (path); g_object_get (info, "filename", &file, NULL); g_assert (file == NULL); @@ -428,6 +483,11 @@ test_from_keyfile (void) int main (int argc, char *argv[]) { + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; + g_test_init (&argc, &argv, NULL); g_test_add_func ("/appinfo/basic", test_basic); diff --git a/gio/tests/gdbus-connection-loss.c b/gio/tests/gdbus-connection-loss.c index 2f99ff511..59fca7a00 100644 --- a/gio/tests/gdbus-connection-loss.c +++ b/gio/tests/gdbus-connection-loss.c @@ -26,6 +26,8 @@ #include "gdbus-tests.h" +static const gchar *datapath; + /* all tests rely on a global connection */ static GDBusConnection *c = NULL; @@ -112,6 +114,12 @@ main (int argc, { GError *error; gint ret; + gchar *path; + + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; g_test_init (&argc, &argv, NULL); @@ -121,7 +129,9 @@ main (int argc, session_bus_up (); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); /* wait for the service to come up */ usleep (500 * 1000); diff --git a/gio/tests/gdbus-connection-slow.c b/gio/tests/gdbus-connection-slow.c index 302cee9d2..889a75eff 100644 --- a/gio/tests/gdbus-connection-slow.c +++ b/gio/tests/gdbus-connection-slow.c @@ -28,6 +28,8 @@ #include "gdbus-tests.h" +static const gchar *datapath; + /* all tests rely on a shared mainloop */ static GMainLoop *loop = NULL; @@ -86,9 +88,11 @@ test_connection_flush (void) gboolean ret; gint exit_status; guint timeout_mainloop_id; + gchar *path; error = NULL; - ret = g_spawn_command_line_sync ("./gdbus-connection-flush-helper", + path = g_build_filename (datapath, "gdbus-connection-flush-helper", NULL); + ret = g_spawn_command_line_sync (path, NULL, /* stdout */ NULL, /* stderr */ &exit_status, @@ -97,6 +101,7 @@ test_connection_flush (void) g_spawn_check_exit_status (exit_status, &error); g_assert_no_error (error); g_assert (ret); + g_free (path); timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n)); g_main_loop_run (loop); @@ -169,11 +174,14 @@ static void test_connection_large_message (void) { guint watcher_id; + gchar *path; session_bus_up (); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, "com.example.TestService", @@ -194,6 +202,11 @@ int main (int argc, char *argv[]) { + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; + g_test_init (&argc, &argv, NULL); /* all the tests rely on a shared main loop */ diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c index f57c776c3..1ab04a2fc 100644 --- a/gio/tests/gdbus-connection.c +++ b/gio/tests/gdbus-connection.c @@ -28,6 +28,8 @@ #include "gdbus-tests.h" +const gchar *datapath; + /* all tests rely on a shared mainloop */ static GMainLoop *loop = NULL; @@ -919,6 +921,7 @@ test_connection_filter (void) FilterEffects effects; GVariant *result; const gchar *s; + gchar *path; memset (&data, '\0', sizeof (FilterData)); @@ -1001,7 +1004,10 @@ test_connection_filter (void) g_assert_cmpint (data.num_outgoing, ==, 4); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); + /* wait for service to be available */ signal_handler_id = g_dbus_connection_signal_subscribe (c, "org.freedesktop.DBus", /* sender */ @@ -1221,6 +1227,11 @@ main (int argc, { g_test_init (&argc, &argv, NULL); + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; + /* all the tests rely on a shared main loop */ loop = g_main_loop_new (NULL, FALSE); diff --git a/gio/tests/gdbus-introspection.c b/gio/tests/gdbus-introspection.c index 95d81ecb4..3d00aa952 100644 --- a/gio/tests/gdbus-introspection.c +++ b/gio/tests/gdbus-introspection.c @@ -26,6 +26,8 @@ #include "gdbus-tests.h" +static const gchar *datapath; + /* all tests rely on a shared mainloop */ static GMainLoop *loop = NULL; @@ -107,6 +109,7 @@ test_introspection_parser (void) GDBusProxy *proxy; GDBusConnection *connection; GError *error; + gchar *path; error = NULL; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, @@ -125,7 +128,9 @@ test_introspection_parser (void) g_assert_no_error (error); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); _g_assert_property_notify (proxy, "g-name-owner"); @@ -303,6 +308,11 @@ main (int argc, { gint ret; + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; + g_test_init (&argc, &argv, NULL); /* all the tests rely on a shared main loop */ diff --git a/gio/tests/gdbus-proxy-well-known-name.c b/gio/tests/gdbus-proxy-well-known-name.c index d0b7591bd..5d3b9ee8b 100644 --- a/gio/tests/gdbus-proxy-well-known-name.c +++ b/gio/tests/gdbus-proxy-well-known-name.c @@ -26,6 +26,8 @@ #include "gdbus-tests.h" +static const gchar *datapath; + /* all tests rely on a shared mainloop */ static GMainLoop *loop = NULL; @@ -60,6 +62,7 @@ test_proxy_well_known_name (void) gchar **property_names; GVariant *variant; GVariant *result; + gchar *path; session_bus_up (); @@ -98,7 +101,9 @@ test_proxy_well_known_name (void) g_assert (g_dbus_proxy_get_cached_property_names (ap) == NULL); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); /* check that we get the notify::g-name-owner signal */ _g_assert_property_notify (p, "g-name-owner"); @@ -224,7 +229,10 @@ test_proxy_well_known_name (void) * the 'y' property should be back at 1... */ /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); + /* check that we get the notify::g-name-owner signal */ _g_assert_property_notify (p, "g-name-owner"); /* Now we should have a name owner as well as properties */ @@ -259,6 +267,11 @@ main (int argc, { gint ret; + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; + g_test_init (&argc, &argv, NULL); /* all the tests rely on a shared main loop */ diff --git a/gio/tests/gdbus-proxy.c b/gio/tests/gdbus-proxy.c index a43825526..9fe8ef995 100644 --- a/gio/tests/gdbus-proxy.c +++ b/gio/tests/gdbus-proxy.c @@ -26,6 +26,8 @@ #include "gdbus-tests.h" +static const gchar *datapath; + /* all tests rely on a shared mainloop */ static GMainLoop *loop = NULL; @@ -762,6 +764,7 @@ test_proxy (void) GDBusProxy *proxy; GDBusConnection *connection; GError *error; + gchar *path; error = NULL; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, @@ -780,7 +783,9 @@ test_proxy (void) g_assert_no_error (error); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); _g_assert_property_notify (proxy, "g-name-owner"); @@ -831,6 +836,8 @@ fail_test (gpointer user_data) static void test_async (void) { + gchar *path; + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo */ @@ -842,7 +849,9 @@ test_async (void) NULL); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); g_timeout_add (10000, fail_test, NULL); g_main_loop_run (loop); @@ -912,6 +921,11 @@ main (int argc, gint ret; GDBusNodeInfo *introspection_data = 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 (frob_dbus_interface_xml, NULL); diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c index 1f0fc525c..355d0df56 100644 --- a/gio/tests/gdbus-threading.c +++ b/gio/tests/gdbus-threading.c @@ -26,6 +26,8 @@ #include "gdbus-tests.h" +static const gchar *datapath; + /* all tests rely on a global connection */ static GDBusConnection *c = NULL; @@ -581,13 +583,21 @@ main (int argc, { GError *error; gint ret; + gchar *path; + + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = SRCDIR; g_test_init (&argc, &argv, NULL); session_bus_up (); /* this is safe; testserver will exit once the bus goes away */ - g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL)); + path = g_build_filename (datapath, "gdbus-testserver", NULL); + g_assert (g_spawn_command_line_async (path, NULL)); + g_free (path); /* wait for the service to come up */ usleep (500 * 1000);