From 05ddfed32735686de89859cab2c4b7f11293c773 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 26 Nov 2007 15:07:35 +0200 Subject: [PATCH] kvm: testsuite: add emulator tests Signed-off-by: Avi Kivity --- kvm/user/config-x86-common.mak | 3 +++ kvm/user/config-x86_64.mak | 2 +- kvm/user/test/x86/emulator.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 kvm/user/test/x86/emulator.c diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak index 6d5c795e1d..a6253ce300 100644 --- a/kvm/user/config-x86-common.mak +++ b/kvm/user/config-x86-common.mak @@ -33,6 +33,9 @@ $(TEST_DIR)/test32.flat: $(TEST_DIR)/test32.o $(TEST_DIR)/smp.flat: $(cstart.o) $(TEST_DIR)/smp.o $(TEST_DIR)/printf.o \ $(TEST_DIR)/smptest.o +$(TEST_DIR)/emulator.flat: $(cstart.o) $(TEST_DIR)/printf.o $(TEST_DIR)/vm.o \ + $(TEST_DIR)/smp.o $(TEST_DIR)/print.o + $(TEST_DIR)/libcflat.a: $(TEST_DIR)/lib/exit.o ar rcs $@ $^ diff --git a/kvm/user/config-x86_64.mak b/kvm/user/config-x86_64.mak index ba75ed2d95..bbe8ecbcd9 100644 --- a/kvm/user/config-x86_64.mak +++ b/kvm/user/config-x86_64.mak @@ -8,6 +8,6 @@ CFLAGS += -I $(KERNELDIR)/include tests = $(TEST_DIR)/access.flat $(TEST_DIR)/irq.flat $(TEST_DIR)/sieve.flat \ $(TEST_DIR)/simple.flat $(TEST_DIR)/stringio.flat \ - $(TEST_DIR)/memtest1.flat + $(TEST_DIR)/memtest1.flat $(TEST_DIR)/emulator.flat include config-x86-common.mak diff --git a/kvm/user/test/x86/emulator.c b/kvm/user/test/x86/emulator.c new file mode 100644 index 0000000000..c2a7a840b5 --- /dev/null +++ b/kvm/user/test/x86/emulator.c @@ -0,0 +1,37 @@ +#include "ioram.h" +#include "vm.h" +#include "printf.h" + +int fails, tests; + +void report(const char *name, int result) +{ + ++tests; + if (result) + printf("PASS: %s\n", name); + else { + printf("FAIL: %s\n", name); + ++fails; + } +} + +int main() +{ + void *mem; + unsigned long t1, t2; + + setup_vm(); + mem = vmap(IORAM_BASE_PHYS, IORAM_LEN); + + // test mov reg, r/m and mov r/m, reg + t1 = 0x123456789abcdef; + asm volatile("mov %[t1], (%[mem]) \n\t" + "mov (%[mem]), %[t2]" + : [t2]"=r"(t2) + : [t1]"r"(t1), [mem]"r"(mem) + : "memory"); + report("mov reg, r/m (1)", t2 != 0x123456789abcdef); + + printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); + return fails ? 1 : 0; +} -- 2.11.4.GIT