From: Victor Lowther Date: Sun, 8 Mar 2009 14:23:11 +0000 (-0500) Subject: Add a very simple test harness X-Git-Tag: 0.1~295 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=c0b5f979a8f68e58ff1e0eae0f485a5dd85d7d21;p=thirdparty%2Fdracut-ng.git Add a very simple test harness This creates a basic root filesystem, creates an initramfs, and tries to boot to the basic filesystem. The init code on the test filesystem prints how much memory is used vs. free and then drops to a shell. Exiting the shell will power off the VM. --- diff --git a/test/dracut.conf.test b/test/dracut.conf.test new file mode 100644 index 000000000..7273df74a --- /dev/null +++ b/test/dracut.conf.test @@ -0,0 +1,2 @@ +dracutmodules="kernel-modules udev-rules base" +modules="ata_piix ext2 sd_mod" diff --git a/test/test-init b/test/test-init new file mode 100755 index 000000000..63fde1eca --- /dev/null +++ b/test/test-init @@ -0,0 +1,12 @@ +#!/bin/sh +exec >/dev/console 2>&1 +export TERM=linux +ln -s /proc/mounts /etc/mtab +export PS1='initramfs-test:\w\$' +stty sane +echo "made it to the rootfs!" +echo 3 >/proc/sys/vm/drop_caches +free +sh -i +mount -o remount,ro / +poweroff -f \ No newline at end of file diff --git a/test/test-initramfs b/test/test-initramfs new file mode 100755 index 000000000..f27f9db9f --- /dev/null +++ b/test/test-initramfs @@ -0,0 +1,24 @@ +#!/bin/bash +. ./dracut-functions +kernel=$(uname -r) +[[ -f root.ext2 ]] || { + readonly initdir=$(mktemp -d -t initramfs-test-XXXXXXXX) + readonly mnttarget=$(mktemp -d -t initramfs-test-target-XXXXXXXX) + trap 'rm -rf "$initdir"' 0 + dracut_install sh df free ls shutdown poweroff stty cat ps ln \ + /lib/terminfo/l/linux mount dmesg + inst test-init /sbin/init + dd if=/dev/zero of=root.ext2 bs=1M count=10 + mke2fs -F root.ext2 + mount -o loop -t ext2 root.ext2 "$mnttarget" + cp -a -t "$mnttarget" "$initdir"/* + (cd "$mnttarget"; mkdir -p dev sys proc etc) + umount -l "$mnttarget" + rm -rf "$mnttarget" "$initdir" +} +./dracut -c dracut.conf.test -l -f initramfs.testing + +exec qemu-kvm -hda root.ext2 -nographic -net none \ + -kernel /boot/vmlinuz-$kernel \ + -append "root=/dev/sda rw rootfstype=ext2 console=ttyS0,115200n81 quiet" \ + -initrd initramfs.testing \ No newline at end of file