]>
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 EV |
8 | test_setup() { |
9 | create_empty_image | |
10 | mkdir -p $TESTDIR/root | |
11 | mount ${LOOPDEV}p1 $TESTDIR/root | |
12 | ||
13 | # Create what will eventually be our root filesystem onto an overlay | |
14 | ( | |
15 | LOG_LEVEL=5 | |
16 | eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) | |
17 | ||
18 | setup_basic_environment | |
19 | dracut_install false touch | |
20 | ||
056ae881 YW |
21 | # mask some services that we do not want to run in these tests |
22 | ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service | |
23 | ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service | |
24 | ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service | |
25 | ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket | |
26 | ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service | |
27 | ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service | |
28 | ||
0b2abe0f EV |
29 | # setup the testsuite service |
30 | cat >$initdir/etc/systemd/system/testsuite.service <<EOF | |
31 | [Unit] | |
32 | Description=Testsuite service | |
0b2abe0f EV |
33 | |
34 | [Service] | |
35 | ExecStart=/test-fail-on-restart.sh | |
36 | Type=oneshot | |
37 | EOF | |
38 | ||
39 | cat >$initdir/etc/systemd/system/fail-on-restart.service <<EOF | |
40 | [Unit] | |
41 | Description=Fail on restart | |
546c203d YW |
42 | StartLimitIntervalSec=1m |
43 | StartLimitBurst=3 | |
0b2abe0f EV |
44 | |
45 | [Service] | |
46 | Type=simple | |
47 | ExecStart=/bin/false | |
48 | Restart=always | |
49 | EOF | |
50 | ||
51 | ||
52 | cat >$initdir/test-fail-on-restart.sh <<'EOF' | |
53 | #!/bin/bash -x | |
54 | ||
55 | systemctl start fail-on-restart.service | |
56 | active_state=$(systemctl show --property ActiveState fail-on-restart.service) | |
57 | while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do | |
58 | sleep 1 | |
59 | active_state=$(systemctl show --property ActiveState fail-on-restart.service) | |
60 | done | |
61 | systemctl is-failed fail-on-restart.service || exit 1 | |
62 | touch /testok | |
63 | EOF | |
64 | ||
65 | chmod 0755 $initdir/test-fail-on-restart.sh | |
66 | setup_testsuite | |
cc469c3d | 67 | ) |
0b2abe0f EV |
68 | |
69 | ddebug "umount $TESTDIR/root" | |
70 | umount $TESTDIR/root | |
71 | } | |
72 | ||
0b2abe0f | 73 | do_test "$@" |