Re: [PATCH 3/9] clean root dir of all x86-ness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 14, 2013 at 06:23:29PM +0200, Andrew Jones wrote:
> Remove all references to x86 from the root dir (except from in
> configure).  Also remove references from the root dir README
> by moving that documentation to the x86/README, and touch up
> the READMEs at the same time.

Just giving this a cursory pass...

> 
> Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
> ---
>  Makefile                     |   7 ++-
>  README                       |  55 +++++++++-----------
>  config-i386.mak              |  13 -----
>  config-x86-common.mak        | 120 -------------------------------------------
>  config-x86_64.mak            |  14 -----
>  config/config-i386.mak       |  12 +++++
>  config/config-x86-common.mak | 120 +++++++++++++++++++++++++++++++++++++++++++
>  config/config-x86_64.mak     |  13 +++++
>  configure                    |  17 ++++++
>  docs/testdev.txt             |  11 ++++
>  flat.lds                     |  21 --------
>  run_tests.sh                 |  19 ++++---
>  testdev.txt                  |  14 -----
>  x86-run                      |  41 ---------------
>  x86/README                   |  60 +++++++++++++++++-----
>  x86/flat.lds                 |  21 ++++++++
>  x86/run                      |  41 +++++++++++++++
>  17 files changed, 316 insertions(+), 283 deletions(-)
>  delete mode 100644 config-i386.mak
>  delete mode 100644 config-x86-common.mak
>  delete mode 100644 config-x86_64.mak
>  create mode 100644 config/config-i386.mak
>  create mode 100644 config/config-x86-common.mak
>  create mode 100644 config/config-x86_64.mak
>  create mode 100644 docs/testdev.txt
>  delete mode 100644 flat.lds
>  delete mode 100644 testdev.txt
>  delete mode 100755 x86-run
>  create mode 100644 x86/flat.lds
>  create mode 100755 x86/run
> 
> diff --git a/Makefile b/Makefile
> index 697fc2a766966..7a5ec8e6348bf 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -17,7 +17,7 @@ cflatobjs := \
>  	lib/string.o
>  
>  #include architecure specific make rules
> -include config-$(ARCH).mak
> +include config/config-$(ARCH).mak
>  
>  # cc-option
>  # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
> @@ -29,7 +29,6 @@ CFLAGS += $(autodepend-flags) -Wall
>  CFLAGS += $(call cc-option, -fomit-frame-pointer, "")
>  CFLAGS += $(call cc-option, -fno-stack-protector, "")
>  CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
> -CFLAGS += -I.
>  
>  CXXFLAGS += $(CFLAGS)
>  
> @@ -44,11 +43,11 @@ $(libcflat): $(cflatobjs)
>  %.o: %.S
>  	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
>  
> --include .*.d */.*.d */*/.*.d
> +-include */.*.d */*/.*.d
>  
>  install:
>  	mkdir -p $(DESTDIR)
>  	install $(tests_and_config) $(DESTDIR)
>  
>  clean: arch_clean
> -	$(RM) *.o *.a .*.d lib/.*.d $(libcflat) $(cflatobjs)
> +	$(RM) lib/.*.d $(libcflat) $(cflatobjs)
> diff --git a/README b/README
> index db525e3bbb79d..49468b94bc7fc 100644
> --- a/README
> +++ b/README
> @@ -1,36 +1,27 @@
>  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 ./<ARCH>/*.flat
> -
> -An example of a test invocation:
> -Using qemu-kvm:
> -
> -qemu-kvm -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel ./x86/msr.flat
> -This invocation runs the msr test case. The test outputs to stdio.
> -
> -Using qemu (supported since qemu 1.3):
> -qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat
> -
> -Or use a runner script to detect the correct invocation:
> -./x86-run ./x86/msr.flat
> -To select a specific qemu binary, specify the QEMU=<path> environment:
> -QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
> -
> -The exit status of the binary (and the script) is inconsistent: with
> -qemu-system, after the unittest is done, the exit status of qemu is 1,
> -different from the 'old style' qemu-kvm, whose exit status in successful
> -completion is 0.
> +To create the tests' images do

tests' images doesn't read very nice, can we just say test images?

> +  ./configure
> +  make
> +in this directory. Tests' images are created in ./<ARCH>/*.flat
> +
> +Then use the runner script to detect the correct invocation and
> +invoke the test, e.g.
> +  ./x86-run ./x86/msr.flat
> +or
> +  ./run_tests.sh
> +to run them all.

While you're at it, it would be great to provide a little more context
in the README file.

For example, we start talking abouter 'runner scripts', we refer to
something called '.flat', and we refer to QEMU without explaining how
this whole thing works, what the components are, what is required of
QEMU etc.

I think that would be useful for the wider adoption of kvm-unit-tests to
developers writing ad-hoc patches for KVM.

A reference to docs/testdev.txt from somewhere approrpriate in such text
would probably also be useful...

I know much of this is arch-specific, but there must be something
generic or common across the architecture, and that would in essense be
capturing what 'kvm-unit-tests' give you, which I think is very useful
to have in the readme.

> +
> +To select a specific qemu binary, specify the QEMU=<path>
> +environment, e.g.
> +  QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
>  
>  Directory structure:
> -.:  Makefile and config files for the tests
> -./lib: general services for the tests
> -./lib/<ARCH>: architecture dependent services for the tests
> -./<ARCH>: the sources of the tests and the created objects/images
> -
> +.:		Makefile and config files for the tests
> +./config:	config files for the tests
> +./docs:		documentation files
> +./lib:		general services for the tests
> +./lib/<ARCH>:	architecture dependent services for the tests
> +./<ARCH>:	the sources of the tests and the created objects/images
> +
> +See <ARCH>/README for arch specific documentation.
> diff --git a/config-i386.mak b/config-i386.mak
> deleted file mode 100644
> index de52f3d53cff8..0000000000000
> --- a/config-i386.mak
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -TEST_DIR=x86
> -cstart.o = $(TEST_DIR)/cstart.o
> -bits = 32
> -ldarch = elf32-i386
> -CFLAGS += -D__i386__
> -CFLAGS += -I $(KERNELDIR)/include
> -
> -tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat
> -
> -include config-x86-common.mak
> -
> -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o
> -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o
> diff --git a/config-x86-common.mak b/config-x86-common.mak
> deleted file mode 100644
> index 7e481192a0737..0000000000000
> --- a/config-x86-common.mak
> +++ /dev/null
> @@ -1,120 +0,0 @@
> -#This is a make file with common rules for both x86 & x86-64
> -
> -all: test_cases
> -
> -cflatobjs += lib/x86/io.o
> -cflatobjs += lib/x86/smp.o
> -cflatobjs += lib/x86/vm.o
> -cflatobjs += lib/x86/fwcfg.o
> -cflatobjs += lib/x86/apic.o
> -cflatobjs += lib/x86/atomic.o
> -cflatobjs += lib/x86/desc.o
> -cflatobjs += lib/x86/isr.o
> -cflatobjs += lib/x86/pci.o
> -
> -$(libcflat): LDFLAGS += -nostdlib
> -$(libcflat): CFLAGS += -ffreestanding -I lib
> -
> -CFLAGS += -m$(bits)
> -CFLAGS += -O1
> -
> -libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
> -
> -FLATLIBS = lib/libcflat.a $(libgcc)
> -%.elf: %.o $(FLATLIBS) flat.lds
> -	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds \
> -		$(filter %.o, $^) $(FLATLIBS)
> -
> -%.flat: %.elf
> -	$(OBJCOPY) -O elf32-i386 $^ $@
> -
> -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_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \
> -               $(TEST_DIR)/kvmclock_test.flat  $(TEST_DIR)/eventinj.flat \
> -               $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat \
> -               $(TEST_DIR)/tsc_adjust.flat $(TEST_DIR)/asyncpf.flat \
> -               $(TEST_DIR)/init.flat
> -
> -ifdef API
> -tests-common += api/api-sample
> -tests-common += api/dirty-log
> -tests-common += api/dirty-log-perf
> -endif
> -
> -tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
> -
> -test_cases: $(tests-common) $(tests)
> -
> -$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
> -
> -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o
> -
> -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o
> -
> -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o
> -
> -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o
> -
> -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o
> -
> -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o
> -
> -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o
> -
> -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o
> -
> -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o
> -
> -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o
> -
> -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o
> -
> -$(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
> -	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
> -
> -$(TEST_DIR)/realmode.o: bits = 32
> -
> -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o
> -
> -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o
> -
> -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o
> -
> -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o
> -
> -$(TEST_DIR)/svm.elf: $(cstart.o)
> -
> -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \
> -                                $(TEST_DIR)/kvmclock_test.o
> -
> -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o
> -
> -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o
> -
> -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o
> -
> -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o
> -
> -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o
> -
> -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o
> -
> -arch_clean:
> -	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
> -	$(TEST_DIR)/.*.d lib/x86/.*.d
> -
> -api/%.o: CFLAGS += -m32
> -
> -api/%: LDLIBS += -lstdc++ -lboost_thread-mt -lpthread -lrt
> -api/%: LDFLAGS += -m32
> -
> -api/libapi.a: api/kvmxx.o api/identity.o api/exception.o api/memmap.o
> -	$(AR) rcs $@ $^
> -
> -api/api-sample: api/api-sample.o api/libapi.a
> -
> -api/dirty-log: api/dirty-log.o api/libapi.a
> -
> -api/dirty-log-perf: api/dirty-log-perf.o api/libapi.a
> diff --git a/config-x86_64.mak b/config-x86_64.mak
> deleted file mode 100644
> index bb8ee89713abd..0000000000000
> --- a/config-x86_64.mak
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -TEST_DIR=x86
> -cstart.o = $(TEST_DIR)/cstart64.o
> -bits = 64
> -ldarch = elf64-x86-64
> -CFLAGS += -D__x86_64__
> -
> -tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
> -	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
> -	  $(TEST_DIR)/xsave.flat $(TEST_DIR)/rmap_chain.flat \
> -	  $(TEST_DIR)/pcid.flat
> -tests += $(TEST_DIR)/svm.flat
> -tests += $(TEST_DIR)/vmx.flat
> -
> -include config-x86-common.mak
> diff --git a/config/config-i386.mak b/config/config-i386.mak
> new file mode 100644
> index 0000000000000..82fed0f5a48b0
> --- /dev/null
> +++ b/config/config-i386.mak
> @@ -0,0 +1,12 @@
> +cstart.o = $(TEST_DIR)/cstart.o
> +bits = 32
> +ldarch = elf32-i386
> +CFLAGS += -D__i386__
> +CFLAGS += -I $(KERNELDIR)/include
> +
> +tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat
> +
> +include config/config-x86-common.mak
> +
> +$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o
> +$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o
> diff --git a/config/config-x86-common.mak b/config/config-x86-common.mak
> new file mode 100644
> index 0000000000000..917cbbf801a65
> --- /dev/null
> +++ b/config/config-x86-common.mak
> @@ -0,0 +1,120 @@
> +#This is a make file with common rules for both x86 & x86-64
> +
> +all: test_cases
> +
> +cflatobjs += lib/x86/io.o
> +cflatobjs += lib/x86/smp.o
> +cflatobjs += lib/x86/vm.o
> +cflatobjs += lib/x86/fwcfg.o
> +cflatobjs += lib/x86/apic.o
> +cflatobjs += lib/x86/atomic.o
> +cflatobjs += lib/x86/desc.o
> +cflatobjs += lib/x86/isr.o
> +cflatobjs += lib/x86/pci.o
> +
> +$(libcflat): LDFLAGS += -nostdlib
> +$(libcflat): CFLAGS += -ffreestanding -I lib
> +
> +CFLAGS += -m$(bits)
> +CFLAGS += -O1
> +
> +libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
> +
> +FLATLIBS = lib/libcflat.a $(libgcc)
> +%.elf: %.o $(FLATLIBS) x86/flat.lds
> +	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
> +		$(filter %.o, $^) $(FLATLIBS)
> +
> +%.flat: %.elf
> +	$(OBJCOPY) -O elf32-i386 $^ $@
> +
> +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_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \
> +               $(TEST_DIR)/kvmclock_test.flat  $(TEST_DIR)/eventinj.flat \
> +               $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat \
> +               $(TEST_DIR)/tsc_adjust.flat $(TEST_DIR)/asyncpf.flat \
> +               $(TEST_DIR)/init.flat
> +
> +ifdef API
> +tests-common += api/api-sample
> +tests-common += api/dirty-log
> +tests-common += api/dirty-log-perf
> +endif
> +
> +tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
> +
> +test_cases: $(tests-common) $(tests)
> +
> +$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
> +
> +$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o
> +
> +$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o
> +
> +$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o
> +
> +$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o
> +
> +$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o
> +
> +$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o
> +
> +$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o
> +
> +$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o
> +
> +$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o
> +
> +$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o
> +
> +$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o
> +
> +$(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
> +	$(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^
> +
> +$(TEST_DIR)/realmode.o: bits = 32
> +
> +$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o
> +
> +$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o
> +
> +$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o
> +
> +$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o
> +
> +$(TEST_DIR)/svm.elf: $(cstart.o)
> +
> +$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \
> +                                $(TEST_DIR)/kvmclock_test.o
> +
> +$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o
> +
> +$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o
> +
> +$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o
> +
> +$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o
> +
> +$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o
> +
> +$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o
> +
> +arch_clean:
> +	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
> +	$(TEST_DIR)/.*.d lib/x86/.*.d
> +
> +api/%.o: CFLAGS += -m32
> +
> +api/%: LDLIBS += -lstdc++ -lboost_thread-mt -lpthread -lrt
> +api/%: LDFLAGS += -m32
> +
> +api/libapi.a: api/kvmxx.o api/identity.o api/exception.o api/memmap.o
> +	$(AR) rcs $@ $^
> +
> +api/api-sample: api/api-sample.o api/libapi.a
> +
> +api/dirty-log: api/dirty-log.o api/libapi.a
> +
> +api/dirty-log-perf: api/dirty-log-perf.o api/libapi.a
> diff --git a/config/config-x86_64.mak b/config/config-x86_64.mak
> new file mode 100644
> index 0000000000000..f089b05a178c3
> --- /dev/null
> +++ b/config/config-x86_64.mak
> @@ -0,0 +1,13 @@
> +cstart.o = $(TEST_DIR)/cstart64.o
> +bits = 64
> +ldarch = elf64-x86-64
> +CFLAGS += -D__x86_64__
> +
> +tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
> +	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
> +	  $(TEST_DIR)/xsave.flat $(TEST_DIR)/rmap_chain.flat \
> +	  $(TEST_DIR)/pcid.flat
> +tests += $(TEST_DIR)/svm.flat
> +tests += $(TEST_DIR)/vmx.flat
> +
> +include config/config-x86-common.mak
> diff --git a/configure b/configure
> index d0c62e24dd1d2..6cfc64943f6e6 100755
> --- a/configure
> +++ b/configure
> @@ -15,6 +15,7 @@ usage() {
>  	Usage: $0 [options]
>  
>  	Options include:
> +	    --test-dir=DIR         the main directory for tests ($arch)
>  	    --arch=ARCH            architecture to compile for ($arch)
>  	    --cross-prefix=PREFIX  cross compiler prefix
>  	    --cc=CC		   c compiler to use ($cc)
> @@ -33,6 +34,9 @@ while [[ "$1" = -* ]]; do
>  	opt="${opt%%=*}"
>      fi
>      case "$opt" in
> +	--test-dir)
> +	    testdir="$arg"
> +	    ;;
>  	--prefix)
>  	    prefix="$arg"
>  	    ;;
> @@ -62,6 +66,18 @@ while [[ "$1" = -* ]]; do
>  	    ;;
>      esac
>  done
> +if [ -z "$testdir" -a \( "$arch" = "i386" -o "$arch" = "x86_64" \) ]; then
> +    testdir=x86
> +elif [ -z "$testdir" ]; then
> +    testdir=$arch
> +fi
> +if [ ! -d $testdir ]; then
> +    echo "$testdir does not exist!"
> +    exit 1
> +fi
> +if [ -f $testdir/run ]; then
> +    ln -fs $testdir/run $testdir-run
> +fi
>  
>  # check for dependent 32 bit libraries
>  cat << EOF > lib_test.c
> @@ -89,4 +105,5 @@ LD=$cross_prefix$ld
>  OBJCOPY=$cross_prefix$objcopy
>  AR=$cross_prefix$ar
>  API=$api
> +TEST_DIR=$testdir
>  EOF
> diff --git a/docs/testdev.txt b/docs/testdev.txt
> new file mode 100644
> index 0000000000000..854b5c774b60c
> --- /dev/null
> +++ b/docs/testdev.txt
> @@ -0,0 +1,11 @@
> +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
> diff --git a/flat.lds b/flat.lds
> deleted file mode 100644
> index a278b56c9a4e3..0000000000000
> --- a/flat.lds
> +++ /dev/null
> @@ -1,21 +0,0 @@
> -SECTIONS
> -{
> -    . = 4M + SIZEOF_HEADERS;
> -    stext = .;
> -    .text : { *(.init) *(.text) *(.text.*) }
> -    . = ALIGN(4K);
> -    .data : {
> -          *(.data)
> -          exception_table_start = .;
> -          *(.data.ex)
> -	  exception_table_end = .;
> -	  }
> -    . = ALIGN(16);
> -    .rodata : { *(.rodata) }
> -    . = ALIGN(16);
> -    .bss : { *(.bss) }
> -    . = ALIGN(4K);
> -    edata = .;
> -}
> -
> -ENTRY(start)
> diff --git a/run_tests.sh b/run_tests.sh
> index f373c533b75b2..400c62458ae18 100755
> --- a/run_tests.sh
> +++ b/run_tests.sh
> @@ -1,8 +1,10 @@
>  #!/bin/bash
>  
> -testroot=x86
> -config=$testroot/unittests.cfg
> -qemu=${qemu:-qemu-system-x86_64}
> +# As it happens, config.mak is valid shell script code, too :-)
> +source config.mak
> +
> +config=$TEST_DIR/unittests.cfg
> +qemu=${QEMU:-qemu-system-$ARCH}
>  verbose=0
>  
>  function run()
> @@ -27,7 +29,7 @@ function run()
>          return
>      fi
>  
> -	cmdline="./x86-run $kernel -smp $smp $opts"
> +	cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
>      if [ $verbose != 0 ]; then
>          echo $cmdline
>      fi
> @@ -65,7 +67,7 @@ function run_all()
>              groups=""
>              arch=""
>          elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
> -            kernel=$testroot/${BASH_REMATCH[1]}
> +            kernel=$TEST_DIR/${BASH_REMATCH[1]}
>          elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
>              smp=${BASH_REMATCH[1]}
>          elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
> @@ -92,15 +94,12 @@ Usage: $0 [-g group] [-h] [-v]
>      -h: Output this help text
>      -v: Enables verbose mode
>  
> -Set the environment variable QEMU=/path/to/qemu-system-x86_64 to allow the
> -internally used x86-run to pick up the right qemu binary.
> +Set the environment variable QEMU=/path/to/qemu-system-ARCH to allow the
> +internally used ARCH-run to pick up the right qemu binary.
>  
>  EOF
>  }
>  
> -# As it happens, config.mak is valid shell script code, too :-)
> -source config.mak
> -
>  echo > test.log
>  while getopts "g:hv" opt; do
>      case $opt in
> diff --git a/testdev.txt b/testdev.txt
> deleted file mode 100644
> index ac436efadb633..0000000000000
> --- a/testdev.txt
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -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
> -
> -
> -
> diff --git a/x86-run b/x86-run
> deleted file mode 100755
> index 646c5770ed03f..0000000000000
> --- a/x86-run
> +++ /dev/null
> @@ -1,41 +0,0 @@
> -#!/bin/bash
> -
> -qemukvm="${QEMU:-qemu-kvm}"
> -qemusystem="${QEMU:-qemu-system-x86_64}"
> -if
> -	${qemukvm} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> -then
> -	qemu="${qemukvm}"
> -else
> -	if
> -		${qemusystem} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> -	then
> -		qemu="${qemusystem}"
> -	else
> -		echo QEMU binary ${QEMU} has no support for test device. Exiting.
> -		exit 2
> -	fi
> -fi
> -
> -if
> -	${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null;
> -then
> -	pci_testdev="-device pci-testdev"
> -else
> -	pci_testdev=""
> -fi
> -
> -if
> -	${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null;
> -then
> -	pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4"
> -else
> -	pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
> -fi
> -
> -command="${qemu} -enable-kvm $pc_testdev -display none -serial stdio $pci_testdev -kernel"
> -echo ${command} "$@"
> -${command} "$@"
> -ret=$?
> -echo Return value from qemu: $ret
> -exit $ret
> diff --git a/x86/README b/x86/README
> index d644abdf31708..2f4baa46c6ed1 100644
> --- a/x86/README
> +++ b/x86/README
> @@ -1,16 +1,48 @@
> +
> +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 docs/testdev.txt for more details.
> +
> +An example of a test invocation:
> +Using qemu-kvm:
> +
> +qemu-kvm -device testdev,chardev=testlog \
> +         -chardev file,id=testlog,path=msr.out \
> +         -serial stdio -kernel ./x86/msr.flat
> +This invocation runs the msr test case. The test outputs to stdio.
> +
> +Using qemu (supported since qemu 1.3):
> +qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio \
> +                   -device isa-debug-exit,iobase=0xf4,iosize=0x4 \
> +                   -kernel ./x86/msr.flat
> +
>  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
> -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
> -kvmclock_test: test of wallclock, monotonic cycle and performance of kvmclock
> -pcid: basic functionality test of PCID/INVPCID feature
> \ No newline at end of file
> +  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
> +  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
> +  kvmclock_test: test of wallclock, monotonic cycle and performance of kvmclock
> +  pcid:		basic functionality test of PCID/INVPCID featureThis directory
> +		contains sources for a kvm test suite.
> +
> +Legacy notes:
> +
> +  The exit status of the binary (and the script) is inconsistent: with
> +  qemu-system, after the unittest is done, the exit status of qemu is 1,
> +  different from the 'old style' qemu-kvm, whose exit status in successful
> +  completion is 0.
> diff --git a/x86/flat.lds b/x86/flat.lds
> new file mode 100644
> index 0000000000000..a278b56c9a4e3
> --- /dev/null
> +++ b/x86/flat.lds
> @@ -0,0 +1,21 @@
> +SECTIONS
> +{
> +    . = 4M + SIZEOF_HEADERS;
> +    stext = .;
> +    .text : { *(.init) *(.text) *(.text.*) }
> +    . = ALIGN(4K);
> +    .data : {
> +          *(.data)
> +          exception_table_start = .;
> +          *(.data.ex)
> +	  exception_table_end = .;
> +	  }
> +    . = ALIGN(16);
> +    .rodata : { *(.rodata) }
> +    . = ALIGN(16);
> +    .bss : { *(.bss) }
> +    . = ALIGN(4K);
> +    edata = .;
> +}
> +
> +ENTRY(start)
> diff --git a/x86/run b/x86/run
> new file mode 100755
> index 0000000000000..646c5770ed03f
> --- /dev/null
> +++ b/x86/run
> @@ -0,0 +1,41 @@
> +#!/bin/bash
> +
> +qemukvm="${QEMU:-qemu-kvm}"
> +qemusystem="${QEMU:-qemu-system-x86_64}"
> +if
> +	${qemukvm} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> +then
> +	qemu="${qemukvm}"
> +else
> +	if
> +		${qemusystem} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
> +	then
> +		qemu="${qemusystem}"
> +	else
> +		echo QEMU binary ${QEMU} has no support for test device. Exiting.
> +		exit 2
> +	fi
> +fi
> +
> +if
> +	${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null;
> +then
> +	pci_testdev="-device pci-testdev"
> +else
> +	pci_testdev=""
> +fi
> +
> +if
> +	${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null;
> +then
> +	pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4"
> +else
> +	pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
> +fi
> +
> +command="${qemu} -enable-kvm $pc_testdev -display none -serial stdio $pci_testdev -kernel"
> +echo ${command} "$@"
> +${command} "$@"
> +ret=$?
> +echo Return value from qemu: $ret
> +exit $ret
> -- 
> 1.8.1.4
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux