summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2022-04-08 08:32:04 +0200
committerFranck Bui <fbui@suse.com>2022-04-11 11:22:39 +0200
commit9f55d48ba50afaad4557710f983d2971e9746582 (patch)
treec5d731b6ca4aee0da86630990ab8395395c67cda /test
parenttmpfiles.d: only 'w+' can have multiple lines for the same path (diff)
downloadsystemd-9f55d48ba50afaad4557710f983d2971e9746582.tar.xz
systemd-9f55d48ba50afaad4557710f983d2971e9746582.zip
test tmpfiles: add a test for 'w+'
Diffstat (limited to 'test')
-rwxr-xr-xtest/units/testsuite-22.03.sh12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/units/testsuite-22.03.sh b/test/units/testsuite-22.03.sh
index 404e33e2fa..a9df3d6bdd 100755
--- a/test/units/testsuite-22.03.sh
+++ b/test/units/testsuite-22.03.sh
@@ -186,6 +186,7 @@ test ! -e /tmp/F/daemon/unsafe-symlink/exploit
# 'w'
#
touch /tmp/w/overwritten
+touch /tmp/w/appended
### nop if the target does not exist.
systemd-tmpfiles --create - <<EOF
@@ -205,13 +206,22 @@ EOF
test -f /tmp/w/overwritten
test "$(< /tmp/w/overwritten)" = "old content"
-### new content is overwritten
+### old content is overwritten
systemd-tmpfiles --create - <<EOF
w /tmp/w/overwritten 0644 - - - new content
EOF
test -f /tmp/w/overwritten
test "$(< /tmp/w/overwritten)" = "new content"
+### append lines
+systemd-tmpfiles --create - <<EOF
+w+ /tmp/w/appended 0644 - - - 1
+w+ /tmp/w/appended 0644 - - - 2\n
+w+ /tmp/w/appended 0644 - - - 3
+EOF
+test -f /tmp/w/appended
+test "$(< /tmp/w/appended)" = "$(echo -ne '12\n3')"
+
### writing into an 'exotic' file should be allowed.
systemd-tmpfiles --create - <<EOF
w /dev/null - - - - new content