]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-11-ISSUE-3166/test.sh
test: Drop SKIP_INITRD for QEMU-based tests
[thirdparty/systemd.git] / test / TEST-11-ISSUE-3166 / test.sh
CommitLineData
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 4set -e
0b2abe0f 5TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
054ee249 6TEST_NO_NSPAWN=1
0b2abe0f
EV
7
8. $TEST_BASE_DIR/test-functions
0b2abe0f 9
0b2abe0f
EV
10test_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]
26Description=Testsuite service
27After=multi-user.target
28
29[Service]
30ExecStart=/test-fail-on-restart.sh
31Type=oneshot
32EOF
33
34 cat >$initdir/etc/systemd/system/fail-on-restart.service <<EOF
35[Unit]
36Description=Fail on restart
37
38[Service]
39Type=simple
40ExecStart=/bin/false
41Restart=always
42EOF
43
44
45 cat >$initdir/test-fail-on-restart.sh <<'EOF'
46#!/bin/bash -x
47
48systemctl start fail-on-restart.service
49active_state=$(systemctl show --property ActiveState fail-on-restart.service)
50while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do
51 sleep 1
52 active_state=$(systemctl show --property ActiveState fail-on-restart.service)
53done
54systemctl is-failed fail-on-restart.service || exit 1
55touch /testok
56EOF
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 66do_test "$@"