1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
systemd/test/units/TEST-22-TMPFILES.13.sh
Daan De Meyer 7a321b5a21 test: Rename testsuite-XX units to match test name
Having these named differently than the test itself mostly creates
unecessary confusion and makes writing logic against the tests harder
so let's rename the testsuite-xx units and scripts to just use the
test name itself.
2024-05-14 12:43:28 +02:00

76 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for configuration directory and file precedences
#
set -eux
rm -f /{usr/lib,etc}/tmpfiles.d/{L,w}-*.conf
rm -fr /tmp/precedence/{L,w}
mkdir -p /{usr/lib,etc}/tmpfiles.d
mkdir -p /tmp/precedence/{L,w}
#
# 'L'
#
ln -s /dev/null /tmp/precedence/L
# Overwrite the existing symlink
cat >/usr/lib/tmpfiles.d/L-z.conf<<EOF
L+ /tmp/precedence/L - - - - /usr/lib/tmpfiles.d/L-z.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/usr/lib/tmpfiles.d/L-z.conf"
# Files in /etc should override those in /usr
cat >/etc/tmpfiles.d/L-z.conf<<EOF
L+ /tmp/precedence/L - - - - /etc/tmpfiles.d/L-z.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/etc/tmpfiles.d/L-z.conf"
# /usr/…/L-a.conf has higher prio than /etc/…/L-z.conf
cat >/usr/lib/tmpfiles.d/L-a.conf<<EOF
L+ /tmp/precedence/L - - - - /usr/lib/tmpfiles.d/L-a.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/usr/lib/tmpfiles.d/L-a.conf"
# Files in /etc should override those in /usr
cat >/etc/tmpfiles.d/L-a.conf<<EOF
L+ /tmp/precedence/L - - - - /etc/tmpfiles.d/L-a.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/etc/tmpfiles.d/L-a.conf"
#
# 'w'
#
touch /tmp/precedence/w/f
# Multiple configuration files specifying 'w+' for the same path is allowed.
for i in a c; do
cat >/usr/lib/tmpfiles.d/w-$i.conf<<EOF
w+ /tmp/precedence/w/f - - - - /usr/lib/tmpfiles.d/w-$i.conf\n
EOF
cat >/etc/tmpfiles.d/w-$i.conf<<EOF
w+ /tmp/precedence/w/f - - - - /etc/tmpfiles.d/w-$i.conf\n
EOF
done
cat >/usr/lib/tmpfiles.d/w-b.conf<<EOF
w+ /tmp/precedence/w/f - - - - /usr/lib/tmpfiles.d/w-b.conf\n
EOF
systemd-tmpfiles --create
cmp /tmp/precedence/w/f <<EOF
/etc/tmpfiles.d/w-a.conf
/usr/lib/tmpfiles.d/w-b.conf
/etc/tmpfiles.d/w-c.conf
EOF