diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2017-02-13 17:31:41 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2017-02-20 12:52:38 +0000 |
commit | eef176eb72c17773610ef2780133ad2a65fd26c2 (patch) | |
tree | d54a3b0152987f777084e5d6e8d4e7ff833c2b40 | |
parent | 96e6b3698ddda314066870e7faa263f129436581 (diff) | |
download | dbus-eef176eb72c17773610ef2780133ad2a65fd26c2.tar.gz |
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 <withnall@endlessm.com>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | test/dbus-daemon-eavesdrop.c | 2 | ||||
-rw-r--r-- | test/dbus-daemon.c | 2 | ||||
-rw-r--r-- | test/monitor.c | 2 | ||||
-rw-r--r-- | test/sd-activation.c | 2 | ||||
-rw-r--r-- | test/test-utils-glib.c | 13 | ||||
-rw-r--r-- | test/test-utils-glib.h | 1 | ||||
-rw-r--r-- | test/uid-permissions.c | 2 |
7 files changed, 17 insertions, 7 deletions
diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index 9dac06f2..be51f6ab 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 ba67f434..35538c68 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 6133721f..9446294d 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 73fdc0e0..086edaa9 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 ee286b98..f90244c3 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 acacee0a..4016f73f 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 57f7ec96..19a9aa46 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) |