]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-17-LVM-THIN/test.sh
splitup dracut-init.sh from dracut-functions.sh
[thirdparty/dracut.git] / test / TEST-17-LVM-THIN / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on LVM PV with thin pool"
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 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
12 -m 256M -smp 2 -nographic \
13 -net none \
14 -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
15 -initrd $TESTDIR/initramfs.testing
16 grep -F -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=80
22
23 kernel=$KVERSION
24 # Create what will eventually be our root filesystem onto an overlay
25 (
26 export initdir=$TESTDIR/overlay/source
27 . $basedir/dracut-init.sh
28 (
29 cd "$initdir"
30 mkdir -p -- dev sys proc etc var/run tmp
31 mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
32 for i in bin sbin lib lib64; do
33 ln -sfnr usr/$i $i
34 done
35 mkdir -p -- var/lib/nfs/rpc_pipefs
36 )
37 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \
38 mount dmesg ifconfig dhclient mkdir cp ping dhclient
39 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
40 [ -f ${_terminfodir}/l/linux ] && break
41 done
42 inst_multiple -o ${_terminfodir}/l/linux
43 inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
44 inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
45 inst_multiple grep
46 inst_simple /etc/os-release
47 inst ./test-init.sh /sbin/init
48 find_binary plymouth >/dev/null && inst_multiple plymouth
49 cp -a /etc/ld.so.conf* $initdir/etc
50 mkdir $initdir/run
51 sudo ldconfig -r "$initdir"
52 )
53
54 # second, install the files needed to make the root filesystem
55 (
56 export initdir=$TESTDIR/overlay
57 . $basedir/dracut-init.sh
58 inst_multiple sfdisk mke2fs poweroff cp umount
59 inst_hook initqueue 01 ./create-root.sh
60 inst_hook initqueue/finished 01 ./finished-false.sh
61 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
62 )
63
64 # create an initramfs that will create the target root filesystem.
65 # We do it this way so that we do not risk trashing the host mdraid
66 # devices, volume groups, encrypted partitions, etc.
67 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
68 -m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
69 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
70 --no-hostonly-cmdline -N \
71 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
72 rm -rf -- $TESTDIR/overlay
73 # Invoke KVM and/or QEMU to actually create the target filesystem.
74 $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
75 -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
76 -initrd $TESTDIR/initramfs.makeroot || return 1
77 grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
78 (
79 export initdir=$TESTDIR/overlay
80 . $basedir/dracut-init.sh
81 inst_multiple poweroff shutdown
82 inst_hook emergency 000 ./hard-off.sh
83 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
84 )
85 sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
86 -o "plymouth network kernel-network-modules" \
87 -a "debug" -I lvs \
88 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
89 --no-hostonly-cmdline -N \
90 -f $TESTDIR/initramfs.testing $KVERSION || return 1
91 }
92
93 test_cleanup() {
94 return 0
95 }
96
97 . $testdir/test-functions