]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-14-IMSM/test.sh
dracut: let some arguments add up
[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
40ef4325 7#DEBUGFAIL="rdshell"
0e9bb3f3 8
0e9bb3f3
HH
9client_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 \
85fd75f9 13 -append "$@ root=LABEL=root rw quiet rd_retry=5 rdinitdebug console=ttyS0,115200n81 selinux=0 rdinfo $DEBUGFAIL" \
0e9bb3f3
HH
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
25test_run() {
0e9bb3f3 26 client_run rd_NO_MDIMSM || return 1
26fbe9a1 27 client_run || return 1
0e9bb3f3 28 client_run rd_NO_DM || return 1
26fbe9a1
HH
29 # This test succeeds, because the mirror parts are found without
30 # assembling the mirror itsself, which is what we want
31 client_run rd_NO_DM rd_NO_MDIMSM rd_NO_MDADMCONF || return 1
f12b432e
HH
32 client_run rd_NO_MD rd_NO_MDIMSM failme && return 1
33 client_run rd_NO_MD failme && return 1
2f02ae9d 34 return 0
0e9bb3f3
HH
35}
36
37test_setup() {
38 # Create the blank file to use as a root filesystem
39 dd if=/dev/zero of=root.ext2 bs=1M count=1
40 dd if=/dev/zero of=disk1 bs=1M count=40
41 dd if=/dev/zero of=disk2 bs=1M count=40
42
43 kernel=$KVERSION
44 # Create what will eventually be our root filesystem onto an overlay
45 (
46 initdir=overlay/source
47 . $basedir/dracut-functions
48 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
49 /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
50 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
51 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
52 dracut_install grep
53 inst ./test-init /sbin/init
54 find_binary plymouth >/dev/null && dracut_install plymouth
55 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
8a080127
PS
56 cp -a /etc/ld.so.conf* $initdir/etc
57 sudo ldconfig -r "$initdir"
0e9bb3f3
HH
58 )
59
60 # second, install the files needed to make the root filesystem
61 (
62 initdir=overlay
63 . $basedir/dracut-functions
fdf2a763 64 dracut_install sfdisk mke2fs poweroff cp umount
0e9bb3f3 65 inst_simple ./create-root.sh /initqueue/01create-root.sh
778d2ba2 66 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
0e9bb3f3
HH
67 )
68
69 # create an initramfs that will create the target root filesystem.
70 # We do it this way so that we do not risk trashing the host mdraid
71 # devices, volume groups, encrypted partitions, etc.
72 $basedir/dracut -l -i overlay / \
73 -m "dash lvm mdraid dmraid udev-rules base rootfs-block kernel-modules" \
778d2ba2 74 -d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
0e9bb3f3
HH
75 -f initramfs.makeroot $KVERSION || return 1
76 rm -rf overlay
77 # Invoke KVM and/or QEMU to actually create the target filesystem.
78 $testdir/run-qemu -hda root.ext2 -hdb disk1 -hdc disk2 -m 256M -nographic -net none \
79 -kernel "/boot/vmlinuz-$kernel" \
8eb16b08 80 -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
0e9bb3f3
HH
81 -initrd initramfs.makeroot || return 1
82 grep -m 1 -q dracut-root-block-created root.ext2 || return 1
83 (
84 initdir=overlay
85 . $basedir/dracut-functions
86 dracut_install poweroff shutdown
87 inst_simple ./hard-off.sh /emergency/01hard-off.sh
778d2ba2 88 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
0e9bb3f3
HH
89 )
90 sudo $basedir/dracut -l -i overlay / \
91 -o "plymouth" \
92 -a "debug" \
778d2ba2 93 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
0e9bb3f3
HH
94 -f initramfs.testing $KVERSION || return 1
95}
96
97test_cleanup() {
98 rm -fr overlay mnt
99 rm -f root.ext2 initramfs.makeroot initramfs.testing
100 rm -f disk1 disk2
101}
102
103. $testdir/test-functions