]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-01-BASIC/test.sh
Revert "test: run-qemu refactor common qemu parameters"
[thirdparty/dracut.git] / test / TEST-01-BASIC / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
3
4 KVERSION=${KVERSION-$(uname -r)}
5
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell rd.break"
8
9 test_run() {
10 dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
11 $testdir/run-qemu \
12 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
13 -drive format=raw,index=1,media=disk,file=$TESTDIR/result \
14 -m 512M -smp 2 -nographic \
15 -net none \
16 -watchdog i6300esb -watchdog-action poweroff \
17 -no-reboot \
18 -append "panic=1 systemd.crash_reboot root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
19 -initrd $TESTDIR/initramfs.testing || return 1
20 grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
21 }
22
23 test_setup() {
24 rm -f -- $TESTDIR/root.ext3
25 # Create the blank file to use as a root filesystem
26 dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
27
28 kernel=$KVERSION
29 # Create what will eventually be our root filesystem onto an overlay
30 (
31 export initdir=$TESTDIR/overlay/source
32 mkdir -p $initdir
33 . $basedir/dracut-init.sh
34 (
35 cd "$initdir"
36 mkdir -p -- dev sys proc etc var/run tmp
37 mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
38 for i in bin sbin lib lib64; do
39 ln -sfnr usr/$i $i
40 done
41 )
42 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
43 mount dmesg dhclient mkdir cp ping dhclient \
44 umount strace less setsid
45 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
46 [ -f ${_terminfodir}/l/linux ] && break
47 done
48 inst_multiple -o ${_terminfodir}/l/linux
49 inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
50 inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
51 inst_multiple grep
52 inst_simple /etc/os-release
53 inst ./test-init.sh /sbin/init
54 find_binary plymouth >/dev/null && inst_multiple plymouth
55 cp -a /etc/ld.so.conf* $initdir/etc
56 ldconfig -r "$initdir"
57 )
58
59 # second, install the files needed to make the root filesystem
60 (
61 export initdir=$TESTDIR/overlay
62 . $basedir/dracut-init.sh
63 inst_multiple sfdisk mkfs.ext3 poweroff cp umount sync
64 inst_hook initqueue 01 ./create-root.sh
65 inst_hook initqueue/finished 01 ./finished-false.sh
66 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
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.sh -l -i $TESTDIR/overlay / \
73 -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
74 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
75 --nomdadmconf \
76 --no-hostonly-cmdline -N \
77 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
78 rm -rf -- $TESTDIR/overlay
79 # Invoke KVM and/or QEMU to actually create the target filesystem.
80
81 $testdir/run-qemu \
82 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
83 -m 512M -smp 2 -nographic -net none \
84 -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
85 -initrd $TESTDIR/initramfs.makeroot || return 1
86 grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
87
88
89 (
90 export initdir=$TESTDIR/overlay
91 . $basedir/dracut-init.sh
92 inst_multiple poweroff shutdown
93 inst_hook shutdown-emergency 000 ./hard-off.sh
94 inst_hook emergency 000 ./hard-off.sh
95 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
96 )
97 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
98 -a "debug watchdog" \
99 -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \
100 --no-hostonly-cmdline -N \
101 -f $TESTDIR/initramfs.testing $KVERSION || return 1
102
103 # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
104 }
105
106 test_cleanup() {
107 return 0
108 }
109
110 . $testdir/test-functions