2022-10-13 01:46:28 +03:00
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for the --purge switch
#
set -eux
set -o pipefail
export SYSTEMD_LOG_LEVEL = debug
2023-12-08 12:17:04 +03:00
c = '
2024-09-12 19:23:06 +03:00
d$ /tmp/somedir
f$ /tmp/somedir/somefile - - - - baz
f /tmp/someotherfile - - - - qux
2023-12-08 12:17:04 +03:00
'
2022-10-13 01:46:28 +03:00
2023-12-08 12:17:04 +03:00
systemd-tmpfiles --create - <<< " $c "
2022-10-13 01:46:28 +03:00
test -f /tmp/somedir/somefile
grep -q baz /tmp/somedir/somefile
2024-09-12 19:23:06 +03:00
grep -q qux /tmp/someotherfile
2022-10-13 01:46:28 +03:00
2023-12-08 12:17:04 +03:00
systemd-tmpfiles --purge --dry-run - <<< " $c "
test -f /tmp/somedir/somefile
grep -q baz /tmp/somedir/somefile
2024-09-12 19:23:06 +03:00
grep -q qux /tmp/someotherfile
2022-10-13 01:46:28 +03:00
2023-12-08 12:17:04 +03:00
systemd-tmpfiles --purge - <<< " $c "
2022-10-13 01:46:28 +03:00
test ! -f /tmp/somedir/somefile
test ! -d /tmp/somedir/
2024-09-12 19:23:06 +03:00
grep -q qux /tmp/someotherfile
2022-10-13 01:46:28 +03:00
2023-12-08 12:17:04 +03:00
systemd-tmpfiles --create --purge --dry-run - <<< " $c "
test ! -f /tmp/somedir/somefile
test ! -d /tmp/somedir/
2024-09-12 19:23:06 +03:00
grep -q qux /tmp/someotherfile
2022-10-13 01:46:28 +03:00
2023-12-08 12:17:04 +03:00
systemd-tmpfiles --create --purge - <<< " $c "
2022-10-13 01:46:28 +03:00
test -f /tmp/somedir/somefile
grep -q baz /tmp/somedir/somefile
2024-09-12 19:23:06 +03:00
grep -q qux /tmp/someotherfile
systemd-tmpfiles --purge - <<< " $c "
test ! -f /tmp/somedir/somefile
test ! -d /tmp/somedir/
grep -q qux /tmp/someotherfile
rm /tmp/someotherfile