repository: /home/avi/kvm
branch: master
commit de1ecf61de5d4c1cd7efafc239fac2bd3af8cfc7
Author: Avi Kivity <[EMAIL PROTECTED]>
Date:   Mon Nov 26 15:07:35 2007 +0200

    kvm: testsuite: add emulator tests

diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
index 6d5c795..a6253ce 100644
--- a/user/config-x86-common.mak
+++ b/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/user/config-x86_64.mak b/user/config-x86_64.mak
index ba75ed2..bbe8ecb 100644
--- a/user/config-x86_64.mak
+++ b/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/user/test/x86/emulator.c b/user/test/x86/emulator.c
new file mode 100644
index 0000000..c2a7a84
--- /dev/null
+++ b/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;
+}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to