]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-39.sh
core,journald: use quoted commandlines
[thirdparty/systemd.git] / test / units / testsuite-39.sh
1 #!/usr/bin/env bash
2
3 set -ex
4 set -o pipefail
5
6 systemd-analyze log-level debug
7 systemd-analyze log-target console
8
9 export SYSTEMD_PAGER=
10 SERVICE_PATH="$(mktemp /etc/systemd/system/execreloadXXX.service)"
11 SERVICE_NAME="${SERVICE_PATH##*/}"
12
13 echo "[#1] Failing ExecReload= should not kill the service"
14 cat > "$SERVICE_PATH" << EOF
15 [Service]
16 ExecStart=/bin/sleep infinity
17 ExecReload=/bin/false
18 EOF
19
20 systemctl daemon-reload
21 systemctl start $SERVICE_NAME
22 systemctl status $SERVICE_NAME
23 # The reload SHOULD fail but SHOULD NOT affect the service state
24 ! systemctl reload $SERVICE_NAME
25 systemctl status $SERVICE_NAME
26 systemctl stop $SERVICE_NAME
27
28
29 echo "[#2] Failing ExecReload= should not kill the service (multiple ExecReload=)"
30 cat > "$SERVICE_PATH" << EOF
31 [Service]
32 ExecStart=/bin/sleep infinity
33 ExecReload=/bin/true
34 ExecReload=/bin/false
35 ExecReload=/bin/true
36 EOF
37
38 systemctl daemon-reload
39 systemctl start $SERVICE_NAME
40 systemctl status $SERVICE_NAME
41 # The reload SHOULD fail but SHOULD NOT affect the service state
42 ! systemctl reload $SERVICE_NAME
43 systemctl status $SERVICE_NAME
44 systemctl stop $SERVICE_NAME
45
46 echo "[#3] Failing ExecReload=- should not affect reload's exit code"
47 cat > "$SERVICE_PATH" << EOF
48 [Service]
49 ExecStart=/bin/sleep infinity
50 ExecReload=-/bin/false
51 EOF
52
53 systemctl daemon-reload
54 systemctl start $SERVICE_NAME
55 systemctl status $SERVICE_NAME
56 systemctl reload $SERVICE_NAME
57 systemctl status $SERVICE_NAME
58 systemctl stop $SERVICE_NAME
59
60 systemd-analyze log-level info
61
62 echo OK > /testok
63
64 exit 0