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