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