]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-15-BTRFSRAID/test.sh
Renamed all shell scripts to *.sh
[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 \
12 -m 256M -nographic \
54703a71
HH
13 -net none -kernel /boot/vmlinuz-$KVERSION \
14 -append "root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
0be1785a 15 -initrd $TESTDIR/initramfs.testing
54703a71
HH
16 grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
17}
18
19test_setup() {
20 # Create the blank file to use as a root filesystem
12018c91 21 DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
0be1785a 22 rm -f $DISKIMAGE
54703a71
HH
23 dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024
24
25 kernel=$KVERSION
26 # Create what will eventually be our root filesystem onto an overlay
27 (
0be1785a 28 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
54703a71
HH
36 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
37 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
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 (
0be1785a 48 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
52 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
53 )
54
55 # create an initramfs that will create the target root filesystem.
56 # We do it this way so that we do not risk trashing the host mdraid
57 # devices, volume groups, encrypted partitions, etc.
552ecca6 58 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
54703a71
HH
59 -m "dash btrfs udev-rules base rootfs-block kernel-modules" \
60 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
61 --nomdadmconf \
0be1785a
HH
62 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
63
64 rm -rf $TESTDIR/overlay
65
54703a71 66 # Invoke KVM and/or QEMU to actually create the target filesystem.
0be1785a
HH
67 $testdir/run-qemu \
68 -hda $DISKIMAGE \
69 -m 256M -nographic -net none \
54703a71
HH
70 -kernel "/boot/vmlinuz-$kernel" \
71 -append "root=LABEL=root rw quiet console=ttyS0,115200n81 selinux=0" \
0be1785a
HH
72 -initrd $TESTDIR/initramfs.makeroot || return 1
73
54703a71 74 grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
0be1785a
HH
75
76 (
77 initdir=$TESTDIR/overlay
552ecca6 78 . $basedir/dracut-functions.sh
54703a71
HH
79 dracut_install poweroff shutdown
80 inst_hook emergency 000 ./hard-off.sh
552ecca6 81 inst ./cryptroot-ask.sh /sbin/cryptroot-ask
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