]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-14-IMSM/test.sh
fixed bridge setup
[thirdparty/dracut.git] / test / TEST-14-IMSM / test.sh
CommitLineData
0e9bb3f3
HH
1#!/bin/bash
2TEST_DESCRIPTION="root filesystem on LVM PV on a isw dmraid"
3
4KVERSION=${KVERSION-$(uname -r)}
5
6# Uncomment this to debug failures
0d6d85b4 7#DEBUGFAIL="rd.shell"
cc97412c 8#DEBUGFAIL="$DEBUGFAIL udev.log-priority=debug"
0e9bb3f3 9
0e9bb3f3
HH
10client_run() {
11 echo "CLIENT TEST START: $@"
0be1785a
HH
12 $testdir/run-qemu \
13 -hda $TESTDIR/root.ext2 \
14 -hdb $TESTDIR/disk1 \
15 -hdc $TESTDIR/disk2 \
16 -m 256M -nographic \
0e9bb3f3 17 -net none -kernel /boot/vmlinuz-$KVERSION \
0d6d85b4 18 -append "$* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info $DEBUGFAIL" \
0be1785a 19 -initrd $TESTDIR/initramfs.testing
021b2fdd 20 if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
0e9bb3f3
HH
21 echo "CLIENT TEST END: $@ [FAIL]"
22 return 1;
23 fi
24
0be1785a 25 sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2
0e9bb3f3
HH
26 echo "CLIENT TEST END: $@ [OK]"
27 return 0
28}
29
30test_run() {
0d6d85b4
HH
31 read MD_UUID < $TESTDIR/mduuid
32 client_run rd.auto rd.md.imsm=0 || return 1
33 client_run rd.auto rd.md.uuid=$MD_UUID rd.dm=0 || return 1
26fbe9a1
HH
34 # This test succeeds, because the mirror parts are found without
35 # assembling the mirror itsself, which is what we want
0d6d85b4
HH
36 client_run rd.auto rd.md.uuid=$MD_UUID rd.md=0 rd.md.imsm failme && return 1
37 client_run rd.auto rd.md.uuid=$MD_UUID rd.md=0 failme && return 1
cc97412c 38 # the following test hangs on newer md
0d6d85b4 39 client_run rd.auto rd.md.uuid=$MD_UUID rd.dm=0 rd.md.imsm rd.md.conf=0 || return 1
2f02ae9d 40 return 0
0e9bb3f3
HH
41}
42
43test_setup() {
0be1785a 44
0e9bb3f3 45 # Create the blank file to use as a root filesystem
32bd2fbb
HH
46 rm -f -- $TESTDIR/root.ext2
47 rm -f -- $TESTDIR/disk1
48 rm -f -- $TESTDIR/disk2
0be1785a
HH
49 dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=1
50 dd if=/dev/null of=$TESTDIR/disk1 bs=1M seek=80
51 dd if=/dev/null of=$TESTDIR/disk2 bs=1M seek=80
0e9bb3f3
HH
52
53 kernel=$KVERSION
54 # Create what will eventually be our root filesystem onto an overlay
55 (
27fa6044 56 export initdir=$TESTDIR/overlay/source
552ecca6 57 . $basedir/dracut-functions.sh
af119460 58 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \
96d22bd7
HH
59 mount dmesg ifconfig dhclient mkdir cp ping dhclient
60 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
61 [ -f ${_terminfodir}/l/linux ] && break
62 done
af119460 63 inst_multiple -o ${_terminfodir}/l/linux
0d6d85b4 64 inst_simple /etc/os-release
f0558da5
HH
65 inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
66 inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
af119460 67 inst_multiple grep
552ecca6 68 inst ./test-init.sh /sbin/init
af119460 69 find_binary plymouth >/dev/null && inst_multiple plymouth
0e9bb3f3 70 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
8a080127 71 cp -a /etc/ld.so.conf* $initdir/etc
07434861 72 mkdir $initdir/run
8a080127 73 sudo ldconfig -r "$initdir"
0e9bb3f3 74 )
3b403b32 75
0e9bb3f3
HH
76 # second, install the files needed to make the root filesystem
77 (
27fa6044 78 export initdir=$TESTDIR/overlay
552ecca6 79 . $basedir/dracut-functions.sh
0d6d85b4 80 inst_multiple sfdisk mke2fs poweroff cp umount grep
0b53ca70 81 inst_hook initqueue 01 ./create-root.sh
778d2ba2 82 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
0e9bb3f3 83 )
3b403b32 84
0e9bb3f3
HH
85 # create an initramfs that will create the target root filesystem.
86 # We do it this way so that we do not risk trashing the host mdraid
87 # devices, volume groups, encrypted partitions, etc.
552ecca6 88 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
0e9bb3f3 89 -m "dash lvm mdraid dmraid udev-rules base rootfs-block kernel-modules" \
778d2ba2 90 -d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
0be1785a 91 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
32bd2fbb 92 rm -rf -- $TESTDIR/overlay
0e9bb3f3 93 # Invoke KVM and/or QEMU to actually create the target filesystem.
0be1785a
HH
94 $testdir/run-qemu \
95 -hda $TESTDIR/root.ext2 \
96 -hdb $TESTDIR/disk1 \
97 -hdc $TESTDIR/disk2 \
98 -m 256M -nographic -net none \
0e9bb3f3 99 -kernel "/boot/vmlinuz-$kernel" \
8eb16b08 100 -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
0be1785a 101 -initrd $TESTDIR/initramfs.makeroot || return 1
021b2fdd 102 grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
0d6d85b4
HH
103 eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)
104 echo $MD_UUID > $TESTDIR/mduuid
0e9bb3f3 105 (
27fa6044 106 export initdir=$TESTDIR/overlay
552ecca6 107 . $basedir/dracut-functions.sh
af119460 108 inst_multiple poweroff shutdown
0b53ca70 109 inst_hook emergency 000 ./hard-off.sh
778d2ba2 110 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
0e9bb3f3 111 )
552ecca6 112 sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
9c111e59 113 -o "plymouth network" \
0e9bb3f3 114 -a "debug" \
778d2ba2 115 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
0be1785a 116 -f $TESTDIR/initramfs.testing $KVERSION || return 1
0e9bb3f3
HH
117}
118
119test_cleanup() {
0be1785a 120 return 0
0e9bb3f3
HH
121}
122
123. $testdir/test-functions