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