1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

TEST-22-TMPFILES: add reproducer for bug with X

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-04-07 22:35:19 +02:00
parent 3dd61ee5be
commit 1672be8602

141
test/units/testsuite-22.11.sh Executable file
View File

@ -0,0 +1,141 @@
#! /bin/bash
set -e
set -x
rm -fr /tmp/x
mkdir /tmp/x
#
# 'x'
#
mkdir -p /tmp/x/{1,2}
touch /tmp/x/1/{x1,x2} /tmp/x/2/{y1,y2} /tmp/x/{z1,z2}
systemd-tmpfiles --clean - <<EOF
d /tmp/x - - - 0
x /tmp/x/1
EOF
find /tmp/x | sort
test -d /tmp/x/1
test -f /tmp/x/1/x1
test -f /tmp/x/1/x2
test ! -d /tmp/x/2
test ! -f /tmp/x/2/x1
test ! -f /tmp/x/2/x2
test ! -f /tmp/x/z1
test ! -f /tmp/x/z2
#
# 'X'
#
mkdir -p /tmp/x/{1,2}
touch /tmp/x/1/{x1,x2} /tmp/x/2/{y1,y2} /tmp/x/{z1,z2}
systemd-tmpfiles --clean - <<EOF
d /tmp/x - - - 0
X /tmp/x/1
EOF
find /tmp/x | sort
test -d /tmp/x/1
test ! -f /tmp/x/1/x1
test ! -f /tmp/x/1/x2
test ! -d /tmp/x/2
test ! -f /tmp/x/2/x1
test ! -f /tmp/x/2/x2
test ! -f /tmp/x/z1
test ! -f /tmp/x/z2
#
# 'x' with glob
#
mkdir -p /tmp/x/{1,2}
touch /tmp/x/1/{x1,x2} /tmp/x/2/{y1,y2} /tmp/x/{z1,z2}
systemd-tmpfiles --clean - <<EOF
d /tmp/x - - - 0
x /tmp/x/[1345]
x /tmp/x/z*
EOF
find /tmp/x | sort
test -d /tmp/x/1
test -f /tmp/x/1/x1
test -f /tmp/x/1/x2
test ! -d /tmp/x/2
test ! -f /tmp/x/2/x1
test ! -f /tmp/x/2/x2
test -f /tmp/x/z1
test -f /tmp/x/z2
#
# 'X' with glob
#
mkdir -p /tmp/x/{1,2}
touch /tmp/x/1/{x1,x2} /tmp/x/2/{y1,y2} /tmp/x/{z1,z2}
systemd-tmpfiles --clean - <<EOF
d /tmp/x - - - 0
X /tmp/x/[1345]
X /tmp/x/?[12]
EOF
find /tmp/x | sort
test -d /tmp/x/1
test ! -f /tmp/x/1/x1
test ! -f /tmp/x/1/x2
test ! -d /tmp/x/2
test ! -f /tmp/x/2/x1
test ! -f /tmp/x/2/x2
test -f /tmp/x/z1
test -f /tmp/x/z2
#
# 'x' with 'r'
#
mkdir -p /tmp/x/{1,2}/a
touch /tmp/x/1/a/{x1,x2} /tmp/x/2/a/{y1,y2}
systemd-tmpfiles --clean - <<EOF
# x/X is not supposed to influence r
x /tmp/x/1/a
X /tmp/x/2/a
r /tmp/x/1
r /tmp/x/2
EOF
find /tmp/x | sort
test -d /tmp/x/1
test -d /tmp/x/1/a
test -f /tmp/x/1/a/x1
test -f /tmp/x/1/a/x2
test -f /tmp/x/2/a/y1
test -f /tmp/x/2/a/y2
#
# 'x' with 'R'
#
mkdir -p /tmp/x/{1,2}/a
touch /tmp/x/1/a/{x1,x2} /tmp/x/2/a/{y1,y2}
systemd-tmpfiles --remove - <<EOF
# X is not supposed to influence R
X /tmp/x/1/a
X /tmp/x/2/a
R /tmp/x/1
EOF
find /tmp/x | sort
test ! -d /tmp/x/1
test ! -d /tmp/x/1/a
test ! -f /tmp/x/1/a/x1
test ! -f /tmp/x/1/a/x2
test -f /tmp/x/2/a/y1
test -f /tmp/x/2/a/y2