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/test-utils-glib.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/test-utils-glib.c')
-rw-r--r-- | test/test-utils-glib.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index fac5ddaf..e60a40d3 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -546,3 +546,27 @@ test_rmdir_must_exist (const gchar *path) g_strerror (saved_errno)); } } + +/* + * Delete empty directory @path, with a retry loop if the system call is + * interrupted by an async signal. If @path does not exist, ignore. + */ +void +test_rmdir_if_exists (const gchar *path) +{ + while (g_remove (path) != 0) + { + int saved_errno = errno; + + if (saved_errno == ENOENT) + return; + +#ifdef G_OS_UNIX + if (saved_errno == EINTR) + continue; +#endif + + g_error ("Unable to remove directory \"%s\": %s", path, + g_strerror (saved_errno)); + } +} |