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