]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-10-ISSUE-2467/test.sh
test: replace echo with socat
[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 set -e
5 TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
6
7 . $TEST_BASE_DIR/test-functions
8
9 test_setup() {
10 create_empty_image
11 mkdir -p $TESTDIR/root
12 mount ${LOOPDEV}p1 $TESTDIR/root
13
14 # Create what will eventually be our root filesystem onto an overlay
15 (
16 LOG_LEVEL=5
17 eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
18
19 setup_basic_environment
20 dracut_install true rm socat
21
22 # setup the testsuite service
23 cat >$initdir/etc/systemd/system/testsuite.service <<'EOF'
24 [Unit]
25 Description=Testsuite service
26
27 [Service]
28 Type=oneshot
29 StandardOutput=tty
30 StandardError=tty
31 ExecStart=/bin/sh -e -x -c 'rm -f /tmp/nonexistent; systemctl start test.socket; printf x > test.file; socat -t20 OPEN:test.file UNIX-CONNECT:/run/test.ctl; >/testok'
32 TimeoutStartSec=10s
33 EOF
34
35 cat >$initdir/etc/systemd/system/test.socket <<'EOF'
36 [Socket]
37 ListenStream=/run/test.ctl
38 EOF
39
40 cat > $initdir/etc/systemd/system/test.service <<'EOF'
41 [Unit]
42 Requires=test.socket
43 ConditionPathExistsGlob=/tmp/nonexistent
44
45 [Service]
46 ExecStart=/bin/true
47 EOF
48
49 setup_testsuite
50 ) || return 1
51 setup_nspawn_root
52
53 # mask some services that we do not want to run in these tests
54 ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service
55 ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service
56 ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service
57 ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
58 ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service
59
60 ddebug "umount $TESTDIR/root"
61 umount $TESTDIR/root
62 }
63
64 do_test "$@"