]>
Commit | Line | Data |
---|---|---|
0b2abe0f | 1 | #!/bin/bash |
818567fc | 2 | set -e |
0b2abe0f | 3 | TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" |
054ee249 | 4 | TEST_NO_NSPAWN=1 |
0b2abe0f EV |
5 | |
6 | . $TEST_BASE_DIR/test-functions | |
0b2abe0f | 7 | |
0b2abe0f | 8 | test_setup() { |
ec4cab49 | 9 | create_empty_image_rootdir |
0b2abe0f EV |
10 | |
11 | # Create what will eventually be our root filesystem onto an overlay | |
12 | ( | |
13 | LOG_LEVEL=5 | |
14 | eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) | |
15 | ||
16 | setup_basic_environment | |
51fa8591 | 17 | mask_supporting_services |
0b2abe0f EV |
18 | dracut_install false touch |
19 | ||
20 | # setup the testsuite service | |
21 | cat >$initdir/etc/systemd/system/testsuite.service <<EOF | |
22 | [Unit] | |
23 | Description=Testsuite service | |
0b2abe0f EV |
24 | |
25 | [Service] | |
26 | ExecStart=/test-fail-on-restart.sh | |
27 | Type=oneshot | |
28 | EOF | |
29 | ||
30 | cat >$initdir/etc/systemd/system/fail-on-restart.service <<EOF | |
31 | [Unit] | |
32 | Description=Fail on restart | |
546c203d YW |
33 | StartLimitIntervalSec=1m |
34 | StartLimitBurst=3 | |
0b2abe0f EV |
35 | |
36 | [Service] | |
37 | Type=simple | |
38 | ExecStart=/bin/false | |
39 | Restart=always | |
40 | EOF | |
41 | ||
42 | ||
43 | cat >$initdir/test-fail-on-restart.sh <<'EOF' | |
44 | #!/bin/bash -x | |
45 | ||
46 | systemctl start fail-on-restart.service | |
47 | active_state=$(systemctl show --property ActiveState fail-on-restart.service) | |
48 | while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do | |
49 | sleep 1 | |
50 | active_state=$(systemctl show --property ActiveState fail-on-restart.service) | |
51 | done | |
52 | systemctl is-failed fail-on-restart.service || exit 1 | |
53 | touch /testok | |
54 | EOF | |
55 | ||
56 | chmod 0755 $initdir/test-fail-on-restart.sh | |
57 | setup_testsuite | |
cc469c3d | 58 | ) |
0b2abe0f EV |
59 | } |
60 | ||
0b2abe0f | 61 | do_test "$@" |