create simple disk image for 'make test'
authorroot <root@lon.fritz.box>
Wed, 6 Feb 2013 12:42:18 +0000 (13:42 +0100)
committerKay Sievers <kay@vrfy.org>
Wed, 6 Feb 2013 12:47:57 +0000 (13:47 +0100)
Makefile
test-create-disk.sh [new file with mode: 0755]

index c66b4cf..b76b4b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -64,12 +64,8 @@ clean:
 tar:
        git archive --format=tar --prefix=gummiboot-$(VERSION)/ $(VERSION) | xz > gummiboot-$(VERSION).tar.xz
 
-test: gummiboot$(MACHINE_TYPE_NAME).efi
-       mkdir -p /boot/EFI/gummiboot/
-       cp -v gummiboot$(MACHINE_TYPE_NAME).efi /boot/EFI/gummiboot/
-       @# unmount to sync EFI partition to disk
-       sync
-       umount /boot
-       echo 3 > /proc/sys/vm/drop_caches
-       @# run QEMU with UEFI firmware
-       qemu-kvm -m 512 -L /usr/lib/qemu-bios -snapshot /dev/sda
+test-disk:
+       ./test-create-disk.sh
+
+test: gummiboot$(MACHINE_TYPE_NAME).efi test-disk
+       qemu-kvm -m 256 -L /usr/lib/qemu-bios -snapshot test-disk
diff --git a/test-create-disk.sh b/test-create-disk.sh
new file mode 100755 (executable)
index 0000000..33c5037
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash -e
+
+# create GPT table with EFI System Partition
+rm -f test-disk
+dd if=/dev/null of=test-disk bs=1M seek=64 count=1
+parted --script test-disk "mklabel gpt" "mkpart ESP fat32 1M 64M" "set 1 boot on" "print"
+
+# create FAT32 file system
+LOOP=$(losetup --show -f -P test-disk)
+mkfs.vfat -F32 $LOOP
+mkdir mnt
+mount $LOOP mnt
+
+# install gummiboot
+mkdir -p mnt/EFI/BOOT
+cp gummibootx64.efi mnt/EFI/BOOT/BOOTX64.EFI
+
+# install entries
+mkdir -p mnt/loader/entries
+echo -e "timeout 3\n" > mnt/loader/loader.conf
+echo -e "title Test\nefi /test\n" > mnt/loader/entries/test.conf
+echo -e "title Test2\nefi /test2\n" > mnt/loader/entries/test2.conf
+echo -e "title Test3\nefi /test3\n" > mnt/loader/entries/test3.conf
+echo -e "title Test4\nefi /test4\n" > mnt/loader/entries/test4.conf
+echo -e "title Test5\nefi /test5\n" > mnt/loader/entries/test5.conf
+
+umount mnt
+rmdir mnt
+losetup -d $LOOP