]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-16.sh
user units: implicitly enable PrivateUsers= when sandboxing options are set
[thirdparty/systemd.git] / test / units / testsuite-16.sh
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 set -eux
4 set -o pipefail
5
6 rm -f /test.log
7
8 TESTLOG=/test.log.XXXXXXXX
9
10 function wait_for()
11 {
12 local service="${1:-wait_for: missing service argument}"
13 local result="${2:-success}"
14 local time="${3:-45}"
15
16 while [[ ! -f /${service}.terminated && ! -f /${service}.success && $time -gt 0 ]]; do
17 sleep 1
18 time=$((time - 1))
19 done
20
21 if [[ ! -f /${service}.${result} ]]; then
22 journalctl -u "${service/_/-}.service" >>"$TESTLOG"
23 fi
24 }
25
26 # This checks all stages, start, runtime and stop, can be extended by
27 # EXTEND_TIMEOUT_USEC
28
29 wait_for success_all
30
31 # These check that EXTEND_TIMEOUT_USEC that occurs at greater than the
32 # extend timeout interval but less then the stage limit (TimeoutStartSec,
33 # RuntimeMaxSec, TimeoutStopSec) still succeed.
34
35 wait_for success_start
36 wait_for success_runtime
37 wait_for success_stop
38
39 # These ensure that EXTEND_TIMEOUT_USEC will still timeout in the
40 # appropriate stage, after the stage limit, when the EXTEND_TIMEOUT_USEC
41 # message isn't sent within the extend timeout interval.
42
43 wait_for fail_start startfail
44 wait_for fail_stop stopfail
45 wait_for fail_runtime runtimefail
46
47 if [[ -f "$TESTLOG" ]]; then
48 # no mv
49 cp "$TESTLOG" /test.log
50 exit 1
51 fi
52
53 touch /testok
54 exit 0