]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Modify Makefile to use new test harness
authorVictor Lowther <victor.lowther@gmail.com>
Sun, 8 Mar 2009 15:49:44 +0000 (10:49 -0500)
committerVictor Lowther <victor.lowther@gmail.com>
Sun, 8 Mar 2009 16:51:21 +0000 (11:51 -0500)
Makefile
test/make-test-root [new file with mode: 0755]
test/test-initramfs

index a40b8ee48fff80f4a13ba5d38768f3120df8f942..45ad1a5148a583630968389f405169ceb8503a92 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,8 @@ modules.d/99base/switch_root: switch_root.c
 
 all: modules.d/99base/switch_root
 
+.PHONY: install clean archive rpm testimage test
+
 install:
        mkdir -p $(DESTDIR)/usr/lib/dracut
        mkdir -p $(DESTDIR)/sbin
@@ -30,6 +32,12 @@ rpm: dracut-$(VERSION)-$(GITVERSION).tar.bz2
        rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec 
        rm -fr BUILD BUILDROOT
 
+test: test/root.ext2 all
+       sudo test/test-initramfs
+
+test/root.ext2: test/test-init test/make-test-root all
+       sudo test/make-test-root
+
 testimage: all
        ./dracut -l -f test-$(shell uname -r).img $(shell uname -r)
        @echo wrote  test-$(shell uname -r).img 
diff --git a/test/make-test-root b/test/make-test-root
new file mode 100755 (executable)
index 0000000..474c9af
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+. ./dracut-functions
+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/test-init /sbin/init
+dd if=/dev/zero of=test/root.ext2 bs=1M count=10
+mke2fs -F test/root.ext2
+mount -o loop -t ext2 test/root.ext2 "$mnttarget"
+cp -a -t "$mnttarget" "$initdir"/*
+(cd "$mnttarget"; mkdir -p dev sys proc etc)
+umount -l "$mnttarget"
+rm -rf "$mnttarget" "$initdir"
\ No newline at end of file
index f27f9db9f209c6a976bf27d31cb97dc7518558d7..2fde6e39c30aef80692ab18d58409d51d8831314 100755 (executable)
@@ -1,24 +1,9 @@
 #!/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
+[[ -f test/root.ext2 ]] || test/make-test-root
+./dracut -c test/dracut.conf.test -l -f test/initramfs.testing || exit
 
-exec qemu-kvm -hda root.ext2 -nographic -net none \
+exec qemu-kvm -hda test/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
+    -initrd test/initramfs.testing
\ No newline at end of file