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