]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/units/testsuite-22.02.sh
tests: add spdx headers to scripts and Makefiles
[thirdparty/systemd.git] / test / units / testsuite-22.02.sh
CommitLineData
084575ff 1#!/bin/bash
7b3cec95 2# SPDX-License-Identifier: LGPL-2.1-or-later
9f36a8fb
FB
3#
4# Basic tests for types creating directories
084575ff
FS
5set -eux
6set -o pipefail
9f36a8fb 7
55b25c43
RG
8rm -fr /tmp/{C,d,D,e}
9mkdir /tmp/{C,d,D,e}
9f36a8fb
FB
10
11#
12# 'd'
13#
14mkdir /tmp/d/2
15chmod 777 /tmp/d/2
16
17systemd-tmpfiles --create - <<EOF
18d /tmp/d/1 0755 daemon daemon - -
19d /tmp/d/2 0755 daemon daemon - -
20EOF
21
22test -d /tmp/d/1
38825267 23test "$(stat -c %U:%G:%a /tmp/d/1)" = "daemon:daemon:755"
9f36a8fb
FB
24
25test -d /tmp/d/2
38825267 26test "$(stat -c %U:%G:%a /tmp/d/2)" = "daemon:daemon:755"
9f36a8fb
FB
27
28#
29# 'D'
30#
31mkdir /tmp/D/2
32chmod 777 /tmp/D/2
33touch /tmp/D/2/foo
34
35systemd-tmpfiles --create - <<EOF
36D /tmp/D/1 0755 daemon daemon - -
37D /tmp/D/2 0755 daemon daemon - -
38EOF
39
40test -d /tmp/D/1
38825267 41test "$(stat -c %U:%G:%a /tmp/D/1)" = "daemon:daemon:755"
9f36a8fb
FB
42
43test -d /tmp/D/2
38825267 44test "$(stat -c %U:%G:%a /tmp/D/2)" = "daemon:daemon:755"
9f36a8fb
FB
45
46systemd-tmpfiles --remove - <<EOF
47D /tmp/D/2 0755 daemon daemon - -
48EOF
49
50# the content of '2' should be removed
51test "$(echo /tmp/D/2/*)" = "/tmp/D/2/*"
52
53#
54# 'e'
55#
56mkdir -p /tmp/e/2/{d1,d2}
57chmod 777 /tmp/e/2
58chmod 777 /tmp/e/2/d*
59
60systemd-tmpfiles --create - <<EOF
61e /tmp/e/1 0755 daemon daemon - -
62e /tmp/e/2/* 0755 daemon daemon - -
63EOF
64
ffa328f0 65test ! -d /tmp/e/1
9f36a8fb
FB
66
67test -d /tmp/e/2
38825267 68test "$(stat -c %U:%G:%a /tmp/e/2)" = "root:root:777"
9f36a8fb
FB
69
70test -d /tmp/e/2/d1
38825267 71test "$(stat -c %U:%G:%a /tmp/e/2/d1)" = "daemon:daemon:755"
9f36a8fb 72test -d /tmp/e/2/d2
38825267 73test "$(stat -c %U:%G:%a /tmp/e/2/d2)" = "daemon:daemon:755"
9f36a8fb
FB
74
75# 'e' operates on directories only
76mkdir -p /tmp/e/3/{d1,d2}
77chmod 777 /tmp/e/3
78chmod 777 /tmp/e/3/d*
79touch /tmp/e/3/f1
80chmod 644 /tmp/e/3/f1
81
b88ba6c7 82systemd-tmpfiles --create - <<EOF
9f36a8fb
FB
83e /tmp/e/3/* 0755 daemon daemon - -
84EOF
85
86# the directories should have been processed although systemd-tmpfiles failed
87# previously due to the presence of a file.
88test -d /tmp/e/3/d1
38825267 89test "$(stat -c %U:%G:%a /tmp/e/3/d1)" = "daemon:daemon:755"
9f36a8fb 90test -d /tmp/e/3/d2
38825267 91test "$(stat -c %U:%G:%a /tmp/e/3/d2)" = "daemon:daemon:755"
9f36a8fb
FB
92
93test -f /tmp/e/3/f1
38825267 94test "$(stat -c %U:%G:%a /tmp/e/3/f1)" = "root:root:644"
55b25c43
RG
95
96#
97# 'C'
98#
99
100mkdir /tmp/C/{1,2,3}-origin
101touch /tmp/C/{1,2,3}-origin/f1
102chmod 755 /tmp/C/{1,2,3}-origin/f1
103
104mkdir /tmp/C/{2,3}
105touch /tmp/C/3/f1
106
107systemd-tmpfiles --create - <<EOF
108C /tmp/C/1 0755 daemon daemon - /tmp/C/1-origin
109C /tmp/C/2 0755 daemon daemon - /tmp/C/2-origin
110EOF
111
112test -d /tmp/C/1
38825267 113test "$(stat -c %U:%G:%a /tmp/C/1/f1)" = "daemon:daemon:755"
55b25c43 114test -d /tmp/C/2
38825267 115test "$(stat -c %U:%G:%a /tmp/C/2/f1)" = "daemon:daemon:755"
55b25c43 116
b88ba6c7 117systemd-tmpfiles --create - <<EOF
55b25c43
RG
118C /tmp/C/3 0755 daemon daemon - /tmp/C/3-origin
119EOF
120
38825267 121test "$(stat -c %U:%G:%a /tmp/C/3/f1)" = "root:root:644"