]> git.proxmox.com Git - systemd.git/blob - test/units/testsuite-42.sh
New upstream version 249~rc1
[systemd.git] / test / units / testsuite-42.sh
1 #!/usr/bin/env bash
2 set -eux
3
4 systemd-analyze log-level debug
5
6 systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple1' true
7 test -f /run/simple1
8
9 systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false \
10 && { echo 'unexpected success'; exit 1; }
11 test -f /run/simple2
12
13 systemd-run --unit=exec1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec1' sleep 1
14 test -f /run/exec1
15
16 systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false' \
17 && { echo 'unexpected success'; exit 1; }
18 test -f /run/exec2
19
20 cat >/tmp/forking1.sh <<EOF
21 #!/usr/bin/env bash
22
23 set -eux
24
25 sleep 4 &
26 MAINPID=\$!
27 disown
28
29 systemd-notify MAINPID=\$MAINPID
30 EOF
31 chmod +x /tmp/forking1.sh
32
33 systemd-run --unit=forking1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking1' /tmp/forking1.sh
34 test -f /run/forking1
35
36 cat >/tmp/forking2.sh <<EOF
37 #!/usr/bin/env bash
38
39 set -eux
40
41 ( sleep 4; exit 1 ) &
42 MAINPID=\$!
43 disown
44
45 systemd-notify MAINPID=\$MAINPID
46 EOF
47 chmod +x /tmp/forking2.sh
48
49 systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh \
50 && { echo 'unexpected success'; exit 1; }
51 test -f /run/forking2
52
53 systemd-run --unit=oneshot1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot1' true
54 test -f /run/oneshot1
55
56 systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false \
57 && { echo 'unexpected success'; exit 1; }
58 test -f /run/oneshot2
59
60 systemd-run --unit=dbus1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus1' \
61 busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus RequestName su systemd.test.ExecStopPost 4 \
62 || :
63 test -f /run/dbus1
64
65 systemd-run --unit=dbus2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus2' true
66 test -f /run/dbus2
67
68 # https://github.com/systemd/systemd/issues/19920
69 systemd-run --unit=dbus3.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p ExecStopPost='/bin/touch /run/dbus3' true \
70 && { echo 'unexpected success'; exit 1; }
71
72 cat >/tmp/notify1.sh <<EOF
73 #!/usr/bin/env bash
74
75 set -eux
76
77 systemd-notify --ready
78 EOF
79 chmod +x /tmp/notify1.sh
80
81 systemd-run --unit=notify1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify1' /tmp/notify1.sh
82 test -f /run/notify1
83
84 systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true \
85 && { echo 'unexpected success'; exit 1; }
86 test -f /run/notify2
87
88 systemd-run --unit=idle1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle1' true
89 test -f /run/idle1
90
91 systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false \
92 && { echo 'unexpected success'; exit 1; }
93 test -f /run/idle2
94
95 systemd-analyze log-level info
96
97 echo OK >/testok
98
99 exit 0