]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test tmpfiles: add a test for 'w+'
authorFranck Bui <fbui@suse.com>
Fri, 8 Apr 2022 06:32:04 +0000 (08:32 +0200)
committerFranck Bui <fbui@suse.com>
Mon, 11 Apr 2022 09:22:39 +0000 (11:22 +0200)
test/units/testsuite-22.03.sh

index 404e33e2fa8c148fbff7b854ac591a1a4f5e6118..a9df3d6bdd5a1a6e386f96d1383fddc8ff12b9be 100755 (executable)
@@ -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