]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-14-IMSM/test.sh
TEST-14-IMSM: "rd_NO_DM rd_NO_MDIMSM rd_NO_MDADMCONF" fails
[thirdparty/dracut.git] / test / TEST-14-IMSM / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on LVM PV on a isw dmraid"
3
4 KVERSION=${KVERSION-$(uname -r)}
5
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rdinitdebug rdnetdebug"
8
9 client_run() {
10 echo "CLIENT TEST START: $@"
11 $testdir/run-qemu -hda root.ext2 -hdb disk1 -hdc disk2 -m 256M -nographic \
12 -net none -kernel /boot/vmlinuz-$KVERSION \
13 -append "$@ root=LABEL=root rw quiet rdinfo console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
14 -initrd initramfs.testing
15 if ! grep -m 1 -q dracut-root-block-success root.ext2; then
16 echo "CLIENT TEST END: $@ [FAIL]"
17 return 1;
18 fi
19
20 sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' root.ext2
21 echo "CLIENT TEST END: $@ [OK]"
22 return 0
23 }
24
25 test_run() {
26 client_run || return 1
27 client_run rd_NO_MDIMSM || return 1
28 client_run rd_NO_DM || return 1
29 client_run rd_NO_DM rd_NO_MDIMSM rd_NO_MDADMCONF && return 1
30 client_run rd_NO_MD rd_NO_MDIMSM && return 1
31 client_run rd_NO_MD && return 1
32 return 0
33 }
34
35 test_setup() {
36 # Create the blank file to use as a root filesystem
37 dd if=/dev/zero of=root.ext2 bs=1M count=1
38 dd if=/dev/zero of=disk1 bs=1M count=40
39 dd if=/dev/zero of=disk2 bs=1M count=40
40
41 kernel=$KVERSION
42 # Create what will eventually be our root filesystem onto an overlay
43 (
44 initdir=overlay/source
45 . $basedir/dracut-functions
46 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
47 /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
48 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
49 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
50 dracut_install grep
51 inst ./test-init /sbin/init
52 find_binary plymouth >/dev/null && dracut_install plymouth
53 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
54 )
55
56 # second, install the files needed to make the root filesystem
57 (
58 initdir=overlay
59 . $basedir/dracut-functions
60 dracut_install sfdisk mke2fs poweroff cp umount
61 inst_simple ./create-root.sh /initqueue/01create-root.sh
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 -l -i overlay / \
68 -m "dash lvm mdraid dmraid udev-rules base rootfs-block kernel-modules" \
69 -d "ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
70 -f initramfs.makeroot $KVERSION || return 1
71 rm -rf overlay
72 # Invoke KVM and/or QEMU to actually create the target filesystem.
73 $testdir/run-qemu -hda root.ext2 -hdb disk1 -hdc disk2 -m 256M -nographic -net none \
74 -kernel "/boot/vmlinuz-$kernel" \
75 -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \
76 -initrd initramfs.makeroot || return 1
77 grep -m 1 -q dracut-root-block-created root.ext2 || return 1
78 (
79 initdir=overlay
80 . $basedir/dracut-functions
81 dracut_install poweroff shutdown
82 inst_simple ./hard-off.sh /emergency/01hard-off.sh
83 )
84 sudo $basedir/dracut -l -i overlay / \
85 -o "plymouth" \
86 -a "debug" \
87 -d "ata_piix ext2 sd_mod" \
88 -f initramfs.testing $KVERSION || return 1
89 }
90
91 test_cleanup() {
92 rm -fr overlay mnt
93 rm -f root.ext2 initramfs.makeroot initramfs.testing
94 rm -f disk1 disk2
95 }
96
97 . $testdir/test-functions