]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-11-ISSUE-3166/test.sh
Merge pull request #13069 from yuwata/network-do-not-set-routes-when-carrier-lost
[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
EV
8test_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]
32Description=Testsuite service
0b2abe0f
EV
33
34[Service]
35ExecStart=/test-fail-on-restart.sh
36Type=oneshot
37EOF
38
39 cat >$initdir/etc/systemd/system/fail-on-restart.service <<EOF
40[Unit]
41Description=Fail on restart
546c203d
YW
42StartLimitIntervalSec=1m
43StartLimitBurst=3
0b2abe0f
EV
44
45[Service]
46Type=simple
47ExecStart=/bin/false
48Restart=always
49EOF
50
51
52 cat >$initdir/test-fail-on-restart.sh <<'EOF'
53#!/bin/bash -x
54
55systemctl start fail-on-restart.service
56active_state=$(systemctl show --property ActiveState fail-on-restart.service)
57while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do
58 sleep 1
59 active_state=$(systemctl show --property ActiveState fail-on-restart.service)
60done
61systemctl is-failed fail-on-restart.service || exit 1
62touch /testok
63EOF
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 73do_test "$@"