chiark / gitweb /
tests: override XDG_RUNTIME_DIR where we use the user runtime dir
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Apr 2016 16:54:05 +0000 (18:54 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:57 +0000 (10:12 +0200)
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.

src/basic/rm-rf.h

index 6d032689190266f9f6429d42f0deb9558c8fc631..40b5b527d57265e98f7994dbdbea8eae82ab5f78 100644 (file)
@@ -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);