]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-01-BASIC/test.sh
test/TEST-01-BASIC: add basic ext3 test
[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
7DEBUGFAIL="rd.shell rd.break"
8
9test_run() {
10 $testdir/run-qemu -hda root.ext3 -m 256M -nographic \
11 -net none -kernel /boot/vmlinuz-$KVERSION \
12 -append "root=LABEL=dracut rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
13 -initrd initramfs.testing
14 grep -m 1 -q dracut-root-block-success root.ext3 || return 1
15}
16
17test_setup() {
18
19 if [ ! -e root.ext3 ]; then
20
21 # Create the blank file to use as a root filesystem
22 dd if=/dev/zero of=root.ext3 bs=1M count=40
23
24 kernel=$KVERSION
25 # Create what will eventually be our root filesystem onto an overlay
26 (
27 initdir=overlay/source
28 . $basedir/dracut-functions
29 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
30 /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \
31 umount strace less
32 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
33 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
34 dracut_install grep
35 inst ./test-init /sbin/init
36 find_binary plymouth >/dev/null && dracut_install plymouth
37 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
38 cp -a /etc/ld.so.conf* $initdir/etc
39 sudo ldconfig -r "$initdir"
40 )
41
42 # second, install the files needed to make the root filesystem
43 (
44 initdir=overlay
45 . $basedir/dracut-functions
46 dracut_install sfdisk mkfs.ext3 poweroff cp umount
47 inst_hook initqueue 01 ./create-root.sh
48 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
49 )
50
51 # create an initramfs that will create the target root filesystem.
52 # We do it this way so that we do not risk trashing the host mdraid
53 # devices, volume groups, encrypted partitions, etc.
54 $basedir/dracut -l -i overlay / \
55 -m "dash udev-rules base rootfs-block kernel-modules" \
56 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
57 --nomdadmconf \
58 -f initramfs.makeroot $KVERSION || return 1
59 rm -rf overlay
60 # Invoke KVM and/or QEMU to actually create the target filesystem.
61 $testdir/run-qemu -hda root.ext3 -m 256M -nographic -net none \
62 -kernel "/boot/vmlinuz-$kernel" \
63 -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
64 -initrd initramfs.makeroot || return 1
65 grep -m 1 -q dracut-root-block-created root.ext3 || return 1
66 fi
67
68 (
69 initdir=overlay
70 . $basedir/dracut-functions
71 dracut_install poweroff shutdown
72 inst_hook emergency 000 ./hard-off.sh
73 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
74 )
75 sudo $basedir/dracut -l -i overlay / \
76 -a "debug" \
77 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
78 -f initramfs.testing $KVERSION || return 1
79
80# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
81}
82
83test_cleanup() {
84 rm -fr overlay mnt
85 rm -f root.ext3 initramfs.makeroot initramfs.testing
86}
87
88. $testdir/test-functions