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