]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-11-LVM/test.sh
test: remove "sudo" calls in test scripts
[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 10 $testdir/run-qemu \
2f78bafa
HH
11 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
12 -m 512M -smp 2 -nographic \
13 -net none \
36867f1a 14 -no-reboot \
2f78bafa
HH
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
021b2fdd 17 grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
4fafddf7
HH
18}
19
20test_setup() {
21 # Create the blank file to use as a root filesystem
66a3d405 22 dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80
4fafddf7
HH
23
24 kernel=$KVERSION
25 # Create what will eventually be our root filesystem onto an overlay
26 (
2f78bafa
HH
27 export initdir=$TESTDIR/overlay/source
28 . $basedir/dracut-init.sh
06853123
HH
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 )
2f78bafa
HH
38 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
39 mount dmesg dhclient mkdir cp ping dhclient
96d22bd7 40 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
2f78bafa
HH
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
021b2fdd 47 inst_simple /etc/os-release
2f78bafa
HH
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
4bd0ab61 52 ldconfig -r "$initdir"
4fafddf7 53 )
3b403b32 54
4fafddf7
HH
55 # second, install the files needed to make the root filesystem
56 (
2f78bafa
HH
57 export initdir=$TESTDIR/overlay
58 . $basedir/dracut-init.sh
59 inst_multiple sfdisk mke2fs poweroff cp umount
60 inst_hook initqueue 01 ./create-root.sh
356333b3 61 inst_hook initqueue/finished 01 ./finished-false.sh
2f78bafa 62 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
4fafddf7 63 )
3b403b32 64
4fafddf7
HH
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.
552ecca6 68 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
2f78bafa
HH
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
32bd2fbb 73 rm -rf -- $TESTDIR/overlay
4fafddf7 74 # Invoke KVM and/or QEMU to actually create the target filesystem.
9b8e6e40 75 $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 512M -smp 2 -nographic -net none \
2f78bafa
HH
76 -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
77 -initrd $TESTDIR/initramfs.makeroot || return 1
021b2fdd 78 grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
4fafddf7 79 (
2f78bafa
HH
80 export initdir=$TESTDIR/overlay
81 . $basedir/dracut-init.sh
82 inst_multiple poweroff shutdown
83 inst_hook shutdown-emergency 000 ./hard-off.sh
781f1971 84 inst_hook emergency 000 ./hard-off.sh
2f78bafa 85 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
4fafddf7 86 )
4bd0ab61 87 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
2f78bafa
HH
88 -o "plymouth network kernel-network-modules" \
89 -a "debug" \
90 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
91 --no-hostonly-cmdline -N \
92 -f $TESTDIR/initramfs.testing $KVERSION || return 1
4fafddf7
HH
93}
94
95test_cleanup() {
0be1785a 96 return 0
4fafddf7
HH
97}
98
99. $testdir/test-functions