Merge pull request #68 from dracut-mailing-devs/1431698021-16626-3-git-send-email...
[dracut.git] / test / TEST-01-BASIC / test.sh
blobd1062ee880d86cf2ec12d917c8a5292da31328f2
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
4 KVERSION=${KVERSION-$(uname -r)}
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell rd.break"
9 test_run() {
10 dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
11 $testdir/run-qemu \
12 -hda $TESTDIR/root.ext3 \
13 -hdb $TESTDIR/result \
14 -m 256M -smp 2 -nographic \
15 -net none -kernel /boot/vmlinuz-$KVERSION \
16 -watchdog i6300esb -watchdog-action poweroff \
17 -append "root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 $DEBUGFAIL" \
18 -initrd $TESTDIR/initramfs.testing || return 1
19 grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
22 test_setup() {
23 rm -f -- $TESTDIR/root.ext3
24 # Create the blank file to use as a root filesystem
25 dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
27 kernel=$KVERSION
28 # Create what will eventually be our root filesystem onto an overlay
30 export initdir=$TESTDIR/overlay/source
31 mkdir -p $initdir
32 . $basedir/dracut-functions.sh
34 cd "$initdir"
35 mkdir -p -- dev sys proc etc var/run tmp
36 mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
37 for i in bin sbin lib lib64; do
38 ln -sfnr usr/$i $i
39 done
41 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \
42 mount dmesg ifconfig dhclient mkdir cp ping dhclient \
43 umount strace less setsid
44 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
45 [ -f ${_terminfodir}/l/linux ] && break
46 done
47 inst_multiple -o ${_terminfodir}/l/linux
48 inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
49 inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
50 inst_multiple grep
51 inst_simple /etc/os-release
52 inst ./test-init.sh /sbin/init
53 find_binary plymouth >/dev/null && inst_multiple plymouth
54 cp -a /etc/ld.so.conf* $initdir/etc
55 sudo ldconfig -r "$initdir"
58 # second, install the files needed to make the root filesystem
60 export initdir=$TESTDIR/overlay
61 . $basedir/dracut-functions.sh
62 inst_multiple sfdisk mkfs.ext3 poweroff cp umount sync
63 inst_hook initqueue 01 ./create-root.sh
64 inst_hook initqueue/finished 01 ./finished-false.sh
65 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
68 # create an initramfs that will create the target root filesystem.
69 # We do it this way so that we do not risk trashing the host mdraid
70 # devices, volume groups, encrypted partitions, etc.
71 $basedir/dracut.sh -l -i $TESTDIR/overlay / \
72 -m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib" \
73 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
74 --nomdadmconf \
75 --no-hostonly-cmdline -N \
76 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
77 rm -rf -- $TESTDIR/overlay
78 # Invoke KVM and/or QEMU to actually create the target filesystem.
80 $testdir/run-qemu \
81 -hda $TESTDIR/root.ext3 \
82 -m 256M -smp 2 -nographic -net none \
83 -kernel "/boot/vmlinuz-$kernel" \
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
90 export initdir=$TESTDIR/overlay
91 . $basedir/dracut-functions.sh
92 inst_multiple poweroff shutdown
93 inst_hook emergency 000 ./hard-off.sh
94 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
96 sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
97 -a "debug watchdog" \
98 -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \
99 --no-hostonly-cmdline -N \
100 -f $TESTDIR/initramfs.testing $KVERSION || return 1
102 # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
105 test_cleanup() {
106 return 0
109 . $testdir/test-functions