mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
test tmpfiles: add a test for 'w+'
This commit is contained in:
parent
9af74e0f59
commit
9f55d48ba5
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user