]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-11-ISSUE-3166/test.sh
test: add function to reduce copied setup boilerplate
[thirdparty/systemd.git] / test / TEST-11-ISSUE-3166 / test.sh
CommitLineData
0b2abe0f 1#!/bin/bash
818567fc 2set -e
0b2abe0f 3TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
054ee249 4TEST_NO_NSPAWN=1
0b2abe0f
EV
5
6. $TEST_BASE_DIR/test-functions
0b2abe0f 7
0b2abe0f 8test_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]
23Description=Testsuite service
0b2abe0f
EV
24
25[Service]
26ExecStart=/test-fail-on-restart.sh
27Type=oneshot
28EOF
29
30 cat >$initdir/etc/systemd/system/fail-on-restart.service <<EOF
31[Unit]
32Description=Fail on restart
546c203d
YW
33StartLimitIntervalSec=1m
34StartLimitBurst=3
0b2abe0f
EV
35
36[Service]
37Type=simple
38ExecStart=/bin/false
39Restart=always
40EOF
41
42
43 cat >$initdir/test-fail-on-restart.sh <<'EOF'
44#!/bin/bash -x
45
46systemctl start fail-on-restart.service
47active_state=$(systemctl show --property ActiveState fail-on-restart.service)
48while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do
49 sleep 1
50 active_state=$(systemctl show --property ActiveState fail-on-restart.service)
51done
52systemctl is-failed fail-on-restart.service || exit 1
53touch /testok
54EOF
55
56 chmod 0755 $initdir/test-fail-on-restart.sh
57 setup_testsuite
cc469c3d 58 )
0b2abe0f
EV
59}
60
0b2abe0f 61do_test "$@"