]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-10-RAID/test.sh
Renamed all shell scripts to *.sh
[thirdparty/dracut.git] / test / TEST-10-RAID / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a RAID-5"
3
4 KVERSION=${KVERSION-$(uname -r)}
5
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell"
8 test_run() {
9 DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
10 $testdir/run-qemu \
11 -hda $DISKIMAGE \
12 -m 256M -nographic \
13 -net none -kernel /boot/vmlinuz-$KVERSION \
14 -append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
15 -initrd $TESTDIR/initramfs.testing
16 grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
17 }
18
19 test_setup() {
20 DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
21 # Create the blank file to use as a root filesystem
22 rm -f $DISKIMAGE
23 dd if=/dev/null of=$DISKIMAGE bs=1M seek=40
24
25 kernel=$KVERSION
26 # Create what will eventually be our root filesystem onto an overlay
27 (
28 initdir=$TESTDIR/overlay/source
29 (mkdir -p "$initdir"; cd "$initdir"; mkdir -p dev sys proc etc var/run tmp run)
30 . $basedir/dracut-functions.sh
31 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
32 mount dmesg ifconfig dhclient mkdir cp ping dhclient
33 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
34 [ -f ${_terminfodir}/l/linux ] && break
35 done
36 dracut_install -o ${_terminfodir}/l/linux
37 inst ./test-init.sh /sbin/init
38 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
39 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
40 dracut_install grep
41 dracut_install /lib/systemd/systemd-shutdown
42 find_binary plymouth >/dev/null && dracut_install plymouth
43 cp -a /etc/ld.so.conf* $initdir/etc
44 sudo ldconfig -r "$initdir"
45 )
46
47 # second, install the files needed to make the root filesystem
48 (
49 initdir=$TESTDIR/overlay
50 . $basedir/dracut-functions.sh
51 dracut_install sfdisk mke2fs poweroff cp umount
52 inst_hook initqueue 01 ./create-root.sh
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.
59 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
60 -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
61 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
62 --nomdadmconf \
63 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
64 rm -rf $TESTDIR/overlay
65 # Invoke KVM and/or QEMU to actually create the target filesystem.
66 $testdir/run-qemu \
67 -hda $DISKIMAGE \
68 -m 256M -nographic -net none \
69 -kernel "/boot/vmlinuz-$kernel" \
70 -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
71 -initrd $TESTDIR/initramfs.makeroot || return 1
72 grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
73
74 (
75 initdir=$TESTDIR/overlay
76 . $basedir/dracut-functions.sh
77 dracut_install poweroff shutdown
78 inst_hook emergency 000 ./hard-off.sh
79 inst ./cryptroot-ask.sh /sbin/cryptroot-ask
80 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
81 )
82 sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
83 -o "plymouth network" \
84 -a "debug" \
85 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
86 -f $TESTDIR/initramfs.testing $KVERSION || return 1
87 }
88
89 test_cleanup() {
90 return 0
91 }
92
93 . $testdir/test-functions