]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-01-BASIC/test.sh
test/Makefile: fixed TESTS parsing
[thirdparty/dracut.git] / test / TEST-01-BASIC / test.sh
CommitLineData
dd26a551
HH
1#!/bin/bash
2TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
3
4KVERSION=${KVERSION-$(uname -r)}
5
6# Uncomment this to debug failures
ef85627e 7#DEBUGFAIL="rd.shell rd.break"
dd26a551
HH
8
9test_run() {
c8f3a1c0 10 dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
0be1785a
HH
11 $testdir/run-qemu \
12 -hda $TESTDIR/root.ext3 \
c8f3a1c0 13 -hdb $TESTDIR/result \
0be1785a 14 -m 256M -nographic \
dd26a551 15 -net none -kernel /boot/vmlinuz-$KVERSION \
c8f3a1c0 16 -watchdog ib700 -watchdog-action poweroff \
9ede75b1 17 -append "root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 $DEBUGFAIL" \
c8f3a1c0
HH
18 -initrd $TESTDIR/initramfs.testing || return 1
19 grep -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
dd26a551
HH
20}
21
22test_setup() {
0be1785a 23 rm -f $TESTDIR/root.ext3
dd26a551 24 # Create the blank file to use as a root filesystem
47057875 25 dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
dd26a551 26
0be1785a 27 kernel=$KVERSION
dd26a551 28 # Create what will eventually be our root filesystem onto an overlay
0be1785a 29 (
27fa6044 30 export initdir=$TESTDIR/overlay/source
96d22bd7 31 mkdir -p $initdir
552ecca6 32 . $basedir/dracut-functions.sh
0be1785a 33 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
96d22bd7 34 mount dmesg ifconfig dhclient mkdir cp ping dhclient \
d8eb522e 35 umount strace less setsid
96d22bd7
HH
36 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
37 [ -f ${_terminfodir}/l/linux ] && break
38 done
39 dracut_install -o ${_terminfodir}/l/linux
f0558da5
HH
40 inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
41 inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
0be1785a 42 dracut_install grep
552ecca6 43 inst ./test-init.sh /sbin/init
0be1785a
HH
44 find_binary plymouth >/dev/null && dracut_install plymouth
45 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
46 cp -a /etc/ld.so.conf* $initdir/etc
47 sudo ldconfig -r "$initdir"
48 )
49
dd26a551 50 # second, install the files needed to make the root filesystem
0be1785a 51 (
27fa6044 52 export initdir=$TESTDIR/overlay
552ecca6 53 . $basedir/dracut-functions.sh
cfe32ef5 54 dracut_install sfdisk mkfs.ext3 poweroff cp umount sync
0be1785a
HH
55 inst_hook initqueue 01 ./create-root.sh
56 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
57 )
58
dd26a551
HH
59 # create an initramfs that will create the target root filesystem.
60 # We do it this way so that we do not risk trashing the host mdraid
61 # devices, volume groups, encrypted partitions, etc.
552ecca6 62 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
0be1785a
HH
63 -m "dash udev-rules base rootfs-block kernel-modules" \
64 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
65 --nomdadmconf \
66 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
4b13b2e2 67 rm -rf $TESTDIR/overlay
dd26a551 68 # Invoke KVM and/or QEMU to actually create the target filesystem.
0be1785a
HH
69
70 $testdir/run-qemu \
71 -hda $TESTDIR/root.ext3 \
72 -m 256M -nographic -net none \
73 -kernel "/boot/vmlinuz-$kernel" \
74 -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
75 -initrd $TESTDIR/initramfs.makeroot || return 1
76 grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
77
dd26a551
HH
78
79 (
27fa6044 80 export initdir=$TESTDIR/overlay
552ecca6 81 . $basedir/dracut-functions.sh
dd26a551
HH
82 dracut_install poweroff shutdown
83 inst_hook emergency 000 ./hard-off.sh
84 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
85 )
552ecca6 86 sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
c8f3a1c0
HH
87 -a "debug watchdog" \
88 -d "piix ide-gd_mod ata_piix ext3 sd_mod ib700wdt" \
0be1785a 89 -f $TESTDIR/initramfs.testing $KVERSION || return 1
dd26a551 90
3b403b32 91# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
dd26a551
HH
92}
93
94test_cleanup() {
0be1785a 95 return 0
dd26a551
HH
96}
97
98. $testdir/test-functions