1#!/bin/bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
3#
4# Inspired by https://github.com/systemd/systemd/issues/9508
5set -eux
6set -o pipefail
7
8test_snippet() {
9        systemd-tmpfiles "$@" - <<EOF
10d /var/tmp/foobar-test-06
11d /var/tmp/foobar-test-06/important
12R /var/tmp/foobar-test-06
13EOF
14}
15
16test_snippet --create --remove
17test -d /var/tmp/foobar-test-06
18test -d /var/tmp/foobar-test-06/important
19
20test_snippet --remove
21test ! -f /var/tmp/foobar-test-06
22test ! -f /var/tmp/foobar-test-06/important
23
24test_snippet --create
25test -d /var/tmp/foobar-test-06
26test -d /var/tmp/foobar-test-06/important
27
28touch /var/tmp/foobar-test-06/something-else
29
30test_snippet --create
31test -d /var/tmp/foobar-test-06
32test -d /var/tmp/foobar-test-06/important
33test -f /var/tmp/foobar-test-06/something-else
34
35test_snippet --create --remove
36test -d /var/tmp/foobar-test-06
37test -d /var/tmp/foobar-test-06/important
38test ! -f /var/tmp/foobar-test-06/something-else
39