]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-02-SYSTEMD/test.sh
test: run-qemu refactor common qemu parameters
[thirdparty/dracut.git] / test / TEST-02-SYSTEMD / 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=1 rd.break=pre-mount"
8 test_run() {
9 $testdir/run-qemu \
10 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
11 -append "panic=1 systemd.crash_reboot root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.shell=0 $DEBUGFAIL" \
12 -initrd $TESTDIR/initramfs.testing
13 grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
14 }
15
16 test_setup() {
17 rm -f -- $TESTDIR/root.ext3
18 # Create the blank file to use as a root filesystem
19 dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
20
21 kernel=$KVERSION
22 # Create what will eventually be our root filesystem onto an overlay
23 (
24 export initdir=$TESTDIR/overlay/source
25 mkdir -p $initdir
26 . $basedir/dracut-init.sh
27 (
28 cd "$initdir"
29 mkdir -p -- dev sys proc etc var/run tmp
30 mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
31 for i in bin sbin lib lib64; do
32 ln -sfnr usr/$i $i
33 done
34 mkdir -p -- var/lib/nfs/rpc_pipefs
35 )
36 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
37 mount dmesg dhclient mkdir cp ping dhclient \
38 umount strace less setsid systemd-analyze
39 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
40 [ -f ${_terminfodir}/l/linux ] && break
41 done
42 inst_multiple -o ${_terminfodir}/l/linux
43 inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
44 inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
45 inst_multiple grep
46 inst_simple /etc/os-release
47 inst ./test-init.sh /sbin/init
48 find_binary plymouth >/dev/null && inst_multiple plymouth
49 cp -a /etc/ld.so.conf* $initdir/etc
50 ldconfig -r "$initdir"
51 )
52
53 # second, install the files needed to make the root filesystem
54 (
55 export initdir=$TESTDIR/overlay
56 . $basedir/dracut-init.sh
57 inst_multiple sfdisk mkfs.ext3 poweroff cp umount
58 inst_hook initqueue 01 ./create-root.sh
59 inst_hook initqueue/finished 01 ./finished-false.sh
60 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
61 )
62
63 # create an initramfs that will create the target root filesystem.
64 # We do it this way so that we do not risk trashing the host mdraid
65 # devices, volume groups, encrypted partitions, etc.
66 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
67 -m "dash udev-rules base rootfs-block fs-lib kernel-modules qemu" \
68 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
69 --nomdadmconf \
70 --no-hostonly-cmdline -N \
71 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
72 rm -rf -- $TESTDIR/overlay
73 # Invoke KVM and/or QEMU to actually create the target filesystem.
74
75 $testdir/run-qemu \
76 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
77 -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
78 -initrd $TESTDIR/initramfs.makeroot || return 1
79 grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
80
81
82 (
83 export initdir=$TESTDIR/overlay
84 . $basedir/dracut-init.sh
85 inst_multiple poweroff shutdown
86 inst_hook shutdown-emergency 000 ./hard-off.sh
87 inst_hook pre-pivot 000 ./systemd-analyze.sh
88 inst_hook emergency 000 ./hard-off.sh
89 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
90 )
91 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
92 -a "debug systemd" \
93 -o "network kernel-network-modules" \
94 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
95 --no-hostonly-cmdline -N \
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