summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-04-08 18:54:05 +0200
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:57 +0200
commitc6ec3ad2eb8d451af61a6180047918092c71656e (patch)
treea53975062e74c06f747551b8b570acbf3c3ab62e /src
parentc6ac7991dc7a5b7a35d446bf211c947611418b70 (diff)
tests: override XDG_RUNTIME_DIR where we use the user runtime dir
We don#t really support systems where XDG_RUNTIME_DIR is not supported for elogind --user. Hence, let's always set our own XDG_RUNTIME_DIR for tests that involve elogind --user, so that we know it is set, and that it doesn't polute the user's actual runtime dir.
Diffstat (limited to 'src')
-rw-r--r--src/basic/rm-rf.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/basic/rm-rf.h b/src/basic/rm-rf.h
index 6d0326891..40b5b527d 100644
--- a/src/basic/rm-rf.h
+++ b/src/basic/rm-rf.h
@@ -30,3 +30,12 @@ typedef enum RemoveFlags {
int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev);
int rm_rf(const char *path, RemoveFlags flags);
+
+/* Useful for usage with _cleanup_(), destroys a directory and frees the pointer */
+static inline void rm_rf_and_free(char *p) {
+ if (!p)
+ return;
+ (void) rm_rf(p, REMOVE_ROOT);
+ free(p);
+}
+DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_and_free);