]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test_get_dbus_daemon: Take a custom XDG_RUNTIME_DIR as an argument
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 13 Feb 2017 17:31:41 +0000 (17:31 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 20 Feb 2017 12:52:38 +0000 (12:52 +0000)
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>
test/dbus-daemon-eavesdrop.c
test/dbus-daemon.c
test/monitor.c
test/sd-activation.c
test/test-utils-glib.c
test/test-utils-glib.h
test/uid-permissions.c

index 9dac06f27138858a91080d80eb432750f9867332..be51f6abc38e56d6db545d21072a345653bee375 100644 (file)
@@ -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,
index ba67f434e5b060830d3b5359a705f342727348c5..35538c686aac3f569b05c1698eb59b64350c8d5d 100644 (file)
@@ -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)
index 6133721f63c7406fe80f21098b09694cd1824f7c..9446294d4f2e9e966eb22378c65fb6a1285288ce 100644 (file)
@@ -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;
index 73fdc0e0349b4adb9cc48f295f1a96147bac2260..086edaa9992724a47d027c1461bfae20e483a4f9 100644 (file)
@@ -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;
index ee286b983a4ef977b75b8dd4c055836d3ac865c8..f90244c3f68419a5cb089749a78e6625c073c6b4 100644 (file)
@@ -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);
index acacee0a89f5bffa24dfd34dc4b2dddccc478aa9..4016f73f70c841e5cc55bb7f30473b26c9a677df 100644 (file)
@@ -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,
index 57f7ec962a8af2b789a3444d19b2076404b8b034..19a9aa46eb42d61eb024af9daeb3d1dc67166004 100644 (file)
@@ -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)