]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-15-BTRFSRAID/test.sh
873b779a7d4c72b294c286a4a04c79cdb3e1dbd7
[thirdparty/dracut.git] / test / TEST-15-BTRFSRAID / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on multiple device btrfs"
3
4 KVERSION=${KVERSION-$(uname -r)}
5
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell"
8 test_run() {
9 DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
10 MARKER_DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-marker.img
11 dd if=/dev/zero of=$MARKER_DISKIMAGE bs=512 count=10
12 $testdir/run-qemu \
13 -drive format=raw,index=0,media=disk,file=$MARKER_DISKIMAGE \
14 -drive format=raw,index=1,media=disk,file=$DISKIMAGE \
15 -append "panic=1 systemd.crash_reboot root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
16 -initrd $TESTDIR/initramfs.testing
17 grep -F -m 1 -q dracut-root-block-success $MARKER_DISKIMAGE || return 1
18 }
19
20 test_setup() {
21 # Create the blank file to use as a root filesystem
22 DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
23 rm -f -- $DISKIMAGE
24 dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024
25
26 kernel=$KVERSION
27 # Create what will eventually be our root filesystem onto an overlay
28 (
29 export initdir=$TESTDIR/overlay/source
30 . $basedir/dracut-init.sh
31 (
32 cd "$initdir"
33 mkdir -p -- dev sys proc etc var/run tmp
34 mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
35 for i in bin sbin lib lib64; do
36 ln -sfnr usr/$i $i
37 done
38 mkdir -p -- var/lib/nfs/rpc_pipefs
39 )
40 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
41 mount dmesg dhclient mkdir cp ping dhclient sync
42 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
43 [ -f ${_terminfodir}/l/linux ] && break
44 done
45 inst_multiple -o ${_terminfodir}/l/linux
46 inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
47 inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
48 inst_multiple grep
49 inst ./test-init.sh /sbin/init
50 inst_simple /etc/os-release
51 find_binary plymouth >/dev/null && inst_multiple plymouth
52 cp -a /etc/ld.so.conf* $initdir/etc
53 ldconfig -r "$initdir"
54 )
55
56 # second, install the files needed to make the root filesystem
57 (
58 export initdir=$TESTDIR/overlay
59 . $basedir/dracut-init.sh
60 inst_multiple sfdisk mkfs.btrfs poweroff cp umount
61 inst_hook initqueue 01 ./create-root.sh
62 inst_hook initqueue/finished 01 ./finished-false.sh
63 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
64 )
65
66 # create an initramfs that will create the target root filesystem.
67 # We do it this way so that we do not risk trashing the host mdraid
68 # devices, volume groups, encrypted partitions, etc.
69 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
70 -m "dash btrfs udev-rules base rootfs-block fs-lib kernel-modules qemu" \
71 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
72 --nomdadmconf \
73 --no-hostonly-cmdline -N \
74 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
75
76 rm -rf -- $TESTDIR/overlay
77
78 # Invoke KVM and/or QEMU to actually create the target filesystem.
79 $testdir/run-qemu \
80 -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
81 -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
82 -initrd $TESTDIR/initramfs.makeroot || return 1
83
84 dd if=$DISKIMAGE bs=512 count=4 skip=2048 | grep -F -m 1 -q dracut-root-block-created || return 1
85
86 (
87 export initdir=$TESTDIR/overlay
88 . $basedir/dracut-init.sh
89 inst_multiple poweroff shutdown
90 inst_hook shutdown-emergency 000 ./hard-off.sh
91 inst_hook emergency 000 ./hard-off.sh
92 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
93 )
94 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
95 -o "plymouth network kernel-network-modules" \
96 -a "debug" \
97 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
98 --no-hostonly-cmdline -N \
99 -f $TESTDIR/initramfs.testing $KVERSION || return 1
100 }
101
102 test_cleanup() {
103 return 0
104 }
105
106 . $testdir/test-functions