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