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