]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-56.sh
network: make MACAddress= takes hardware address with its length is INFINIBAND_ALEN
[thirdparty/systemd.git] / test / units / testsuite-56.sh
1 #!/usr/bin/env bash
2 set -eux
3
4 systemd-analyze log-level debug
5
6 # Multiple level process tree, parent process stays up
7 cat >/tmp/test56-exit-cgroup.sh <<EOF
8 #!/usr/bin/env bash
9 set -eux
10
11 # process tree: systemd -> sleep
12 sleep infinity &
13 disown
14
15 # process tree: systemd -> bash -> bash -> sleep
16 ((sleep infinity); true) &
17
18 systemd-notify --ready
19
20 # process tree: systemd -> bash -> sleep
21 sleep infinity
22 EOF
23 chmod +x /tmp/test56-exit-cgroup.sh
24
25 # service should be stopped cleanly
26 systemd-run --wait --unit=one -p Type=notify -p ExitType=cgroup \
27 -p ExecStartPost='bash -c "systemctl stop one &"' \
28 /tmp/test56-exit-cgroup.sh
29
30 # same thing with a truthy exec condition
31 systemd-run --wait --unit=two -p Type=notify -p ExitType=cgroup \
32 -p ExecCondition=true \
33 -p ExecStartPost='bash -c "systemctl stop two &"' \
34 /tmp/test56-exit-cgroup.sh
35
36 # false exec condition: systemd-run should exit immediately with status code: 1
37 systemd-run --wait --unit=three -p Type=notify -p ExitType=cgroup \
38 -p ExecCondition=false \
39 /tmp/test56-exit-cgroup.sh \
40 && { echo 'unexpected success'; exit 1; }
41
42 # service should exit uncleanly (main process exits with SIGKILL)
43 systemd-run --wait --unit=four -p Type=notify -p ExitType=cgroup \
44 -p ExecStartPost='bash -c "systemctl kill --signal 9 four &"' \
45 /tmp/test56-exit-cgroup.sh \
46 && { echo 'unexpected success'; exit 1; }
47
48
49 # Multiple level process tree, parent process exits quickly
50 cat >/tmp/test56-exit-cgroup-parentless.sh <<EOF
51 #!/usr/bin/env bash
52 set -eux
53
54 # process tree: systemd -> sleep
55 sleep infinity &
56
57 # process tree: systemd -> bash -> sleep
58 ((sleep infinity); true) &
59
60 systemd-notify --ready
61 EOF
62 chmod +x /tmp/test56-exit-cgroup-parentless.sh
63
64 # service should be stopped cleanly
65 systemd-run --wait --unit=five -p Type=notify -p ExitType=cgroup \
66 -p ExecStartPost='bash -c "systemctl stop five &"' \
67 /tmp/test56-exit-cgroup-parentless.sh
68
69 # service should still exit cleanly despite SIGKILL (the main process already exited cleanly)
70 systemd-run --wait --unit=six -p Type=notify -p ExitType=cgroup \
71 -p ExecStartPost='bash -c "systemctl kill --signal 9 six &"' \
72 /tmp/test56-exit-cgroup-parentless.sh
73
74
75 systemd-analyze log-level info
76
77 echo OK >/testok
78
79 exit 0