]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-10-ISSUE-2467/test.sh
Merge pull request #3132 from ssahani/route-table
[thirdparty/systemd.git] / test / TEST-10-ISSUE-2467 / test.sh
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
4 TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
5
6 . $TEST_BASE_DIR/test-functions
7 SKIP_INITRD=yes
8
9 check_result_qemu() {
10 ret=1
11 mkdir -p $TESTDIR/root
12 mount ${LOOPDEV}p1 $TESTDIR/root
13 [[ -e $TESTDIR/root/testok ]] && ret=0
14 [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
15 cp -a $TESTDIR/root/var/log/journal $TESTDIR
16 umount $TESTDIR/root
17 [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
18 ls -l $TESTDIR/journal/*/*.journal
19 test -s $TESTDIR/failed && ret=$(($ret+1))
20 return $ret
21 }
22
23 test_run() {
24 run_qemu || return 1
25 check_result_qemu || return 1
26 return 0
27 }
28
29 test_setup() {
30 create_empty_image
31 mkdir -p $TESTDIR/root
32 mount ${LOOPDEV}p1 $TESTDIR/root
33
34 # Create what will eventually be our root filesystem onto an overlay
35 (
36 LOG_LEVEL=5
37 eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
38
39 setup_basic_environment
40 dracut_install nc true rm
41
42 # setup the testsuite service
43 cat >$initdir/etc/systemd/system/testsuite.service <<'EOF'
44 [Unit]
45 Description=Testsuite service
46 After=multi-user.target
47
48 [Service]
49 Type=oneshot
50 ExecStart=/bin/sh -e -x -c 'rm -f /tmp/nonexistent; systemctl start test.socket; echo a | nc -U /run/test.ctl; >/testok'
51 TimeoutStartSec=10s
52 EOF
53
54 cat >$initdir/etc/systemd/system/test.socket <<'EOF'
55 [Socket]
56 ListenStream=/run/test.ctl
57 EOF
58
59 cat > $initdir/etc/systemd/system/test.service <<'EOF'
60 [Unit]
61 Requires=test.socket
62 ConditionPathExistsGlob=/tmp/nonexistent
63
64 [Service]
65 ExecStart=/bin/true
66 EOF
67
68 setup_testsuite
69 ) || return 1
70
71 # mask some services that we do not want to run in these tests
72 ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service
73 ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service
74 ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service
75 ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
76 ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service
77
78 ddebug "umount $TESTDIR/root"
79 umount $TESTDIR/root
80 }
81
82 test_cleanup() {
83 umount $TESTDIR/root 2>/dev/null
84 [[ $LOOPDEV ]] && losetup -d $LOOPDEV
85 return 0
86 }
87
88 do_test "$@"