]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-10-ISSUE-2467/test.sh
test: add function to reduce copied setup boilerplate
[thirdparty/systemd.git] / test / TEST-10-ISSUE-2467 / test.sh
1 #!/bin/bash
2 set -e
3 TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
4
5 . $TEST_BASE_DIR/test-functions
6
7 test_setup() {
8 create_empty_image_rootdir
9
10 # Create what will eventually be our root filesystem onto an overlay
11 (
12 LOG_LEVEL=5
13 eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
14
15 setup_basic_environment
16 mask_supporting_services
17 dracut_install true rm socat
18
19 # setup the testsuite service
20 cat >$initdir/etc/systemd/system/testsuite.service <<'EOF'
21 [Unit]
22 Description=Testsuite service
23
24 [Service]
25 Type=oneshot
26 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'
27 EOF
28
29 cat >$initdir/etc/systemd/system/test.socket <<'EOF'
30 [Socket]
31 ListenStream=/run/test.ctl
32 EOF
33
34 cat > $initdir/etc/systemd/system/test.service <<'EOF'
35 [Unit]
36 Requires=test.socket
37 ConditionPathExistsGlob=/tmp/nonexistent
38
39 [Service]
40 ExecStart=/bin/true
41 EOF
42
43 setup_testsuite
44 )
45 setup_nspawn_root
46 }
47
48 do_test "$@"