TEST-50-MULTINIC: fixup test suite
[platform/upstream/dracut.git] / test / TEST-01-BASIC / 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 rd.break"
8
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 -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
20 }
21
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
26
27     kernel=$KVERSION
28     # Create what will eventually be our root filesystem onto an overlay
29     (
30         export initdir=$TESTDIR/overlay/source
31         mkdir -p $initdir
32         . $basedir/dracut-functions.sh
33         dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
34             mount dmesg ifconfig dhclient mkdir cp ping dhclient \
35             umount strace less setsid
36         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
37             [ -f ${_terminfodir}/l/linux ] && break
38         done
39         dracut_install -o ${_terminfodir}/l/linux
40         inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
41         inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
42         dracut_install grep
43         inst ./test-init.sh /sbin/init
44         find_binary plymouth >/dev/null && dracut_install plymouth
45         (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
46         cp -a /etc/ld.so.conf* $initdir/etc
47         sudo ldconfig -r "$initdir"
48     )
49
50     # second, install the files needed to make the root filesystem
51     (
52         export initdir=$TESTDIR/overlay
53         . $basedir/dracut-functions.sh
54         dracut_install sfdisk mkfs.ext3 poweroff cp umount sync
55         inst_hook initqueue 01 ./create-root.sh
56         inst_hook initqueue/finished 01 ./finished-false.sh
57         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
58     )
59
60     # create an initramfs that will create the target root filesystem.
61     # We do it this way so that we do not risk trashing the host mdraid
62     # devices, volume groups, encrypted partitions, etc.
63     $basedir/dracut.sh -l -i $TESTDIR/overlay / \
64         -m "dash udev-rules base rootfs-block kernel-modules" \
65         -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
66         --nomdadmconf \
67         -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
68     rm -rf $TESTDIR/overlay
69     # Invoke KVM and/or QEMU to actually create the target filesystem.
70
71     $testdir/run-qemu \
72         -hda $TESTDIR/root.ext3 \
73         -m 256M -smp 2 -nographic -net none \
74         -kernel "/boot/vmlinuz-$kernel" \
75         -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
76         -initrd $TESTDIR/initramfs.makeroot  || return 1
77     grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
78
79
80     (
81         export initdir=$TESTDIR/overlay
82         . $basedir/dracut-functions.sh
83         dracut_install poweroff shutdown
84         inst_hook emergency 000 ./hard-off.sh
85         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
86     )
87     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
88         -a "debug watchdog" \
89         -d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esbwdt" \
90         -f $TESTDIR/initramfs.testing $KVERSION || return 1
91
92 #       -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
93 }
94
95 test_cleanup() {
96     return 0
97 }
98
99 . $testdir/test-functions