]>
Commit | Line | Data |
---|---|---|
aa27b158 MP |
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() { | |
5a920b42 MP |
24 | if run_qemu; then |
25 | check_result_qemu || return 1 | |
26 | else | |
27 | dwarn "can't run QEMU, skipping" | |
28 | fi | |
aa27b158 MP |
29 | return 0 |
30 | } | |
31 | ||
32 | test_setup() { | |
33 | create_empty_image | |
34 | mkdir -p $TESTDIR/root | |
35 | mount ${LOOPDEV}p1 $TESTDIR/root | |
36 | ||
37 | # Create what will eventually be our root filesystem onto an overlay | |
38 | ( | |
39 | LOG_LEVEL=5 | |
40 | eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) | |
41 | ||
42 | setup_basic_environment | |
43 | dracut_install nc true rm | |
44 | ||
45 | # setup the testsuite service | |
46 | cat >$initdir/etc/systemd/system/testsuite.service <<'EOF' | |
47 | [Unit] | |
48 | Description=Testsuite service | |
49 | After=multi-user.target | |
50 | ||
51 | [Service] | |
52 | Type=oneshot | |
53 | ExecStart=/bin/sh -e -x -c 'rm -f /tmp/nonexistent; systemctl start test.socket; echo a | nc -U /run/test.ctl; >/testok' | |
54 | TimeoutStartSec=10s | |
55 | EOF | |
56 | ||
57 | cat >$initdir/etc/systemd/system/test.socket <<'EOF' | |
58 | [Socket] | |
59 | ListenStream=/run/test.ctl | |
60 | EOF | |
61 | ||
62 | cat > $initdir/etc/systemd/system/test.service <<'EOF' | |
63 | [Unit] | |
64 | Requires=test.socket | |
65 | ConditionPathExistsGlob=/tmp/nonexistent | |
66 | ||
67 | [Service] | |
68 | ExecStart=/bin/true | |
69 | EOF | |
70 | ||
71 | setup_testsuite | |
72 | ) || return 1 | |
73 | ||
74 | # mask some services that we do not want to run in these tests | |
75 | ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service | |
76 | ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service | |
77 | ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service | |
78 | ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket | |
79 | ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service | |
80 | ||
81 | ddebug "umount $TESTDIR/root" | |
82 | umount $TESTDIR/root | |
83 | } | |
84 | ||
85 | test_cleanup() { | |
86 | umount $TESTDIR/root 2>/dev/null | |
87 | [[ $LOOPDEV ]] && losetup -d $LOOPDEV | |
88 | return 0 | |
89 | } | |
90 | ||
91 | do_test "$@" |