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