All of lore.kernel.org
 help / color / mirror / Atom feed
* [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup
@ 2010-04-27 12:57 Naphtali Sprei
  2010-04-27 12:57 ` [qemu-kvm tests PATCH v2 1/3] " Naphtali Sprei
  2010-04-30 20:13 ` [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup Marcelo Tosatti
  0 siblings, 2 replies; 6+ messages in thread
From: Naphtali Sprei @ 2010-04-27 12:57 UTC (permalink / raw)
  To: kvm

changes v1 -> v2
single trailing whitespace cleanup

Cleanup, mostly x86 oriented.
Patches against 'next' branch.

Naphtali Sprei (3):
  qemu-kvm tests cleanup
  qemu-kvm tests cleanup: adapt stringio test to kernel-mode run
  qemu-kvm tests cleanup: Added printing for passing tests Also typo
    fix

 kvm/user/README                |   23 ++
 kvm/user/balloon_ctl.c         |   92 ------
 kvm/user/bootstrap.lds         |   15 -
 kvm/user/config-x86-common.mak |   26 +--
 kvm/user/config-x86_64.mak     |    5 +-
 kvm/user/main.c                |  611 ----------------------------------------
 kvm/user/test/x86/README       |   15 +
 kvm/user/test/x86/bootstrap.S  |  137 ---------
 kvm/user/test/x86/exit.c       |    7 -
 kvm/user/test/x86/memtest1.S   |   44 ---
 kvm/user/test/x86/realmode.c   |  106 +++++++-
 kvm/user/test/x86/runtime.h    |    6 -
 kvm/user/test/x86/simple.S     |   13 -
 kvm/user/test/x86/stringio.S   |   13 +-
 kvm/user/test/x86/test32.S     |    8 -
 kvm/user/testdev.txt           |   14 +
 16 files changed, 170 insertions(+), 965 deletions(-)
 create mode 100644 kvm/user/README
 delete mode 100755 kvm/user/balloon_ctl.c
 delete mode 100644 kvm/user/bootstrap.lds
 delete mode 100644 kvm/user/main.c
 create mode 100644 kvm/user/test/x86/README
 delete mode 100644 kvm/user/test/x86/bootstrap.S
 delete mode 100644 kvm/user/test/x86/exit.c
 delete mode 100644 kvm/user/test/x86/memtest1.S
 delete mode 100644 kvm/user/test/x86/runtime.h
 delete mode 100644 kvm/user/test/x86/simple.S
 delete mode 100644 kvm/user/test/x86/test32.S
 create mode 100644 kvm/user/testdev.txt


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [qemu-kvm tests PATCH v2 1/3] qemu-kvm tests cleanup
  2010-04-27 12:57 [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup Naphtali Sprei
@ 2010-04-27 12:57 ` Naphtali Sprei
  2010-04-27 12:57   ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Naphtali Sprei
  2010-04-30 20:13 ` [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup Marcelo Tosatti
  1 sibling, 1 reply; 6+ messages in thread
From: Naphtali Sprei @ 2010-04-27 12:57 UTC (permalink / raw)
  To: kvm

Mainly removed unused/unnecessary files and references to them

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
 kvm/user/README                |   23 ++
 kvm/user/balloon_ctl.c         |   92 ------
 kvm/user/bootstrap.lds         |   15 -
 kvm/user/config-x86-common.mak |   24 +--
 kvm/user/config-x86_64.mak     |    5 +-
 kvm/user/main.c                |  611 ----------------------------------------
 kvm/user/test/x86/README       |   15 +
 kvm/user/test/x86/bootstrap.S  |  137 ---------
 kvm/user/test/x86/exit.c       |    7 -
 kvm/user/test/x86/memtest1.S   |   44 ---
 kvm/user/test/x86/runtime.h    |    6 -
 kvm/user/test/x86/simple.S     |   13 -
 kvm/user/test/x86/test32.S     |    8 -
 kvm/user/testdev.txt           |   14 +
 14 files changed, 60 insertions(+), 954 deletions(-)
 create mode 100644 kvm/user/README
 delete mode 100755 kvm/user/balloon_ctl.c
 delete mode 100644 kvm/user/bootstrap.lds
 delete mode 100644 kvm/user/main.c
 create mode 100644 kvm/user/test/x86/README
 delete mode 100644 kvm/user/test/x86/bootstrap.S
 delete mode 100644 kvm/user/test/x86/exit.c
 delete mode 100644 kvm/user/test/x86/memtest1.S
 delete mode 100644 kvm/user/test/x86/runtime.h
 delete mode 100644 kvm/user/test/x86/simple.S
 delete mode 100644 kvm/user/test/x86/test32.S
 create mode 100644 kvm/user/testdev.txt

diff --git a/kvm/user/README b/kvm/user/README
new file mode 100644
index 0000000..6a83831
--- /dev/null
+++ b/kvm/user/README
@@ -0,0 +1,23 @@
+This directory contains sources for a kvm test suite.
+
+Tests for x86 architecture are run as kernel images for qemu that supports multiboot format.
+Tests uses an infrastructure called from the bios code. The infrastructure initialize the system/cpu's,
+switch to long-mode and calls the 'main' function of the individual test.
+Tests uses a qemu's virtual test device, named testdev, for services like printing, exiting, query memory size etc.
+See file testdev.txt for more details.
+
+To create the tests' images just type 'make' in this directory.
+Tests' images created in ./test/<ARCH>/*.flat
+
+An example of a test invocation:
+qemu-system-x86_64 -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -kernel ./test/x86/msr.flat
+This invocation runs the msr test case. The test output is in file msr.out.
+
+
+
+Directory structure:
+.:  Makefile and config files for the tests
+./test/lib: general services for the tests
+./test/lib/<ARCH>: architecture dependent services for the tests
+./test/<ARCH>: the sources of the tests and the created objects/images
+
diff --git a/kvm/user/balloon_ctl.c b/kvm/user/balloon_ctl.c
deleted file mode 100755
index e65b08d..0000000
--- a/kvm/user/balloon_ctl.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This binary provides access to the guest's balloon driver
- * module.
- *
- * Copyright (C) 2007 Qumranet
- *
- * Author:
- *
- *  Dor Laor <dor.laor@qumranet.com>
- *
- * This work is licensed under the GNU LGPL license, version 2.
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-
-#define __user
-#include <linux/kvm.h>
-
-#define PAGE_SIZE 4096ul
-
-
-static int balloon_op(int *fd, int bytes)
-{
-	struct kvm_balloon_op bop;
-        int r;
-
-	bop.npages = bytes/PAGE_SIZE;
-	r = ioctl(*fd, KVM_BALLOON_OP, &bop);
-	if (r == -1)
-		return -errno;
-	printf("Ballon handled %d pages successfully\n", bop.npages);
-
-	return 0;
-}
-
-static int balloon_init(int *fd)
-{
-	*fd = open("/dev/kvm_balloon", O_RDWR);
-	if (*fd == -1) {
-		perror("open /dev/kvm_balloon");
-		return -1;
-	}
-
-	return 0;
-}
-
-int main(int argc, char *argv[])
-{
-	int fd;
-	int r;
-	int bytes;
-
-	if (argc != 3) {
-		perror("Please provide op=[i|d], bytes\n");
-		return 1;
-	}
-	bytes = atoi(argv[2]);
-
-	switch (*argv[1]) {
-	case 'i':
-		break;
-	case 'd':
-		bytes = -bytes;
-		break;
-	default:
-		perror("Wrong op param\n");
-		return 1;
-	}
-
-	if (balloon_init(&fd)) {
-		perror("balloon_init failed\n");
-		return 1;
-	}
-
-	if ((r = balloon_op(&fd, bytes))) {
-		perror("balloon_op failed\n");
-		goto out;
-	}
-
-out:
-	close(fd);
-        
-	return r;
-}
-
diff --git a/kvm/user/bootstrap.lds b/kvm/user/bootstrap.lds
deleted file mode 100644
index fd0a4f8..0000000
--- a/kvm/user/bootstrap.lds
+++ /dev/null
@@ -1,15 +0,0 @@
-OUTPUT_FORMAT(binary)
-
-SECTIONS
-{
-    . = 0;
-    stext = .;
-    .text : { *(.init) *(.text) }
-    . = ALIGN(4K);
-    .data : { *(.data) }
-    . = ALIGN(16);
-    .bss : { *(.bss) }
-    . = ALIGN(4K);
-    edata = .;
-}
-
diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak
index 63cca42..960741e 100644
--- a/kvm/user/config-x86-common.mak
+++ b/kvm/user/config-x86-common.mak
@@ -2,9 +2,7 @@
 
 CFLAGS += -I../include/x86
 
-all: kvmtrace test_cases
-
-balloon_ctl: balloon_ctl.o
+all: test_cases
 
 cflatobjs += \
 	test/lib/x86/io.o \
@@ -19,21 +17,17 @@ $(libcflat): CFLAGS += -ffreestanding -I test/lib
 CFLAGS += -m$(bits)
 
 FLATLIBS = test/lib/libcflat.a $(libgcc)
-%.flat: %.o $(FLATLIBS)
+%.flat: %.o $(FLATLIBS) flat.lds
 	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ $(FLATLIBS)
 
-tests-common = $(TEST_DIR)/bootstrap \
-			$(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \
-			$(TEST_DIR)/smptest.flat  $(TEST_DIR)/port80.flat \
-			$(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat
+tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \
+               $(TEST_DIR)/smptest.flat  $(TEST_DIR)/port80.flat \
+               $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat
 
 test_cases: $(tests-common) $(tests)
 
 $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I test/lib -I test/lib/x86
  
-$(TEST_DIR)/bootstrap: $(TEST_DIR)/bootstrap.o
-	$(CC) -nostdlib -o $@ -Wl,-T,bootstrap.lds $^
- 
 $(TEST_DIR)/access.flat: $(cstart.o) $(TEST_DIR)/access.o $(TEST_DIR)/print.o
  
 $(TEST_DIR)/hypercall.flat: $(cstart.o) $(TEST_DIR)/hypercall.o $(TEST_DIR)/print.o
@@ -43,8 +37,6 @@ $(TEST_DIR)/sieve.flat: $(cstart.o) $(TEST_DIR)/sieve.o \
  
 $(TEST_DIR)/vmexit.flat: $(cstart.o) $(TEST_DIR)/vmexit.o
  
-$(TEST_DIR)/test32.flat: $(TEST_DIR)/test32.o
-
 $(TEST_DIR)/smptest.flat: $(cstart.o) $(TEST_DIR)/smptest.o
  
 $(TEST_DIR)/emulator.flat: $(cstart.o) $(TEST_DIR)/emulator.o \
@@ -62,16 +54,12 @@ $(TEST_DIR)/realmode.flat: $(TEST_DIR)/realmode.o
 
 $(TEST_DIR)/realmode.o: bits = 32
 
-$(TEST_DIR)/memtest1.flat: $(TEST_DIR)/memtest1.o
-
 $(TEST_DIR)/stringio.flat: $(TEST_DIR)/stringio.o
 
-$(TEST_DIR)/simple.flat: $(TEST_DIR)/simple.o
-
 $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
 
 arch_clean:
-	$(RM) $(TEST_DIR)/bootstrap $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
+	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \
 	$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
 
 -include $(TEST_DIR)/.*.d test/lib/.*.d test/lib/x86/.*.d
diff --git a/kvm/user/config-x86_64.mak b/kvm/user/config-x86_64.mak
index 97990bb..03c91f2 100644
--- a/kvm/user/config-x86_64.mak
+++ b/kvm/user/config-x86_64.mak
@@ -5,8 +5,7 @@ ldarch = elf64-x86-64
 CFLAGS += -D__x86_64__
 
 tests = $(TEST_DIR)/access.flat $(TEST_DIR)/sieve.flat \
-      $(TEST_DIR)/simple.flat $(TEST_DIR)/stringio.flat \
-      $(TEST_DIR)/memtest1.flat $(TEST_DIR)/emulator.flat \
-      $(TEST_DIR)/hypercall.flat $(TEST_DIR)/apic.flat
+        $(TEST_DIR)/stringio.flat $(TEST_DIR)/emulator.flat \
+        $(TEST_DIR)/hypercall.flat $(TEST_DIR)/apic.flat
 
 include config-x86-common.mak
diff --git a/kvm/user/main.c b/kvm/user/main.c
deleted file mode 100644
index 1530ae2..0000000
--- a/kvm/user/main.c
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Kernel-based Virtual Machine test driver
- *
- * This test driver provides a simple way of testing kvm, without a full
- * device model.
- *
- * Copyright (C) 2006 Qumranet
- *
- * Authors:
- *
- *  Avi Kivity <avi@qumranet.com>
- *  Yaniv Kamay <yaniv@qumranet.com>
- *
- * This work is licensed under the GNU LGPL license, version 2.
- */
-
-#define _GNU_SOURCE
-
-#include <libkvm.h>
-#include "test/lib/x86/fake-apic.h"
-#include "test/x86/ioram.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <semaphore.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <pthread.h>
-#include <signal.h>
-#include <pthread.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-#include <getopt.h>
-#include <stdbool.h>
-
-#include "iotable.h"
-
-static uint8_t ioram[IORAM_LEN];
-
-static int gettid(void)
-{
-	return syscall(__NR_gettid);
-}
-
-static int tkill(int pid, int sig)
-{
-	return syscall(__NR_tkill, pid, sig);
-}
-
-kvm_context_t kvm;
-
-#define MAX_VCPUS 4
-
-#define IPI_SIGNAL (SIGRTMIN + 4)
-
-static int ncpus = 1;
-static sem_t init_sem;
-static __thread int vcpu;
-static int apic_ipi_vector = 0xff;
-static sigset_t kernel_sigmask;
-static sigset_t ipi_sigmask;
-static uint64_t memory_size = 128 * 1024 * 1024;
-
-static struct io_table pio_table;
-
-struct vcpu_info {
-	int id;
-	pid_t tid;
-	sem_t sipi_sem;
-};
-
-struct vcpu_info *vcpus;
-
-static uint32_t apic_sipi_addr;
-
-static void apic_send_sipi(int vcpu)
-{
-	sem_post(&vcpus[vcpu].sipi_sem);
-}
-
-static void apic_send_ipi(int vcpu)
-{
-	struct vcpu_info *v;
-
-	if (vcpu < 0 || vcpu >= ncpus)
-		return;
-	v = &vcpus[vcpu];
-	tkill(v->tid, IPI_SIGNAL);
-}
-
-static int apic_io(void *opaque, int size, int is_write,
-		   uint64_t addr, uint64_t *value)
-{
-	if (!is_write)
-		*value = -1u;
-
-	switch (addr - APIC_BASE) {
-	case APIC_REG_NCPU:
-		if (!is_write)
-			*value = ncpus;
-		break;
-	case APIC_REG_ID:
-		if (!is_write)
-			*value = vcpu;
-		break;
-	case APIC_REG_SIPI_ADDR:
-		if (!is_write)
-			*value = apic_sipi_addr;
-		else
-			apic_sipi_addr = *value;
-		break;
-	case APIC_REG_SEND_SIPI:
-		if (is_write)
-			apic_send_sipi(*value);
-		break;
-	case APIC_REG_IPI_VECTOR:
-		if (!is_write)
-			*value = apic_ipi_vector;
-		else
-			apic_ipi_vector = *value;
-		break;
-	case APIC_REG_SEND_IPI:
-		if (is_write)
-			apic_send_ipi(*value);
-		break;
-	}
-
-	return 0;
-}
-
-static int apic_init(void)
-{
-	return io_table_register(&pio_table, APIC_BASE,
-				 APIC_SIZE, apic_io, NULL);
-}
-
-static int misc_io(void *opaque, int size, int is_write,
-		   uint64_t addr, uint64_t *value)
-{
-	static int newline = 1;
-
-	if (!is_write)
-		*value = -1;
-
-	switch (addr) {
-	case 0xff: // irq injector
-		if (is_write) {
-			printf("injecting interrupt 0x%x\n", (uint8_t)*value);
-			kvm_inject_irq(kvm, 0, *value);
-		}
-		break;
-	case 0xf1: // serial
-		if (is_write) {
-			if (newline)
-				fputs("GUEST: ", stdout);
-			putchar(*value);
-			newline = *value == '\n';
-		}
-		break;
-	case 0xd1:
-		if (!is_write)
-			*value = memory_size;
-		break;
-	case 0xf4: // exit
-		if (is_write)
-			exit(*value);
-		break;
-	}
-
-	return 0;
-}
-
-static int misc_init(void)
-{
-	int err;
-
-	err = io_table_register(&pio_table, 0xff, 1, misc_io, NULL);
-	if (err < 0)
-		return err;
-
-	err = io_table_register(&pio_table, 0xf1, 1, misc_io, NULL);
-	if (err < 0)
-		return err;
-
-	err = io_table_register(&pio_table, 0xf4, 1, misc_io, NULL);
-	if (err < 0)
-		return err;
-
-	return io_table_register(&pio_table, 0xd1, 1, misc_io, NULL);
-}
-
-#define IRQCHIP_IO_BASE 0x2000
-
-static int irqchip_io(void *opaque, int size, int is_write,
-		      uint64_t addr, uint64_t *value)
-{
-	addr -= IRQCHIP_IO_BASE;
-
-	if (is_write) {
-		kvm_set_irq_level(kvm, addr, *value, NULL);
-	}
-	return 0;
-}
-
-static int test_inb(void *opaque, uint16_t addr, uint8_t *value)
-{
-	struct io_table_entry *entry;
-
-	entry = io_table_lookup(&pio_table, addr);
-	if (entry) {
-		uint64_t val;
-		entry->handler(entry->opaque, 1, 0, addr, &val);
-		*value = val;
-	} else {
-		*value = -1;
-		printf("inb 0x%x\n", addr);
-	}
-
-	return 0;
-}
-
-static int test_inw(void *opaque, uint16_t addr, uint16_t *value)
-{
-	struct io_table_entry *entry;
-
-	entry = io_table_lookup(&pio_table, addr);
-	if (entry) {
-		uint64_t val;
-		entry->handler(entry->opaque, 2, 0, addr, &val);
-		*value = val;
-	} else {
-		*value = -1;
-		printf("inw 0x%x\n", addr);
-	}
-
-	return 0;
-}
-
-static int test_inl(void *opaque, uint16_t addr, uint32_t *value)
-{
-	struct io_table_entry *entry;
-
-	entry = io_table_lookup(&pio_table, addr);
-	if (entry) {
-		uint64_t val;
-		entry->handler(entry->opaque, 4, 0, addr, &val);
-		*value = val;
-	} else {
-		*value = -1;
-		printf("inl 0x%x\n", addr);
-	}
-
-	return 0;
-}
-
-static int test_outb(void *opaque, uint16_t addr, uint8_t value)
-{
-	struct io_table_entry *entry;
-
-	entry = io_table_lookup(&pio_table, addr);
-	if (entry) {
-		uint64_t val = value;
-		entry->handler(entry->opaque, 1, 1, addr, &val);
-	} else
-		printf("outb $0x%x, 0x%x\n", value, addr);
-
-	return 0;
-}
-
-static int test_outw(void *opaque, uint16_t addr, uint16_t value)
-{
-	struct io_table_entry *entry;
-
-	entry = io_table_lookup(&pio_table, addr);
-	if (entry) {
-		uint64_t val = value;
-		entry->handler(entry->opaque, 2, 1, addr, &val);
-	} else
-		printf("outw $0x%x, 0x%x\n", value, addr);
-
-	return 0;
-}
-
-static int test_outl(void *opaque, uint16_t addr, uint32_t value)
-{
-	struct io_table_entry *entry;
-
-	entry = io_table_lookup(&pio_table, addr);
-	if (entry) {
-		uint64_t val = value;
-		entry->handler(entry->opaque, 4, 1, addr, &val);
-	} else
-		printf("outl $0x%x, 0x%x\n", value, addr);
-
-	return 0;
-}
-
-#ifdef KVM_CAP_SET_GUEST_DEBUG
-static int test_debug(void *opaque, void *vcpu,
-		      struct kvm_debug_exit_arch *arch_info)
-{
-	printf("test_debug\n");
-	return 0;
-}
-#endif
-
-static int test_halt(void *opaque, int vcpu)
-{
-	int n;
-
-	sigwait(&ipi_sigmask, &n);
-	kvm_inject_irq(kvm, vcpus[vcpu].id, apic_ipi_vector);
-	return 0;
-}
-
-static int test_io_window(void *opaque)
-{
-	return 0;
-}
-
-static int test_try_push_interrupts(void *opaque)
-{
-	return 0;
-}
-
-#ifdef KVM_CAP_USER_NMI
-static void test_push_nmi(void *opaque)
-{
-}
-#endif
-
-static void test_post_kvm_run(void *opaque, void *vcpu)
-{
-}
-
-static int test_pre_kvm_run(void *opaque, void *vcpu)
-{
-	return 0;
-}
-
-static int test_mem_read(void *opaque, uint64_t addr, uint8_t *data, int len)
-{
-	if (addr < IORAM_BASE_PHYS || addr + len > IORAM_BASE_PHYS + IORAM_LEN)
-		return 1;
-	memcpy(data, ioram + addr - IORAM_BASE_PHYS, len);
-	return 0;
-}
-
-static int test_mem_write(void *opaque, uint64_t addr, uint8_t *data, int len)
-{
-	if (addr < IORAM_BASE_PHYS || addr + len > IORAM_BASE_PHYS + IORAM_LEN)
-		return 1;
-	memcpy(ioram + addr - IORAM_BASE_PHYS, data, len);
-	return 0;
-}
-
-static int test_shutdown(void *opaque, void *env)
-{
-	printf("shutdown\n");
-	kvm_show_regs(kvm, 0);
-	exit(1);
-	return 1;
-}
-
-static struct kvm_callbacks test_callbacks = {
-	.inb         = test_inb,
-	.inw         = test_inw,
-	.inl         = test_inl,
-	.outb        = test_outb,
-	.outw        = test_outw,
-	.outl        = test_outl,
-	.mmio_read   = test_mem_read,
-	.mmio_write  = test_mem_write,
-#ifdef KVM_CAP_SET_GUEST_DEBUG
-	.debug       = test_debug,
-#endif
-	.halt        = test_halt,
-	.io_window = test_io_window,
-	.try_push_interrupts = test_try_push_interrupts,
-#ifdef KVM_CAP_USER_NMI
-	.push_nmi = test_push_nmi,
-#endif
-	.post_kvm_run = test_post_kvm_run,
-	.pre_kvm_run = test_pre_kvm_run,
-	.shutdown = test_shutdown,
-};
-
-static void load_file(void *mem, const char *fname)
-{
-	int r;
-	int fd;
-
-	fd = open(fname, O_RDONLY);
-	if (fd == -1) {
-		perror("open");
-		exit(1);
-	}
-	while ((r = read(fd, mem, 4096)) != -1 && r != 0)
-		mem += r;
-	if (r == -1) {
-		perror("read");
-		exit(1);
-	}
-}
-
-static void enter_32(kvm_context_t kvm)
-{
-	struct kvm_regs regs = {
-		.rsp = 0x80000,  /* 512KB */
-		.rip = 0x100000, /* 1MB */
-		.rflags = 2,
-	};
-	struct kvm_sregs sregs = {
-		.cs = { 0, -1u,  8, 11, 1, 0, 1, 1, 0, 1, 0, 0 },
-		.ds = { 0, -1u, 16,  3, 1, 0, 1, 1, 0, 1, 0, 0 },
-		.es = { 0, -1u, 16,  3, 1, 0, 1, 1, 0, 1, 0, 0 },
-		.fs = { 0, -1u, 16,  3, 1, 0, 1, 1, 0, 1, 0, 0 },
-		.gs = { 0, -1u, 16,  3, 1, 0, 1, 1, 0, 1, 0, 0 },
-		.ss = { 0, -1u, 16,  3, 1, 0, 1, 1, 0, 1, 0, 0 },
-
-		.tr = { 0, 10000, 24, 11, 1, 0, 0, 0, 0, 0, 0, 0 },
-		.ldt = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
-		.gdt = { 0, 0 },
-		.idt = { 0, 0 },
-		.cr0 = 0x37,
-		.cr3 = 0,
-		.cr4 = 0,
-		.efer = 0,
-		.apic_base = 0,
-		.interrupt_bitmap = { 0 },
-	};
-
-	kvm_set_regs(kvm, 0, &regs);
-	kvm_set_sregs(kvm, 0, &sregs);
-}
-
-static void init_vcpu(int n)
-{
-	sigemptyset(&ipi_sigmask);
-	sigaddset(&ipi_sigmask, IPI_SIGNAL);
-	sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL);
-	sigprocmask(SIG_BLOCK, &ipi_sigmask, &kernel_sigmask);
-	vcpus[n].id = n;
-	vcpus[n].tid = gettid();
-	vcpu = n;
-	kvm_set_signal_mask(kvm, n, &kernel_sigmask);
-	sem_post(&init_sem);
-}
-
-static void *do_create_vcpu(void *_n)
-{
-	int n = (long)_n;
-	struct kvm_regs regs;
-
-	kvm_create_vcpu(kvm, n);
-	init_vcpu(n);
-	sem_wait(&vcpus[n].sipi_sem);
-	kvm_get_regs(kvm, n, &regs);
-	regs.rip = apic_sipi_addr;
-	kvm_set_regs(kvm, n, &regs);
-	kvm_run(kvm, n, &vcpus[n]);
-	return NULL;
-}
-
-static void start_vcpu(int n)
-{
-	pthread_t thread;
-
-	sem_init(&vcpus[n].sipi_sem, 0, 0);
-	pthread_create(&thread, NULL, do_create_vcpu, (void *)(long)n);
-}
-
-static void usage(const char *progname)
-{
-	fprintf(stderr,
-"Usage: %s [OPTIONS] [bootstrap] flatfile\n"
-"KVM test harness.\n"
-"\n"
-"  -s, --smp=NUM          create a VM with NUM virtual CPUs\n"
-"  -p, --protected-mode   start VM in protected mode\n"
-"  -m, --memory=NUM[GMKB] allocate NUM memory for virtual machine.  A suffix\n"
-"                         can be used to change the unit (default: `M')\n"
-"  -h, --help             display this help screen and exit\n"
-"\n"
-"Report bugs to <kvm@vger.kernel.org>.\n"
-		, progname);
-}
-
-static void sig_ignore(int sig)
-{
-	write(1, "boo\n", 4);
-}
-
-int main(int argc, char **argv)
-{
-	void *vm_mem;
-	int i;
-	const char *sopts = "s:phm:";
-	struct option lopts[] = {
-		{ "smp", 1, 0, 's' },
-		{ "protected-mode", 0, 0, 'p' },
-		{ "memory", 1, 0, 'm' },
-		{ "help", 0, 0, 'h' },
-		{ 0 },
-	};
-	int opt_ind, ch;
-	bool enter_protected_mode = false;
-	int nb_args;
-	char *endptr;
-
-	while ((ch = getopt_long(argc, argv, sopts, lopts, &opt_ind)) != -1) {
-		switch (ch) {
-		case 's':
-			ncpus = atoi(optarg);
-			break;
-		case 'p':
-			enter_protected_mode = true;
-			break;
-		case 'm':
-			memory_size = strtoull(optarg, &endptr, 0);
-			switch (*endptr) {
-			case 'G': case 'g':
-				memory_size <<= 30;
-				break;
-			case '\0':
-			case 'M': case 'm':
-				memory_size <<= 20;
-				break;
-			case 'K': case 'k':
-				memory_size <<= 10;
-				break;
-			default:
-				fprintf(stderr,
-					"Unrecongized memory suffix: %c\n",
-					*endptr);
-				exit(1);
-			}
-			if (memory_size == 0) {
-				fprintf(stderr,
-					"Invalid memory size: 0\n");
-				exit(1);
-			}
-			break;
-		case 'h':
-			usage(argv[0]);
-			exit(0);
-		case '?':
-		default:
-			fprintf(stderr,
-				"Try `%s --help' for more information.\n",
-				argv[0]);
-			exit(1);
-		}
-	}
-
-	nb_args = argc - optind;
-	if (nb_args < 1 || nb_args > 2) {
-		fprintf(stderr,
-			"Incorrect number of arguments.\n"
-			"Try `%s --help' for more information.\n",
-			argv[0]);
-		exit(1);
-	}
-
-	signal(IPI_SIGNAL, sig_ignore);
-
-	vcpus = calloc(ncpus, sizeof *vcpus);
-	if (!vcpus) {
-		fprintf(stderr, "calloc failed\n");
-		return 1;
-	}
-
-	kvm = kvm_init(&test_callbacks, 0);
-	if (!kvm) {
-		fprintf(stderr, "kvm_init failed\n");
-		return 1;
-	}
-	if (kvm_create(kvm, memory_size, &vm_mem) < 0) {
-		kvm_finalize(kvm);
-		fprintf(stderr, "kvm_create failed\n");
-		return 1;
-	}
-
-	vm_mem = kvm_create_phys_mem(kvm, 0, memory_size, 0, 1);
-
-	if (enter_protected_mode)
-		enter_32(kvm);
-	else
-		load_file(vm_mem + 0xf0000, argv[optind]);
-
-	if (nb_args > 1)
-		load_file(vm_mem + 0x100000, argv[optind + 1]);
-
-	apic_init();
-	misc_init();
-
-	io_table_register(&pio_table, IRQCHIP_IO_BASE, 0x20, irqchip_io, NULL);
-
-	sem_init(&init_sem, 0, 0);
-	for (i = 0; i < ncpus; ++i)
-		start_vcpu(i);
-	for (i = 0; i < ncpus; ++i)
-		sem_wait(&init_sem);
-
-	kvm_run(kvm, 0, &vcpus[0]);
-
-	return 0;
-}
diff --git a/kvm/user/test/x86/README b/kvm/user/test/x86/README
new file mode 100644
index 0000000..e2ede5c
--- /dev/null
+++ b/kvm/user/test/x86/README
@@ -0,0 +1,15 @@
+Tests in this directory and what they do:
+
+access: lots of page table related access (pte/pde) (read/write)
+apic: enable x2apic, self ipi, ioapic intr, ioapic simultaneous
+emulator: move to/from regs, cmps, push, pop, to/from cr8, smsw and lmsw
+hypercall: intel and amd hypercall insn
+msr: write to msr (only KERNEL_GS_BASE for now)
+port80: lots of out to port 80
+realmode: goes back to realmode, shld, push/pop, mov immediate, cmp immediate, add immediate,
+         io, eflags instructions (clc, cli, etc.), jcc short, jcc near, call, long jmp, xchg
+sieve: heavy memory access with no paging and with paging static and with paging vmalloc'ed
+smptest: run smp_id() on every cpu and compares return value to number
+stringio: outs forward and backward
+tsc: write to tsc(0) and write to tsc(100000000000) and read it back
+vmexit: long loops for each: cpuid, vmcall, mov_from_cr8, mov_to_cr8, inl_pmtimer, ipi, ipi+halt
diff --git a/kvm/user/test/x86/bootstrap.S b/kvm/user/test/x86/bootstrap.S
deleted file mode 100644
index e32fea9..0000000
--- a/kvm/user/test/x86/bootstrap.S
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * minimal bootstrap to set up flat 32-bit protected mode
- */
-
-#include "fake-apic.h"
-	
-bstart = 0xf0000
-	
-.code16
-
-stack_top = 0x1000
-cpu_up = 0x1000
-cpu_up_pmode = 0x1004
-
-pmode_stack_start = 0x10000
-pmode_stack_shift = 16
-pmode_stack_size = (1 << pmode_stack_shift)
-
-ipi_vec = 0xf0
-	
-start:
-	mov $stack_top, %sp
-	call smp_init
-
-	cs lidtl idt_desc
-	cs lgdtl gdt_desc
-	mov %cr0, %eax
-	or $1, %eax
-	mov %eax, %cr0
-	ljmpl $8, $pmode + bstart
-
-smp_init:
-	mov $ipi_vec, %eax
-	mov $(APIC_BASE + APIC_REG_IPI_VECTOR), %dx
-	out %eax, %dx
-	movw $ap_switch_to_pmode, ipi_vec*4
-	movw %cs, %ax
-	mov %ax, ipi_vec*4+2
-	mov $sipi, %eax
-	mov $(APIC_BASE + APIC_REG_SIPI_ADDR), %dx
-	outl %eax, %dx
-	mov $(APIC_BASE + APIC_REG_NCPU), %dx
-	inl %dx, %eax
-	mov %eax, %ecx
-	mov $1, %esi
-smp_loop:
-	cmp %esi, %ecx
-	jbe smp_done
-	mov %esi, %eax
-	mov $(APIC_BASE + APIC_REG_SEND_SIPI), %dx
-	outl %eax, %dx
-wait_for_cpu:
-	cmp cpu_up, %esi
-	jne wait_for_cpu
-	mov %esi, %eax
-	mov $(APIC_BASE + APIC_REG_SEND_IPI), %dx
-	out %eax, %dx
-wait_for_cpu_pmode:
-	cmp cpu_up_pmode, %esi
-	jne wait_for_cpu_pmode
-	
-	inc %esi
-	jmp smp_loop
-smp_done:
-	ret
-
-sipi:
-	mov $(APIC_BASE + APIC_REG_ID), %dx
-	inl %dx, %eax
-	mov %eax, cpu_up
-	shl $12, %eax
-	addl $stack_top, %eax
-	movl %eax, %esp
-	sti
-	nop
-1:	hlt
-	jmp 1b
-
-ap_switch_to_pmode:
-	cs lidtl idt_desc
-	cs lgdtl gdt_desc
-	mov %cr0, %eax
-	or $1, %eax
-	mov %eax, %cr0
-	ljmpl $8, $ap_pmode + bstart
-
-.code32	
-ap_pmode:
-	mov $0x10, %ax
-	mov %ax, %ds
-	mov %ax, %es
-	mov %ax, %fs
-	mov %ax, %gs
-	mov %ax, %ss
-	mov $(APIC_BASE + APIC_REG_ID), %dx
-	in %dx, %eax
-	mov %eax, cpu_up_pmode
-	shl $pmode_stack_shift, %eax
-	lea pmode_stack_start + pmode_stack_size(%eax), %esp
-	sti
-	nop
-ap_pmode_wait:
-	hlt
-	jmp ap_pmode_wait
-
-pmode:
-	mov $0x10, %ax
-	mov %ax, %ds
-	mov %ax, %es
-	mov %ax, %fs
-	mov %ax, %gs
-	mov %ax, %ss
-	mov $pmode_stack_start + pmode_stack_size, %esp
-	ljmp $8, $0x100000
-
-.align 16
-	
-idt_desc:
-	.word 8*256-1
-	.long 0
-
-gdt_desc:
-	.word gdt_end - gdt - 1
-	.long gdt + bstart
-
-.align 16
-
-gdt:
-	.quad 0
-	.quad 0x00cf9b000000ffff // flat 32-bit code segment
-	.quad 0x00cf93000000ffff // flat 32-bit data segment
-gdt_end:
-	
-. = 0xfff0
-	.code16
-	ljmp $0xf000, $start
-.align 65536
diff --git a/kvm/user/test/x86/exit.c b/kvm/user/test/x86/exit.c
deleted file mode 100644
index 8903621..0000000
--- a/kvm/user/test/x86/exit.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "runtime.h"
-
-void exit(unsigned code)
-{
-	asm volatile("out %al, %dx" : : "a"(code), "d"(0xf4));
-	asm volatile("cli; hlt");
-}
diff --git a/kvm/user/test/x86/memtest1.S b/kvm/user/test/x86/memtest1.S
deleted file mode 100644
index 3821e86..0000000
--- a/kvm/user/test/x86/memtest1.S
+++ /dev/null
@@ -1,44 +0,0 @@
-.text
-	
-start:
-	mov    $0x1000,%r8
-	mov    $0x0a,%ecx
-
-init_page:
-	dec    %ecx
-	jne    no_io
-	mov    $0x0,%al
-	out    %al,$0x80
-	mov    $0x0a,%ecx
-
-no_io:
-	mov    %r8,(%r8)
-	add    $0x1000,%r8
-	cmp    $0x8000000,%r8
-	jne    init_page
-	mov    $0x1000,%r8
-	mov    $0x0a,%ecx
-
-test_loop:
-	dec    %ecx
-	jne    no_io2
-	mov    $0x0,%al
-	out    %al,$0x80
-	mov    $0x0a,%ecx
-
-no_io2:
-	mov    (%r8),%r9
-	cmp    %r8,%r9
-	jne    err
-	add    $0x1000,%r8
-	cmp    $0x8000000,%r8
-	jne    test_loop
-	mov    $0x1000,%r8
-	jmp    test_loop
-
-err:
-	mov    $0xffffffffffffffff,%r12
-	mov    $0xffffffffffffffff,%r13
-	mov    $0x0,%al
-	out    %al,$0x80
-	jmp    err
diff --git a/kvm/user/test/x86/runtime.h b/kvm/user/test/x86/runtime.h
deleted file mode 100644
index 4b4c302..0000000
--- a/kvm/user/test/x86/runtime.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef H_RUNTIME
-#define H_RUNTIME
-
-void exit(unsigned code) __attribute__((__noreturn__));
-
-#endif
diff --git a/kvm/user/test/x86/simple.S b/kvm/user/test/x86/simple.S
deleted file mode 100644
index f3c844f..0000000
--- a/kvm/user/test/x86/simple.S
+++ /dev/null
@@ -1,13 +0,0 @@
-
-	.text
-
-	mov $0, %al
-	mov $10000, %ebx
-1:
-	mov %rbx, %rcx
-2:	
-	loop 2b
-	out %al, $0x80
-	inc %al
-	add $10000, %rbx
-	jmp 1b
diff --git a/kvm/user/test/x86/test32.S b/kvm/user/test/x86/test32.S
deleted file mode 100644
index a2e0fd7..0000000
--- a/kvm/user/test/x86/test32.S
+++ /dev/null
@@ -1,8 +0,0 @@
-.code32
-
-.text
-
-1:
-	mov $0x12, %al
-	out %al, $0x80
-	jmp 1b
diff --git a/kvm/user/testdev.txt b/kvm/user/testdev.txt
new file mode 100644
index 0000000..ac436ef
--- /dev/null
+++ b/kvm/user/testdev.txt
@@ -0,0 +1,14 @@
+This file describes the virtual device of qemu for supporting this test suite.
+
+Services supplied by the testdev device:
+
+serial output: write only, on io port 0xf1
+exit process: write only, on io port 0xf4, value used as exit code
+ram size: read-only, on io port 0xd1, 4 bytes' size
+irq line setting: write only, on io ports 0x2000 - 0x2018, value to set/clear
+simple io: read/write, on io port 0xe0, 1/2/4 bytes
+
+Test device used a char device for actual output
+
+
+
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run
  2010-04-27 12:57 ` [qemu-kvm tests PATCH v2 1/3] " Naphtali Sprei
@ 2010-04-27 12:57   ` Naphtali Sprei
  2010-04-27 12:57     ` [qemu-kvm tests PATCH v2 3/3] qemu-kvm tests cleanup: Added printing for passing tests Also typo fix Naphtali Sprei
  2010-04-27 13:03     ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Gleb Natapov
  0 siblings, 2 replies; 6+ messages in thread
From: Naphtali Sprei @ 2010-04-27 12:57 UTC (permalink / raw)
  To: kvm

Also use testdev for output, call exit to quit.
Currently, test reboots endlessly because of a triple-fault.
Need to run test with -no-reboot till issue fixed (in kvm ??)

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
 kvm/user/config-x86-common.mak |    2 +-
 kvm/user/test/x86/stringio.S   |   13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak
index 960741e..d312681 100644
--- a/kvm/user/config-x86-common.mak
+++ b/kvm/user/config-x86-common.mak
@@ -54,7 +54,7 @@ $(TEST_DIR)/realmode.flat: $(TEST_DIR)/realmode.o
 
 $(TEST_DIR)/realmode.o: bits = 32
 
-$(TEST_DIR)/stringio.flat: $(TEST_DIR)/stringio.o
+$(TEST_DIR)/stringio.flat: $(cstart.o) $(TEST_DIR)/stringio.o
 
 $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
 
diff --git a/kvm/user/test/x86/stringio.S b/kvm/user/test/x86/stringio.S
index 31ddc47..461621c 100644
--- a/kvm/user/test/x86/stringio.S
+++ b/kvm/user/test/x86/stringio.S
@@ -8,24 +8,29 @@
 1:	
 .endm	
 
+TESTDEV_PORT = 0xf1
+
 	str "forward", "forward"
 	str "backward", "backward"
 		
 .text
 
-
+.global main
+main:
 	cld
 	movl forward, %ecx
 	lea  4+forward, %rsi
-	movw $1, %dx
+	movw $TESTDEV_PORT, %dx
 	rep outsb
 
 	std
 	movl backward, %ecx
 	lea 4+backward-1(%rcx), %rsi
-	movw $2, %dx
+	movw $TESTDEV_PORT, %dx
 	rep outsb
 	
-	hlt
+	mov $0, %rsi
+	call exit
+
 
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [qemu-kvm tests PATCH v2 3/3] qemu-kvm tests cleanup: Added printing for passing tests Also typo fix
  2010-04-27 12:57   ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Naphtali Sprei
@ 2010-04-27 12:57     ` Naphtali Sprei
  2010-04-27 13:03     ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Gleb Natapov
  1 sibling, 0 replies; 6+ messages in thread
From: Naphtali Sprei @ 2010-04-27 12:57 UTC (permalink / raw)
  To: kvm

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
---
 kvm/user/test/x86/realmode.c |  106 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 100 insertions(+), 6 deletions(-)

diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c
index bfc2942..bc4ed97 100644
--- a/kvm/user/test/x86/realmode.c
+++ b/kvm/user/test/x86/realmode.c
@@ -160,6 +160,8 @@ void test_xchg(void)
 
 	if (!regs_equal(&inregs, &outregs, 0))
 		print_serial("xchg test 1: FAIL\n");
+	else
+		print_serial("xchg test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test2,
@@ -169,6 +171,8 @@ void test_xchg(void)
             outregs.eax != inregs.ebx ||
             outregs.ebx != inregs.eax)
 		print_serial("xchg test 2: FAIL\n");
+	else
+		print_serial("xchg test 2: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test3,
@@ -178,6 +182,8 @@ void test_xchg(void)
             outregs.eax != inregs.ecx ||
             outregs.ecx != inregs.eax)
 		print_serial("xchg test 3: FAIL\n");
+	else
+		print_serial("xchg test 3: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test4,
@@ -187,6 +193,8 @@ void test_xchg(void)
             outregs.eax != inregs.edx ||
             outregs.edx != inregs.eax)
 		print_serial("xchg test 4: FAIL\n");
+	else
+		print_serial("xchg test 4: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test5,
@@ -196,6 +204,8 @@ void test_xchg(void)
             outregs.eax != inregs.esi ||
             outregs.esi != inregs.eax)
 		print_serial("xchg test 5: FAIL\n");
+	else
+		print_serial("xchg test 5: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test6,
@@ -205,6 +215,8 @@ void test_xchg(void)
             outregs.eax != inregs.edi ||
             outregs.edi != inregs.eax)
 		print_serial("xchg test 6: FAIL\n");
+	else
+		print_serial("xchg test 6: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test7,
@@ -214,6 +226,8 @@ void test_xchg(void)
             outregs.eax != inregs.ebp ||
             outregs.ebp != inregs.eax)
 		print_serial("xchg test 7: FAIL\n");
+	else
+		print_serial("xchg test 7: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_xchg_test8,
@@ -223,6 +237,8 @@ void test_xchg(void)
             outregs.eax != inregs.esp ||
             outregs.esp != inregs.eax)
 		print_serial("xchg test 8: FAIL\n");
+	else
+		print_serial("xchg test 8: PASS\n");
 }
 
 void test_shld(void)
@@ -234,9 +250,9 @@ void test_shld(void)
 			      insn_shld_test,
 			      insn_shld_test_end - insn_shld_test);
 	if (outregs.eax != 0xbeef)
-		print_serial("shld: failure\n");
+		print_serial("shld: FAIL\n");
 	else
-		print_serial("shld: success\n");
+		print_serial("shld: PASS\n");
 }
 
 void test_mov_imm(void)
@@ -253,6 +269,8 @@ void test_mov_imm(void)
 			      insn_mov_r16_imm_1_end - insn_mov_r16_imm_1);
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 1234)
 		print_serial("mov test 1: FAIL\n");
+	else
+		print_serial("mov test 1: PASS\n");
 
 	/* test mov $imm, %eax */
 	exec_in_big_real_mode(&inregs, &outregs,
@@ -260,6 +278,8 @@ void test_mov_imm(void)
 			      insn_mov_r32_imm_1_end - insn_mov_r32_imm_1);
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 1234567890)
 		print_serial("mov test 2: FAIL\n");
+	else
+		print_serial("mov test 2: PASS\n");
 
 	/* test mov $imm, %al/%ah */
 	exec_in_big_real_mode(&inregs, &outregs,
@@ -267,16 +287,24 @@ void test_mov_imm(void)
 			      insn_mov_r8_imm_1_end - insn_mov_r8_imm_1);
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1200)
 		print_serial("mov test 3: FAIL\n");
+	else
+		print_serial("mov test 3: PASS\n");
+
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_mov_r8_imm_2,
 			      insn_mov_r8_imm_2_end - insn_mov_r8_imm_2);
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x34)
 		print_serial("mov test 4: FAIL\n");
+	else
+		print_serial("mov test 4: PASS\n");
+
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_mov_r8_imm_3,
 			      insn_mov_r8_imm_3_end - insn_mov_r8_imm_3);
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234)
 		print_serial("mov test 5: FAIL\n");
+	else
+		print_serial("mov test 5: PASS\n");
 }
 
 void test_cmp_imm(void)
@@ -298,18 +326,24 @@ void test_cmp_imm(void)
 			      insn_cmp_test1_end - insn_cmp_test1);
 	if ((outregs.eflags & (1<<6)) != (1<<6))
 		print_serial("cmp test 1: FAIL\n");
+	else
+		print_serial("cmp test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_cmp_test2,
 			      insn_cmp_test2_end - insn_cmp_test2);
 	if ((outregs.eflags & (1<<6)) != 0)
 		print_serial("cmp test 2: FAIL\n");
+	else
+		print_serial("cmp test 2: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_cmp_test3,
 			      insn_cmp_test3_end - insn_cmp_test3);
 	if ((outregs.eflags & (1<<6)) != 0)
 		print_serial("cmp test 3: FAIL\n");
+	else
+		print_serial("cmp test 3: PASS\n");
 }
 
 void test_add_imm(void)
@@ -325,12 +359,16 @@ void test_add_imm(void)
 			      insn_add_test1_end - insn_add_test1);
 	if (outregs.eax != 0x55555555)
 		print_serial("add test 1: FAIL\n");
+	else
+		print_serial("add test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_add_test2,
 			      insn_add_test2_end - insn_add_test2);
 	if (outregs.eax != 0x33)
 		print_serial("add test 2: FAIL\n");
+	else
+		print_serial("add test 2: PASS\n");
 }
 
 void test_eflags_insn(void)
@@ -347,30 +385,40 @@ void test_eflags_insn(void)
 			      insn_clc_end - insn_clc);
 	if (outregs.eflags & 1)
 		print_serial("clc test: FAIL\n");
+	else
+		print_serial("clc test: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_cli,
 			      insn_cli_end - insn_cli);
 	if (outregs.eflags & (1 << 9))
 		print_serial("cli test: FAIL\n");
+	else
+		print_serial("cli test: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_sti,
 			      insn_sti_end - insn_sti);
 	if (!(outregs.eflags & (1 << 9)))
 		print_serial("sti test: FAIL\n");
+	else
+		print_serial("sti test: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_cld,
 			      insn_cld_end - insn_cld);
 	if (outregs.eflags & (1 << 10))
 		print_serial("cld test: FAIL\n");
+	else
+		print_serial("cld test: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_std,
 			      insn_std_end - insn_std);
 	if (!(outregs.eflags & (1 << 10)))
 		print_serial("std test: FAIL\n");
+	else
+		print_serial("std test: PASS\n");
 }
 
 void test_io(void)
@@ -410,6 +458,8 @@ void test_io(void)
 
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0xff)
 		print_serial("I/O test 1: FAIL\n");
+	else
+		print_serial("I/O test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_io_test2,
@@ -417,6 +467,8 @@ void test_io(void)
 
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0xffff)
 		print_serial("I/O test 2: FAIL\n");
+	else
+		print_serial("I/O test 2: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_io_test3,
@@ -424,6 +476,8 @@ void test_io(void)
 
 	if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0xffffffff)
 		print_serial("I/O test 3: FAIL\n");
+	else
+		print_serial("I/O test 3: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_io_test4,
@@ -431,6 +485,8 @@ void test_io(void)
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_DX) || outregs.eax != 0xff)
 		print_serial("I/O test 4: FAIL\n");
+	else
+		print_serial("I/O test 4: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_io_test5,
@@ -438,6 +494,8 @@ void test_io(void)
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_DX) || outregs.eax != 0xffff)
 		print_serial("I/O test 5: FAIL\n");
+	else
+		print_serial("I/O test 5: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_io_test6,
@@ -445,7 +503,8 @@ void test_io(void)
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_DX) || outregs.eax != 0xffffffff)
 		print_serial("I/O test 6: FAIL\n");
-
+	else
+		print_serial("I/O test 6: PASS\n");
 }
 
 void test_call(void)
@@ -472,15 +531,22 @@ void test_call(void)
 			      insn_call1_end - insn_call1);
 	if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234)
 		print_serial("Call Test 1: FAIL\n");
+	else
+		print_serial("Call Test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_call_near1, insn_call_near1_end - insn_call_near1);
 	if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234)
 		print_serial("Call near Test 1: FAIL\n");
+	else
+		print_serial("Call near Test 1: PASS\n");
+
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_call_near2, insn_call_near2_end - insn_call_near2);
 	if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234)
 		print_serial("Call near Test 2: FAIL\n");
+	else
+		print_serial("Call near Test 2: PASS\n");
 }
 
 void test_jcc_short(void)
@@ -500,17 +566,23 @@ void test_jcc_short(void)
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_jnz_short1, insn_jnz_short1_end - insn_jnz_short1);
 	if(!regs_equal(&inregs, &outregs, 0))
-		print_serial("JNZ sort Test 1: FAIL\n");
+		print_serial("JNZ short Test 1: FAIL\n");
+	else
+		print_serial("JNZ short Test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_jnz_short2, insn_jnz_short2_end - insn_jnz_short2);
 	if(!regs_equal(&inregs, &outregs, R_AX) || !(outregs.eflags & (1 << 6)))
-		print_serial("JNZ sort Test 2: FAIL\n");
+		print_serial("JNZ short Test 2: FAIL\n");
+	else
+		print_serial("JNZ short Test 2: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_jmp_short1, insn_jmp_short1_end - insn_jmp_short1);
 	if(!regs_equal(&inregs, &outregs, 0))
-		print_serial("JMP sort Test 1: FAIL\n");
+		print_serial("JMP short Test 1: FAIL\n");
+	else
+		print_serial("JMP short Test 1: PASS\n");
 }
 
 void test_jcc_near(void)
@@ -529,16 +601,22 @@ void test_jcc_near(void)
 			insn_jnz_near1, insn_jnz_near1_end - insn_jnz_near1);
 	if(!regs_equal(&inregs, &outregs, 0))
 		print_serial("JNZ near Test 1: FAIL\n");
+	else
+		print_serial("JNZ near Test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_jnz_near2, insn_jnz_near2_end - insn_jnz_near2);
 	if(!regs_equal(&inregs, &outregs, R_AX) || !(outregs.eflags & (1 << 6)))
 		print_serial("JNZ near Test 2: FAIL\n");
+	else
+		print_serial("JNZ near Test 2: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			insn_jmp_near1, insn_jmp_near1_end - insn_jmp_near1);
 	if(!regs_equal(&inregs, &outregs, 0))
 		print_serial("JMP near Test 1: FAIL\n");
+	else
+		print_serial("JMP near Test 1: PASS\n");
 }
 
 void test_long_jmp()
@@ -556,6 +634,8 @@ void test_long_jmp()
 			      insn_long_jmp_end - insn_long_jmp);
 	if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234)
 		print_serial("Long JMP Test: FAIL\n");
+	else
+		print_serial("Long JMP Test: PASS\n");
 }
 void test_push_pop()
 {
@@ -595,6 +675,8 @@ void test_push_pop()
 			      insn_push32_end - insn_push32);
 	if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.eax != outregs.ebx || outregs.eax != 0x12345678)
 		print_serial("Push/Pop Test 1: FAIL\n");
+	else
+		print_serial("Push/Pop Test 1: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_push16,
@@ -602,12 +684,16 @@ void test_push_pop()
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.eax != outregs.ebx || outregs.eax != 0x1234)
 		print_serial("Push/Pop Test 2: FAIL\n");
+	else
+		print_serial("Push/Pop Test 2: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_push_es,
 			      insn_push_es_end - insn_push_es);
 	if (!regs_equal(&inregs, &outregs, R_AX|R_BX) ||  outregs.ebx != outregs.eax || outregs.eax != 0x123)
 		print_serial("Push/Pop Test 3: FAIL\n");
+	else
+		print_serial("Push/Pop Test 3: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_pop_es,
@@ -615,6 +701,8 @@ void test_push_pop()
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax)
 		print_serial("Push/Pop Test 4: FAIL\n");
+	else
+		print_serial("Push/Pop Test 4: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_push_pop_ss,
@@ -622,6 +710,8 @@ void test_push_pop()
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax)
 		print_serial("Push/Pop Test 5: FAIL\n");
+	else
+		print_serial("Push/Pop Test 5: PASS\n");
 
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_push_pop_fs,
@@ -629,6 +719,8 @@ void test_push_pop()
 
 	if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax)
 		print_serial("Push/Pop Test 6: FAIL\n");
+	else
+		print_serial("Push/Pop Test 6: PASS\n");
 }
 
 void test_null(void)
@@ -637,6 +729,8 @@ void test_null(void)
 	exec_in_big_real_mode(&inregs, &outregs, 0, 0);
 	if (!regs_equal(&inregs, &outregs, 0))
 		print_serial("null test: FAIL\n");
+	else
+		print_serial("null test: PASS\n");
 }
 
 void realmode_start(void)
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run
  2010-04-27 12:57   ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Naphtali Sprei
  2010-04-27 12:57     ` [qemu-kvm tests PATCH v2 3/3] qemu-kvm tests cleanup: Added printing for passing tests Also typo fix Naphtali Sprei
@ 2010-04-27 13:03     ` Gleb Natapov
  1 sibling, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2010-04-27 13:03 UTC (permalink / raw)
  To: Naphtali Sprei; +Cc: kvm

On Tue, Apr 27, 2010 at 03:57:44PM +0300, Naphtali Sprei wrote:
> Also use testdev for output, call exit to quit.
> Currently, test reboots endlessly because of a triple-fault.
> Need to run test with -no-reboot till issue fixed (in kvm ??)
> 
Rewriting this in C would be nice. May be adding this as additional test into
emulator.c
 
> Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
> ---
>  kvm/user/config-x86-common.mak |    2 +-
>  kvm/user/test/x86/stringio.S   |   13 +++++++++----
>  2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak
> index 960741e..d312681 100644
> --- a/kvm/user/config-x86-common.mak
> +++ b/kvm/user/config-x86-common.mak
> @@ -54,7 +54,7 @@ $(TEST_DIR)/realmode.flat: $(TEST_DIR)/realmode.o
>  
>  $(TEST_DIR)/realmode.o: bits = 32
>  
> -$(TEST_DIR)/stringio.flat: $(TEST_DIR)/stringio.o
> +$(TEST_DIR)/stringio.flat: $(cstart.o) $(TEST_DIR)/stringio.o
>  
>  $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
>  
> diff --git a/kvm/user/test/x86/stringio.S b/kvm/user/test/x86/stringio.S
> index 31ddc47..461621c 100644
> --- a/kvm/user/test/x86/stringio.S
> +++ b/kvm/user/test/x86/stringio.S
> @@ -8,24 +8,29 @@
>  1:	
>  .endm	
>  
> +TESTDEV_PORT = 0xf1
> +
>  	str "forward", "forward"
>  	str "backward", "backward"
>  		
>  .text
>  
> -
> +.global main
> +main:
>  	cld
>  	movl forward, %ecx
>  	lea  4+forward, %rsi
> -	movw $1, %dx
> +	movw $TESTDEV_PORT, %dx
>  	rep outsb
>  
>  	std
>  	movl backward, %ecx
>  	lea 4+backward-1(%rcx), %rsi
> -	movw $2, %dx
> +	movw $TESTDEV_PORT, %dx
>  	rep outsb
>  	
> -	hlt
> +	mov $0, %rsi
> +	call exit
> +
>  
>  
> -- 
> 1.6.3.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
			Gleb.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup
  2010-04-27 12:57 [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup Naphtali Sprei
  2010-04-27 12:57 ` [qemu-kvm tests PATCH v2 1/3] " Naphtali Sprei
@ 2010-04-30 20:13 ` Marcelo Tosatti
  1 sibling, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2010-04-30 20:13 UTC (permalink / raw)
  To: Naphtali Sprei; +Cc: kvm

On Tue, Apr 27, 2010 at 03:57:42PM +0300, Naphtali Sprei wrote:
> changes v1 -> v2
> single trailing whitespace cleanup
> 
> Cleanup, mostly x86 oriented.
> Patches against 'next' branch.
> 
> Naphtali Sprei (3):
>   qemu-kvm tests cleanup
>   qemu-kvm tests cleanup: adapt stringio test to kernel-mode run
>   qemu-kvm tests cleanup: Added printing for passing tests Also typo
>     fix

Applied, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-04-30 20:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-27 12:57 [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup Naphtali Sprei
2010-04-27 12:57 ` [qemu-kvm tests PATCH v2 1/3] " Naphtali Sprei
2010-04-27 12:57   ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Naphtali Sprei
2010-04-27 12:57     ` [qemu-kvm tests PATCH v2 3/3] qemu-kvm tests cleanup: Added printing for passing tests Also typo fix Naphtali Sprei
2010-04-27 13:03     ` [qemu-kvm tests PATCH v2 2/3] qemu-kvm tests cleanup: adapt stringio test to kernel-mode run Gleb Natapov
2010-04-30 20:13 ` [qemu-kvm tests PATCH v2 0/3] qemu-kvm tests cleanup Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.