]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-02-SYSTEMD/test.sh
Revert "test: run-qemu refactor common qemu parameters"
[thirdparty/dracut.git] / test / TEST-02-SYSTEMD / test.sh
CommitLineData
2c431e8e
HH
1#!/bin/bash
2TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
3
b093aa2d 4KVERSION="${KVERSION-$(uname -r)}"
2c431e8e
HH
5
6# Uncomment this to debug failures
c0371761 7#DEBUGFAIL="rd.shell=1 rd.break=pre-mount"
2c431e8e
HH
8test_run() {
9 $testdir/run-qemu \
c0371761 10 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
4b60a347
HH
11 -m 512M -smp 2 -nographic \
12 -net none \
13 -no-reboot \
7934c6f9 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" \
c0371761 15 -initrd $TESTDIR/initramfs.testing
021b2fdd 16 grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
2c431e8e
HH
17}
18
19test_setup() {
32bd2fbb 20 rm -f -- $TESTDIR/root.ext3
2c431e8e 21 # Create the blank file to use as a root filesystem
1d59e3e5 22 dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
2c431e8e
HH
23
24 kernel=$KVERSION
25 # Create what will eventually be our root filesystem onto an overlay
26 (
c0371761
HH
27 export initdir=$TESTDIR/overlay/source
28 mkdir -p $initdir
29 . $basedir/dracut-init.sh
06853123
HH
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 )
c0371761 39 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
2f78bafa
HH
40 mount dmesg dhclient mkdir cp ping dhclient \
41 umount strace less setsid systemd-analyze
c0371761 42 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
2c431e8e 43 [ -f ${_terminfodir}/l/linux ] && break
c0371761
HH
44 done
45 inst_multiple -o ${_terminfodir}/l/linux
225e4b94
HH
46 inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
47 inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
c0371761 48 inst_multiple grep
021b2fdd 49 inst_simple /etc/os-release
c0371761
HH
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
4bd0ab61 53 ldconfig -r "$initdir"
2c431e8e
HH
54 )
55
56 # second, install the files needed to make the root filesystem
57 (
c0371761
HH
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
356333b3 62 inst_hook initqueue/finished 01 ./finished-false.sh
c0371761 63 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
2c431e8e
HH
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 / \
2f78bafa
HH
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
32bd2fbb 75 rm -rf -- $TESTDIR/overlay
2c431e8e
HH
76 # Invoke KVM and/or QEMU to actually create the target filesystem.
77
78 $testdir/run-qemu \
c0371761 79 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
4b60a347 80 -m 512M -smp 2 -nographic -net none \
c0371761
HH
81 -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
82 -initrd $TESTDIR/initramfs.makeroot || return 1
021b2fdd 83 grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
2c431e8e
HH
84
85
86 (
c0371761
HH
87 export initdir=$TESTDIR/overlay
88 . $basedir/dracut-init.sh
89 inst_multiple poweroff shutdown
90 inst_hook shutdown-emergency 000 ./hard-off.sh
c75ce027 91 inst_hook pre-pivot 000 ./systemd-analyze.sh
781f1971 92 inst_hook emergency 000 ./hard-off.sh
c0371761 93 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
2c431e8e 94 )
4bd0ab61 95 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
2f78bafa
HH
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
2c431e8e 101
2f78bafa 102 # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
2c431e8e
HH
103}
104
105test_cleanup() {
106 return 0
107}
108
109. $testdir/test-functions