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