Convert remaining gio tests to installed

This commit is contained in:
Matthias Clasen 2013-05-20 08:46:21 -04:00
parent 5e1f9173c3
commit 142d78214d
9 changed files with 194 additions and 43 deletions

View File

@ -72,10 +72,8 @@ test_progs = \
credentials \ credentials \
$(NULL) $(NULL)
TEST_PROGS += $(test_progs)
if HAVE_DBUS_DAEMON if HAVE_DBUS_DAEMON
TEST_PROGS += \ test_progs += \
actions \ actions \
gdbus-connection \ gdbus-connection \
gdbus-connection-loss \ gdbus-connection-loss \
@ -93,9 +91,8 @@ TEST_PROGS += \
$(NULL) $(NULL)
endif endif
if OS_UNIX if OS_UNIX
TEST_PROGS += \ test_progs += \
gdbus-close-pending \ gdbus-close-pending \
gdbus-connection-flush \ gdbus-connection-flush \
gdbus-peer \ gdbus-peer \
@ -125,7 +122,6 @@ SAMPLE_PROGS = \
gdbus-example-subtree \ gdbus-example-subtree \
gdbus-example-peer \ gdbus-example-peer \
gdbus-example-proxy-subclass \ gdbus-example-proxy-subclass \
gdbus-connection-flush-helper \
proxy \ proxy \
gapplication-example-open \ gapplication-example-open \
gapplication-example-cmdline \ gapplication-example-cmdline \
@ -134,11 +130,15 @@ SAMPLE_PROGS = \
gapplication-example-actions \ gapplication-example-actions \
gapplication-example-dbushooks \ gapplication-example-dbushooks \
gdbus-daemon \ gdbus-daemon \
$(NULL)
other_progs = \
gdbus-testserver \ gdbus-testserver \
gdbus-connection-flush-helper \
$(NULL) $(NULL)
if OS_UNIX if OS_UNIX
TEST_PROGS += \ test_progs += \
live-g-file \ live-g-file \
desktop-app-info \ desktop-app-info \
unix-fd \ unix-fd \
@ -148,12 +148,16 @@ TEST_PROGS += \
gdbus-test-codegen \ gdbus-test-codegen \
socket-address \ socket-address \
$(NULL) $(NULL)
other_progs += \
appinfo-test \
$(NULL)
SAMPLE_PROGS += \ SAMPLE_PROGS += \
gdbus-example-unix-fd-client \ gdbus-example-unix-fd-client \
gdbus-example-objectmanager-server \ gdbus-example-objectmanager-server \
gdbus-example-objectmanager-client \ gdbus-example-objectmanager-client \
gdbus-test-fixture \ gdbus-test-fixture \
appinfo-test \
$(NULL) $(NULL)
endif endif
@ -202,13 +206,13 @@ gdbus_daemon_SOURCES = gdbus-daemon.c $(top_srcdir)/gio/gdbusdaemon.c $(top_buil
gdbus_testserver_SOURCES = gdbus-testserver.c gdbus_testserver_SOURCES = gdbus-testserver.c
if HAVE_DBUS1 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_SOURCES = gdbus-serialization.c gdbus-tests.h gdbus-tests.c
gdbus_serialization_CFLAGS = $(AM_CFLAGS) $(DBUS1_CFLAGS) gdbus_serialization_CFLAGS = $(AM_CFLAGS) $(DBUS1_CFLAGS)
gdbus_serialization_LDADD = $(LDADD) $(DBUS1_LIBS) gdbus_serialization_LDADD = $(LDADD) $(DBUS1_LIBS)
endif 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_SOURCES = gdbus-auth.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
gdbus_auth_LDADD = $(LDADD) 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 gmenumodel_SOURCES = gmenumodel.c gdbus-sessionbus.h gdbus-sessionbus.c
TEST_PROGS += $(test_progs)
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \
GLIB_MKENUMS=../../gobject/glib-mkenums \ GLIB_MKENUMS=../../gobject/glib-mkenums \
GLIB_COMPILE_SCHEMAS=../glib-compile-schemas GLIB_COMPILE_SCHEMAS=../glib-compile-schemas
@ -497,10 +503,14 @@ test_files = \
org.gtk.test.gschema.xml \ org.gtk.test.gschema.xml \
org.gtk.schemasourcecheck.gschema.xml \ org.gtk.schemasourcecheck.gschema.xml \
test.gresource \ test.gresource \
appinfo-test.desktop \
appinfo-test2.desktop \
appinfo-test-gnome.desktop \
appinfo-test-notgnome.desktop \
$(NULL) $(NULL)
if BUILDOPT_INSTALL_TESTS if BUILDOPT_INSTALL_TESTS
insttest_PROGRAMS = $(test_progs) insttest_PROGRAMS = $(test_progs) $(other_progs)
schematestdir = $(insttestdir)/schema-tests schematestdir = $(insttestdir)/schema-tests
schematest_DATA = $(schema_test_files) schematest_DATA = $(schema_test_files)

View File

@ -4,6 +4,8 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gio/gdesktopappinfo.h> #include <gio/gdesktopappinfo.h>
static const gchar *datapath;
static void static void
test_launch (void) test_launch (void)
{ {
@ -11,9 +13,12 @@ test_launch (void)
GError *error; GError *error;
GFile *file; GFile *file;
GList *l; 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_assert (appinfo != NULL);
g_free (path);
error = NULL; error = NULL;
g_assert (g_app_info_launch (appinfo, NULL, NULL, &error)); 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 (g_app_info_launch_uris (appinfo, NULL, NULL, &error));
g_assert_no_error (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 = NULL;
l = g_list_append (l, file); l = g_list_append (l, file);
@ -32,12 +39,14 @@ test_launch (void)
g_object_unref (file); g_object_unref (file);
l = NULL; 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"); l = g_list_append (l, "file:///etc/group#adm");
g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error)); g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error));
g_assert_no_error (error); g_assert_no_error (error);
g_list_free (l); g_list_free (l);
g_free (path);
g_object_unref (appinfo); g_object_unref (appinfo);
} }
@ -47,12 +56,15 @@ test_locale (const char *locale)
{ {
GAppInfo *appinfo; GAppInfo *appinfo;
const gchar *orig; const gchar *orig;
gchar *path;
orig = setlocale (LC_ALL, NULL); orig = setlocale (LC_ALL, NULL);
g_setenv ("LANGUAGE", locale, TRUE); g_setenv ("LANGUAGE", locale, TRUE);
setlocale (LC_ALL, ""); 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) if (g_strcmp0 (locale, "C") == 0)
{ {
@ -94,8 +106,11 @@ test_basic (void)
GAppInfo *appinfo; GAppInfo *appinfo;
GAppInfo *appinfo2; GAppInfo *appinfo2;
GIcon *icon, *icon2; 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_id (appinfo), ==, "appinfo-test.desktop");
g_assert_cmpstr (g_app_info_get_executable (appinfo), ==, "./appinfo-test"); g_assert_cmpstr (g_app_info_get_executable (appinfo), ==, "./appinfo-test");
@ -118,20 +133,27 @@ static void
test_show_in (void) test_show_in (void)
{ {
GAppInfo *appinfo; GAppInfo *appinfo;
gchar *path;
g_desktop_app_info_set_desktop_env ("GNOME"); 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_assert (g_app_info_should_show (appinfo));
g_object_unref (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_assert (g_app_info_should_show (appinfo));
g_object_unref (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_assert (!g_app_info_should_show (appinfo));
g_object_unref (appinfo); g_object_unref (appinfo);
g_free (path);
} }
static void static void
@ -139,34 +161,45 @@ test_commandline (void)
{ {
GAppInfo *appinfo; GAppInfo *appinfo;
GError *error; GError *error;
gchar *cmdline;
gchar *cmdline_out;
cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
cmdline_out = g_strconcat (cmdline, " %u", NULL);
error = NULL; error = NULL;
appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test", "cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS, G_APP_INFO_CREATE_SUPPORTS_URIS,
&error); &error);
g_assert (appinfo != NULL); g_assert (appinfo != NULL);
g_assert_no_error (error); g_assert_no_error (error);
g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test"); 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_uris (appinfo));
g_assert (!g_app_info_supports_files (appinfo)); g_assert (!g_app_info_supports_files (appinfo));
g_object_unref (appinfo); g_object_unref (appinfo);
g_free (cmdline_out);
cmdline_out = g_strconcat (cmdline, " %f", NULL);
error = NULL; error = NULL;
appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test", "cmdline-app-test",
G_APP_INFO_CREATE_NONE, G_APP_INFO_CREATE_NONE,
&error); &error);
g_assert (appinfo != NULL); g_assert (appinfo != NULL);
g_assert_no_error (error); g_assert_no_error (error);
g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test"); 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_uris (appinfo));
g_assert (g_app_info_supports_files (appinfo)); g_assert (g_app_info_supports_files (appinfo));
g_object_unref (appinfo); g_object_unref (appinfo);
g_free (cmdline);
g_free (cmdline_out);
} }
static void static void
@ -175,9 +208,12 @@ test_launch_context (void)
GAppLaunchContext *context; GAppLaunchContext *context;
GAppInfo *appinfo; GAppInfo *appinfo;
gchar *str; gchar *str;
gchar *cmdline;
cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
context = g_app_launch_context_new (); 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", "cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS, G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL); NULL);
@ -190,6 +226,8 @@ test_launch_context (void)
g_object_unref (appinfo); g_object_unref (appinfo);
g_object_unref (context); g_object_unref (context);
g_free (cmdline);
} }
static gboolean launched_reached; static gboolean launched_reached;
@ -222,11 +260,14 @@ test_launch_context_signals (void)
GAppLaunchContext *context; GAppLaunchContext *context;
GAppInfo *appinfo; GAppInfo *appinfo;
GError *error = NULL; GError *error = NULL;
gchar *cmdline;
cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
context = g_app_launch_context_new (); context = g_app_launch_context_new ();
g_signal_connect (context, "launched", G_CALLBACK (launched), NULL); g_signal_connect (context, "launched", G_CALLBACK (launched), NULL);
g_signal_connect (context, "launch_failed", G_CALLBACK (launch_failed), 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", "cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS, G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL); NULL);
@ -239,16 +280,22 @@ test_launch_context_signals (void)
g_object_unref (appinfo); g_object_unref (appinfo);
g_object_unref (context); g_object_unref (context);
g_free (cmdline);
} }
static void static void
test_tryexec (void) test_tryexec (void)
{ {
GAppInfo *appinfo; 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_assert (appinfo == NULL);
g_free (path);
} }
/* Test that we can set an appinfo as default for a mime type or /* Test that we can set an appinfo as default for a mime type or
@ -262,8 +309,10 @@ test_associations (void)
GError *error; GError *error;
gboolean result; gboolean result;
GList *list; 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", "cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS, G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL); NULL);
@ -362,13 +411,16 @@ test_startup_wm_class (void)
{ {
GDesktopAppInfo *appinfo; GDesktopAppInfo *appinfo;
const char *wm_class; 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); wm_class = g_desktop_app_info_get_startup_wm_class (appinfo);
g_assert_cmpstr (wm_class, ==, "appinfo-class"); g_assert_cmpstr (wm_class, ==, "appinfo-class");
g_object_unref (appinfo); g_object_unref (appinfo);
g_free (path);
} }
static void static void
@ -376,14 +428,17 @@ test_supported_types (void)
{ {
GAppInfo *appinfo; GAppInfo *appinfo;
const char * const *content_types; 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); content_types = g_app_info_get_supported_types (appinfo);
g_assert_cmpint (g_strv_length ((char**)content_types), ==, 2); g_assert_cmpint (g_strv_length ((char**)content_types), ==, 2);
g_assert_cmpstr (content_types[0], ==, "image/png"); g_assert_cmpstr (content_types[0], ==, "image/png");
g_object_unref (appinfo); g_object_unref (appinfo);
g_free (path);
} }
static void static void
@ -396,16 +451,16 @@ test_from_keyfile (void)
gchar **keywords; gchar **keywords;
const gchar *file; const gchar *file;
const gchar *name; const gchar *name;
gchar *path;
path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
kf = g_key_file_new (); kf = g_key_file_new ();
g_key_file_load_from_file (kf, g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, &error);
SRCDIR "/appinfo-test.desktop",
G_KEY_FILE_NONE,
&error);
g_assert_no_error (error); g_assert_no_error (error);
info = g_desktop_app_info_new_from_keyfile (kf); info = g_desktop_app_info_new_from_keyfile (kf);
g_key_file_free (kf); g_key_file_free (kf);
g_assert (info != NULL); g_assert (info != NULL);
g_free (path);
g_object_get (info, "filename", &file, NULL); g_object_get (info, "filename", &file, NULL);
g_assert (file == NULL); g_assert (file == NULL);
@ -428,6 +483,11 @@ test_from_keyfile (void)
int int
main (int argc, char *argv[]) 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_init (&argc, &argv, NULL);
g_test_add_func ("/appinfo/basic", test_basic); g_test_add_func ("/appinfo/basic", test_basic);

View File

@ -26,6 +26,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
static const gchar *datapath;
/* all tests rely on a global connection */ /* all tests rely on a global connection */
static GDBusConnection *c = NULL; static GDBusConnection *c = NULL;
@ -112,6 +114,12 @@ main (int argc,
{ {
GError *error; GError *error;
gint ret; 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); g_test_init (&argc, &argv, NULL);
@ -121,7 +129,9 @@ main (int argc,
session_bus_up (); session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */ /* 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 */ /* wait for the service to come up */
usleep (500 * 1000); usleep (500 * 1000);

View File

@ -28,6 +28,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
static const gchar *datapath;
/* all tests rely on a shared mainloop */ /* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL; static GMainLoop *loop = NULL;
@ -86,9 +88,11 @@ test_connection_flush (void)
gboolean ret; gboolean ret;
gint exit_status; gint exit_status;
guint timeout_mainloop_id; guint timeout_mainloop_id;
gchar *path;
error = NULL; 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, /* stdout */
NULL, /* stderr */ NULL, /* stderr */
&exit_status, &exit_status,
@ -97,6 +101,7 @@ test_connection_flush (void)
g_spawn_check_exit_status (exit_status, &error); g_spawn_check_exit_status (exit_status, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret); g_assert (ret);
g_free (path);
timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n)); timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n));
g_main_loop_run (loop); g_main_loop_run (loop);
@ -169,11 +174,14 @@ static void
test_connection_large_message (void) test_connection_large_message (void)
{ {
guint watcher_id; guint watcher_id;
gchar *path;
session_bus_up (); session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */ /* 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, watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
"com.example.TestService", "com.example.TestService",
@ -194,6 +202,11 @@ int
main (int argc, main (int argc,
char *argv[]) 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_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */ /* all the tests rely on a shared main loop */

View File

@ -28,6 +28,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
const gchar *datapath;
/* all tests rely on a shared mainloop */ /* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL; static GMainLoop *loop = NULL;
@ -919,6 +921,7 @@ test_connection_filter (void)
FilterEffects effects; FilterEffects effects;
GVariant *result; GVariant *result;
const gchar *s; const gchar *s;
gchar *path;
memset (&data, '\0', sizeof (FilterData)); memset (&data, '\0', sizeof (FilterData));
@ -1001,7 +1004,10 @@ test_connection_filter (void)
g_assert_cmpint (data.num_outgoing, ==, 4); g_assert_cmpint (data.num_outgoing, ==, 4);
/* this is safe; testserver will exit once the bus goes away */ /* 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 */ /* wait for service to be available */
signal_handler_id = g_dbus_connection_signal_subscribe (c, signal_handler_id = g_dbus_connection_signal_subscribe (c,
"org.freedesktop.DBus", /* sender */ "org.freedesktop.DBus", /* sender */
@ -1221,6 +1227,11 @@ main (int argc,
{ {
g_test_init (&argc, &argv, NULL); 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 */ /* all the tests rely on a shared main loop */
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);

View File

@ -26,6 +26,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
static const gchar *datapath;
/* all tests rely on a shared mainloop */ /* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL; static GMainLoop *loop = NULL;
@ -107,6 +109,7 @@ test_introspection_parser (void)
GDBusProxy *proxy; GDBusProxy *proxy;
GDBusConnection *connection; GDBusConnection *connection;
GError *error; GError *error;
gchar *path;
error = NULL; error = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
@ -125,7 +128,9 @@ test_introspection_parser (void)
g_assert_no_error (error); g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */ /* 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"); _g_assert_property_notify (proxy, "g-name-owner");
@ -303,6 +308,11 @@ main (int argc,
{ {
gint ret; gint ret;
if (g_getenv ("G_TEST_DATA"))
datapath = g_getenv ("G_TEST_DATA");
else
datapath = SRCDIR;
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */ /* all the tests rely on a shared main loop */

View File

@ -26,6 +26,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
static const gchar *datapath;
/* all tests rely on a shared mainloop */ /* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL; static GMainLoop *loop = NULL;
@ -60,6 +62,7 @@ test_proxy_well_known_name (void)
gchar **property_names; gchar **property_names;
GVariant *variant; GVariant *variant;
GVariant *result; GVariant *result;
gchar *path;
session_bus_up (); session_bus_up ();
@ -98,7 +101,9 @@ test_proxy_well_known_name (void)
g_assert (g_dbus_proxy_get_cached_property_names (ap) == NULL); g_assert (g_dbus_proxy_get_cached_property_names (ap) == NULL);
/* this is safe; testserver will exit once the bus goes away */ /* 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 */ /* check that we get the notify::g-name-owner signal */
_g_assert_property_notify (p, "g-name-owner"); _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... * the 'y' property should be back at 1...
*/ */
/* this is safe; testserver will exit once the bus goes away */ /* 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 */ /* check that we get the notify::g-name-owner signal */
_g_assert_property_notify (p, "g-name-owner"); _g_assert_property_notify (p, "g-name-owner");
/* Now we should have a name owner as well as properties */ /* Now we should have a name owner as well as properties */
@ -259,6 +267,11 @@ main (int argc,
{ {
gint ret; gint ret;
if (g_getenv ("G_TEST_DATA"))
datapath = g_getenv ("G_TEST_DATA");
else
datapath = SRCDIR;
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */ /* all the tests rely on a shared main loop */

View File

@ -26,6 +26,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
static const gchar *datapath;
/* all tests rely on a shared mainloop */ /* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL; static GMainLoop *loop = NULL;
@ -762,6 +764,7 @@ test_proxy (void)
GDBusProxy *proxy; GDBusProxy *proxy;
GDBusConnection *connection; GDBusConnection *connection;
GError *error; GError *error;
gchar *path;
error = NULL; error = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
@ -780,7 +783,9 @@ test_proxy (void)
g_assert_no_error (error); g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */ /* 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"); _g_assert_property_notify (proxy, "g-name-owner");
@ -831,6 +836,8 @@ fail_test (gpointer user_data)
static void static void
test_async (void) test_async (void)
{ {
gchar *path;
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
NULL, /* GDBusInterfaceInfo */ NULL, /* GDBusInterfaceInfo */
@ -842,7 +849,9 @@ test_async (void)
NULL); NULL);
/* this is safe; testserver will exit once the bus goes away */ /* 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_timeout_add (10000, fail_test, NULL);
g_main_loop_run (loop); g_main_loop_run (loop);
@ -912,6 +921,11 @@ main (int argc,
gint ret; gint ret;
GDBusNodeInfo *introspection_data = NULL; 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); g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (frob_dbus_interface_xml, NULL); introspection_data = g_dbus_node_info_new_for_xml (frob_dbus_interface_xml, NULL);

View File

@ -26,6 +26,8 @@
#include "gdbus-tests.h" #include "gdbus-tests.h"
static const gchar *datapath;
/* all tests rely on a global connection */ /* all tests rely on a global connection */
static GDBusConnection *c = NULL; static GDBusConnection *c = NULL;
@ -581,13 +583,21 @@ main (int argc,
{ {
GError *error; GError *error;
gint ret; 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); g_test_init (&argc, &argv, NULL);
session_bus_up (); session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */ /* 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 */ /* wait for the service to come up */
usleep (500 * 1000); usleep (500 * 1000);