]>
Commit | Line | Data |
---|---|---|
2c431e8e HH |
1 | #!/bin/bash |
2 | TEST_DESCRIPTION="root filesystem on a ext3 filesystem" | |
3 | ||
b093aa2d | 4 | KVERSION="${KVERSION-$(uname -r)}" |
2c431e8e HH |
5 | |
6 | # Uncomment this to debug failures | |
7 | #DEBUGFAIL="rd.shell" | |
8 | test_run() { | |
9 | $testdir/run-qemu \ | |
10 | -hda $TESTDIR/root.ext3 \ | |
bb278147 | 11 | -m 256M -smp 2 -nographic \ |
2c431e8e | 12 | -net none -kernel /boot/vmlinuz-$KVERSION \ |
f7231824 | 13 | -append "root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init $DEBUGFAIL" \ |
2c431e8e | 14 | -initrd $TESTDIR/initramfs.testing |
021b2fdd | 15 | grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1 |
2c431e8e HH |
16 | } |
17 | ||
18 | test_setup() { | |
32bd2fbb | 19 | rm -f -- $TESTDIR/root.ext3 |
2c431e8e | 20 | # Create the blank file to use as a root filesystem |
1d59e3e5 | 21 | dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80 |
2c431e8e HH |
22 | |
23 | kernel=$KVERSION | |
24 | # Create what will eventually be our root filesystem onto an overlay | |
25 | ( | |
27fa6044 | 26 | export initdir=$TESTDIR/overlay/source |
2c431e8e HH |
27 | mkdir -p $initdir |
28 | . $basedir/dracut-functions.sh | |
06853123 HH |
29 | ( |
30 | cd "$initdir" | |
31 | mkdir -p -- dev sys proc etc var/run tmp | |
32 | mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin | |
33 | for i in bin sbin lib lib64; do | |
34 | ln -sfnr usr/$i $i | |
35 | done | |
36 | mkdir -p -- var/lib/nfs/rpc_pipefs | |
37 | ) | |
af119460 | 38 | inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \ |
2c431e8e HH |
39 | mount dmesg ifconfig dhclient mkdir cp ping dhclient \ |
40 | umount strace less setsid | |
41 | for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do | |
42 | [ -f ${_terminfodir}/l/linux ] && break | |
43 | done | |
af119460 | 44 | inst_multiple -o ${_terminfodir}/l/linux |
f0558da5 HH |
45 | inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" |
46 | inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" | |
af119460 | 47 | inst_multiple grep |
021b2fdd | 48 | inst_simple /etc/os-release |
2c431e8e | 49 | inst ./test-init.sh /sbin/init |
af119460 | 50 | find_binary plymouth >/dev/null && inst_multiple plymouth |
2c431e8e HH |
51 | cp -a /etc/ld.so.conf* $initdir/etc |
52 | sudo ldconfig -r "$initdir" | |
53 | ) | |
54 | ||
55 | # second, install the files needed to make the root filesystem | |
56 | ( | |
27fa6044 | 57 | export initdir=$TESTDIR/overlay |
2c431e8e | 58 | . $basedir/dracut-functions.sh |
af119460 | 59 | inst_multiple sfdisk mkfs.ext3 poweroff cp umount |
2c431e8e | 60 | inst_hook initqueue 01 ./create-root.sh |
356333b3 | 61 | inst_hook initqueue/finished 01 ./finished-false.sh |
2c431e8e HH |
62 | inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules |
63 | ) | |
64 | ||
65 | # create an initramfs that will create the target root filesystem. | |
66 | # We do it this way so that we do not risk trashing the host mdraid | |
67 | # devices, volume groups, encrypted partitions, etc. | |
68 | $basedir/dracut.sh -l -i $TESTDIR/overlay / \ | |
69 | -m "dash udev-rules base rootfs-block kernel-modules" \ | |
70 | -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ | |
71 | --nomdadmconf \ | |
72 | -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 | |
32bd2fbb | 73 | rm -rf -- $TESTDIR/overlay |
2c431e8e HH |
74 | # Invoke KVM and/or QEMU to actually create the target filesystem. |
75 | ||
76 | $testdir/run-qemu \ | |
77 | -hda $TESTDIR/root.ext3 \ | |
bb278147 | 78 | -m 256M -smp 2 -nographic -net none \ |
2c431e8e | 79 | -kernel "/boot/vmlinuz-$kernel" \ |
bb278147 | 80 | -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \ |
2c431e8e | 81 | -initrd $TESTDIR/initramfs.makeroot || return 1 |
021b2fdd | 82 | grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1 |
2c431e8e HH |
83 | |
84 | ||
85 | ( | |
27fa6044 | 86 | export initdir=$TESTDIR/overlay |
2c431e8e | 87 | . $basedir/dracut-functions.sh |
af119460 | 88 | inst_multiple poweroff shutdown |
2c431e8e HH |
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.sh -l -i $TESTDIR/overlay / \ | |
93 | -a "debug systemd" \ | |
94 | -o "network" \ | |
95 | -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ | |
96 | -f $TESTDIR/initramfs.testing $KVERSION || return 1 | |
97 | ||
98 | # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm" | |
99 | } | |
100 | ||
101 | test_cleanup() { | |
102 | return 0 | |
103 | } | |
104 | ||
105 | . $testdir/test-functions |