mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 06:28:00 +02:00
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>
This commit is contained in:
parent
96e6b3698d
commit
eef176eb72
7 changed files with 17 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue