From: Simon McVittie Date: Mon, 13 Feb 2017 17:31:41 +0000 (+0000) Subject: test_get_dbus_daemon: Take a custom XDG_RUNTIME_DIR as an argument X-Git-Tag: dbus-1.11.12~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eef176eb72c17773610ef2780133ad2a65fd26c2;p=thirdparty%2Fdbus.git test_get_dbus_daemon: Take a custom XDG_RUNTIME_DIR as an argument Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825 Reviewed-by: Philip Withnall Signed-off-by: Simon McVittie --- diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index 9dac06f27..be51f6abc 100644 --- a/test/dbus-daemon-eavesdrop.c +++ b/test/dbus-daemon-eavesdrop.c @@ -287,7 +287,7 @@ setup (Fixture *f, f->ge = NULL; dbus_error_init (&f->e); - address = test_get_dbus_daemon (NULL, TEST_USER_ME, &f->daemon_pid); + address = test_get_dbus_daemon (NULL, TEST_USER_ME, NULL, &f->daemon_pid); f->sender = test_connect_to_bus (f->ctx, address); dbus_bus_request_name (f->sender, SENDER_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE, diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index ba67f434e..35538c686 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -173,7 +173,7 @@ setup (Fixture *f, } f->address = test_get_dbus_daemon (config ? config->config_file : NULL, - TEST_USER_ME, + TEST_USER_ME, NULL, &f->daemon_pid); if (f->address == NULL) diff --git a/test/monitor.c b/test/monitor.c index 6133721f6..9446294d4 100644 --- a/test/monitor.c +++ b/test/monitor.c @@ -450,7 +450,7 @@ setup (Fixture *f, dbus_error_init (&f->e); f->address = test_get_dbus_daemon (f->config ? f->config->config_file : NULL, - TEST_USER_ME, &f->daemon_pid); + TEST_USER_ME, NULL, &f->daemon_pid); if (f->address == NULL) return; diff --git a/test/sd-activation.c b/test/sd-activation.c index 73fdc0e03..086edaa99 100644 --- a/test/sd-activation.c +++ b/test/sd-activation.c @@ -252,7 +252,7 @@ setup (Fixture *f, f->address = test_get_dbus_daemon ( "valid-config-files/systemd-activation.conf", - TEST_USER_ME, &f->daemon_pid); + TEST_USER_ME, NULL, &f->daemon_pid); if (f->address == NULL) return; diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index ee286b983..f90244c3f 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -95,12 +95,14 @@ spawn_dbus_daemon (const gchar *binary, const gchar *configuration, const gchar *listen_address, TestUser user, + const gchar *runtime_dir, GPid *daemon_pid) { GError *error = NULL; GString *address; gint address_fd; GPtrArray *argv; + gchar **envp; #ifdef DBUS_UNIX const struct passwd *pwd = NULL; #endif @@ -158,6 +160,11 @@ spawn_dbus_daemon (const gchar *binary, #endif } + envp = g_get_environ (); + + if (runtime_dir != NULL) + envp = g_environ_setenv (envp, "XDG_RUNTIME_DIR", runtime_dir, TRUE); + argv = g_ptr_array_new_with_free_func (g_free); g_ptr_array_add (argv, g_strdup (binary)); g_ptr_array_add (argv, g_strdup (configuration)); @@ -175,7 +182,7 @@ spawn_dbus_daemon (const gchar *binary, g_spawn_async_with_pipes (NULL, /* working directory */ (gchar **) argv->pdata, - NULL, /* envp */ + envp, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, #ifdef DBUS_UNIX child_setup, (gpointer) pwd, @@ -190,6 +197,7 @@ spawn_dbus_daemon (const gchar *binary, g_assert_no_error (error); g_ptr_array_free (argv, TRUE); + g_strfreev (envp); address = g_string_new (NULL); @@ -228,6 +236,7 @@ spawn_dbus_daemon (const gchar *binary, gchar * test_get_dbus_daemon (const gchar *config_file, TestUser user, + const gchar *runtime_dir, GPid *daemon_pid) { gchar *dbus_daemon; @@ -296,7 +305,7 @@ test_get_dbus_daemon (const gchar *config_file, else { address = spawn_dbus_daemon (dbus_daemon, arg, - listen_address, user, daemon_pid); + listen_address, user, runtime_dir, daemon_pid); } g_free (dbus_daemon); diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h index acacee0a8..4016f73f7 100644 --- a/test/test-utils-glib.h +++ b/test/test-utils-glib.h @@ -69,6 +69,7 @@ void _test_assert_no_error (const DBusError *e, gchar *test_get_dbus_daemon (const gchar *config_file, TestUser user, + const gchar *runtime_dir, GPid *daemon_pid); DBusConnection *test_connect_to_bus (TestMainContext *ctx, diff --git a/test/uid-permissions.c b/test/uid-permissions.c index 57f7ec962..19a9aa46e 100644 --- a/test/uid-permissions.c +++ b/test/uid-permissions.c @@ -60,7 +60,7 @@ setup (Fixture *f, dbus_error_init (&f->e); address = test_get_dbus_daemon (config ? config->config_file : NULL, - TEST_USER_MESSAGEBUS, + TEST_USER_MESSAGEBUS, NULL, &f->daemon_pid); if (address == NULL)