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