diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2017-02-14 19:03:44 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2017-02-21 13:23:34 +0000 |
commit | f2b6cc4207ef3e263a7ddcbc8c03b815f8f651b8 (patch) | |
tree | c30d27398cbb29045137aa697331d0280712440a /test/sd-activation.c | |
parent | ec9d39b95c2ff335992ff71e05b1fa6dbfec1342 (diff) | |
download | dbus-f2b6cc4207ef3e263a7ddcbc8c03b815f8f651b8.tar.gz |
sd-activation test: Create and destroy a temporary XDG_RUNTIME_DIR
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>
Diffstat (limited to 'test/sd-activation.c')
-rw-r--r-- | test/sd-activation.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/test/sd-activation.c b/test/sd-activation.c index 086edaa9..71a6da25 100644 --- a/test/sd-activation.c +++ b/test/sd-activation.c @@ -34,6 +34,8 @@ #include <string.h> #include <sys/types.h> +#include <glib/gstdio.h> + #if defined(HAVE_APPARMOR_2_10) && defined(DBUS_TEST_APPARMOR_ACTIVATION) #include <sys/apparmor.h> #endif @@ -62,6 +64,8 @@ typedef struct { const char *activated_name; DBusMessage *activated_message; dbus_bool_t activated_filter_added; + + gchar *tmp_runtime_dir; } Fixture; typedef struct @@ -211,6 +215,16 @@ static void setup (Fixture *f, gconstpointer context G_GNUC_UNUSED) { +#if defined(DBUS_TEST_APPARMOR_ACTIVATION) && defined(HAVE_APPARMOR_2_10) + aa_features *features; +#endif + + f->ge = NULL; + dbus_error_init (&f->e); + + f->tmp_runtime_dir = g_dir_make_tmp ("dbus-daemon-test.XXXXXX", &f->ge); + g_assert_no_error (f->ge); + #if defined(DBUS_TEST_APPARMOR_ACTIVATION) && !defined(HAVE_APPARMOR_2_10) g_test_skip ("AppArmor support not compiled or AppArmor 2.10 unavailable"); @@ -219,8 +233,6 @@ setup (Fixture *f, #else #if defined(DBUS_TEST_APPARMOR_ACTIVATION) - aa_features *features; - if (!aa_is_enabled ()) { g_test_message ("aa_is_enabled() -> %s", g_strerror (errno)); @@ -247,12 +259,9 @@ setup (Fixture *f, f->ctx = test_main_context_get (); - f->ge = NULL; - dbus_error_init (&f->e); - f->address = test_get_dbus_daemon ( "valid-config-files/systemd-activation.conf", - TEST_USER_ME, NULL, &f->daemon_pid); + TEST_USER_ME, f->tmp_runtime_dir, &f->daemon_pid); if (f->address == NULL) return; @@ -820,6 +829,13 @@ teardown (Fixture *f, test_main_context_unref (f->ctx); g_free (f->address); + + if (f->tmp_runtime_dir != NULL) + { + test_rmdir_if_exists (f->tmp_runtime_dir); + + g_free (f->tmp_runtime_dir); + } } static const Config deny_send_tests[] = |