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