From 3747b1ae432e871e31578d781ad8cb83746c5bb9 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Fri, 13 May 2011 18:39:12 +0300 Subject: [PATCH] kvm tools: Add boot test to checks 'make check' will now try booting a kernel and will exit gracefully once the kernel has finished loading. Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- tools/kvm/.gitignore | 2 ++ tools/kvm/Makefile | 3 +++ tools/kvm/tests/Makefile | 7 ++++++- tools/kvm/tests/boot/Makefile | 13 +++++++++++++ tools/kvm/tests/boot/init.c | 11 +++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tools/kvm/tests/boot/Makefile create mode 100644 tools/kvm/tests/boot/init.c diff --git a/tools/kvm/.gitignore b/tools/kvm/.gitignore index 197ccb7e5325..12c9e48067ce 100644 --- a/tools/kvm/.gitignore +++ b/tools/kvm/.gitignore @@ -4,3 +4,5 @@ .cscope tags include/common-cmds.h +tests/boot/boot_test.iso +tests/boot/rootfs/ diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 1aaed24489a5..64fdcbee2161 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -148,6 +148,7 @@ bios/bios-rom.bin: bios/bios-rom.S bios/e820.c check: $(PROGRAM) $(MAKE) -C tests ./$(PROGRAM) run tests/pit/tick.bin + ./$(PROGRAM) run -d tests/boot/boot_test.iso -p "init=init" .PHONY: check clean: @@ -156,6 +157,8 @@ clean: $(Q) rm -f bios/*.elf $(Q) rm -f bios/*.o $(Q) rm -f bios/bios-rom.h + $(Q) rm -f tests/boot/boot_test.iso + $(Q) rm -rf tests/boot/rootfs/ $(Q) rm -f $(DEPS) $(OBJS) $(PROGRAM) $(Q) rm -f cscope.* $(Q) rm -f $(KVM_INCLUDE)/common-cmds.h diff --git a/tools/kvm/tests/Makefile b/tools/kvm/tests/Makefile index 94b411d8deaf..cad14ecbae1b 100644 --- a/tools/kvm/tests/Makefile +++ b/tools/kvm/tests/Makefile @@ -1,4 +1,4 @@ -all: kernel pit +all: kernel pit boot kernel: $(MAKE) -C kernel @@ -8,7 +8,12 @@ pit: $(MAKE) -C pit .PHONY: pit +boot: + $(MAKE) -C boot +.PHONY: boot + clean: $(MAKE) -C kernel clean $(MAKE) -C pit clean + $(MAKE) -C boot clean .PHONY: clean diff --git a/tools/kvm/tests/boot/Makefile b/tools/kvm/tests/boot/Makefile new file mode 100644 index 000000000000..40cba6847ccd --- /dev/null +++ b/tools/kvm/tests/boot/Makefile @@ -0,0 +1,13 @@ +NAME := init + +OBJ := $(NAME).o + +all: $(.o) + rm -rf rootfs + mkdir rootfs + gcc -static init.c -o rootfs/init + mkisofs rootfs > boot_test.iso + +clean: + rm -rf rootfs boot_test.iso +.PHONY: clean diff --git a/tools/kvm/tests/boot/init.c b/tools/kvm/tests/boot/init.c new file mode 100644 index 000000000000..094f8ba37317 --- /dev/null +++ b/tools/kvm/tests/boot/init.c @@ -0,0 +1,11 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + puts("hello, KVM guest!\r"); + + reboot(LINUX_REBOOT_CMD_RESTART); + + return 0; +} -- 2.39.5