mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-08 11:40:22 +01:00
When running dbus-daemon --session in tests, override listen address
Otherwise, we can't reliably run tests for Windows, because the default listening address on Windows is "autolaunch:" which is global to a machine, resulting in testing an installed dbus-daemon instead of the one we intended to test. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92538 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
parent
382cb17d37
commit
4eddd1bf52
1 changed files with 32 additions and 12 deletions
|
|
@ -93,22 +93,14 @@ child_setup (gpointer user_data)
|
|||
static gchar *
|
||||
spawn_dbus_daemon (const gchar *binary,
|
||||
const gchar *configuration,
|
||||
const gchar *listen_address,
|
||||
TestUser user,
|
||||
GPid *daemon_pid)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GString *address;
|
||||
gint address_fd;
|
||||
const gchar *const argv[] = {
|
||||
binary,
|
||||
configuration,
|
||||
"--nofork",
|
||||
"--print-address=1", /* stdout */
|
||||
#ifdef DBUS_UNIX
|
||||
"--systemd-activation",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
GPtrArray *argv;
|
||||
#ifdef DBUS_UNIX
|
||||
const struct passwd *pwd = NULL;
|
||||
#endif
|
||||
|
|
@ -166,8 +158,23 @@ spawn_dbus_daemon (const gchar *binary,
|
|||
#endif
|
||||
}
|
||||
|
||||
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));
|
||||
g_ptr_array_add (argv, g_strdup ("--nofork"));
|
||||
g_ptr_array_add (argv, g_strdup ("--print-address=1")); /* stdout */
|
||||
|
||||
if (listen_address != NULL)
|
||||
g_ptr_array_add (argv, g_strdup (listen_address));
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
g_ptr_array_add (argv, g_strdup ("--systemd-activation"));
|
||||
#endif
|
||||
|
||||
g_ptr_array_add (argv, NULL);
|
||||
|
||||
g_spawn_async_with_pipes (NULL, /* working directory */
|
||||
(gchar **) argv, /* g_s_a_w_p() is not const-correct :-( */
|
||||
(gchar **) argv->pdata,
|
||||
NULL, /* envp */
|
||||
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
|
||||
#ifdef DBUS_UNIX
|
||||
|
|
@ -182,6 +189,8 @@ spawn_dbus_daemon (const gchar *binary,
|
|||
&error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_ptr_array_free (argv, TRUE);
|
||||
|
||||
address = g_string_new (NULL);
|
||||
|
||||
/* polling until the dbus-daemon writes out its address is a bit stupid,
|
||||
|
|
@ -223,8 +232,14 @@ test_get_dbus_daemon (const gchar *config_file,
|
|||
{
|
||||
gchar *dbus_daemon;
|
||||
gchar *arg;
|
||||
const gchar *listen_address = NULL;
|
||||
gchar *address;
|
||||
|
||||
/* we often have to override this because on Windows, the default may be
|
||||
* autolaunch:, which is globally-scoped and hence unsuitable for
|
||||
* regression tests */
|
||||
listen_address = "--address=" TEST_LISTEN;
|
||||
|
||||
if (config_file != NULL)
|
||||
{
|
||||
|
||||
|
|
@ -239,6 +254,10 @@ test_get_dbus_daemon (const gchar *config_file,
|
|||
arg = g_strdup_printf (
|
||||
"--config-file=%s/%s",
|
||||
g_getenv ("DBUS_TEST_DATA"), config_file);
|
||||
|
||||
/* The configuration file is expected to give a suitable address,
|
||||
* do not override it */
|
||||
listen_address = NULL;
|
||||
}
|
||||
else if (g_getenv ("DBUS_TEST_DATADIR") != NULL)
|
||||
{
|
||||
|
|
@ -276,7 +295,8 @@ test_get_dbus_daemon (const gchar *config_file,
|
|||
}
|
||||
else
|
||||
{
|
||||
address = spawn_dbus_daemon (dbus_daemon, arg, user, daemon_pid);
|
||||
address = spawn_dbus_daemon (dbus_daemon, arg,
|
||||
listen_address, user, daemon_pid);
|
||||
}
|
||||
|
||||
g_free (dbus_daemon);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue