Commit de44c044 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/stsquad/tags/pull-tcg-testing-revivial-210618-2' into staging



Add check-tcg machinary

This restores the ability to run TCG smoke tests by using our docker
infrastructure to support cross building simple tests. It represents
the first step to making better cross-architecture testing available
straight from the source tree ;-)

v2
  - fix quoting of target_compiler
  - make docker.py Py3 safe
  - tweak .travis.yml recipe
  - don't probe docker when HAVE_USER_DOCKER not set

# gpg: Signature made Thu 21 Jun 2018 07:23:45 BST
# gpg:                using RSA key FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>"
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-tcg-testing-revivial-210618-2: (57 commits)
  .travis.yml: add check-tcg test
  tests/docker/Makefile.include: only force SID to NOCACHE if old
  docker: docker.py adding age check command
  tests/Makefile: call sub-makes with SKIP_DOCKER_BUILD=1
  docker: docker.py add check sub-command
  docker: docker.py don't conflate checksums for extra_files
  docker: docker.py use "version" to probe usage
  tests: add top-level make dependency for docker builds
  tests/tcg/i386: extend timeout for runcom test
  tests/tcg: override runners for broken tests
  tests/tcg: add run, diff, and skip helper macros
  tests/Makefile.include: add [build|clean|check]-tcg targets
  Makefile.target: add (clean-/build-)guest-tests targets
  tests/tcg/Makefile: update to be called from Makefile.target
  tests/tcg: enable building for PowerPC
  docker: move debian-powerpc-cross to sid based build
  tests/tcg: enable building for RISCV64
  tests/tcg: enable building for mips64
  tests/tcg: enable building for sparc64
  tests/tcg: enable building for sh4
  ...

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 409ef9eb 65b26da4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -153,3 +153,11 @@ matrix:
        - TEST_CMD=""
      before_script:
        - ./configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread -fuse-ld=gold" || { cat config.log && exit 1; }
    - env:
        - CONFIG="--disable-system --disable-docs"
        - TEST_CMD="make check-tcg"
      script:
        - make ${MAKEFLAGS} && ${TEST_CMD} ${MAKEFLAGS}
      sudo: required
      dist: trusty
      compiler: gcc
+15 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ M: Peter Maydell <peter.maydell@linaro.org>
L: qemu-arm@nongnu.org
S: Maintained
F: target/arm/
F: tests/tcg/arm/
F: tests/tcg/aarch64/
F: hw/arm/
F: hw/cpu/a*mpcore.c
F: include/hw/cpu/a*mpcore.h
@@ -283,6 +285,8 @@ M: Richard Henderson <rth@twiddle.net>
M: Eduardo Habkost <ehabkost@redhat.com>
S: Maintained
F: target/i386/
F: tests/tcg/i386/
F: tests/tcg/x86_64/
F: hw/i386/
F: disas/i386.c
T: git git://github.com/ehabkost/qemu.git x86-next
@@ -303,6 +307,10 @@ F: target/tricore/
F: hw/tricore/
F: include/hw/tricore/

Multiarch Linux User Tests
M: Alex Bennée <alex.bennee@linaro.org>
F: tests/tcg/multiarch/

Guest CPU Cores (KVM):
----------------------

@@ -2149,6 +2157,13 @@ W: https://travis-ci.org/qemu/qemu
W: https://app.shippable.com/github/qemu/qemu
W: http://patchew.org/QEMU/

Guest Test Compilation Support
M: Alex Bennée <alex.bennee@linaro.org>
R: Philippe Mathieu-Daudé <f4bug@amsat.org>
F: tests/tcg/Makefile
F: tests/tcg/Makefile.include
L: qemu-devel@nongnu.org

Documentation
-------------
Build system architecture
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ endif
PROGS=$(QEMU_PROG) $(QEMU_PROGW)
STPFILES=

# Makefile Tests
ifdef CONFIG_USER_ONLY
include $(SRC_PATH)/tests/tcg/Makefile.include
endif

config-target.h: config-target.h-timestamp
config-target.h-timestamp: config-target.mak

+128 −5
Original line number Diff line number Diff line
@@ -289,7 +289,6 @@ libs_softmmu=""
libs_tools=""
audio_pt_int=""
audio_win_int=""
cc_i386=i386-pc-linux-gnu-gcc
libs_qga=""
debug_info="yes"
stack_protector=""
@@ -458,6 +457,19 @@ vxhs=""
libxml2=""
docker="no"

# cross compilers defaults, can be overridden with --cross-cc-ARCH
cross_cc_aarch64="aarch64-linux-gnu-gcc"
cross_cc_aarch64_be="$cross_cc_aarch64"
cross_cc_cflags_aarch64_be="-mbig-endian"
cross_cc_arm="arm-linux-gnueabihf-gcc"
cross_cc_cflags_armeb="-mbig-endian"
cross_cc_i386="i386-pc-linux-gnu-gcc"
cross_cc_cflags_i386=""
cross_cc_powerpc="powerpc-linux-gnu-gcc"
cross_cc_powerpc="powerpc-linux-gnu-gcc"

enabled_cross_compilers=""

supported_cpu="no"
supported_os="no"
bogus_os="no"
@@ -488,6 +500,14 @@ for opt do
  ;;
  --disable-debug-info) debug_info="no"
  ;;
  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
  ;;
  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
  ;;
  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
                eval "cross_cc_${cc_arch}=\$optarg"
  ;;
  esac
done
# OS specific
@@ -676,30 +696,37 @@ case "$cpu" in
  ppc|ppc64|s390|s390x|sparc64|x32)
    cpu="$cpu"
    supported_cpu="yes"
    eval "cross_cc_${cpu}=\$host_cc"
  ;;
  i386|i486|i586|i686|i86pc|BePC)
    cpu="i386"
    supported_cpu="yes"
    cross_cc_i386=$host_cc
  ;;
  x86_64|amd64)
    cpu="x86_64"
    supported_cpu="yes"
    cross_cc_x86_64=$host_cc
  ;;
  armv*b|armv*l|arm)
    cpu="arm"
    supported_cpu="yes"
    cross_cc_arm=$host_cc
  ;;
  aarch64)
    cpu="aarch64"
    supported_cpu="yes"
    cross_cc_aarch64=$host_cc
  ;;
  mips*)
    cpu="mips"
    supported_cpu="yes"
    cross_cc_mips=$host_cc
  ;;
  sparc|sun4[cdmuv])
    cpu="sparc"
    supported_cpu="yes"
    cross_cc_sparc=$host_cc
  ;;
  *)
    # This will result in either an error or falling back to TCI later
@@ -917,6 +944,8 @@ for opt do
  ;;
  --disable-debug-info)
  ;;
  --cross-cc-*)
  ;;
  --enable-modules)
      modules="yes"
  ;;
@@ -1402,31 +1431,44 @@ case "$cpu" in
    ppc)
           CPU_CFLAGS="-m32"
           LDFLAGS="-m32 $LDFLAGS"
           cross_cc_powerpc=$cc
           cross_cc_cflags_powerpc=$CPU_CFLAGS
           ;;
    ppc64)
           CPU_CFLAGS="-m64"
           LDFLAGS="-m64 $LDFLAGS"
           cross_cc_ppc64=$cc
           cross_cc_cflags_ppc64=$CPU_CFLAGS
           ;;
    sparc)
           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
           LDFLAGS="-m32 -mv8plus $LDFLAGS"
           cross_cc_sparc=$cc
           cross_cc_cflags_sparc=$CPU_CFLAGS
           ;;
    sparc64)
           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
           LDFLAGS="-m64 $LDFLAGS"
           cross_cc_sparc64=$cc
           cross_cc_cflags_sparc64=$CPU_CFLAGS
           ;;
    s390)
           CPU_CFLAGS="-m31"
           LDFLAGS="-m31 $LDFLAGS"
           cross_cc_s390=$cc
           cross_cc_cflags_s390=$CPU_CFLAGS
           ;;
    s390x)
           CPU_CFLAGS="-m64"
           LDFLAGS="-m64 $LDFLAGS"
           cross_cc_s390x=$cc
           cross_cc_cflags_s390x=$CPU_CFLAGS
           ;;
    i386)
           CPU_CFLAGS="-m32"
           LDFLAGS="-m32 $LDFLAGS"
           cc_i386='$(CC) -m32'
           cross_cc_i386=$cc
           cross_cc_cflags_i386=$CPU_CFLAGS
           ;;
    x86_64)
           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
@@ -1434,12 +1476,14 @@ case "$cpu" in
           # runtime and generate the fallback to serial emulation.
           CPU_CFLAGS="-m64 -mcx16"
           LDFLAGS="-m64 $LDFLAGS"
           cc_i386='$(CC) -m32'
           cross_cc_x86_64=$cc
           cross_cc_cflags_x86_64=$CPU_CFLAGS
           ;;
    x32)
           CPU_CFLAGS="-mx32"
           LDFLAGS="-mx32 $LDFLAGS"
           cc_i386='$(CC) -m32'
           cross_cc_i386=$cc
           cross_cc_cflags_i386=$CPU_CFLAGS
           ;;
    # No special flags required for other host CPUs
esac
@@ -1501,6 +1545,8 @@ Advanced options (experts only):
  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
  --make=MAKE              use specified make [$make]
  --install=INSTALL        use specified install [$install]
  --python=PYTHON          use specified python [$python]
@@ -6702,7 +6748,6 @@ echo "CC=$cc" >> $config_host_mak
if $iasl -h > /dev/null 2>&1; then
  echo "IASL=$iasl" >> $config_host_mak
fi
echo "CC_I386=$cc_i386" >> $config_host_mak
echo "HOST_CC=$host_cc" >> $config_host_mak
echo "CXX=$cxx" >> $config_host_mak
echo "OBJCC=$objcc" >> $config_host_mak
@@ -6821,6 +6866,10 @@ case "$target" in
    ;;
esac

target_compiler=""
target_compiler_static=""
target_compiler_cflags=""

mkdir -p $target_dir
echo "# Automatically generated by configure - do not modify" > $config_target_mak

@@ -6836,19 +6885,25 @@ TARGET_ABI_DIR=""
case "$target_name" in
  i386)
    gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
    target_compiler=$cross_cc_i386
    target_compiler_cflags=$cross_cc_ccflags_i386
  ;;
  x86_64)
    TARGET_BASE_ARCH=i386
    gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
    target_compiler=$cross_cc_x86_64
  ;;
  alpha)
    mttcg="yes"
    target_compiler=$cross_cc_alpha
  ;;
  arm|armeb)
    TARGET_ARCH=arm
    bflt="yes"
    mttcg="yes"
    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
    target_compiler=$cross_cc_arm
    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
  ;;
  aarch64|aarch64_be)
    TARGET_ARCH=aarch64
@@ -6856,59 +6911,75 @@ case "$target_name" in
    bflt="yes"
    mttcg="yes"
    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
    target_compiler=$cross_cc_aarch64
    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
  ;;
  cris)
    target_compiler=$cross_cc_cris
  ;;
  hppa)
    mttcg="yes"
    target_compiler=$cross_cc_hppa
  ;;
  lm32)
    target_compiler=$cross_cc_lm32
  ;;
  m68k)
    bflt="yes"
    gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
    target_compiler=$cross_cc_m68k
  ;;
  microblaze|microblazeel)
    TARGET_ARCH=microblaze
    bflt="yes"
    echo "TARGET_ABI32=y" >> $config_target_mak
    target_compiler=$cross_cc_microblaze
  ;;
  mips|mipsel)
    TARGET_ARCH=mips
    target_compiler=$cross_cc_mips
    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
  ;;
  mipsn32|mipsn32el)
    TARGET_ARCH=mips64
    TARGET_BASE_ARCH=mips
    target_compiler=$cross_cc_mipsn32
    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
    echo "TARGET_ABI32=y" >> $config_target_mak
  ;;
  mips64|mips64el)
    TARGET_ARCH=mips64
    TARGET_BASE_ARCH=mips
    target_compiler=$cross_cc_mips64
    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
  ;;
  moxie)
    target_compiler=$cross_cc_moxie
  ;;
  nios2)
    target_compiler=$cross_cc_nios2
  ;;
  or1k)
    target_compiler=$cross_cc_or1k
    TARGET_ARCH=openrisc
    TARGET_BASE_ARCH=openrisc
  ;;
  ppc)
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
    target_compiler=$cross_cc_powerpc
  ;;
  ppcemb)
    TARGET_BASE_ARCH=ppc
    TARGET_ABI_DIR=ppc
    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
    target_compiler=$cross_cc_ppcemb
  ;;
  ppc64)
    TARGET_BASE_ARCH=ppc
    TARGET_ABI_DIR=ppc
    mttcg=yes
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
    target_compiler=$cross_cc_ppc64
  ;;
  ppc64le)
    TARGET_ARCH=ppc64
@@ -6916,6 +6987,7 @@ case "$target_name" in
    TARGET_ABI_DIR=ppc
    mttcg=yes
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
    target_compiler=$cross_cc_ppc64le
  ;;
  ppc64abi32)
    TARGET_ARCH=ppc64
@@ -6923,45 +6995,57 @@ case "$target_name" in
    TARGET_ABI_DIR=ppc
    echo "TARGET_ABI32=y" >> $config_target_mak
    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
    target_compiler=$cross_cc_ppc64abi32
  ;;
  riscv32)
    TARGET_BASE_ARCH=riscv
    TARGET_ABI_DIR=riscv
    mttcg=yes
    target_compiler=$cross_cc_riscv32
  ;;
  riscv64)
    TARGET_BASE_ARCH=riscv
    TARGET_ABI_DIR=riscv
    mttcg=yes
    target_compiler=$cross_cc_riscv64
  ;;
  sh4|sh4eb)
    TARGET_ARCH=sh4
    bflt="yes"
    target_compiler=$cross_cc_sh4
  ;;
  sparc)
    target_compiler=$cross_cc_sparc
  ;;
  sparc64)
    TARGET_BASE_ARCH=sparc
    target_compiler=$cross_cc_sparc64
  ;;
  sparc32plus)
    TARGET_ARCH=sparc64
    TARGET_BASE_ARCH=sparc
    TARGET_ABI_DIR=sparc
    target_compiler=$cross_cc_sparc32plus
    echo "TARGET_ABI32=y" >> $config_target_mak
  ;;
  s390x)
    mttcg=yes
    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
    target_compiler=$cross_cc_s390x
  ;;
  tilegx)
    target_compiler=$cross_cc_tilegx
  ;;
  tricore)
    target_compiler=$cross_cc_tricore
  ;;
  unicore32)
    target_compiler=$cross_cc_unicore32
  ;;
  xtensa|xtensaeb)
    TARGET_ARCH=xtensa
    mttcg="yes"
    target_compiler=$cross_cc_xtensa
  ;;
  *)
    error_exit "Unsupported target CPU"
@@ -6972,6 +7056,27 @@ if [ "$TARGET_BASE_ARCH" = "" ]; then
  TARGET_BASE_ARCH=$TARGET_ARCH
fi

# Do we have a cross compiler for this target?
if has $target_compiler; then

    write_c_skeleton

    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
        # For host systems we might get away with building without -static
        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
            target_compiler=""
        else
            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
            target_compiler_static="n"
        fi
    else
        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
        target_compiler_static="y"
    fi
else
    target_compiler=""
fi

symlink "$source_path/Makefile.target" "$target_dir/Makefile"

upper() {
@@ -7045,6 +7150,19 @@ if test "$target_bsd_user" = "yes" ; then
  echo "CONFIG_BSD_USER=y" >> $config_target_mak
fi

if test -n "$target_compiler"; then
  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak

  if test -n "$target_compiler_static"; then
      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
  fi

  if test -n "$target_compiler_cflags"; then
      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
  fi
fi


# generate QEMU_CFLAGS/LDFLAGS for targets

cflags=""
@@ -7167,6 +7285,11 @@ echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak

done # for target in $targets

if test -n "$enabled_cross_compilers"; then
    echo
    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
fi

if [ "$fdt" = "git" ]; then
  echo "config-host.h: subdir-dtc" >> $config_host_mak
fi
+37 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ check-help:
	@echo " $(MAKE) check-speed          Run qobject speed tests"
	@echo " $(MAKE) check-qapi-schema    Run QAPI schema tests"
	@echo " $(MAKE) check-block          Run block tests"
	@echo " $(MAKE) check-tcg            Run TCG tests"
	@echo " $(MAKE) check-report.html    Generates an HTML test report"
	@echo " $(MAKE) check-clean          Clean the tests"
	@echo
@@ -930,6 +931,42 @@ check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check
check-report.html: check-report.xml
	$(call quiet-command,gtester-report $< > $@,"GEN","$@")

# Per guest TCG tests

LINUX_USER_TARGETS=$(filter %-linux-user,$(TARGET_LIST))
BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(LINUX_USER_TARGETS))
CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(LINUX_USER_TARGETS))
RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(LINUX_USER_TARGETS))

ifeq ($(HAVE_USER_DOCKER),y)
# Probe for the Docker Builds needed for each build
$(foreach PROBE_TARGET,$(TARGET_LIST), 				\
	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) 	\
	$(if $(DOCKER_PREREQ), 					\
		$(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ))))
endif

build-tcg-tests-%:
	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \
		"BUILD", "TCG tests for $*")

run-tcg-tests-%: % build-tcg-tests-%
	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \
		"RUN", "TCG tests for $*")

clean-tcg-tests-%:
	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)

.PHONY: build-tcg
build-tcg: $(BUILD_TCG_TARGET_RULES)

.PHONY: check-tcg
check-tcg: $(RUN_TCG_TARGET_RULES)

.PHONY: clean-tcg
clean-tcg: $(CLEAN_TCG_TARGET_RULES)

# Other tests

@@ -972,7 +1009,6 @@ check-speed: $(patsubst %,check-%, $(check-speed-y))
check-block: $(patsubst %,check-%, $(check-block-y))
check: check-qapi-schema check-unit check-qtest check-decodetree
check-clean:
	$(MAKE) -C tests/tcg clean
	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
	rm -f tests/test-qapi-gen-timestamp
Loading