]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-08-ISSUE-2730/test.sh
test: add function to reduce copied setup boilerplate
[thirdparty/systemd.git] / test / TEST-08-ISSUE-2730 / test.sh
1 #!/bin/bash
2 set -e
3 TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
4 TEST_NO_NSPAWN=1
5
6 . $TEST_BASE_DIR/test-functions
7 QEMU_TIMEOUT=180
8 FSTYPE=ext4
9
10 test_setup() {
11 create_empty_image_rootdir
12
13 # Create what will eventually be our root filesystem onto an overlay
14 (
15 LOG_LEVEL=5
16 eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
17
18 setup_basic_environment
19
20 # setup the testsuite service
21 cat >$initdir/etc/systemd/system/testsuite.service <<EOF
22 [Unit]
23 Description=Testsuite service
24
25 [Service]
26 ExecStart=/bin/sh -x -c 'mount -o remount,rw /dev/sda1 && echo OK > /testok; systemctl poweroff'
27 Type=oneshot
28 EOF
29
30 rm $initdir/etc/fstab
31 cat >$initdir/etc/systemd/system/-.mount <<EOF
32 [Unit]
33 Before=local-fs.target
34
35 [Mount]
36 What=/dev/sda1
37 Where=/
38 Type=ext4
39 Options=errors=remount-ro,noatime
40
41 [Install]
42 WantedBy=local-fs.target
43 Alias=root.mount
44 EOF
45
46 cat >$initdir/etc/systemd/system/systemd-remount-fs.service <<EOF
47 [Unit]
48 DefaultDependencies=no
49 Conflicts=shutdown.target
50 After=systemd-fsck-root.service
51 Before=local-fs-pre.target local-fs.target shutdown.target
52 Wants=local-fs-pre.target
53
54 [Service]
55 Type=oneshot
56 RemainAfterExit=yes
57 ExecStart=/bin/systemctl reload /
58 EOF
59
60 setup_testsuite
61 )
62
63 ln -s /etc/systemd/system/-.mount $initdir/etc/systemd/system/root.mount
64 mkdir -p $initdir/etc/systemd/system/local-fs.target.wants
65 ln -s /etc/systemd/system/-.mount $initdir/etc/systemd/system/local-fs.target.wants/-.mount
66
67 mask_supporting_services
68 }
69
70 do_test "$@"