All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg
@ 2018-04-10 19:38 Alex Bennée
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability Alex Bennée
                   ` (25 more replies)
  0 siblings, 26 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

Hi,

We've talked about fixing this up for a long time and there have been
several RFC patches sent attempting to do that. This is yet another
RFC but hopefully shows a way forward which can build on our docker
support but also allow users to specify their own guest cross
compilers.

So far I've built arm, aarch64, ppc64 and s390x but adding support for
additional guests is simple, especially if we already have a docker
cross compile setup.

I've weeded out any tests that linked with QEMU (testpath) and reduced
the expectations of any tests/tcg test to just having access to libc.
This is the lowest common denominator for anything that can reasonably
be called a cross compiler.

The tests are all aimed at linux-user targets. We could probably come
up with something for building bare-metal softmmu tests but I suspect
that might be better served by using a different mechanism to import
existing tests into our build (e.g. kvm-unit-tests).

Let's breakdown the series:

configure:

As we need make magic we move the detection of docker and cross
compilers into configure. If any cross compiler is detected for a
given target we set CROSS_CC_GUEST in each config-target.mak. A
functioning cross compiler takes precedence over the docker fallback.
I think this makes sense for individual target sub-maintainers as they
likely already have a cross compile setup.

For docker we only set HAVE_USER_DOCKER in config-host.mak if the user
can run docker without sudo. We still need match up a docker image and
compiler once we build. This is handled by
tests/tcg/$(ARCH)/Makefile.include.

docker:

I've extended Fam's original patches to allow a bit more flexibility
for the "cc" command. I'm not overly wedded to using the docker.py
wrapper, we could just construct the command directly in Make if we
wanted to.

tests/tcg:

The top of the tree has been cleared out and everything moved into
sub-directories. There is a new multiarch sub-directory which is built
for every linux-user guest that has compiler support. Additional tests
are then included from tests/tcg/$(ARCH)/*.c or manually
added/modified by tests/tcg/$(ARCH)/Makefile.target.

Makefile:

As we are building tests/tcg for each target so Makefile.target now
invokes a sub-make with tests/tcg/Makefile while in the appropriate
build directory $(ARCH)-linux-user/tests/. The check-tcg and clean-tcg
targets unroll into all the configured FOO-linux-user targets and will
build the tests if cross compilation is available, otherwise the build
is skipped without failing the make.

Running tests:

Currently this is done manually from the build directory:

  ./qemu-arm tests/hello-arm

However once we have everything converted it shouldn't be too hard to
plumb into the normal make check sequence.

So what do people think? Is this a viable way to go forward?

Alex Bennée (20):
  configure: add test for docker availability
  configure: add support for --cross-cc-FOO
  configure: move i386_cc to cross_cc_i386
  docker: extend "cc" command to accept compiler
  docker: allow "cc" command to run in user context
  docker: Makefile.include introduce DOCKER_SCRIPT
  tests/tcg: move architecture independent tests into subdir
  tests/tcg: move i386 specific tests into subdir
  tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c
  tests/tcg/i386: fix test-i386
  tests/tcg/i368: fix hello-i386
  tests/tcg/i386: fix test-i386-fprem
  tests/tcg: move ARM specific tests into subdir
  tests/tcg/arm: fix hello-arm
  tests/tcg: move MIPS specific tests into subdir
  tests/tcg: enable building for s390x
  tests/tcg: enable building for ppc64
  tests/tcg/Makefile: update to be called from Makefile.target
  Makefile.target: add (clean-)guest-tests targets
  tests/Makefile.include: add (clean-)check-tcg targets

Fam Zheng (4):
  Makefile: Rename TARGET_DIRS to TARGET_LIST
  docker: Add "cc" subcommand
  tests/tcg/multiarch: Build fix for linux-test
  tests/tcg/i386: Build fix for hello-i386

 Makefile                                           |  20 +--
 Makefile.target                                    |   5 +
 configure                                          |  92 +++++++++-
 scripts/create_config                              |   2 +-
 tests/Makefile.include                             |  21 ++-
 tests/docker/Makefile.include                      |  10 +-
 tests/docker/docker.py                             |  40 +++++
 tests/tcg/Makefile                                 | 185 +++++----------------
 tests/tcg/Makefile.include                         |  79 +++++++++
 tests/tcg/README                                   |  69 +-------
 tests/tcg/arm/Makefile.target                      |   6 +
 tests/tcg/arm/README                               |  11 ++
 tests/tcg/{ => arm}/hello-arm.c                    |   0
 tests/tcg/{ => arm}/test-arm-iwmmxt.s              |   0
 tests/tcg/i386/Makefile.target                     |  35 ++++
 tests/tcg/i386/README                              |  38 +++++
 tests/tcg/{ => i386}/hello-i386.c                  |   1 +
 tests/tcg/{ => i386}/pi_10.com                     | Bin
 tests/tcg/{ => i386}/runcom.c                      |   0
 tests/tcg/{ => i386}/test-i386-code16.S            |   0
 tests/tcg/{ => i386}/test-i386-fprem.c             |   9 +-
 tests/tcg/{ => i386}/test-i386-muldiv.h            |   0
 tests/tcg/{ => i386}/test-i386-shift.h             |   0
 tests/tcg/{ => i386}/test-i386-vm86.S              |   0
 tests/tcg/{ => i386}/test-i386.c                   |   1 -
 tests/tcg/{ => i386}/test-i386.h                   |   0
 tests/tcg/mips/README                              |   7 +
 tests/tcg/{ => mips}/hello-mips.c                  |   0
 tests/tcg/multiarch/README                         |   1 +
 tests/tcg/{ => multiarch}/linux-test.c             |  68 +++-----
 tests/tcg/{ => multiarch}/sha1.c                   |   0
 tests/tcg/{ => multiarch}/test-mmap.c              |   0
 tests/tcg/{ => multiarch}/testthread.c             |   0
 tests/tcg/ppc64/Makefile.include                   |   2 +
 tests/tcg/s390x/Makefile.include                   |   2 +
 tests/tcg/test_path.c                              | 157 -----------------
 tests/tcg/{test-i386-ssse3.c => x86_64/test-sse.c} |   6 +-
 37 files changed, 424 insertions(+), 443 deletions(-)
 create mode 100644 tests/tcg/Makefile.include
 create mode 100644 tests/tcg/arm/Makefile.target
 create mode 100644 tests/tcg/arm/README
 rename tests/tcg/{ => arm}/hello-arm.c (100%)
 rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)
 create mode 100644 tests/tcg/i386/Makefile.target
 create mode 100644 tests/tcg/i386/README
 rename tests/tcg/{ => i386}/hello-i386.c (96%)
 rename tests/tcg/{ => i386}/pi_10.com (100%)
 rename tests/tcg/{ => i386}/runcom.c (100%)
 rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
 rename tests/tcg/{ => i386}/test-i386-fprem.c (98%)
 rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
 rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
 rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
 rename tests/tcg/{ => i386}/test-i386.c (99%)
 rename tests/tcg/{ => i386}/test-i386.h (100%)
 create mode 100644 tests/tcg/mips/README
 rename tests/tcg/{ => mips}/hello-mips.c (100%)
 create mode 100644 tests/tcg/multiarch/README
 rename tests/tcg/{ => multiarch}/linux-test.c (91%)
 rename tests/tcg/{ => multiarch}/sha1.c (100%)
 rename tests/tcg/{ => multiarch}/test-mmap.c (100%)
 rename tests/tcg/{ => multiarch}/testthread.c (100%)
 create mode 100644 tests/tcg/ppc64/Makefile.include
 create mode 100644 tests/tcg/s390x/Makefile.include
 delete mode 100644 tests/tcg/test_path.c
 rename tests/tcg/{test-i386-ssse3.c => x86_64/test-sse.c} (93%)

-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
@ 2018-04-10 19:38 ` Alex Bennée
  2018-04-11  8:50   ` Fam Zheng
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO Alex Bennée
                   ` (24 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

This tests for a working docker installation without sudo and sets up
config-host.mak accordingly. This will be useful from cross compiling
things in the future.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/configure b/configure
index 4d0e92c96c..b402befe94 100755
--- a/configure
+++ b/configure
@@ -451,6 +451,7 @@ jemalloc="no"
 replication="yes"
 vxhs=""
 libxml2=""
+docker="no"
 
 supported_cpu="no"
 supported_os="no"
@@ -5396,6 +5397,23 @@ EOF
   fi
 fi
 
+##########################################
+# Docker and cross-compiler support
+#
+# This is specifically for building test
+# cases for foreign architectures, not
+# cross-compiling QEMU itself.
+
+if has "docker"; then
+    if docker images  >/dev/null 2>&1 ; then
+        docker="yes"
+    else
+        # docker may be available but using sudo
+        # so we won't use it for cross-building
+        docker="maybe"
+    fi
+fi
+
 ##########################################
 # End of CC checks
 # After here, no more $cc or $ld runs
@@ -5857,6 +5875,7 @@ echo "avx2 optimization $avx2_opt"
 echo "replication support $replication"
 echo "VxHS block device $vxhs"
 echo "capstone          $capstone"
+echo "docker            $docker"
 
 if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -6680,6 +6699,10 @@ if test "$gcov" = "yes" ; then
   echo "GCOV=$gcov_tool" >> $config_host_mak
 fi
 
+if test "$docker" = "yes"; then
+    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
+fi
+
 # use included Linux headers
 if test "$linux" = "yes" ; then
   mkdir -p linux-headers
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability Alex Bennée
@ 2018-04-10 19:38 ` Alex Bennée
  2018-04-16  2:04   ` Philippe Mathieu-Daudé
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386 Alex Bennée
                   ` (23 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

This allows us to specify cross compilers for our guests. This is
useful for building test images/programs. Currently we re-run the
compile test for each target. I couldn't think of a way to cache the
value for a given arch without getting messier configure code.

The cross compiler for the guest is visible to each target as
CROSS_CC_GUEST in config-target.mak.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/configure b/configure
index b402befe94..b5f3b3fe29 100755
--- a/configure
+++ b/configure
@@ -453,6 +453,13 @@ vxhs=""
 libxml2=""
 docker="no"
 
+# cross compilers defaults, can be overridden with --cross-cc-ARCH
+cross_cc_aarch64="aarch64-linux-gnu-gcc"
+cross_cc_arm="arm-linux-gnueabihf-gcc"
+cross_cc_powerpc="powerpc-linux-gnu-gcc"
+
+enabled_cross_compilers=""
+
 supported_cpu="no"
 supported_os="no"
 bogus_os="no"
@@ -483,6 +490,11 @@ for opt do
   ;;
   --disable-debug-info) debug_info="no"
   ;;
+  --cross-cc-*[!a-zA-Z0-9_0]=*) error_exit "Passed bad --cross-cc-FOO option"
+  ;;
+  --cross-cc-*) cc_arch=${opt#--cross-cc-}
+                eval "cross_cc_${cc_arch}=\$optarg"
+  ;;
   esac
 done
 # OS specific
@@ -675,10 +687,12 @@ case "$cpu" in
   i386|i486|i586|i686|i86pc|BePC)
     cpu="i386"
     supported_cpu="yes"
+    cross_cc_i386=gcc
   ;;
   x86_64|amd64)
     cpu="x86_64"
     supported_cpu="yes"
+    cross_cc_x86_64=gcc
   ;;
   armv*b|armv*l|arm)
     cpu="arm"
@@ -912,6 +926,8 @@ for opt do
   ;;
   --disable-debug-info)
   ;;
+  --cross-cc-*)
+  ;;
   --enable-modules)
       modules="yes"
   ;;
@@ -6766,6 +6782,8 @@ case "$target" in
     ;;
 esac
 
+target_compiler=""
+
 mkdir -p $target_dir
 echo "# Automatically generated by configure - do not modify" > $config_target_mak
 
@@ -6794,6 +6812,7 @@ case "$target_name" in
     bflt="yes"
     mttcg="yes"
     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
+    target_compiler=$cross_cc_arm
   ;;
   aarch64|aarch64_be)
     TARGET_ARCH=aarch64
@@ -6801,6 +6820,7 @@ 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
   ;;
   cris)
   ;;
@@ -6842,6 +6862,7 @@ case "$target_name" in
   ;;
   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
@@ -6916,6 +6937,25 @@ 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
+
+    cat > $TMPC << EOF
+#include <stdio.h>
+int main(void) {
+    printf("Hello World!\n");
+}
+EOF
+
+    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
+        target_compiler=""
+    else
+        enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
+    fi
+else
+    target_compiler=""
+fi
+
 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
 
 upper() {
@@ -6989,6 +7029,10 @@ 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
+fi
+
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
 cflags=""
@@ -7111,6 +7155,12 @@ 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:"
+    printf '%s\n' $enabled_cross_compilers | sort -u
+fi
+
 if [ "$dtc_internal" = "yes" ]; then
   echo "config-host.h: subdir-dtc" >> $config_host_mak
 fi
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability Alex Bennée
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO Alex Bennée
@ 2018-04-10 19:38 ` Alex Bennée
  2018-04-16  0:01   ` Philippe Mathieu-Daudé
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST Alex Bennée
                   ` (22 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

We should still be able to use the system cross compiler with the
appropriate flags on x86_64 hosts.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index b5f3b3fe29..add87ff4d4 100755
--- a/configure
+++ b/configure
@@ -284,7 +284,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=""
@@ -457,6 +456,8 @@ docker="no"
 cross_cc_aarch64="aarch64-linux-gnu-gcc"
 cross_cc_arm="arm-linux-gnueabihf-gcc"
 cross_cc_powerpc="powerpc-linux-gnu-gcc"
+cross_cc_i386="i386-pc-linux-gnu-gcc"
+cross_cc_i386_cflags=""
 
 enabled_cross_compilers=""
 
@@ -687,12 +688,10 @@ case "$cpu" in
   i386|i486|i586|i686|i86pc|BePC)
     cpu="i386"
     supported_cpu="yes"
-    cross_cc_i386=gcc
   ;;
   x86_64|amd64)
     cpu="x86_64"
     supported_cpu="yes"
-    cross_cc_x86_64=gcc
   ;;
   armv*b|armv*l|arm)
     cpu="arm"
@@ -1435,7 +1434,6 @@ case "$cpu" in
     i386)
            CPU_CFLAGS="-m32"
            LDFLAGS="-m32 $LDFLAGS"
-           cc_i386='$(CC) -m32'
            ;;
     x86_64)
            # ??? Only extremely old AMD cpus do not have cmpxchg16b.
@@ -1443,12 +1441,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_i386=$cc
+           cross_cc_i386_cflags="-m32"
            ;;
     x32)
            CPU_CFLAGS="-mx32"
            LDFLAGS="-mx32 $LDFLAGS"
-           cc_i386='$(CC) -m32'
+           cross_cc_i386=$cc
+           cross_cc_i386_cflags="-m32"
            ;;
     # No special flags required for other host CPUs
 esac
@@ -6664,7 +6664,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
@@ -6783,6 +6782,7 @@ case "$target" in
 esac
 
 target_compiler=""
+target_compiler_cflags=""
 
 mkdir -p $target_dir
 echo "# Automatically generated by configure - do not modify" > $config_target_mak
@@ -6799,10 +6799,13 @@ 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_i386_cflags
   ;;
   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"
@@ -6947,7 +6950,7 @@ int main(void) {
 }
 EOF
 
-    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
+    if ! do_compiler $target_compiler $target_compiler_cflags -o $TMPE $TMPC -static ; then
         target_compiler=""
     else
         enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
@@ -7033,6 +7036,10 @@ if test -n "$target_compiler"; then
   echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
 fi
 
+if test -n "$target_compiler_cflags"; then
+  echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
+fi
+
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
 cflags=""
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (2 preceding siblings ...)
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386 Alex Bennée
@ 2018-04-10 19:38 ` Alex Bennée
  2018-04-12 14:33   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand Alex Bennée
                   ` (21 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota

From: Fam Zheng <famz@redhat.com>

To be more accurate on its purpose and make code that looks for a certain
target out of this variable more readable.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 Makefile               | 20 ++++++++++----------
 configure              |  2 +-
 scripts/create_config  |  2 +-
 tests/Makefile.include |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 727ef118f3..2c54cd8345 100644
--- a/Makefile
+++ b/Makefile
@@ -62,8 +62,8 @@ seems to have been used for an in-tree build. You can fix this by running \
 endif
 endif
 
-CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
-CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
+CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_LIST)),y)
+CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_LIST)),y)
 CONFIG_XEN := $(CONFIG_XEN_BACKEND)
 CONFIG_ALL=y
 -include config-all-devices.mak
@@ -362,8 +362,8 @@ DOCS=
 endif
 
 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
-SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
-SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
+SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_LIST))
+SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_LIST))
 
 ifeq ($(SUBDIR_DEVICES_MAK),)
 config-all-devices.mak:
@@ -466,7 +466,7 @@ config-host.h-timestamp: config-host.mak
 qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
 
-SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
+SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_LIST))
 SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
 
 $(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
@@ -510,7 +510,7 @@ ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
 romsubdir-%:
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
 
-ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
+ALL_SUBDIRS=$(TARGET_LIST) $(patsubst %,pc-bios/%, $(ROMS))
 
 recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
@@ -763,7 +763,7 @@ distclean: clean
 	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
 	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
 	rm -f docs/qemu-block-drivers.7
-	for d in $(TARGET_DIRS); do \
+	for d in $(TARGET_LIST); do \
 	rm -rf $$d || exit 1 ; \
         done
 	rm -Rf .sdk
@@ -864,7 +864,7 @@ endif
 		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
 	done
 	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
-	for d in $(TARGET_DIRS); do \
+	for d in $(TARGET_LIST); do \
 	$(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
         done
 
@@ -1062,9 +1062,9 @@ endif
 	@echo  '  ctags/TAGS      - Generate tags file for editors'
 	@echo  '  cscope          - Generate cscope index'
 	@echo  ''
-	@$(if $(TARGET_DIRS), \
+	@$(if $(TARGET_LIST), \
 		echo 'Architecture specific targets:'; \
-		$(foreach t, $(TARGET_DIRS), \
+		$(foreach t, $(TARGET_LIST), \
 		printf "  %-30s - Build for %s\\n" $(patsubst %,subdir-%,$(t)) $(t);) \
 		echo '')
 	@echo  'Cleaning targets:'
diff --git a/configure b/configure
index add87ff4d4..5a41c87cc3 100755
--- a/configure
+++ b/configure
@@ -6094,7 +6094,7 @@ qemu_version=$(head $source_path/VERSION)
 echo "VERSION=$qemu_version" >>$config_host_mak
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
-echo "TARGET_DIRS=$target_list" >> $config_host_mak
+echo "TARGET_LIST=$target_list" >> $config_host_mak
 if [ "$docs" = "yes" ] ; then
   echo "BUILD_DOCS=yes" >> $config_host_mak
 fi
diff --git a/scripts/create_config b/scripts/create_config
index d727e5e36e..58948a67a4 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -107,7 +107,7 @@ case $line in
     target_name=${line#*=}
     echo "#define TARGET_NAME \"$target_name\""
     ;;
- TARGET_DIRS=*)
+ TARGET_LIST=*)
     # do nothing
     ;;
  TARGET_*=y) # configuration
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3b9a5e31a2..3d2f0458ab 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -854,7 +854,7 @@ endif
 
 # QTest rules
 
-TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
+TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_LIST)))
 ifeq ($(CONFIG_POSIX),y)
 QTEST_TARGETS = $(TARGETS)
 check-qtest-y=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y))
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (3 preceding siblings ...)
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-16  1:48   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler Alex Bennée
                   ` (20 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, famz, cota, Alex Bennée, Philippe Mathieu-Daudé

From: Fam Zheng <famz@redhat.com>

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/docker/docker.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 1246ba9578..8733266153 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -390,6 +390,29 @@ class ImagesCommand(SubCommand):
     def run(self, args, argv):
         return Docker().command("images", argv, args.quiet)
 
+class CcCommand(SubCommand):
+    """Compile sources with cc in images"""
+    name = "cc"
+
+    def args(self, parser):
+        parser.add_argument("--image", "-i", required=True,
+                            help="The docker image in which to run cc")
+        parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
+                            help="""Extra paths to (ro) mount into container for
+                            reading sources""")
+
+    def run(self, args, argv):
+        if argv and argv[0] == "--":
+            argv = argv[1:]
+        cwd = os.getcwd()
+        cmd = ["--rm", "-w", cwd,
+               "-v", "%s:%s:rw" % (cwd, cwd)]
+        for p in args.paths:
+           cmd += ["-v", "%s:%s:ro,z" % (p, p)]
+        cmd += [args.image, "cc"]
+        cmd += argv
+        return Docker().command("run", cmd, True)
+
 def main():
     parser = argparse.ArgumentParser(description="A Docker helper",
             usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (4 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-12  8:07   ` Fam Zheng
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context Alex Bennée
                   ` (19 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, famz, cota, Alex Bennée, Philippe Mathieu-Daudé

When calling our cross-compilation images we want to call something
other than the default cc.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/docker/docker.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 8733266153..9444f4bea4 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -397,6 +397,8 @@ class CcCommand(SubCommand):
     def args(self, parser):
         parser.add_argument("--image", "-i", required=True,
                             help="The docker image in which to run cc")
+        parser.add_argument("--cc",
+                            help="The compiler executable to call")
         parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
                             help="""Extra paths to (ro) mount into container for
                             reading sources""")
@@ -407,9 +409,19 @@ class CcCommand(SubCommand):
         cwd = os.getcwd()
         cmd = ["--rm", "-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
-        for p in args.paths:
-           cmd += ["-v", "%s:%s:ro,z" % (p, p)]
-        cmd += [args.image, "cc"]
+
+        if args.paths:
+            for p in args.paths:
+                cmd += ["-v", "%s:%s:ro,z" % (p, p)]
+
+        cmd += [args.image]
+
+        # The compile command we are running
+        if args.cc:
+            cmd += [args.cc]
+        else:
+            cmd += ["cc"]
+
         cmd += argv
         return Docker().command("run", cmd, True)
 
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (5 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-12  8:08   ` Fam Zheng
  2018-04-16  0:02   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT Alex Bennée
                   ` (18 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, famz, cota, Alex Bennée, Philippe Mathieu-Daudé

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/docker/docker.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 9444f4bea4..f79213044d 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -399,6 +399,8 @@ class CcCommand(SubCommand):
                             help="The docker image in which to run cc")
         parser.add_argument("--cc",
                             help="The compiler executable to call")
+        parser.add_argument("--user",
+                            help="The user-id to run under")
         parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
                             help="""Extra paths to (ro) mount into container for
                             reading sources""")
@@ -414,6 +416,9 @@ class CcCommand(SubCommand):
             for p in args.paths:
                 cmd += ["-v", "%s:%s:ro,z" % (p, p)]
 
+        if args.user:
+            cmd += ["-u", args.user]
+
         cmd += [args.image]
 
         # The compile command we are running
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (6 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:10   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir Alex Bennée
                   ` (17 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, famz, cota, Alex Bennée, Philippe Mathieu-Daudé

Define this in one place to make it easy to re-use.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/docker/Makefile.include | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index de87341528..6a5aa9ec71 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -14,6 +14,8 @@ DOCKER_TESTS := $(notdir $(shell \
 
 DOCKER_TOOLS := travis
 
+DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py
+
 TESTS ?= %
 IMAGES ?= %
 
@@ -37,7 +39,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
 		echo WARNING: EXECUTABLE is not set, debootstrap may fail. 2>&1 ; \
 	fi
 	$(call quiet-command,\
-		$(SRC_PATH)/tests/docker/docker.py build qemu:$* $< \
+		$(DOCKER_SCRIPT) build qemu:$* $< \
 		$(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
 		$(if $(NOUSER),,--add-current-user) \
 		$(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
@@ -129,11 +131,11 @@ docker-run: docker-qemu-src
 	fi
 	$(if $(EXECUTABLE),						\
 		$(call quiet-command,					\
-			$(SRC_PATH)/tests/docker/docker.py update 	\
+			$(DOCKER_SCRIPT) update 			\
 			$(IMAGE) $(EXECUTABLE),				\
 			"  COPYING $(EXECUTABLE) to $(IMAGE)"))
 	$(call quiet-command,						\
-		$(SRC_PATH)/tests/docker/docker.py run 			\
+		$(DOCKER_SCRIPT) run 					\
 			$(if $(NOUSER),,-u $(shell id -u)) 		\
 			--security-opt seccomp=unconfined		\
 			$(if $V,,--rm) 					\
@@ -163,4 +165,4 @@ docker-run-%:
 	@$(MAKE) docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE)
 
 docker-clean:
-	$(call quiet-command, $(SRC_PATH)/tests/docker/docker.py clean)
+	$(call quiet-command, $(DOCKER_SCRIPT) clean)
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (7 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 10:22   ` Thomas Huth
  2018-04-16  0:05   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test Alex Bennée
                   ` (16 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

We will want to build these for all supported guest architectures so
lets move them all into one place. We also drop test_path at this
point because it needs qemu utils and glib bits which is hard to
support for cross compiling.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/README                       |  10 +--
 tests/tcg/multiarch/README             |   1 +
 tests/tcg/{ => multiarch}/linux-test.c |   0
 tests/tcg/{ => multiarch}/sha1.c       |   0
 tests/tcg/{ => multiarch}/test-mmap.c  |   0
 tests/tcg/{ => multiarch}/testthread.c |   0
 tests/tcg/test_path.c                  | 157 ---------------------------------
 7 files changed, 5 insertions(+), 163 deletions(-)
 create mode 100644 tests/tcg/multiarch/README
 rename tests/tcg/{ => multiarch}/linux-test.c (100%)
 rename tests/tcg/{ => multiarch}/sha1.c (100%)
 rename tests/tcg/{ => multiarch}/test-mmap.c (100%)
 rename tests/tcg/{ => multiarch}/testthread.c (100%)
 delete mode 100644 tests/tcg/test_path.c

diff --git a/tests/tcg/README b/tests/tcg/README
index 5dcfb4852b..0890044cf0 100644
--- a/tests/tcg/README
+++ b/tests/tcg/README
@@ -1,9 +1,7 @@
-This directory contains various interesting programs for
-regression testing.
-
-The target "make test" runs the programs and, if applicable,
-runs "diff" to detect mismatches between output on the host and
-output on QEMU.
+This directory contains various interesting guest programs for
+regression testing. Tests are either multi-arch, meaning they can be
+built for all guest architectures that support linux-user executable,
+or they are architecture specific.
 
 i386
 ====
diff --git a/tests/tcg/multiarch/README b/tests/tcg/multiarch/README
new file mode 100644
index 0000000000..522c9d2ea3
--- /dev/null
+++ b/tests/tcg/multiarch/README
@@ -0,0 +1 @@
+Multi-architecture linux-user tests
diff --git a/tests/tcg/linux-test.c b/tests/tcg/multiarch/linux-test.c
similarity index 100%
rename from tests/tcg/linux-test.c
rename to tests/tcg/multiarch/linux-test.c
diff --git a/tests/tcg/sha1.c b/tests/tcg/multiarch/sha1.c
similarity index 100%
rename from tests/tcg/sha1.c
rename to tests/tcg/multiarch/sha1.c
diff --git a/tests/tcg/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
similarity index 100%
rename from tests/tcg/test-mmap.c
rename to tests/tcg/multiarch/test-mmap.c
diff --git a/tests/tcg/testthread.c b/tests/tcg/multiarch/testthread.c
similarity index 100%
rename from tests/tcg/testthread.c
rename to tests/tcg/multiarch/testthread.c
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
deleted file mode 100644
index 1c29bce263..0000000000
--- a/tests/tcg/test_path.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Test path override code */
-#include "config-host.h"
-#include "util/cutils.c"
-#include "util/hexdump.c"
-#include "util/iov.c"
-#include "util/path.c"
-#include "util/qemu-timer-common.c"
-#include <stdarg.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-void qemu_log(const char *fmt, ...);
-
-/* Any log message kills the test. */
-void qemu_log(const char *fmt, ...)
-{
-    va_list ap;
-
-    fprintf(stderr, "FATAL: ");
-    va_start(ap, fmt);
-    vfprintf(stderr, fmt, ap);
-    va_end(ap);
-    exit(1);
-}
-
-#define NO_CHANGE(_path)						\
-	do {								\
-	    if (strcmp(path(_path), _path) != 0) return __LINE__;	\
-	} while(0)
-
-#define CHANGE_TO(_path, _newpath)					\
-	do {								\
-	    if (strcmp(path(_path), _newpath) != 0) return __LINE__;	\
-	} while(0)
-
-static void cleanup(void)
-{
-    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE2");
-    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE3");
-    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE4");
-    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE5");
-    rmdir("/tmp/qemu-test_path/DIR1/DIR2");
-    rmdir("/tmp/qemu-test_path/DIR1/DIR3");
-    rmdir("/tmp/qemu-test_path/DIR1");
-    rmdir("/tmp/qemu-test_path");
-}
-
-static unsigned int do_test(void)
-{
-    if (mkdir("/tmp/qemu-test_path", 0700) != 0)
-	return __LINE__;
-
-    if (mkdir("/tmp/qemu-test_path/DIR1", 0700) != 0)
-	return __LINE__;
-
-    if (mkdir("/tmp/qemu-test_path/DIR1/DIR2", 0700) != 0)
-	return __LINE__;
-
-    if (mkdir("/tmp/qemu-test_path/DIR1/DIR3", 0700) != 0)
-	return __LINE__;
-
-    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE", 0600)) != 0)
-	return __LINE__;
-
-    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE2", 0600)) != 0)
-	return __LINE__;
-
-    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE3", 0600)) != 0)
-	return __LINE__;
-
-    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE4", 0600)) != 0)
-	return __LINE__;
-
-    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE5", 0600)) != 0)
-	return __LINE__;
-
-    init_paths("/tmp/qemu-test_path");
-
-    NO_CHANGE("/tmp");
-    NO_CHANGE("/tmp/");
-    NO_CHANGE("/tmp/qemu-test_path");
-    NO_CHANGE("/tmp/qemu-test_path/");
-    NO_CHANGE("/tmp/qemu-test_path/D");
-    NO_CHANGE("/tmp/qemu-test_path/DI");
-    NO_CHANGE("/tmp/qemu-test_path/DIR");
-    NO_CHANGE("/tmp/qemu-test_path/DIR1");
-    NO_CHANGE("/tmp/qemu-test_path/DIR1/");
-
-    NO_CHANGE("/D");
-    NO_CHANGE("/DI");
-    NO_CHANGE("/DIR");
-    NO_CHANGE("/DIR2");
-    NO_CHANGE("/DIR1.");
-
-    CHANGE_TO("/DIR1", "/tmp/qemu-test_path/DIR1");
-    CHANGE_TO("/DIR1/", "/tmp/qemu-test_path/DIR1");
-
-    NO_CHANGE("/DIR1/D");
-    NO_CHANGE("/DIR1/DI");
-    NO_CHANGE("/DIR1/DIR");
-    NO_CHANGE("/DIR1/DIR1");
-
-    CHANGE_TO("/DIR1/DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
-    CHANGE_TO("/DIR1/DIR2/", "/tmp/qemu-test_path/DIR1/DIR2");
-
-    CHANGE_TO("/DIR1/DIR3", "/tmp/qemu-test_path/DIR1/DIR3");
-    CHANGE_TO("/DIR1/DIR3/", "/tmp/qemu-test_path/DIR1/DIR3");
-
-    NO_CHANGE("/DIR1/DIR2/F");
-    NO_CHANGE("/DIR1/DIR2/FI");
-    NO_CHANGE("/DIR1/DIR2/FIL");
-    NO_CHANGE("/DIR1/DIR2/FIL.");
-
-    CHANGE_TO("/DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/DIR1/DIR2/FILE2", "/tmp/qemu-test_path/DIR1/DIR2/FILE2");
-    CHANGE_TO("/DIR1/DIR2/FILE3", "/tmp/qemu-test_path/DIR1/DIR2/FILE3");
-    CHANGE_TO("/DIR1/DIR2/FILE4", "/tmp/qemu-test_path/DIR1/DIR2/FILE4");
-    CHANGE_TO("/DIR1/DIR2/FILE5", "/tmp/qemu-test_path/DIR1/DIR2/FILE5");
-
-    NO_CHANGE("/DIR1/DIR2/FILE6");
-    NO_CHANGE("/DIR1/DIR2/FILE/X");
-
-    CHANGE_TO("/DIR1/../DIR1", "/tmp/qemu-test_path/DIR1");
-    CHANGE_TO("/DIR1/../DIR1/", "/tmp/qemu-test_path/DIR1");
-    CHANGE_TO("/../DIR1", "/tmp/qemu-test_path/DIR1");
-    CHANGE_TO("/../DIR1/", "/tmp/qemu-test_path/DIR1");
-    CHANGE_TO("/DIR1/DIR2/../DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
-    CHANGE_TO("/DIR1/DIR2/../DIR2/../../DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/DIR1/DIR2/../DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-
-    NO_CHANGE("/DIR1/DIR2/../DIR1");
-    NO_CHANGE("/DIR1/DIR2/../FILE");
-
-    CHANGE_TO("/./DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/././DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/DIR1/./DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/DIR1/././DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/DIR1/DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/DIR1/DIR2/././FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-    CHANGE_TO("/./DIR1/./DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
-
-    return 0;
-}
-
-int main(int argc, char *argv[])
-{
-    int ret;
-
-    ret = do_test();
-    cleanup();
-    if (ret) {
-	fprintf(stderr, "test_path: failed on line %i\n", ret);
-	return 1;
-    }
-    return 0;
-}
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (8 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 10:25   ` Thomas Huth
       [not found]   ` <4bc22552-25b4-2a04-dc73-dc17201a2251@amsat.org>
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir Alex Bennée
                   ` (15 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

From: Fam Zheng <famz@redhat.com>

To keep the compiler happy, and to fit in our buildsys flags:

- Make local functions "static"
- #ifdef out unused functions
- drop cutils/osdep dependencies

Signed-off-by: Fam Zheng <famz@redhat.com>
[AJB: drop cutils/osdep dependencies]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
 1 file changed, 21 insertions(+), 47 deletions(-)

diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index 5070d31446..4457bd04ba 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -16,7 +16,6 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
-#define _GNU_SOURCE
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -31,6 +30,7 @@
 #include <utime.h>
 #include <time.h>
 #include <sys/time.h>
+#include <sys/resource.h>
 #include <sys/uio.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -39,13 +39,12 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
-#include "qemu/cutils.h"
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
 #define STACK_SIZE 16384
 
-void error1(const char *filename, int line, const char *fmt, ...)
+static void error1(const char *filename, int line, const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
@@ -56,7 +55,7 @@ void error1(const char *filename, int line, const char *fmt, ...)
     exit(1);
 }
 
-int __chk_error(const char *filename, int line, int ret)
+static int __chk_error(const char *filename, int line, int ret)
 {
     if (ret < 0) {
         error1(filename, line, "%m (ret=%d, errno=%d)",
@@ -73,7 +72,7 @@ int __chk_error(const char *filename, int line, int ret)
 
 #define FILE_BUF_SIZE 300
 
-void test_file(void)
+static void test_file(void)
 {
     int fd, i, len, ret;
     uint8_t buf[FILE_BUF_SIZE];
@@ -210,7 +209,7 @@ void test_file(void)
     chk_error(rmdir(TESTPATH));
 }
 
-void test_fork(void)
+static void test_fork(void)
 {
     int pid, status;
 
@@ -224,7 +223,7 @@ void test_fork(void)
         error("waitpid status=0x%x", status);
 }
 
-void test_time(void)
+static void test_time(void)
 {
     struct timeval tv, tv2;
     struct timespec ts, rem;
@@ -251,34 +250,7 @@ void test_time(void)
         error("getrusage");
 }
 
-void pstrcpy(char *buf, int buf_size, const char *str)
-{
-    int c;
-    char *q = buf;
-
-    if (buf_size <= 0)
-        return;
-
-    for(;;) {
-        c = *str++;
-        if (c == 0 || q >= buf + buf_size - 1)
-            break;
-        *q++ = c;
-    }
-    *q = '\0';
-}
-
-/* strcat and truncate. */
-char *pstrcat(char *buf, int buf_size, const char *s)
-{
-    int len;
-    len = strlen(buf);
-    if (len < buf_size)
-        pstrcpy(buf + len, buf_size - len, s);
-    return buf;
-}
-
-int server_socket(void)
+static int server_socket(void)
 {
     int val, fd;
     struct sockaddr_in sockaddr;
@@ -298,7 +270,7 @@ int server_socket(void)
 
 }
 
-int client_socket(void)
+static int client_socket(void)
 {
     int fd;
     struct sockaddr_in sockaddr;
@@ -312,9 +284,9 @@ int client_socket(void)
     return fd;
 }
 
-const char socket_msg[] = "hello socket\n";
+static const char socket_msg[] = "hello socket\n";
 
-void test_socket(void)
+static void test_socket(void)
 {
     int server_fd, client_fd, fd, pid, ret, val;
     struct sockaddr_in sockaddr;
@@ -348,9 +320,10 @@ void test_socket(void)
     chk_error(close(server_fd));
 }
 
+#if 0
 #define WCOUNT_MAX 512
 
-void test_pipe(void)
+static void test_pipe(void)
 {
     fd_set rfds, wfds;
     int fds[2], fd_max, ret;
@@ -391,10 +364,10 @@ void test_pipe(void)
     chk_error(close(fds[1]));
 }
 
-int thread1_res;
-int thread2_res;
+static int thread1_res;
+static int thread2_res;
 
-int thread1_func(void *arg)
+static int thread1_func(void *arg)
 {
     int i;
     for(i=0;i<5;i++) {
@@ -404,7 +377,7 @@ int thread1_func(void *arg)
     return 0;
 }
 
-int thread2_func(void *arg)
+static int thread2_func(void *arg)
 {
     int i;
     for(i=0;i<6;i++) {
@@ -435,27 +408,28 @@ void test_clone(void)
         thread2_res != 6)
         error("clone");
 }
+#endif
 
 /***********************************/
 
 volatile int alarm_count;
 jmp_buf jmp_env;
 
-void sig_alarm(int sig)
+static void sig_alarm(int sig)
 {
     if (sig != SIGALRM)
         error("signal");
     alarm_count++;
 }
 
-void sig_segv(int sig, siginfo_t *info, void *puc)
+static void sig_segv(int sig, siginfo_t *info, void *puc)
 {
     if (sig != SIGSEGV)
         error("signal");
     longjmp(jmp_env, 1);
 }
 
-void test_signal(void)
+static void test_signal(void)
 {
     struct sigaction act;
     struct itimerval it, oit;
@@ -510,7 +484,7 @@ void test_signal(void)
 
 #define SHM_SIZE 32768
 
-void test_shm(void)
+static void test_shm(void)
 {
     void *ptr;
     int shmid;
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (9 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 10:30   ` Thomas Huth
  2018-04-16  0:08   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386 Alex Bennée
                   ` (14 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

These only need to be built for i386 guests. This includes a stub
tests/tcg/i386/Makfile.target which absorbs some of what was in
tests/tcg/Makefile.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/README                        |  39 --------------------------------
 tests/tcg/i386/Makefile.target          |  10 ++++++++
 tests/tcg/i386/README                   |  38 +++++++++++++++++++++++++++++++
 tests/tcg/{ => i386}/hello-i386.c       |   0
 tests/tcg/{ => i386}/pi_10.com          | Bin
 tests/tcg/{ => i386}/runcom.c           |   0
 tests/tcg/{ => i386}/test-i386-code16.S |   0
 tests/tcg/{ => i386}/test-i386-fprem.c  |   0
 tests/tcg/{ => i386}/test-i386-muldiv.h |   0
 tests/tcg/{ => i386}/test-i386-shift.h  |   0
 tests/tcg/{ => i386}/test-i386-ssse3.c  |   0
 tests/tcg/{ => i386}/test-i386-vm86.S   |   0
 tests/tcg/{ => i386}/test-i386.c        |   0
 tests/tcg/{ => i386}/test-i386.h        |   0
 14 files changed, 48 insertions(+), 39 deletions(-)
 create mode 100644 tests/tcg/i386/Makefile.target
 create mode 100644 tests/tcg/i386/README
 rename tests/tcg/{ => i386}/hello-i386.c (100%)
 rename tests/tcg/{ => i386}/pi_10.com (100%)
 rename tests/tcg/{ => i386}/runcom.c (100%)
 rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
 rename tests/tcg/{ => i386}/test-i386-fprem.c (100%)
 rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
 rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
 rename tests/tcg/{ => i386}/test-i386-ssse3.c (100%)
 rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
 rename tests/tcg/{ => i386}/test-i386.c (100%)
 rename tests/tcg/{ => i386}/test-i386.h (100%)

diff --git a/tests/tcg/README b/tests/tcg/README
index 0890044cf0..469504c4cb 100644
--- a/tests/tcg/README
+++ b/tests/tcg/README
@@ -3,45 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
 built for all guest architectures that support linux-user executable,
 or they are architecture specific.
 
-i386
-====
-
-test-i386
----------
-
-This program executes most of the 16 bit and 32 bit x86 instructions and
-generates a text output, for comparison with the output obtained with
-a real CPU or another emulator.
-
-The Linux system call modify_ldt() is used to create x86 selectors
-to test some 16 bit addressing and 32 bit with segmentation cases.
-
-The Linux system call vm86() is used to test vm86 emulation.
-
-Various exceptions are raised to test most of the x86 user space
-exception reporting.
-
-linux-test
-----------
-
-This program tests various Linux system calls. It is used to verify
-that the system call parameters are correctly converted between target
-and host CPUs.
-
-test-i386-fprem
----------------
-
-runcom
-------
-
-test-mmap
----------
-
-sha1
-----
-
-hello-i386
-----------
 
 
 ARM
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
new file mode 100644
index 0000000000..7dbb7992e7
--- /dev/null
+++ b/tests/tcg/i386/Makefile.target
@@ -0,0 +1,10 @@
+# i386 cross compile notes
+
+# If we are using a cross compiler config-target.mak may have also
+# defined some CFLAGs to use.
+
+ifeq ($(CC), $(CROSS_CC_GUEST))
+ifdef CROSS_CC_GUEST_CFLAGS
+CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
+endif
+endif
diff --git a/tests/tcg/i386/README b/tests/tcg/i386/README
new file mode 100644
index 0000000000..7a0a47bf27
--- /dev/null
+++ b/tests/tcg/i386/README
@@ -0,0 +1,38 @@
+These are i386 specific guest programs
+
+test-i386
+---------
+
+This program executes most of the 16 bit and 32 bit x86 instructions and
+generates a text output, for comparison with the output obtained with
+a real CPU or another emulator.
+
+The Linux system call modify_ldt() is used to create x86 selectors
+to test some 16 bit addressing and 32 bit with segmentation cases.
+
+The Linux system call vm86() is used to test vm86 emulation.
+
+Various exceptions are raised to test most of the x86 user space
+exception reporting.
+
+linux-test
+----------
+
+This program tests various Linux system calls. It is used to verify
+that the system call parameters are correctly converted between target
+and host CPUs.
+
+test-i386-fprem
+---------------
+
+runcom
+------
+
+test-mmap
+---------
+
+sha1
+----
+
+hello-i386
+----------
diff --git a/tests/tcg/hello-i386.c b/tests/tcg/i386/hello-i386.c
similarity index 100%
rename from tests/tcg/hello-i386.c
rename to tests/tcg/i386/hello-i386.c
diff --git a/tests/tcg/pi_10.com b/tests/tcg/i386/pi_10.com
similarity index 100%
rename from tests/tcg/pi_10.com
rename to tests/tcg/i386/pi_10.com
diff --git a/tests/tcg/runcom.c b/tests/tcg/i386/runcom.c
similarity index 100%
rename from tests/tcg/runcom.c
rename to tests/tcg/i386/runcom.c
diff --git a/tests/tcg/test-i386-code16.S b/tests/tcg/i386/test-i386-code16.S
similarity index 100%
rename from tests/tcg/test-i386-code16.S
rename to tests/tcg/i386/test-i386-code16.S
diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/i386/test-i386-fprem.c
similarity index 100%
rename from tests/tcg/test-i386-fprem.c
rename to tests/tcg/i386/test-i386-fprem.c
diff --git a/tests/tcg/test-i386-muldiv.h b/tests/tcg/i386/test-i386-muldiv.h
similarity index 100%
rename from tests/tcg/test-i386-muldiv.h
rename to tests/tcg/i386/test-i386-muldiv.h
diff --git a/tests/tcg/test-i386-shift.h b/tests/tcg/i386/test-i386-shift.h
similarity index 100%
rename from tests/tcg/test-i386-shift.h
rename to tests/tcg/i386/test-i386-shift.h
diff --git a/tests/tcg/test-i386-ssse3.c b/tests/tcg/i386/test-i386-ssse3.c
similarity index 100%
rename from tests/tcg/test-i386-ssse3.c
rename to tests/tcg/i386/test-i386-ssse3.c
diff --git a/tests/tcg/test-i386-vm86.S b/tests/tcg/i386/test-i386-vm86.S
similarity index 100%
rename from tests/tcg/test-i386-vm86.S
rename to tests/tcg/i386/test-i386-vm86.S
diff --git a/tests/tcg/test-i386.c b/tests/tcg/i386/test-i386.c
similarity index 100%
rename from tests/tcg/test-i386.c
rename to tests/tcg/i386/test-i386.c
diff --git a/tests/tcg/test-i386.h b/tests/tcg/i386/test-i386.h
similarity index 100%
rename from tests/tcg/test-i386.h
rename to tests/tcg/i386/test-i386.h
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (10 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 10:30   ` Thomas Huth
  2018-04-16  0:11   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c Alex Bennée
                   ` (13 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota

From: Fam Zheng <famz@redhat.com>

We have -Werror=missing-prototype, add a dummy prototype to avoid that
warning.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/tcg/i386/hello-i386.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c
index fa00380de2..cfeb24b2f5 100644
--- a/tests/tcg/i386/hello-i386.c
+++ b/tests/tcg/i386/hello-i386.c
@@ -20,6 +20,7 @@ static inline int write(int fd, const char * buf, int len)
   return status;
 }
 
+void _start(void);
 void _start(void)
 {
     write(1, "Hello World\n", 12);
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (11 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386 Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:33   ` Thomas Huth
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386 Alex Bennée
                   ` (12 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

The test mixes up 32bit and 64 bit code. It should probably be split
into two distinct test cases. However for now just move it out of the
way of the i386 build.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/{i386/test-i386-ssse3.c => x86_64/test-sse.c} | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
 rename tests/tcg/{i386/test-i386-ssse3.c => x86_64/test-sse.c} (93%)

diff --git a/tests/tcg/i386/test-i386-ssse3.c b/tests/tcg/x86_64/test-sse.c
similarity index 93%
rename from tests/tcg/i386/test-i386-ssse3.c
rename to tests/tcg/x86_64/test-sse.c
index 0a42bd03e2..196ec7f32f 100644
--- a/tests/tcg/i386/test-i386-ssse3.c
+++ b/tests/tcg/x86_64/test-sse.c
@@ -1,4 +1,4 @@
-/* See if various MMX/SSE SSSE3 instructions give expected results */
+/* See if various MMX/SSE SSSE3/4 instructions give expected results */
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -41,8 +41,7 @@ int main(int argc, char *argv[]) {
 	asm volatile ("movdqa  %%xmm0, (%0)" : : "r" (hello));
 	printf("%5.5s\n", hello);
 
-#if 1 /* SSE4 */
-	/* popcnt r64, r/m64 */
+	/* SSE4 popcnt r64, r/m64 */
 	asm volatile ("movq    $0x8421000010009c63, %%rax" : : : "rax");
 	asm volatile ("popcnt  %%ax, %%dx" : : : "dx");
 	asm volatile ("popcnt  %%eax, %%ecx" : : : "ecx");
@@ -51,7 +50,6 @@ int main(int argc, char *argv[]) {
 	asm volatile ("movl    %%ecx, %0" : "=m" (c));
 	asm volatile ("movw    %%dx, %0" : "=m" (d));
 	printf("%i = %i\n%i = %i = %i\n", 13, (int) a, 9, c, d + 1);
-#endif
 
 	return 0;
 }
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (12 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:36   ` Thomas Huth
  2018-04-16  0:13   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386 Alex Bennée
                   ` (11 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

The test-i386 test case is a little special as it includes assembler
files. Add the additional compile magic to assemble these bits and
link them to the final binary.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/i386/Makefile.target | 19 +++++++++++++++++++
 tests/tcg/i386/test-i386.c     |  1 -
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index 7dbb7992e7..1df69e0dab 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -8,3 +8,22 @@ ifdef CROSS_CC_GUEST_CFLAGS
 CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
 endif
 endif
+
+#
+# test-386 includes a couple of additional objects that need to be linked together
+#
+
+TEST_I386_DEPS=test-i386-code16.o test-i386-vm86.o
+
+# override the default compile and link in one go rule
+test-i386.o: test-i386.c
+	$(CC) $(CFLAGS) -c $< -o $@
+
+# and provide a rule to compile .S files
+%.o: %.S
+	$(CC) $(CFLAGS) -c $< -o $@
+
+test-i386: LDFLAGS+=-lm -lc
+test-i386: test-i386.o $(TEST_I386_DEPS)
+	$(LD) -melf_i386 $(LDFLAGS) $< $(TEST_I386_DEPS) -o $@
+
diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
index 9599204895..cae6a7773a 100644
--- a/tests/tcg/i386/test-i386.c
+++ b/tests/tcg/i386/test-i386.c
@@ -17,7 +17,6 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
-#include "qemu/compiler.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (13 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386 Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:38   ` Thomas Huth
  2018-04-16  0:14   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem Alex Bennée
                   ` (10 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

This is a direct syscall test so needs additional CFLAGS and LDFLAGS.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/i386/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index 1df69e0dab..44803c0382 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -9,6 +9,12 @@ CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
 endif
 endif
 
+#
+# hello-i386 is a barebones app
+#
+hello-i386: CFLAGS+=-ffreestanding
+hello-i386: LDFLAGS+=-nostdlib
+
 #
 # test-386 includes a couple of additional objects that need to be linked together
 #
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (14 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386 Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:14   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir Alex Bennée
                   ` (9 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

Remove dependencies on QEMU's source tree and build directly.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/i386/test-i386-fprem.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/tcg/i386/test-i386-fprem.c b/tests/tcg/i386/test-i386-fprem.c
index 1a71623204..771dc07433 100644
--- a/tests/tcg/i386/test-i386-fprem.c
+++ b/tests/tcg/i386/test-i386-fprem.c
@@ -23,7 +23,10 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "qemu/osdep.h"
+#include <stdio.h>
+#include <stdint.h>
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 /*
  * Inspired by <ieee754.h>'s union ieee854_long_double, but with single
@@ -39,7 +42,7 @@ union float80u {
         unsigned int exponent:15;
         unsigned int negative:1;
         unsigned int empty:16;
-    } QEMU_PACKED ieee;
+    } __attribute__((packed)) ieee;
 
     /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
     struct {
@@ -49,7 +52,7 @@ union float80u {
         unsigned int exponent:15;
         unsigned int negative:1;
         unsigned int empty:16;
-    } QEMU_PACKED ieee_nan;
+    } __attribute__((packed)) ieee_nan;
 };
 
 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (15 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:40   ` Thomas Huth
  2018-04-16  0:14   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm Alex Bennée
                   ` (8 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

These only need to be built for ARM guests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/README                      |  9 ---------
 tests/tcg/arm/README                  | 11 +++++++++++
 tests/tcg/{ => arm}/hello-arm.c       |  0
 tests/tcg/{ => arm}/test-arm-iwmmxt.s |  0
 4 files changed, 11 insertions(+), 9 deletions(-)
 create mode 100644 tests/tcg/arm/README
 rename tests/tcg/{ => arm}/hello-arm.c (100%)
 rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)

diff --git a/tests/tcg/README b/tests/tcg/README
index 469504c4cb..625f2326e6 100644
--- a/tests/tcg/README
+++ b/tests/tcg/README
@@ -5,15 +5,6 @@ or they are architecture specific.
 
 
 
-ARM
-===
-
-hello-arm
----------
-
-test-arm-iwmmxt
----------------
-
 MIPS
 ====
 
diff --git a/tests/tcg/arm/README b/tests/tcg/arm/README
new file mode 100644
index 0000000000..e6307116e2
--- /dev/null
+++ b/tests/tcg/arm/README
@@ -0,0 +1,11 @@
+These are ARM specific guest programs
+
+hello-arm
+---------
+
+A very simple inline assembly, write syscall based hello world
+
+test-arm-iwmmxt
+---------------
+
+A simple test case for older iwmmxt extended ARMs
diff --git a/tests/tcg/hello-arm.c b/tests/tcg/arm/hello-arm.c
similarity index 100%
rename from tests/tcg/hello-arm.c
rename to tests/tcg/arm/hello-arm.c
diff --git a/tests/tcg/test-arm-iwmmxt.s b/tests/tcg/arm/test-arm-iwmmxt.s
similarity index 100%
rename from tests/tcg/test-arm-iwmmxt.s
rename to tests/tcg/arm/test-arm-iwmmxt.s
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (16 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11 15:42   ` Thomas Huth
  2018-04-16  1:28   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir Alex Bennée
                   ` (7 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

As hello-arm is a bare bones syscall test it needs specific compiler
flags so it doesn't try and link against glibc.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/arm/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 tests/tcg/arm/Makefile.target

diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
new file mode 100644
index 0000000000..b7c146c88e
--- /dev/null
+++ b/tests/tcg/arm/Makefile.target
@@ -0,0 +1,6 @@
+# -*- Mode: makefile -*-
+#
+# ARM specific tweaks
+
+hello-arm: CFLAGS+=-marm -ffreestanding
+hello-arm: LDFLAGS+=-nostdlib
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (17 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-16  1:02   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x Alex Bennée
                   ` (6 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, famz, cota, Alex Bennée, Aurelien Jarno, Yongbok Kim

These only need to be built for MIPS guests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/README                  | 11 -----------
 tests/tcg/mips/README             |  7 +++++++
 tests/tcg/{ => mips}/hello-mips.c |  0
 3 files changed, 7 insertions(+), 11 deletions(-)
 create mode 100644 tests/tcg/mips/README
 rename tests/tcg/{ => mips}/hello-mips.c (100%)

diff --git a/tests/tcg/README b/tests/tcg/README
index 625f2326e6..a5643d33e7 100644
--- a/tests/tcg/README
+++ b/tests/tcg/README
@@ -3,17 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
 built for all guest architectures that support linux-user executable,
 or they are architecture specific.
 
-
-
-MIPS
-====
-
-hello-mips
-----------
-
-hello-mipsel
-------------
-
 CRIS
 ====
 The testsuite for CRIS is in tests/tcg/cris.  You can run it
diff --git a/tests/tcg/mips/README b/tests/tcg/mips/README
new file mode 100644
index 0000000000..e5bbc58ec5
--- /dev/null
+++ b/tests/tcg/mips/README
@@ -0,0 +1,7 @@
+MIPS
+====
+
+hello-mips
+----------
+
+A very simple inline assembly, write syscall based hello world
diff --git a/tests/tcg/hello-mips.c b/tests/tcg/mips/hello-mips.c
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (18 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-11  8:36   ` Cornelia Huck
  2018-04-16  1:33   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64 Alex Bennée
                   ` (5 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, famz, cota, Alex Bennée, Cornelia Huck, open list:S390

This doesn't add any additional tests but enables building the
multiarch tests for s390x.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/s390x/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/s390x/Makefile.include

diff --git a/tests/tcg/s390x/Makefile.include b/tests/tcg/s390x/Makefile.include
new file mode 100644
index 0000000000..1f58115d96
--- /dev/null
+++ b/tests/tcg/s390x/Makefile.include
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-s390x-cross
+DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (19 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-16  1:36   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target Alex Bennée
                   ` (4 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

Currently this just enables building the multiarch tests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/ppc64/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/ppc64/Makefile.include

diff --git a/tests/tcg/ppc64/Makefile.include b/tests/tcg/ppc64/Makefile.include
new file mode 100644
index 0000000000..d71cfc9aa7
--- /dev/null
+++ b/tests/tcg/ppc64/Makefile.include
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-ppc64el-cross
+DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (20 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64 Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-12  8:13   ` Fam Zheng
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets Alex Bennée
                   ` (3 subsequent siblings)
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

This make is now invoked from each individual target make with the
appropriate CC and ARCH set for each guest. It includes all the
multiarch tests by default as well as any tests from
tests/tcg/$(ARCH).

As there may be subtle additional requirements for building some of
the tests it also includes tests/tcg/$(ARCH)/Makefile.target if it is
available. This is distinct from tests/tcg/$(ARCH)/Makefile.include
which is used by the parent make machinery to determine potential
docker targets.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/Makefile | 185 ++++++++++++-----------------------------------------
 1 file changed, 42 insertions(+), 143 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 89e3342f3d..2bba0d2a32 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -1,156 +1,55 @@
--include ../../config-host.mak
--include $(SRC_PATH)/rules.mak
+# -*- Mode: makefile -*-
+#
+# TCG tests
+#
+# These are complicated by the fact we want to build them for guest
+# systems. This requires knowing what guests we are building and which
+# ones we have cross-compilers for or docker images with
+# cross-compilers.
+#
+# The tests themselves should be as minimal as possible as
+# cross-compilers don't always have a large amount of libraries
+# available.
+#
+# We only include the host build system for SRC_PATH and we don't
+# bother with the common rules.mk. We expect CC to have been set for
+# us from the parent make. We also expect to be in the tests build dir
+# for the FOO-linux-user.
+#
 
-$(call set-vpath, $(SRC_PATH)/tests/tcg)
+-include ../../config-host.mak
+-include ../config-target.mak
 
-QEMU=../../i386-linux-user/qemu-i386
-QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
-CC_X86_64=$(CC_I386) -m64
+# Set search path for all sources
+VPATH = $(SRC_PATH)/tests/tcg/multiarch
+TEST_SRCS = $(wildcard $(SRC_PATH)/tests/tcg/multiarch/*.c)
 
-QEMU_INCLUDES += -I../..
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing
-#CFLAGS+=-msse2
-LDFLAGS=
+VPATH     += $(SRC_PATH)/tests/tcg/$(ARCH)
+TEST_SRCS += $(wildcard $(SRC_PATH)/tests/tcg/$(ARCH)/*.c)
 
-# TODO: automatically detect ARM and MIPS compilers, and run those too
+SRCS=$(notdir ${TEST_SRCS})
+TESTS=$(SRCS:.c=)
 
-# runcom maps page 0, so it requires root privileges
-# also, pi_10.com runs indefinitely
+# We use what ever CC we have
+CFLAGS=-Wall -O0 -g -fno-strict-aliasing -static
+QEMU_CFLAGS=
+LDFLAGS=
 
-I386_TESTS=hello-i386 \
-	   linux-test \
-	   testthread \
-	   sha1-i386 \
-	   test-i386 \
-	   test-i386-fprem \
-	   test-mmap \
-	   # runcom
+# The per ARCH target makefile which might add specific compiler flags
+# for some compilation targets.
 
-# native i386 compilers sometimes are not biarch.  assume cross-compilers are
-ifneq ($(ARCH),i386)
-I386_TESTS+=run-test-x86_64
-endif
+EXTRA_MAKEFILE=$(SRC_PATH)/tests/tcg/$(ARCH)/Makefile.target
+CHECK_INCLUDE=$(wildcard $(EXTRA_MAKEFILE))
 
-TESTS = test_path
-ifneq ($(call find-in-path, $(CC_I386)),)
-TESTS += $(I386_TESTS)
+ifeq ($(EXTRA_MAKEFILE),$(CHECK_INCLUDE))
+include $(EXTRA_MAKEFILE)
 endif
 
-all: $(patsubst %,run-%,$(TESTS))
-test: all
-
-# rules to run tests
-
-.PHONY: $(patsubst %,run-%,$(TESTS))
-
-run-%: %
-	-$(QEMU) ./$*
-
-run-hello-i386: hello-i386
-run-linux-test: linux-test
-run-testthread: testthread
-run-sha1-i386: sha1-i386
-
-run-test-i386: test-i386
-	./test-i386 > test-i386.ref
-	-$(QEMU) test-i386 > test-i386.out
-	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
-
-run-test-i386-fprem: test-i386-fprem
-	./test-i386-fprem > test-i386-fprem.ref
-	-$(QEMU) test-i386-fprem > test-i386-fprem.out
-	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
-
-run-test-x86_64: test-x86_64
-	./test-x86_64 > test-x86_64.ref
-	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
-	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
-
-run-test-mmap: test-mmap
-	-$(QEMU) ./test-mmap
-	-$(QEMU) -p 8192 ./test-mmap 8192
-	-$(QEMU) -p 16384 ./test-mmap 16384
-	-$(QEMU) -p 32768 ./test-mmap 32768
-
-run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
-
-run-test_path: test_path
-	./test_path
-
-# rules to compile tests
-
-test_path: test_path.o
-
-test_path.o: test_path.c
-
-hello-i386: hello-i386.c
-	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
-	strip $@
-
-testthread: testthread.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
-
-# i386/x86_64 emulation test (test various opcodes) */
-test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
-           test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
-              $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
-
-test-i386-fprem: test-i386-fprem.c
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-test-x86_64: test-i386.c \
-           test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
-
-# generic Linux and CPU test
-linux-test: linux-test.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
-
-# vm86 test
-runcom: runcom.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-test-mmap: test-mmap.c
-	$(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $<
-
-# speed test
-sha1-i386: sha1.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-sha1: sha1.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-speed: sha1 sha1-i386
-	time ./sha1
-	time $(QEMU) ./sha1-i386
-
-# arm test
-hello-arm: hello-arm.o
-	arm-linux-ld -o $@ $<
-
-hello-arm.o: hello-arm.c
-	arm-linux-gcc -Wall -g -O2 -c -o $@ $<
-
-test-arm-iwmmxt: test-arm-iwmmxt.s
-	cpp < $< | arm-linux-gnu-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
-
-# MIPS test
-hello-mips: hello-mips.c
-	mips-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
-
-hello-mipsel: hello-mips.c
-	mipsel-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
+testthread: LDFLAGS=-lpthread
 
-# testsuite for the CRIS port.
-test-cris:
-	$(MAKE) -C cris check
+%: %.c
+	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
 
-# testsuite for the LM32 port.
-test-lm32:
-	$(MAKE) -C lm32 check
+all: $(TESTS)
 
-clean:
-	rm -f *~ *.o test-i386.out test-i386.ref \
-           test-x86_64.log test-x86_64.ref qruncom $(TESTS)
+# There is no clean target, the calling make just rm's the tests build dir
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (21 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-16  1:12   ` Philippe Mathieu-Daudé
  2018-04-16  1:52   ` Philippe Mathieu-Daudé
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets Alex Bennée
                   ` (2 subsequent siblings)
  25 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

Now all the build infrastructure is in place we can build tests for
each guest that we support. That support mainly depends on having
cross compilers installed or docker setup. To keep all the logic for
that together we put the rules in tests/tcg/Makefile.include and
include it from the main Makefile.target.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include

diff --git a/Makefile.target b/Makefile.target
index d0ec77a307..a30fd40257 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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
 
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
new file mode 100644
index 0000000000..cb8bb36026
--- /dev/null
+++ b/tests/tcg/Makefile.include
@@ -0,0 +1,79 @@
+# -*- Mode: makefile -*-
+#
+# TCG tests (per-target rules)
+#
+# This Makefile fragement is included from the per-target
+# Makefile.target so will be invoked for each linux-user program we
+# build. We have two options for compiling, either using a configured
+# guest compiler or calling one of our docker images to do it for us.
+#
+
+# The per ARCH makefile, if it exists holds extra information about
+# useful docker images or alternative compiler flags. Include it if it
+# exists
+
+ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
+CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
+
+ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
+include $(ARCH_MAKEFILE)
+endif
+
+GUEST_BUILD=
+
+# Support installed Cross Compilers
+
+ifdef CROSS_CC_GUEST
+
+.PHONY: cross-build-guest-tests
+cross-build-guest-tests:
+	$(call quiet-command, \
+          (mkdir -p tests && cd tests && \
+	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
+	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
+
+
+GUEST_BUILD=cross-build-guest-tests
+
+endif
+
+# Support building with Docker
+
+ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
+ifneq ($(DOCKER_IMAGE),)
+
+# We also need the Docker make rules to depend on
+include $(SRC_PATH)/tests/docker/Makefile.include
+
+DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
+		--cc $(DOCKER_CROSS_COMPILER) \
+		-i qemu:$(DOCKER_IMAGE) \
+		-s $(SRC_PATH) -- "
+DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
+
+.PHONY: docker-build-guest-tests
+docker-build-guest-tests: $(DOCKER_PREREQ)
+	$(call quiet-command, \
+          (mkdir -p tests && cd tests && \
+	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
+	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
+
+GUEST_BUILD=docker-build-guest-tests
+
+endif
+endif
+
+# Final targets
+.PHONY: guest-tests
+
+ifneq ($(GUEST_BUILD),)
+guest-tests: $(GUEST_BUILD)
+else
+guest-tests:
+	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
+endif
+
+# It doesn't mater if these don't exits
+.PHONY: clean-guest-tests
+clean-guest-tests:
+	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
-- 
2.16.2

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

* [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (22 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets Alex Bennée
@ 2018-04-10 19:39 ` Alex Bennée
  2018-04-16  1:53   ` Philippe Mathieu-Daudé
  2018-04-10 20:07 ` [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg no-reply
  2018-04-16 10:37 ` Philippe Mathieu-Daudé
  25 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-10 19:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, famz, cota, Alex Bennée

This will ensure all linux-user targets build their guest test
programs.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/Makefile.include | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3d2f0458ab..c402de901e 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -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
@@ -916,6 +917,23 @@ 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 %,tcg-tests-%, $(LINUX_USER_TARGETS))
+CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(LINUX_USER_TARGETS))
+
+tcg-tests-%:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" guest-tests,)
+
+clean-tcg-tests-%:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
+
+.PHONY: check-tcg
+check-tcg: $(BUILD_TCG_TARGET_RULES)
+
+.PHONY: clean-tcg
+clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 
 # Other tests
 
@@ -958,7 +976,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
-- 
2.16.2

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

* Re: [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (23 preceding siblings ...)
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets Alex Bennée
@ 2018-04-10 20:07 ` no-reply
  2018-04-16 10:37 ` Philippe Mathieu-Daudé
  25 siblings, 0 replies; 83+ messages in thread
From: no-reply @ 2018-04-10 20:07 UTC (permalink / raw)
  To: alex.bennee; +Cc: famz, qemu-devel

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180410193919.28026-1-alex.bennee@linaro.org
Subject: [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180410193919.28026-1-alex.bennee@linaro.org -> patchew/20180410193919.28026-1-alex.bennee@linaro.org
Switched to a new branch 'test'
90c03a56a7 tests/Makefile.include: add (clean-)check-tcg targets
4d10ecddd9 Makefile.target: add (clean-)guest-tests targets
419d213b73 tests/tcg/Makefile: update to be called from Makefile.target
42375e278e tests/tcg: enable building for ppc64
48844c4a0b tests/tcg: enable building for s390x
30148808c5 tests/tcg: move MIPS specific tests into subdir
2e1ca97890 tests/tcg/arm: fix hello-arm
7e47cb78d1 tests/tcg: move ARM specific tests into subdir
ae14cce45a tests/tcg/i386: fix test-i386-fprem
fff9127a52 tests/tcg/i368: fix hello-i386
32defdca05 tests/tcg/i386: fix test-i386
f29d705818 tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c
420cad3ca6 tests/tcg/i386: Build fix for hello-i386
b9c79e9220 tests/tcg: move i386 specific tests into subdir
d3d8bafea4 tests/tcg/multiarch: Build fix for linux-test
a0e4f21091 tests/tcg: move architecture independent tests into subdir
4b155dc50c docker: Makefile.include introduce DOCKER_SCRIPT
a8974c3037 docker: allow "cc" command to run in user context
2b879dfb5c docker: extend "cc" command to accept compiler
948d434a34 docker: Add "cc" subcommand
6464064827 Makefile: Rename TARGET_DIRS to TARGET_LIST
ca85716ee3 configure: move i386_cc to cross_cc_i386
d0197823de configure: add support for --cross-cc-FOO
ebd12f8f96 configure: add test for docker availability

=== OUTPUT BEGIN ===
Checking PATCH 1/24: configure: add test for docker availability...
Checking PATCH 2/24: configure: add support for --cross-cc-FOO...
Checking PATCH 3/24: configure: move i386_cc to cross_cc_i386...
Checking PATCH 4/24: Makefile: Rename TARGET_DIRS to TARGET_LIST...
Checking PATCH 5/24: docker: Add "cc" subcommand...
Checking PATCH 6/24: docker: extend "cc" command to accept compiler...
Checking PATCH 7/24: docker: allow "cc" command to run in user context...
Checking PATCH 8/24: docker: Makefile.include introduce DOCKER_SCRIPT...
Checking PATCH 9/24: tests/tcg: move architecture independent tests into subdir...
Checking PATCH 10/24: tests/tcg/multiarch: Build fix for linux-test...
ERROR: if this code is redundant consider removing it
#152: FILE: tests/tcg/multiarch/linux-test.c:323:
+#if 0

total: 1 errors, 0 warnings, 185 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 11/24: tests/tcg: move i386 specific tests into subdir...
Checking PATCH 12/24: tests/tcg/i386: Build fix for hello-i386...
ERROR: externs should be avoided in .c files
#20: FILE: tests/tcg/i386/hello-i386.c:23:
+void _start(void);

total: 1 errors, 0 warnings, 7 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 13/24: tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c...
ERROR: code indent should never use tabs
#36: FILE: tests/tcg/x86_64/test-sse.c:44:
+^I/* SSE4 popcnt r64, r/m64 */$

total: 1 errors, 0 warnings, 21 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 14/24: tests/tcg/i386: fix test-i386...
Checking PATCH 15/24: tests/tcg/i368: fix hello-i386...
Checking PATCH 16/24: tests/tcg/i386: fix test-i386-fprem...
Checking PATCH 17/24: tests/tcg: move ARM specific tests into subdir...
Checking PATCH 18/24: tests/tcg/arm: fix hello-arm...
Checking PATCH 19/24: tests/tcg: move MIPS specific tests into subdir...
Checking PATCH 20/24: tests/tcg: enable building for s390x...
Checking PATCH 21/24: tests/tcg: enable building for ppc64...
Checking PATCH 22/24: tests/tcg/Makefile: update to be called from Makefile.target...
Checking PATCH 23/24: Makefile.target: add (clean-)guest-tests targets...
Checking PATCH 24/24: tests/Makefile.include: add (clean-)check-tcg targets...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x Alex Bennée
@ 2018-04-11  8:36   ` Cornelia Huck
  2018-04-16  1:33   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Cornelia Huck @ 2018-04-11  8:36 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, famz, cota, open list:S390

On Tue, 10 Apr 2018 20:39:15 +0100
Alex Bennée <alex.bennee@linaro.org> wrote:

> This doesn't add any additional tests but enables building the
> multiarch tests for s390x.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/s390x/Makefile.include | 2 ++
>  1 file changed, 2 insertions(+)
>  create mode 100644 tests/tcg/s390x/Makefile.include
> 
> diff --git a/tests/tcg/s390x/Makefile.include b/tests/tcg/s390x/Makefile.include
> new file mode 100644
> index 0000000000..1f58115d96
> --- /dev/null
> +++ b/tests/tcg/s390x/Makefile.include
> @@ -0,0 +1,2 @@
> +DOCKER_IMAGE=debian-s390x-cross
> +DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc

Acked-by: Cornelia Huck <cohuck@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability Alex Bennée
@ 2018-04-11  8:50   ` Fam Zheng
  2018-04-11 10:58     ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Fam Zheng @ 2018-04-11  8:50 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, cota

On Tue, 04/10 20:38, Alex Bennée wrote:
> This tests for a working docker installation without sudo and sets up
> config-host.mak accordingly. This will be useful from cross compiling
> things in the future.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/configure b/configure
> index 4d0e92c96c..b402befe94 100755
> --- a/configure
> +++ b/configure
> @@ -451,6 +451,7 @@ jemalloc="no"
>  replication="yes"
>  vxhs=""
>  libxml2=""
> +docker="no"
>  
>  supported_cpu="no"
>  supported_os="no"
> @@ -5396,6 +5397,23 @@ EOF
>    fi
>  fi
>  
> +##########################################
> +# Docker and cross-compiler support
> +#
> +# This is specifically for building test
> +# cases for foreign architectures, not
> +# cross-compiling QEMU itself.
> +
> +if has "docker"; then
> +    if docker images  >/dev/null 2>&1 ; then
> +        docker="yes"
> +    else
> +        # docker may be available but using sudo
> +        # so we won't use it for cross-building
> +        docker="maybe"

What is the problem with using sudo for cross-building?

Fam

> +    fi
> +fi
> +
>  ##########################################
>  # End of CC checks
>  # After here, no more $cc or $ld runs
> @@ -5857,6 +5875,7 @@ echo "avx2 optimization $avx2_opt"
>  echo "replication support $replication"
>  echo "VxHS block device $vxhs"
>  echo "capstone          $capstone"
> +echo "docker            $docker"
>  
>  if test "$sdl_too_old" = "yes"; then
>  echo "-> Your SDL version is too old - please upgrade to have SDL support"
> @@ -6680,6 +6699,10 @@ if test "$gcov" = "yes" ; then
>    echo "GCOV=$gcov_tool" >> $config_host_mak
>  fi
>  
> +if test "$docker" = "yes"; then
> +    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
> +fi
> +
>  # use included Linux headers
>  if test "$linux" = "yes" ; then
>    mkdir -p linux-headers
> -- 
> 2.16.2
> 

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

* Re: [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir Alex Bennée
@ 2018-04-11 10:22   ` Thomas Huth
  2018-04-16  0:05   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 10:22 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> We will want to build these for all supported guest architectures so
> lets move them all into one place. We also drop test_path at this
> point because it needs qemu utils and glib bits which is hard to
> support for cross compiling.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/README                       |  10 +--
>  tests/tcg/multiarch/README             |   1 +
>  tests/tcg/{ => multiarch}/linux-test.c |   0
>  tests/tcg/{ => multiarch}/sha1.c       |   0
>  tests/tcg/{ => multiarch}/test-mmap.c  |   0
>  tests/tcg/{ => multiarch}/testthread.c |   0
>  tests/tcg/test_path.c                  | 157 ---------------------------------
>  7 files changed, 5 insertions(+), 163 deletions(-)
>  create mode 100644 tests/tcg/multiarch/README
>  rename tests/tcg/{ => multiarch}/linux-test.c (100%)
>  rename tests/tcg/{ => multiarch}/sha1.c (100%)
>  rename tests/tcg/{ => multiarch}/test-mmap.c (100%)
>  rename tests/tcg/{ => multiarch}/testthread.c (100%)
>  delete mode 100644 tests/tcg/test_path.c

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test Alex Bennée
@ 2018-04-11 10:25   ` Thomas Huth
       [not found]   ` <4bc22552-25b4-2a04-dc73-dc17201a2251@amsat.org>
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 10:25 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> From: Fam Zheng <famz@redhat.com>
> 
> To keep the compiler happy, and to fit in our buildsys flags:
> 
> - Make local functions "static"
> - #ifdef out unused functions
> - drop cutils/osdep dependencies
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> [AJB: drop cutils/osdep dependencies]
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
>  1 file changed, 21 insertions(+), 47 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir Alex Bennée
@ 2018-04-11 10:30   ` Thomas Huth
  2018-04-16  0:08   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 10:30 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> These only need to be built for i386 guests. This includes a stub
> tests/tcg/i386/Makfile.target which absorbs some of what was in
> tests/tcg/Makefile.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/README                        |  39 --------------------------------
>  tests/tcg/i386/Makefile.target          |  10 ++++++++
>  tests/tcg/i386/README                   |  38 +++++++++++++++++++++++++++++++
>  tests/tcg/{ => i386}/hello-i386.c       |   0
>  tests/tcg/{ => i386}/pi_10.com          | Bin
>  tests/tcg/{ => i386}/runcom.c           |   0
>  tests/tcg/{ => i386}/test-i386-code16.S |   0
>  tests/tcg/{ => i386}/test-i386-fprem.c  |   0
>  tests/tcg/{ => i386}/test-i386-muldiv.h |   0
>  tests/tcg/{ => i386}/test-i386-shift.h  |   0
>  tests/tcg/{ => i386}/test-i386-ssse3.c  |   0
>  tests/tcg/{ => i386}/test-i386-vm86.S   |   0

Maybe remove the "-i386-" part from the file name now?

Anyway:

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386 Alex Bennée
@ 2018-04-11 10:30   ` Thomas Huth
  2018-04-16  0:11   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 10:30 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> From: Fam Zheng <famz@redhat.com>
> 
> We have -Werror=missing-prototype, add a dummy prototype to avoid that
> warning.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/tcg/i386/hello-i386.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c
> index fa00380de2..cfeb24b2f5 100644
> --- a/tests/tcg/i386/hello-i386.c
> +++ b/tests/tcg/i386/hello-i386.c
> @@ -20,6 +20,7 @@ static inline int write(int fd, const char * buf, int len)
>    return status;
>  }
>  
> +void _start(void);
>  void _start(void)
>  {
>      write(1, "Hello World\n", 12);
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability
  2018-04-11  8:50   ` Fam Zheng
@ 2018-04-11 10:58     ` Alex Bennée
  2018-04-11 12:59       ` Fam Zheng
  0 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-11 10:58 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel, berrange, cota


Fam Zheng <famz@redhat.com> writes:

> On Tue, 04/10 20:38, Alex Bennée wrote:
>> This tests for a working docker installation without sudo and sets up
>> config-host.mak accordingly. This will be useful from cross compiling
>> things in the future.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  configure | 23 +++++++++++++++++++++++
>>  1 file changed, 23 insertions(+)
>>
>> diff --git a/configure b/configure
>> index 4d0e92c96c..b402befe94 100755
>> --- a/configure
>> +++ b/configure
>> @@ -451,6 +451,7 @@ jemalloc="no"
>>  replication="yes"
>>  vxhs=""
>>  libxml2=""
>> +docker="no"
>>
>>  supported_cpu="no"
>>  supported_os="no"
>> @@ -5396,6 +5397,23 @@ EOF
>>    fi
>>  fi
>>
>> +##########################################
>> +# Docker and cross-compiler support
>> +#
>> +# This is specifically for building test
>> +# cases for foreign architectures, not
>> +# cross-compiling QEMU itself.
>> +
>> +if has "docker"; then
>> +    if docker images  >/dev/null 2>&1 ; then
>> +        docker="yes"
>> +    else
>> +        # docker may be available but using sudo
>> +        # so we won't use it for cross-building
>> +        docker="maybe"
>
> What is the problem with using sudo for cross-building?

Nothing in particular but we need someway of testing if the sudo is
passwordless otherwise you might find the build stuck waiting for user
interaction. This is fine for "make docker-foo" but for an eventual
unattended "make check" this may cause problems.

Is there a way we can test for this? Maybe we can push the docker probe
into docker.py and just return to configure if it can run docker
unattended?

--
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability
  2018-04-11 10:58     ` Alex Bennée
@ 2018-04-11 12:59       ` Fam Zheng
  0 siblings, 0 replies; 83+ messages in thread
From: Fam Zheng @ 2018-04-11 12:59 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, cota

On Wed, 04/11 11:58, Alex Bennée wrote:
> 
> Fam Zheng <famz@redhat.com> writes:
> 
> > On Tue, 04/10 20:38, Alex Bennée wrote:
> >> This tests for a working docker installation without sudo and sets up
> >> config-host.mak accordingly. This will be useful from cross compiling
> >> things in the future.
> >>
> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> >> ---
> >>  configure | 23 +++++++++++++++++++++++
> >>  1 file changed, 23 insertions(+)
> >>
> >> diff --git a/configure b/configure
> >> index 4d0e92c96c..b402befe94 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -451,6 +451,7 @@ jemalloc="no"
> >>  replication="yes"
> >>  vxhs=""
> >>  libxml2=""
> >> +docker="no"
> >>
> >>  supported_cpu="no"
> >>  supported_os="no"
> >> @@ -5396,6 +5397,23 @@ EOF
> >>    fi
> >>  fi
> >>
> >> +##########################################
> >> +# Docker and cross-compiler support
> >> +#
> >> +# This is specifically for building test
> >> +# cases for foreign architectures, not
> >> +# cross-compiling QEMU itself.
> >> +
> >> +if has "docker"; then
> >> +    if docker images  >/dev/null 2>&1 ; then
> >> +        docker="yes"
> >> +    else
> >> +        # docker may be available but using sudo
> >> +        # so we won't use it for cross-building
> >> +        docker="maybe"
> >
> > What is the problem with using sudo for cross-building?
> 
> Nothing in particular but we need someway of testing if the sudo is
> passwordless otherwise you might find the build stuck waiting for user
> interaction. This is fine for "make docker-foo" but for an eventual
> unattended "make check" this may cause problems.
> 
> Is there a way we can test for this? Maybe we can push the docker probe
> into docker.py and just return to configure if it can run docker
> unattended?

We can try 'sudo -n -k docker' to test if passwordless docker works. According
to the manpage, -k ignores the credential cache, and -n ensures non-interaction.

Fam

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

* Re: [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT Alex Bennée
@ 2018-04-11 15:10   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-11 15:10 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: berrange, famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> Define this in one place to make it easy to re-use.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/docker/Makefile.include | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index de87341528..6a5aa9ec71 100644
> --- a/tests/docker/Makefile.include
> +++ b/tests/docker/Makefile.include
> @@ -14,6 +14,8 @@ DOCKER_TESTS := $(notdir $(shell \
>  
>  DOCKER_TOOLS := travis
>  
> +DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py
> +
>  TESTS ?= %
>  IMAGES ?= %
>  
> @@ -37,7 +39,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
>  		echo WARNING: EXECUTABLE is not set, debootstrap may fail. 2>&1 ; \
>  	fi
>  	$(call quiet-command,\
> -		$(SRC_PATH)/tests/docker/docker.py build qemu:$* $< \
> +		$(DOCKER_SCRIPT) build qemu:$* $< \
>  		$(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
>  		$(if $(NOUSER),,--add-current-user) \
>  		$(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
> @@ -129,11 +131,11 @@ docker-run: docker-qemu-src
>  	fi
>  	$(if $(EXECUTABLE),						\
>  		$(call quiet-command,					\
> -			$(SRC_PATH)/tests/docker/docker.py update 	\
> +			$(DOCKER_SCRIPT) update 			\
>  			$(IMAGE) $(EXECUTABLE),				\
>  			"  COPYING $(EXECUTABLE) to $(IMAGE)"))
>  	$(call quiet-command,						\
> -		$(SRC_PATH)/tests/docker/docker.py run 			\
> +		$(DOCKER_SCRIPT) run 					\
>  			$(if $(NOUSER),,-u $(shell id -u)) 		\
>  			--security-opt seccomp=unconfined		\
>  			$(if $V,,--rm) 					\
> @@ -163,4 +165,4 @@ docker-run-%:
>  	@$(MAKE) docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE)
>  
>  docker-clean:
> -	$(call quiet-command, $(SRC_PATH)/tests/docker/docker.py clean)
> +	$(call quiet-command, $(DOCKER_SCRIPT) clean)
> 

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

* Re: [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem Alex Bennée
@ 2018-04-11 15:14   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-11 15:14 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> Remove dependencies on QEMU's source tree and build directly.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/tcg/i386/test-i386-fprem.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/tcg/i386/test-i386-fprem.c b/tests/tcg/i386/test-i386-fprem.c
> index 1a71623204..771dc07433 100644
> --- a/tests/tcg/i386/test-i386-fprem.c
> +++ b/tests/tcg/i386/test-i386-fprem.c
> @@ -23,7 +23,10 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -#include "qemu/osdep.h"
> +#include <stdio.h>
> +#include <stdint.h>
> +
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
>  
>  /*
>   * Inspired by <ieee754.h>'s union ieee854_long_double, but with single
> @@ -39,7 +42,7 @@ union float80u {
>          unsigned int exponent:15;
>          unsigned int negative:1;
>          unsigned int empty:16;
> -    } QEMU_PACKED ieee;
> +    } __attribute__((packed)) ieee;
>  
>      /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
>      struct {
> @@ -49,7 +52,7 @@ union float80u {
>          unsigned int exponent:15;
>          unsigned int negative:1;
>          unsigned int empty:16;
> -    } QEMU_PACKED ieee_nan;
> +    } __attribute__((packed)) ieee_nan;
>  };
>  
>  #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
> 

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

* Re: [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c Alex Bennée
@ 2018-04-11 15:33   ` Thomas Huth
  2018-04-11 16:19     ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 15:33 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> The test mixes up 32bit and 64 bit code. It should probably be split
> into two distinct test cases. However for now just move it out of the
> way of the i386 build.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/{i386/test-i386-ssse3.c => x86_64/test-sse.c} | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>  rename tests/tcg/{i386/test-i386-ssse3.c => x86_64/test-sse.c} (93%)

Do we really want to have a separate x86_64 folder here? We also have
64-bit code in hw/i386/ and target/i386/ so I don't think that we should
handle this differently for tests/tcg/i386 ? Wouldn't it be sufficient
to simply move this code to a separate file? ... just my 0.02 €

 Thomas

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

* Re: [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386 Alex Bennée
@ 2018-04-11 15:36   ` Thomas Huth
  2018-04-16  0:13   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 15:36 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> The test-i386 test case is a little special as it includes assembler
> files. Add the additional compile magic to assemble these bits and
> link them to the final binary.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/i386/Makefile.target | 19 +++++++++++++++++++
>  tests/tcg/i386/test-i386.c     |  1 -
>  2 files changed, 19 insertions(+), 1 deletion(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386 Alex Bennée
@ 2018-04-11 15:38   ` Thomas Huth
  2018-04-16  0:14   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 15:38 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> This is a direct syscall test so needs additional CFLAGS and LDFLAGS.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/i386/Makefile.target | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
> index 1df69e0dab..44803c0382 100644
> --- a/tests/tcg/i386/Makefile.target
> +++ b/tests/tcg/i386/Makefile.target
> @@ -9,6 +9,12 @@ CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
>  endif
>  endif
>  
> +#
> +# hello-i386 is a barebones app
> +#
> +hello-i386: CFLAGS+=-ffreestanding
> +hello-i386: LDFLAGS+=-nostdlib
> +
>  #
>  # test-386 includes a couple of additional objects that need to be linked together
>  #
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir Alex Bennée
@ 2018-04-11 15:40   ` Thomas Huth
  2018-04-16  0:14   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 15:40 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> These only need to be built for ARM guests.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/README                      |  9 ---------
>  tests/tcg/arm/README                  | 11 +++++++++++
>  tests/tcg/{ => arm}/hello-arm.c       |  0
>  tests/tcg/{ => arm}/test-arm-iwmmxt.s |  0
>  4 files changed, 11 insertions(+), 9 deletions(-)
>  create mode 100644 tests/tcg/arm/README
>  rename tests/tcg/{ => arm}/hello-arm.c (100%)
>  rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm Alex Bennée
@ 2018-04-11 15:42   ` Thomas Huth
  2018-04-16  1:28   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Thomas Huth @ 2018-04-11 15:42 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 10.04.2018 21:39, Alex Bennée wrote:
> As hello-arm is a bare bones syscall test it needs specific compiler
> flags so it doesn't try and link against glibc.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/arm/Makefile.target | 6 ++++++
>  1 file changed, 6 insertions(+)
>  create mode 100644 tests/tcg/arm/Makefile.target

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c
  2018-04-11 15:33   ` Thomas Huth
@ 2018-04-11 16:19     ` Alex Bennée
  0 siblings, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-11 16:19 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, famz, cota


Thomas Huth <thuth@redhat.com> writes:

> On 10.04.2018 21:39, Alex Bennée wrote:
>> The test mixes up 32bit and 64 bit code. It should probably be split
>> into two distinct test cases. However for now just move it out of the
>> way of the i386 build.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/tcg/{i386/test-i386-ssse3.c => x86_64/test-sse.c} | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>  rename tests/tcg/{i386/test-i386-ssse3.c => x86_64/test-sse.c} (93%)
>
> Do we really want to have a separate x86_64 folder here? We also have
> 64-bit code in hw/i386/ and target/i386/ so I don't think that we should
> handle this differently for tests/tcg/i386 ? Wouldn't it be sufficient
> to simply move this code to a separate file? ... just my 0.02 €

It's certainly simpler for the build rules to have a simple mapping from
$(TARGET_NAME) to tests/tcg/FOO....

--
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler Alex Bennée
@ 2018-04-12  8:07   ` Fam Zheng
  0 siblings, 0 replies; 83+ messages in thread
From: Fam Zheng @ 2018-04-12  8:07 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, cota, Philippe Mathieu-Daudé

On Tue, 04/10 20:39, Alex Bennée wrote:
> When calling our cross-compilation images we want to call something
> other than the default cc.

Makes sense to me!

> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/docker/docker.py | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 8733266153..9444f4bea4 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -397,6 +397,8 @@ class CcCommand(SubCommand):
>      def args(self, parser):
>          parser.add_argument("--image", "-i", required=True,
>                              help="The docker image in which to run cc")
> +        parser.add_argument("--cc",
> +                            help="The compiler executable to call")

If add "default='cc'" to this call, we don't need the 'if args.cc' check below.

>          parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
>                              help="""Extra paths to (ro) mount into container for
>                              reading sources""")
> @@ -407,9 +409,19 @@ class CcCommand(SubCommand):
>          cwd = os.getcwd()
>          cmd = ["--rm", "-w", cwd,
>                 "-v", "%s:%s:rw" % (cwd, cwd)]
> -        for p in args.paths:
> -           cmd += ["-v", "%s:%s:ro,z" % (p, p)]
> -        cmd += [args.image, "cc"]
> +
> +        if args.paths:
> +            for p in args.paths:
> +                cmd += ["-v", "%s:%s:ro,z" % (p, p)]

I'm not sure the introduction of this if condition belongs to this patch, or is
necessary at all. Could you confirm?

Thanks.

Fam

> +
> +        cmd += [args.image]
> +
> +        # The compile command we are running
> +        if args.cc:
> +            cmd += [args.cc]
> +        else:
> +            cmd += ["cc"]
> +
>          cmd += argv
>          return Docker().command("run", cmd, True)
>  
> -- 
> 2.16.2
> 

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

* Re: [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context Alex Bennée
@ 2018-04-12  8:08   ` Fam Zheng
  2018-04-16  0:02   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Fam Zheng @ 2018-04-12  8:08 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, cota, Philippe Mathieu-Daudé

On Tue, 04/10 20:39, Alex Bennée wrote:
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/docker/docker.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 9444f4bea4..f79213044d 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -399,6 +399,8 @@ class CcCommand(SubCommand):
>                              help="The docker image in which to run cc")
>          parser.add_argument("--cc",
>                              help="The compiler executable to call")
> +        parser.add_argument("--user",
> +                            help="The user-id to run under")
>          parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
>                              help="""Extra paths to (ro) mount into container for
>                              reading sources""")
> @@ -414,6 +416,9 @@ class CcCommand(SubCommand):
>              for p in args.paths:
>                  cmd += ["-v", "%s:%s:ro,z" % (p, p)]
>  
> +        if args.user:
> +            cmd += ["-u", args.user]
> +
>          cmd += [args.image]
>  
>          # The compile command we are running
> -- 
> 2.16.2
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

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

* Re: [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target Alex Bennée
@ 2018-04-12  8:13   ` Fam Zheng
  2018-04-12  8:47     ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Fam Zheng @ 2018-04-12  8:13 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, cota

On Tue, 04/10 20:39, Alex Bennée wrote:
> This make is now invoked from each individual target make with the
> appropriate CC and ARCH set for each guest. It includes all the
> multiarch tests by default as well as any tests from
> tests/tcg/$(ARCH).
> 
> As there may be subtle additional requirements for building some of
> the tests it also includes tests/tcg/$(ARCH)/Makefile.target if it is
> available. This is distinct from tests/tcg/$(ARCH)/Makefile.include
> which is used by the parent make machinery to determine potential
> docker targets.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/Makefile | 185 ++++++++++++-----------------------------------------
>  1 file changed, 42 insertions(+), 143 deletions(-)
> 
> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
> index 89e3342f3d..2bba0d2a32 100644
> --- a/tests/tcg/Makefile
> +++ b/tests/tcg/Makefile
> @@ -1,156 +1,55 @@
> --include ../../config-host.mak
> --include $(SRC_PATH)/rules.mak
> +# -*- Mode: makefile -*-
> +#
> +# TCG tests
> +#
> +# These are complicated by the fact we want to build them for guest
> +# systems. This requires knowing what guests we are building and which
> +# ones we have cross-compilers for or docker images with
> +# cross-compilers.
> +#
> +# The tests themselves should be as minimal as possible as
> +# cross-compilers don't always have a large amount of libraries
> +# available.
> +#
> +# We only include the host build system for SRC_PATH and we don't
> +# bother with the common rules.mk. We expect CC to have been set for
> +# us from the parent make. We also expect to be in the tests build dir
> +# for the FOO-linux-user.
> +#
>  
> -$(call set-vpath, $(SRC_PATH)/tests/tcg)
> +-include ../../config-host.mak
> +-include ../config-target.mak
>  
> -QEMU=../../i386-linux-user/qemu-i386
> -QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
> -CC_X86_64=$(CC_I386) -m64
> +# Set search path for all sources
> +VPATH = $(SRC_PATH)/tests/tcg/multiarch
> +TEST_SRCS = $(wildcard $(SRC_PATH)/tests/tcg/multiarch/*.c)
>  
> -QEMU_INCLUDES += -I../..
> -CFLAGS=-Wall -O2 -g -fno-strict-aliasing
> -#CFLAGS+=-msse2
> -LDFLAGS=
> +VPATH     += $(SRC_PATH)/tests/tcg/$(ARCH)
> +TEST_SRCS += $(wildcard $(SRC_PATH)/tests/tcg/$(ARCH)/*.c)
>  
> -# TODO: automatically detect ARM and MIPS compilers, and run those too
> +SRCS=$(notdir ${TEST_SRCS})
> +TESTS=$(SRCS:.c=)
>  
> -# runcom maps page 0, so it requires root privileges
> -# also, pi_10.com runs indefinitely
> +# We use what ever CC we have
> +CFLAGS=-Wall -O0 -g -fno-strict-aliasing -static
> +QEMU_CFLAGS=
> +LDFLAGS=
>  
> -I386_TESTS=hello-i386 \
> -	   linux-test \
> -	   testthread \
> -	   sha1-i386 \
> -	   test-i386 \
> -	   test-i386-fprem \
> -	   test-mmap \
> -	   # runcom
> +# The per ARCH target makefile which might add specific compiler flags
> +# for some compilation targets.
>  
> -# native i386 compilers sometimes are not biarch.  assume cross-compilers are
> -ifneq ($(ARCH),i386)
> -I386_TESTS+=run-test-x86_64
> -endif
> +EXTRA_MAKEFILE=$(SRC_PATH)/tests/tcg/$(ARCH)/Makefile.target
> +CHECK_INCLUDE=$(wildcard $(EXTRA_MAKEFILE))
>  
> -TESTS = test_path
> -ifneq ($(call find-in-path, $(CC_I386)),)
> -TESTS += $(I386_TESTS)
> +ifeq ($(EXTRA_MAKEFILE),$(CHECK_INCLUDE))
> +include $(EXTRA_MAKEFILE)
>  endif
>  
> -all: $(patsubst %,run-%,$(TESTS))
> -test: all
> -
> -# rules to run tests
> -
> -.PHONY: $(patsubst %,run-%,$(TESTS))
> -
> -run-%: %
> -	-$(QEMU) ./$*
> -
> -run-hello-i386: hello-i386
> -run-linux-test: linux-test
> -run-testthread: testthread
> -run-sha1-i386: sha1-i386
> -
> -run-test-i386: test-i386
> -	./test-i386 > test-i386.ref
> -	-$(QEMU) test-i386 > test-i386.out
> -	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
> -
> -run-test-i386-fprem: test-i386-fprem
> -	./test-i386-fprem > test-i386-fprem.ref
> -	-$(QEMU) test-i386-fprem > test-i386-fprem.out
> -	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
> -
> -run-test-x86_64: test-x86_64
> -	./test-x86_64 > test-x86_64.ref
> -	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
> -	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
> -
> -run-test-mmap: test-mmap
> -	-$(QEMU) ./test-mmap
> -	-$(QEMU) -p 8192 ./test-mmap 8192
> -	-$(QEMU) -p 16384 ./test-mmap 16384
> -	-$(QEMU) -p 32768 ./test-mmap 32768
> -
> -run-runcom: runcom
> -	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
> -
> -run-test_path: test_path
> -	./test_path
> -
> -# rules to compile tests
> -
> -test_path: test_path.o
> -
> -test_path.o: test_path.c
> -
> -hello-i386: hello-i386.c
> -	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
> -	strip $@
> -
> -testthread: testthread.c
> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
> -
> -# i386/x86_64 emulation test (test various opcodes) */
> -test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
> -           test-i386.h test-i386-shift.h test-i386-muldiv.h
> -	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
> -              $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
> -
> -test-i386-fprem: test-i386-fprem.c
> -	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
> -
> -test-x86_64: test-i386.c \
> -           test-i386.h test-i386-shift.h test-i386-muldiv.h
> -	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
> -
> -# generic Linux and CPU test
> -linux-test: linux-test.c
> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
> -
> -# vm86 test
> -runcom: runcom.c
> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
> -
> -test-mmap: test-mmap.c
> -	$(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $<
> -
> -# speed test
> -sha1-i386: sha1.c
> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
> -
> -sha1: sha1.c
> -	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
> -
> -speed: sha1 sha1-i386
> -	time ./sha1
> -	time $(QEMU) ./sha1-i386
> -
> -# arm test
> -hello-arm: hello-arm.o
> -	arm-linux-ld -o $@ $<
> -
> -hello-arm.o: hello-arm.c
> -	arm-linux-gcc -Wall -g -O2 -c -o $@ $<
> -
> -test-arm-iwmmxt: test-arm-iwmmxt.s
> -	cpp < $< | arm-linux-gnu-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
> -
> -# MIPS test
> -hello-mips: hello-mips.c
> -	mips-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
> -
> -hello-mipsel: hello-mips.c
> -	mipsel-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
> +testthread: LDFLAGS=-lpthread

I'm a bit curious why only testthread is left in this file but others are gone.

Fam

>  
> -# testsuite for the CRIS port.
> -test-cris:
> -	$(MAKE) -C cris check
> +%: %.c
> +	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
>  
> -# testsuite for the LM32 port.
> -test-lm32:
> -	$(MAKE) -C lm32 check
> +all: $(TESTS)
>  
> -clean:
> -	rm -f *~ *.o test-i386.out test-i386.ref \
> -           test-x86_64.log test-x86_64.ref qruncom $(TESTS)
> +# There is no clean target, the calling make just rm's the tests build dir
> -- 
> 2.16.2
> 

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

* Re: [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target
  2018-04-12  8:13   ` Fam Zheng
@ 2018-04-12  8:47     ` Alex Bennée
  2018-04-12  9:14       ` Fam Zheng
  0 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-12  8:47 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel, berrange, cota


Fam Zheng <famz@redhat.com> writes:

> On Tue, 04/10 20:39, Alex Bennée wrote:
>> This make is now invoked from each individual target make with the
>> appropriate CC and ARCH set for each guest. It includes all the
>> multiarch tests by default as well as any tests from
>> tests/tcg/$(ARCH).
>>
>> As there may be subtle additional requirements for building some of
>> the tests it also includes tests/tcg/$(ARCH)/Makefile.target if it is
>> available. This is distinct from tests/tcg/$(ARCH)/Makefile.include
>> which is used by the parent make machinery to determine potential
>> docker targets.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/tcg/Makefile | 185 ++++++++++++-----------------------------------------
>>  1 file changed, 42 insertions(+), 143 deletions(-)
>>
>> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
>> index 89e3342f3d..2bba0d2a32 100644
>> --- a/tests/tcg/Makefile
>> +++ b/tests/tcg/Makefile
>> @@ -1,156 +1,55 @@
>> --include ../../config-host.mak
>> --include $(SRC_PATH)/rules.mak
>> +# -*- Mode: makefile -*-
>> +#
>> +# TCG tests
>> +#
>> +# These are complicated by the fact we want to build them for guest
>> +# systems. This requires knowing what guests we are building and which
>> +# ones we have cross-compilers for or docker images with
>> +# cross-compilers.
>> +#
>> +# The tests themselves should be as minimal as possible as
>> +# cross-compilers don't always have a large amount of libraries
>> +# available.
>> +#
>> +# We only include the host build system for SRC_PATH and we don't
>> +# bother with the common rules.mk. We expect CC to have been set for
>> +# us from the parent make. We also expect to be in the tests build dir
>> +# for the FOO-linux-user.
>> +#
>>
>> -$(call set-vpath, $(SRC_PATH)/tests/tcg)
>> +-include ../../config-host.mak
>> +-include ../config-target.mak
>>
>> -QEMU=../../i386-linux-user/qemu-i386
>> -QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
>> -CC_X86_64=$(CC_I386) -m64
>> +# Set search path for all sources
>> +VPATH = $(SRC_PATH)/tests/tcg/multiarch
>> +TEST_SRCS = $(wildcard $(SRC_PATH)/tests/tcg/multiarch/*.c)
>>
>> -QEMU_INCLUDES += -I../..
>> -CFLAGS=-Wall -O2 -g -fno-strict-aliasing
>> -#CFLAGS+=-msse2
>> -LDFLAGS=
>> +VPATH     += $(SRC_PATH)/tests/tcg/$(ARCH)
>> +TEST_SRCS += $(wildcard $(SRC_PATH)/tests/tcg/$(ARCH)/*.c)
>>
>> -# TODO: automatically detect ARM and MIPS compilers, and run those too
>> +SRCS=$(notdir ${TEST_SRCS})
>> +TESTS=$(SRCS:.c=)
>>
>> -# runcom maps page 0, so it requires root privileges
>> -# also, pi_10.com runs indefinitely
>> +# We use what ever CC we have
>> +CFLAGS=-Wall -O0 -g -fno-strict-aliasing -static
>> +QEMU_CFLAGS=
>> +LDFLAGS=
>>
>> -I386_TESTS=hello-i386 \
>> -	   linux-test \
>> -	   testthread \
>> -	   sha1-i386 \
>> -	   test-i386 \
>> -	   test-i386-fprem \
>> -	   test-mmap \
>> -	   # runcom
>> +# The per ARCH target makefile which might add specific compiler flags
>> +# for some compilation targets.
>>
>> -# native i386 compilers sometimes are not biarch.  assume cross-compilers are
>> -ifneq ($(ARCH),i386)
>> -I386_TESTS+=run-test-x86_64
>> -endif
>> +EXTRA_MAKEFILE=$(SRC_PATH)/tests/tcg/$(ARCH)/Makefile.target
>> +CHECK_INCLUDE=$(wildcard $(EXTRA_MAKEFILE))
>>
>> -TESTS = test_path
>> -ifneq ($(call find-in-path, $(CC_I386)),)
>> -TESTS += $(I386_TESTS)
>> +ifeq ($(EXTRA_MAKEFILE),$(CHECK_INCLUDE))
>> +include $(EXTRA_MAKEFILE)
>>  endif
>>
>> -all: $(patsubst %,run-%,$(TESTS))
>> -test: all
>> -
>> -# rules to run tests
>> -
>> -.PHONY: $(patsubst %,run-%,$(TESTS))
>> -
>> -run-%: %
>> -	-$(QEMU) ./$*
>> -
>> -run-hello-i386: hello-i386
>> -run-linux-test: linux-test
>> -run-testthread: testthread
>> -run-sha1-i386: sha1-i386
>> -
>> -run-test-i386: test-i386
>> -	./test-i386 > test-i386.ref
>> -	-$(QEMU) test-i386 > test-i386.out
>> -	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
>> -
>> -run-test-i386-fprem: test-i386-fprem
>> -	./test-i386-fprem > test-i386-fprem.ref
>> -	-$(QEMU) test-i386-fprem > test-i386-fprem.out
>> -	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
>> -
>> -run-test-x86_64: test-x86_64
>> -	./test-x86_64 > test-x86_64.ref
>> -	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
>> -	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
>> -
>> -run-test-mmap: test-mmap
>> -	-$(QEMU) ./test-mmap
>> -	-$(QEMU) -p 8192 ./test-mmap 8192
>> -	-$(QEMU) -p 16384 ./test-mmap 16384
>> -	-$(QEMU) -p 32768 ./test-mmap 32768
>> -
>> -run-runcom: runcom
>> -	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
>> -
>> -run-test_path: test_path
>> -	./test_path
>> -
>> -# rules to compile tests
>> -
>> -test_path: test_path.o
>> -
>> -test_path.o: test_path.c
>> -
>> -hello-i386: hello-i386.c
>> -	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
>> -	strip $@
>> -
>> -testthread: testthread.c
>> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
>> -
>> -# i386/x86_64 emulation test (test various opcodes) */
>> -test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
>> -           test-i386.h test-i386-shift.h test-i386-muldiv.h
>> -	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
>> -              $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
>> -
>> -test-i386-fprem: test-i386-fprem.c
>> -	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
>> -
>> -test-x86_64: test-i386.c \
>> -           test-i386.h test-i386-shift.h test-i386-muldiv.h
>> -	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
>> -
>> -# generic Linux and CPU test
>> -linux-test: linux-test.c
>> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
>> -
>> -# vm86 test
>> -runcom: runcom.c
>> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
>> -
>> -test-mmap: test-mmap.c
>> -	$(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $<
>> -
>> -# speed test
>> -sha1-i386: sha1.c
>> -	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
>> -
>> -sha1: sha1.c
>> -	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
>> -
>> -speed: sha1 sha1-i386
>> -	time ./sha1
>> -	time $(QEMU) ./sha1-i386
>> -
>> -# arm test
>> -hello-arm: hello-arm.o
>> -	arm-linux-ld -o $@ $<
>> -
>> -hello-arm.o: hello-arm.c
>> -	arm-linux-gcc -Wall -g -O2 -c -o $@ $<
>> -
>> -test-arm-iwmmxt: test-arm-iwmmxt.s
>> -	cpp < $< | arm-linux-gnu-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
>> -
>> -# MIPS test
>> -hello-mips: hello-mips.c
>> -	mips-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
>> -
>> -hello-mipsel: hello-mips.c
>> -	mipsel-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
>> +testthread: LDFLAGS=-lpthread
>
> I'm a bit curious why only testthread is left in this file but others
> are gone.

testthread is the only one that needs additional flags. However I could
put those rules in a multiarch/Makefile.target if you want?

>
> Fam
>
>>
>> -# testsuite for the CRIS port.
>> -test-cris:
>> -	$(MAKE) -C cris check
>> +%: %.c
>> +	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
>>
>> -# testsuite for the LM32 port.
>> -test-lm32:
>> -	$(MAKE) -C lm32 check
>> +all: $(TESTS)
>>
>> -clean:
>> -	rm -f *~ *.o test-i386.out test-i386.ref \
>> -           test-x86_64.log test-x86_64.ref qruncom $(TESTS)
>> +# There is no clean target, the calling make just rm's the tests build dir
>> --
>> 2.16.2
>>


--
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target
  2018-04-12  8:47     ` Alex Bennée
@ 2018-04-12  9:14       ` Fam Zheng
  0 siblings, 0 replies; 83+ messages in thread
From: Fam Zheng @ 2018-04-12  9:14 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, cota

On Thu, 04/12 09:47, Alex Bennée wrote:
> 
> Fam Zheng <famz@redhat.com> writes:
> >> +testthread: LDFLAGS=-lpthread
> >
> > I'm a bit curious why only testthread is left in this file but others
> > are gone.
> 
> testthread is the only one that needs additional flags. However I could
> put those rules in a multiarch/Makefile.target if you want?

I don't have a preference, and this patch is fine. Thanks for explaining.

Fam

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

* Re: [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST Alex Bennée
@ 2018-04-12 14:33   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-12 14:33 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:38 PM, Alex Bennée wrote:
> From: Fam Zheng <famz@redhat.com>
> 
> To be more accurate on its purpose and make code that looks for a certain
> target out of this variable more readable.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  Makefile               | 20 ++++++++++----------
>  configure              |  2 +-
>  scripts/create_config  |  2 +-
>  tests/Makefile.include |  2 +-
>  4 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 727ef118f3..2c54cd8345 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -62,8 +62,8 @@ seems to have been used for an in-tree build. You can fix this by running \
>  endif
>  endif
>  
> -CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
> -CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
> +CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_LIST)),y)
> +CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_LIST)),y)
>  CONFIG_XEN := $(CONFIG_XEN_BACKEND)
>  CONFIG_ALL=y
>  -include config-all-devices.mak
> @@ -362,8 +362,8 @@ DOCS=
>  endif
>  
>  SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
> -SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
> -SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
> +SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_LIST))
> +SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_LIST))
>  
>  ifeq ($(SUBDIR_DEVICES_MAK),)
>  config-all-devices.mak:
> @@ -466,7 +466,7 @@ config-host.h-timestamp: config-host.mak
>  qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
>  	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
>  
> -SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
> +SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_LIST))
>  SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
>  
>  $(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
> @@ -510,7 +510,7 @@ ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
>  romsubdir-%:
>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
>  
> -ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
> +ALL_SUBDIRS=$(TARGET_LIST) $(patsubst %,pc-bios/%, $(ROMS))
>  
>  recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
>  
> @@ -763,7 +763,7 @@ distclean: clean
>  	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
>  	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
>  	rm -f docs/qemu-block-drivers.7
> -	for d in $(TARGET_DIRS); do \
> +	for d in $(TARGET_LIST); do \
>  	rm -rf $$d || exit 1 ; \
>          done
>  	rm -Rf .sdk
> @@ -864,7 +864,7 @@ endif
>  		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
>  	done
>  	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
> -	for d in $(TARGET_DIRS); do \
> +	for d in $(TARGET_LIST); do \
>  	$(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
>          done
>  
> @@ -1062,9 +1062,9 @@ endif
>  	@echo  '  ctags/TAGS      - Generate tags file for editors'
>  	@echo  '  cscope          - Generate cscope index'
>  	@echo  ''
> -	@$(if $(TARGET_DIRS), \
> +	@$(if $(TARGET_LIST), \
>  		echo 'Architecture specific targets:'; \
> -		$(foreach t, $(TARGET_DIRS), \
> +		$(foreach t, $(TARGET_LIST), \
>  		printf "  %-30s - Build for %s\\n" $(patsubst %,subdir-%,$(t)) $(t);) \
>  		echo '')
>  	@echo  'Cleaning targets:'
> diff --git a/configure b/configure
> index add87ff4d4..5a41c87cc3 100755
> --- a/configure
> +++ b/configure
> @@ -6094,7 +6094,7 @@ qemu_version=$(head $source_path/VERSION)
>  echo "VERSION=$qemu_version" >>$config_host_mak
>  echo "PKGVERSION=$pkgversion" >>$config_host_mak
>  echo "SRC_PATH=$source_path" >> $config_host_mak
> -echo "TARGET_DIRS=$target_list" >> $config_host_mak
> +echo "TARGET_LIST=$target_list" >> $config_host_mak
>  if [ "$docs" = "yes" ] ; then
>    echo "BUILD_DOCS=yes" >> $config_host_mak
>  fi
> diff --git a/scripts/create_config b/scripts/create_config
> index d727e5e36e..58948a67a4 100755
> --- a/scripts/create_config
> +++ b/scripts/create_config
> @@ -107,7 +107,7 @@ case $line in
>      target_name=${line#*=}
>      echo "#define TARGET_NAME \"$target_name\""
>      ;;
> - TARGET_DIRS=*)
> + TARGET_LIST=*)
>      # do nothing
>      ;;
>   TARGET_*=y) # configuration
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 3b9a5e31a2..3d2f0458ab 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -854,7 +854,7 @@ endif
>  
>  # QTest rules
>  
> -TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
> +TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_LIST)))
>  ifeq ($(CONFIG_POSIX),y)
>  QTEST_TARGETS = $(TARGETS)
>  check-qtest-y=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y))
> 

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

* Re: [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386 Alex Bennée
@ 2018-04-16  0:01   ` Philippe Mathieu-Daudé
  2018-04-16  9:02     ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:01 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

Hi Alex,

On 04/10/2018 04:38 PM, Alex Bennée wrote:
> We should still be able to use the system cross compiler with the
> appropriate flags on x86_64 hosts.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/configure b/configure
> index b5f3b3fe29..add87ff4d4 100755
> --- a/configure
> +++ b/configure
> @@ -284,7 +284,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=""
> @@ -457,6 +456,8 @@ docker="no"
>  cross_cc_aarch64="aarch64-linux-gnu-gcc"
>  cross_cc_arm="arm-linux-gnueabihf-gcc"
>  cross_cc_powerpc="powerpc-linux-gnu-gcc"
> +cross_cc_i386="i386-pc-linux-gnu-gcc"
> +cross_cc_i386_cflags=""

Can you keep this sorted? (arm < i386 < powerpc)

Thanks :)

>  
>  enabled_cross_compilers=""
>  
> @@ -687,12 +688,10 @@ case "$cpu" in

What do you think about renaming $cpu -> host_cpu/target_cpu?

>    i386|i486|i586|i686|i86pc|BePC)
>      cpu="i386"
>      supported_cpu="yes"
> -    cross_cc_i386=gcc
>    ;;
>    x86_64|amd64)
>      cpu="x86_64"
>      supported_cpu="yes"
> -    cross_cc_x86_64=gcc
>    ;;
>    armv*b|armv*l|arm)
>      cpu="arm"
> @@ -1435,7 +1434,6 @@ case "$cpu" in
>      i386)
>             CPU_CFLAGS="-m32"
>             LDFLAGS="-m32 $LDFLAGS"
> -           cc_i386='$(CC) -m32'
>             ;;
>      x86_64)
>             # ??? Only extremely old AMD cpus do not have cmpxchg16b.
> @@ -1443,12 +1441,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_i386=$cc
> +           cross_cc_i386_cflags="-m32"
>             ;;
>      x32)
>             CPU_CFLAGS="-mx32"
>             LDFLAGS="-mx32 $LDFLAGS"
> -           cc_i386='$(CC) -m32'
> +           cross_cc_i386=$cc
> +           cross_cc_i386_cflags="-m32"
>             ;;
>      # No special flags required for other host CPUs
>  esac
> @@ -6664,7 +6664,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
> @@ -6783,6 +6782,7 @@ case "$target" in
>  esac
>  
>  target_compiler=""
> +target_compiler_cflags=""
>  
>  mkdir -p $target_dir
>  echo "# Automatically generated by configure - do not modify" > $config_target_mak
> @@ -6799,10 +6799,13 @@ 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_i386_cflags
>    ;;
>    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"
> @@ -6947,7 +6950,7 @@ int main(void) {
>  }
>  EOF
>  
> -    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
> +    if ! do_compiler $target_compiler $target_compiler_cflags -o $TMPE $TMPC -static ; then
>          target_compiler=""
>      else
>          enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
> @@ -7033,6 +7036,10 @@ if test -n "$target_compiler"; then
>    echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
>  fi
>  
> +if test -n "$target_compiler_cflags"; then
> +  echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
> +fi
> +
>  # generate QEMU_CFLAGS/LDFLAGS for targets
>  
>  cflags=""
> 

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

* Re: [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context Alex Bennée
  2018-04-12  8:08   ` Fam Zheng
@ 2018-04-16  0:02   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:02 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: berrange, famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/docker/docker.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 9444f4bea4..f79213044d 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -399,6 +399,8 @@ class CcCommand(SubCommand):
>                              help="The docker image in which to run cc")
>          parser.add_argument("--cc",
>                              help="The compiler executable to call")
> +        parser.add_argument("--user",
> +                            help="The user-id to run under")
>          parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
>                              help="""Extra paths to (ro) mount into container for
>                              reading sources""")
> @@ -414,6 +416,9 @@ class CcCommand(SubCommand):
>              for p in args.paths:
>                  cmd += ["-v", "%s:%s:ro,z" % (p, p)]
>  
> +        if args.user:
> +            cmd += ["-u", args.user]
> +
>          cmd += [args.image]
>  
>          # The compile command we are running
> 

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

* Re: [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir Alex Bennée
  2018-04-11 10:22   ` Thomas Huth
@ 2018-04-16  0:05   ` Philippe Mathieu-Daudé
  2018-04-16  9:01     ` Alex Bennée
  1 sibling, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:05 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

Hi Alex,

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> We will want to build these for all supported guest architectures so
> lets move them all into one place. We also drop test_path at this
> point because it needs qemu utils and glib bits which is hard to
> support for cross compiling.

Can we keep it for the $target==$host case (or when NOT cross
compiling)? Maybe move it to tests/tcg/host/test_path.c

> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/README                       |  10 +--
>  tests/tcg/multiarch/README             |   1 +
>  tests/tcg/{ => multiarch}/linux-test.c |   0
>  tests/tcg/{ => multiarch}/sha1.c       |   0
>  tests/tcg/{ => multiarch}/test-mmap.c  |   0
>  tests/tcg/{ => multiarch}/testthread.c |   0
>  tests/tcg/test_path.c                  | 157 ---------------------------------
>  7 files changed, 5 insertions(+), 163 deletions(-)
>  create mode 100644 tests/tcg/multiarch/README
>  rename tests/tcg/{ => multiarch}/linux-test.c (100%)
>  rename tests/tcg/{ => multiarch}/sha1.c (100%)
>  rename tests/tcg/{ => multiarch}/test-mmap.c (100%)
>  rename tests/tcg/{ => multiarch}/testthread.c (100%)
>  delete mode 100644 tests/tcg/test_path.c
> 
> diff --git a/tests/tcg/README b/tests/tcg/README
> index 5dcfb4852b..0890044cf0 100644
> --- a/tests/tcg/README
> +++ b/tests/tcg/README
> @@ -1,9 +1,7 @@
> -This directory contains various interesting programs for
> -regression testing.
> -
> -The target "make test" runs the programs and, if applicable,
> -runs "diff" to detect mismatches between output on the host and
> -output on QEMU.
> +This directory contains various interesting guest programs for
> +regression testing. Tests are either multi-arch, meaning they can be
> +built for all guest architectures that support linux-user executable,
> +or they are architecture specific.
>  
>  i386
>  ====
> diff --git a/tests/tcg/multiarch/README b/tests/tcg/multiarch/README
> new file mode 100644
> index 0000000000..522c9d2ea3
> --- /dev/null
> +++ b/tests/tcg/multiarch/README
> @@ -0,0 +1 @@
> +Multi-architecture linux-user tests
> diff --git a/tests/tcg/linux-test.c b/tests/tcg/multiarch/linux-test.c
> similarity index 100%
> rename from tests/tcg/linux-test.c
> rename to tests/tcg/multiarch/linux-test.c
> diff --git a/tests/tcg/sha1.c b/tests/tcg/multiarch/sha1.c
> similarity index 100%
> rename from tests/tcg/sha1.c
> rename to tests/tcg/multiarch/sha1.c
> diff --git a/tests/tcg/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
> similarity index 100%
> rename from tests/tcg/test-mmap.c
> rename to tests/tcg/multiarch/test-mmap.c
> diff --git a/tests/tcg/testthread.c b/tests/tcg/multiarch/testthread.c
> similarity index 100%
> rename from tests/tcg/testthread.c
> rename to tests/tcg/multiarch/testthread.c
> diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
> deleted file mode 100644
> index 1c29bce263..0000000000
> --- a/tests/tcg/test_path.c
> +++ /dev/null
> @@ -1,157 +0,0 @@
> -/* Test path override code */
> -#include "config-host.h"
> -#include "util/cutils.c"
> -#include "util/hexdump.c"
> -#include "util/iov.c"
> -#include "util/path.c"
> -#include "util/qemu-timer-common.c"
> -#include <stdarg.h>
> -#include <sys/stat.h>
> -#include <fcntl.h>
> -
> -void qemu_log(const char *fmt, ...);
> -
> -/* Any log message kills the test. */
> -void qemu_log(const char *fmt, ...)
> -{
> -    va_list ap;
> -
> -    fprintf(stderr, "FATAL: ");
> -    va_start(ap, fmt);
> -    vfprintf(stderr, fmt, ap);
> -    va_end(ap);
> -    exit(1);
> -}
> -
> -#define NO_CHANGE(_path)						\
> -	do {								\
> -	    if (strcmp(path(_path), _path) != 0) return __LINE__;	\
> -	} while(0)
> -
> -#define CHANGE_TO(_path, _newpath)					\
> -	do {								\
> -	    if (strcmp(path(_path), _newpath) != 0) return __LINE__;	\
> -	} while(0)
> -
> -static void cleanup(void)
> -{
> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE2");
> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE3");
> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE4");
> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE5");
> -    rmdir("/tmp/qemu-test_path/DIR1/DIR2");
> -    rmdir("/tmp/qemu-test_path/DIR1/DIR3");
> -    rmdir("/tmp/qemu-test_path/DIR1");
> -    rmdir("/tmp/qemu-test_path");
> -}
> -
> -static unsigned int do_test(void)
> -{
> -    if (mkdir("/tmp/qemu-test_path", 0700) != 0)
> -	return __LINE__;
> -
> -    if (mkdir("/tmp/qemu-test_path/DIR1", 0700) != 0)
> -	return __LINE__;
> -
> -    if (mkdir("/tmp/qemu-test_path/DIR1/DIR2", 0700) != 0)
> -	return __LINE__;
> -
> -    if (mkdir("/tmp/qemu-test_path/DIR1/DIR3", 0700) != 0)
> -	return __LINE__;
> -
> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE", 0600)) != 0)
> -	return __LINE__;
> -
> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE2", 0600)) != 0)
> -	return __LINE__;
> -
> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE3", 0600)) != 0)
> -	return __LINE__;
> -
> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE4", 0600)) != 0)
> -	return __LINE__;
> -
> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE5", 0600)) != 0)
> -	return __LINE__;
> -
> -    init_paths("/tmp/qemu-test_path");
> -
> -    NO_CHANGE("/tmp");
> -    NO_CHANGE("/tmp/");
> -    NO_CHANGE("/tmp/qemu-test_path");
> -    NO_CHANGE("/tmp/qemu-test_path/");
> -    NO_CHANGE("/tmp/qemu-test_path/D");
> -    NO_CHANGE("/tmp/qemu-test_path/DI");
> -    NO_CHANGE("/tmp/qemu-test_path/DIR");
> -    NO_CHANGE("/tmp/qemu-test_path/DIR1");
> -    NO_CHANGE("/tmp/qemu-test_path/DIR1/");
> -
> -    NO_CHANGE("/D");
> -    NO_CHANGE("/DI");
> -    NO_CHANGE("/DIR");
> -    NO_CHANGE("/DIR2");
> -    NO_CHANGE("/DIR1.");
> -
> -    CHANGE_TO("/DIR1", "/tmp/qemu-test_path/DIR1");
> -    CHANGE_TO("/DIR1/", "/tmp/qemu-test_path/DIR1");
> -
> -    NO_CHANGE("/DIR1/D");
> -    NO_CHANGE("/DIR1/DI");
> -    NO_CHANGE("/DIR1/DIR");
> -    NO_CHANGE("/DIR1/DIR1");
> -
> -    CHANGE_TO("/DIR1/DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
> -    CHANGE_TO("/DIR1/DIR2/", "/tmp/qemu-test_path/DIR1/DIR2");
> -
> -    CHANGE_TO("/DIR1/DIR3", "/tmp/qemu-test_path/DIR1/DIR3");
> -    CHANGE_TO("/DIR1/DIR3/", "/tmp/qemu-test_path/DIR1/DIR3");
> -
> -    NO_CHANGE("/DIR1/DIR2/F");
> -    NO_CHANGE("/DIR1/DIR2/FI");
> -    NO_CHANGE("/DIR1/DIR2/FIL");
> -    NO_CHANGE("/DIR1/DIR2/FIL.");
> -
> -    CHANGE_TO("/DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/DIR1/DIR2/FILE2", "/tmp/qemu-test_path/DIR1/DIR2/FILE2");
> -    CHANGE_TO("/DIR1/DIR2/FILE3", "/tmp/qemu-test_path/DIR1/DIR2/FILE3");
> -    CHANGE_TO("/DIR1/DIR2/FILE4", "/tmp/qemu-test_path/DIR1/DIR2/FILE4");
> -    CHANGE_TO("/DIR1/DIR2/FILE5", "/tmp/qemu-test_path/DIR1/DIR2/FILE5");
> -
> -    NO_CHANGE("/DIR1/DIR2/FILE6");
> -    NO_CHANGE("/DIR1/DIR2/FILE/X");
> -
> -    CHANGE_TO("/DIR1/../DIR1", "/tmp/qemu-test_path/DIR1");
> -    CHANGE_TO("/DIR1/../DIR1/", "/tmp/qemu-test_path/DIR1");
> -    CHANGE_TO("/../DIR1", "/tmp/qemu-test_path/DIR1");
> -    CHANGE_TO("/../DIR1/", "/tmp/qemu-test_path/DIR1");
> -    CHANGE_TO("/DIR1/DIR2/../DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
> -    CHANGE_TO("/DIR1/DIR2/../DIR2/../../DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/DIR1/DIR2/../DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -
> -    NO_CHANGE("/DIR1/DIR2/../DIR1");
> -    NO_CHANGE("/DIR1/DIR2/../FILE");
> -
> -    CHANGE_TO("/./DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/././DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/DIR1/./DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/DIR1/././DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/DIR1/DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/DIR1/DIR2/././FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -    CHANGE_TO("/./DIR1/./DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
> -
> -    return 0;
> -}
> -
> -int main(int argc, char *argv[])
> -{
> -    int ret;
> -
> -    ret = do_test();
> -    cleanup();
> -    if (ret) {
> -	fprintf(stderr, "test_path: failed on line %i\n", ret);
> -	return 1;
> -    }
> -    return 0;
> -}
> 

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

* Re: [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir Alex Bennée
  2018-04-11 10:30   ` Thomas Huth
@ 2018-04-16  0:08   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:08 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> These only need to be built for i386 guests. This includes a stub
> tests/tcg/i386/Makfile.target which absorbs some of what was in

Mak[e]file

> tests/tcg/Makefile.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/tcg/README                        |  39 --------------------------------
>  tests/tcg/i386/Makefile.target          |  10 ++++++++
>  tests/tcg/i386/README                   |  38 +++++++++++++++++++++++++++++++
>  tests/tcg/{ => i386}/hello-i386.c       |   0
>  tests/tcg/{ => i386}/pi_10.com          | Bin
>  tests/tcg/{ => i386}/runcom.c           |   0
>  tests/tcg/{ => i386}/test-i386-code16.S |   0
>  tests/tcg/{ => i386}/test-i386-fprem.c  |   0
>  tests/tcg/{ => i386}/test-i386-muldiv.h |   0
>  tests/tcg/{ => i386}/test-i386-shift.h  |   0
>  tests/tcg/{ => i386}/test-i386-ssse3.c  |   0
>  tests/tcg/{ => i386}/test-i386-vm86.S   |   0
>  tests/tcg/{ => i386}/test-i386.c        |   0
>  tests/tcg/{ => i386}/test-i386.h        |   0
>  14 files changed, 48 insertions(+), 39 deletions(-)
>  create mode 100644 tests/tcg/i386/Makefile.target
>  create mode 100644 tests/tcg/i386/README
>  rename tests/tcg/{ => i386}/hello-i386.c (100%)
>  rename tests/tcg/{ => i386}/pi_10.com (100%)
>  rename tests/tcg/{ => i386}/runcom.c (100%)
>  rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
>  rename tests/tcg/{ => i386}/test-i386-fprem.c (100%)
>  rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
>  rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
>  rename tests/tcg/{ => i386}/test-i386-ssse3.c (100%)
>  rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
>  rename tests/tcg/{ => i386}/test-i386.c (100%)
>  rename tests/tcg/{ => i386}/test-i386.h (100%)
> 
> diff --git a/tests/tcg/README b/tests/tcg/README
> index 0890044cf0..469504c4cb 100644
> --- a/tests/tcg/README
> +++ b/tests/tcg/README
> @@ -3,45 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
>  built for all guest architectures that support linux-user executable,
>  or they are architecture specific.
>  
> -i386
> -====
> -
> -test-i386
> ----------
> -
> -This program executes most of the 16 bit and 32 bit x86 instructions and
> -generates a text output, for comparison with the output obtained with
> -a real CPU or another emulator.
> -
> -The Linux system call modify_ldt() is used to create x86 selectors
> -to test some 16 bit addressing and 32 bit with segmentation cases.
> -
> -The Linux system call vm86() is used to test vm86 emulation.
> -
> -Various exceptions are raised to test most of the x86 user space
> -exception reporting.
> -
> -linux-test
> -----------
> -
> -This program tests various Linux system calls. It is used to verify
> -that the system call parameters are correctly converted between target
> -and host CPUs.
> -
> -test-i386-fprem
> ----------------
> -
> -runcom
> -------
> -
> -test-mmap
> ----------
> -
> -sha1
> -----
> -
> -hello-i386
> -----------
>  
>  
>  ARM
> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
> new file mode 100644
> index 0000000000..7dbb7992e7
> --- /dev/null
> +++ b/tests/tcg/i386/Makefile.target
> @@ -0,0 +1,10 @@
> +# i386 cross compile notes
> +
> +# If we are using a cross compiler config-target.mak may have also
> +# defined some CFLAGs to use.
> +
> +ifeq ($(CC), $(CROSS_CC_GUEST))
> +ifdef CROSS_CC_GUEST_CFLAGS
> +CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
> +endif
> +endif
> diff --git a/tests/tcg/i386/README b/tests/tcg/i386/README
> new file mode 100644
> index 0000000000..7a0a47bf27
> --- /dev/null
> +++ b/tests/tcg/i386/README
> @@ -0,0 +1,38 @@
> +These are i386 specific guest programs
> +
> +test-i386
> +---------
> +
> +This program executes most of the 16 bit and 32 bit x86 instructions and
> +generates a text output, for comparison with the output obtained with
> +a real CPU or another emulator.
> +
> +The Linux system call modify_ldt() is used to create x86 selectors
> +to test some 16 bit addressing and 32 bit with segmentation cases.
> +
> +The Linux system call vm86() is used to test vm86 emulation.
> +
> +Various exceptions are raised to test most of the x86 user space
> +exception reporting.
> +
> +linux-test
> +----------
> +
> +This program tests various Linux system calls. It is used to verify
> +that the system call parameters are correctly converted between target
> +and host CPUs.
> +
> +test-i386-fprem
> +---------------
> +
> +runcom
> +------
> +
> +test-mmap
> +---------
> +
> +sha1
> +----
> +
> +hello-i386
> +----------
> diff --git a/tests/tcg/hello-i386.c b/tests/tcg/i386/hello-i386.c
> similarity index 100%
> rename from tests/tcg/hello-i386.c
> rename to tests/tcg/i386/hello-i386.c
> diff --git a/tests/tcg/pi_10.com b/tests/tcg/i386/pi_10.com
> similarity index 100%
> rename from tests/tcg/pi_10.com
> rename to tests/tcg/i386/pi_10.com
> diff --git a/tests/tcg/runcom.c b/tests/tcg/i386/runcom.c
> similarity index 100%
> rename from tests/tcg/runcom.c
> rename to tests/tcg/i386/runcom.c
> diff --git a/tests/tcg/test-i386-code16.S b/tests/tcg/i386/test-i386-code16.S
> similarity index 100%
> rename from tests/tcg/test-i386-code16.S
> rename to tests/tcg/i386/test-i386-code16.S
> diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/i386/test-i386-fprem.c
> similarity index 100%
> rename from tests/tcg/test-i386-fprem.c
> rename to tests/tcg/i386/test-i386-fprem.c
> diff --git a/tests/tcg/test-i386-muldiv.h b/tests/tcg/i386/test-i386-muldiv.h
> similarity index 100%
> rename from tests/tcg/test-i386-muldiv.h
> rename to tests/tcg/i386/test-i386-muldiv.h
> diff --git a/tests/tcg/test-i386-shift.h b/tests/tcg/i386/test-i386-shift.h
> similarity index 100%
> rename from tests/tcg/test-i386-shift.h
> rename to tests/tcg/i386/test-i386-shift.h
> diff --git a/tests/tcg/test-i386-ssse3.c b/tests/tcg/i386/test-i386-ssse3.c
> similarity index 100%
> rename from tests/tcg/test-i386-ssse3.c
> rename to tests/tcg/i386/test-i386-ssse3.c
> diff --git a/tests/tcg/test-i386-vm86.S b/tests/tcg/i386/test-i386-vm86.S
> similarity index 100%
> rename from tests/tcg/test-i386-vm86.S
> rename to tests/tcg/i386/test-i386-vm86.S
> diff --git a/tests/tcg/test-i386.c b/tests/tcg/i386/test-i386.c
> similarity index 100%
> rename from tests/tcg/test-i386.c
> rename to tests/tcg/i386/test-i386.c
> diff --git a/tests/tcg/test-i386.h b/tests/tcg/i386/test-i386.h
> similarity index 100%
> rename from tests/tcg/test-i386.h
> rename to tests/tcg/i386/test-i386.h
> 

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

* Re: [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386 Alex Bennée
  2018-04-11 10:30   ` Thomas Huth
@ 2018-04-16  0:11   ` Philippe Mathieu-Daudé
  2018-04-16  8:57     ` Alex Bennée
  1 sibling, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:11 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel, famz; +Cc: cota

Hi Fam, Alex,

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> From: Fam Zheng <famz@redhat.com>
> 
> We have -Werror=missing-prototype, add a dummy prototype to avoid that
> warning.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/tcg/i386/hello-i386.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c
> index fa00380de2..cfeb24b2f5 100644
> --- a/tests/tcg/i386/hello-i386.c
> +++ b/tests/tcg/i386/hello-i386.c
> @@ -20,6 +20,7 @@ static inline int write(int fd, const char * buf, int len)
>    return status;
>  }
>  
> +void _start(void);

What about adding that in a common base file include by all tcg tests?
Such tests/tcg/include/tcg-common.h or better name...

>  void _start(void)
>  {
>      write(1, "Hello World\n", 12);
> 

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

* Re: [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386 Alex Bennée
  2018-04-11 15:36   ` Thomas Huth
@ 2018-04-16  0:13   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:13 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> The test-i386 test case is a little special as it includes assembler
> files. Add the additional compile magic to assemble these bits and
> link them to the final binary.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/tcg/i386/Makefile.target | 19 +++++++++++++++++++
>  tests/tcg/i386/test-i386.c     |  1 -
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
> index 7dbb7992e7..1df69e0dab 100644
> --- a/tests/tcg/i386/Makefile.target
> +++ b/tests/tcg/i386/Makefile.target
> @@ -8,3 +8,22 @@ ifdef CROSS_CC_GUEST_CFLAGS
>  CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
>  endif
>  endif
> +
> +#
> +# test-386 includes a couple of additional objects that need to be linked together
> +#
> +
> +TEST_I386_DEPS=test-i386-code16.o test-i386-vm86.o
> +
> +# override the default compile and link in one go rule
> +test-i386.o: test-i386.c
> +	$(CC) $(CFLAGS) -c $< -o $@
> +
> +# and provide a rule to compile .S files
> +%.o: %.S
> +	$(CC) $(CFLAGS) -c $< -o $@
> +
> +test-i386: LDFLAGS+=-lm -lc
> +test-i386: test-i386.o $(TEST_I386_DEPS)
> +	$(LD) -melf_i386 $(LDFLAGS) $< $(TEST_I386_DEPS) -o $@
> +
> diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
> index 9599204895..cae6a7773a 100644
> --- a/tests/tcg/i386/test-i386.c
> +++ b/tests/tcg/i386/test-i386.c
> @@ -17,7 +17,6 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>  #define _GNU_SOURCE
> -#include "qemu/compiler.h"
>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <string.h>
> 

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

* Re: [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386 Alex Bennée
  2018-04-11 15:38   ` Thomas Huth
@ 2018-04-16  0:14   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:14 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> This is a direct syscall test so needs additional CFLAGS and LDFLAGS.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/tcg/i386/Makefile.target | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
> index 1df69e0dab..44803c0382 100644
> --- a/tests/tcg/i386/Makefile.target
> +++ b/tests/tcg/i386/Makefile.target
> @@ -9,6 +9,12 @@ CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
>  endif
>  endif
>  
> +#
> +# hello-i386 is a barebones app
> +#
> +hello-i386: CFLAGS+=-ffreestanding
> +hello-i386: LDFLAGS+=-nostdlib
> +
>  #
>  # test-386 includes a couple of additional objects that need to be linked together
>  #
> 

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

* Re: [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir Alex Bennée
  2018-04-11 15:40   ` Thomas Huth
@ 2018-04-16  0:14   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  0:14 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> These only need to be built for ARM guests.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/tcg/README                      |  9 ---------
>  tests/tcg/arm/README                  | 11 +++++++++++
>  tests/tcg/{ => arm}/hello-arm.c       |  0
>  tests/tcg/{ => arm}/test-arm-iwmmxt.s |  0
>  4 files changed, 11 insertions(+), 9 deletions(-)
>  create mode 100644 tests/tcg/arm/README
>  rename tests/tcg/{ => arm}/hello-arm.c (100%)
>  rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)
> 
> diff --git a/tests/tcg/README b/tests/tcg/README
> index 469504c4cb..625f2326e6 100644
> --- a/tests/tcg/README
> +++ b/tests/tcg/README
> @@ -5,15 +5,6 @@ or they are architecture specific.
>  
>  
>  
> -ARM
> -===
> -
> -hello-arm
> ----------
> -
> -test-arm-iwmmxt
> ----------------
> -
>  MIPS
>  ====
>  
> diff --git a/tests/tcg/arm/README b/tests/tcg/arm/README
> new file mode 100644
> index 0000000000..e6307116e2
> --- /dev/null
> +++ b/tests/tcg/arm/README
> @@ -0,0 +1,11 @@
> +These are ARM specific guest programs
> +
> +hello-arm
> +---------
> +
> +A very simple inline assembly, write syscall based hello world
> +
> +test-arm-iwmmxt
> +---------------
> +
> +A simple test case for older iwmmxt extended ARMs
> diff --git a/tests/tcg/hello-arm.c b/tests/tcg/arm/hello-arm.c
> similarity index 100%
> rename from tests/tcg/hello-arm.c
> rename to tests/tcg/arm/hello-arm.c
> diff --git a/tests/tcg/test-arm-iwmmxt.s b/tests/tcg/arm/test-arm-iwmmxt.s
> similarity index 100%
> rename from tests/tcg/test-arm-iwmmxt.s
> rename to tests/tcg/arm/test-arm-iwmmxt.s
> 

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

* Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir Alex Bennée
@ 2018-04-16  1:02   ` Philippe Mathieu-Daudé
  2018-04-16  1:33     ` Philippe Mathieu-Daudé
  2018-04-16  8:56     ` Alex Bennée
  0 siblings, 2 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:02 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, Yongbok Kim, cota, Aurelien Jarno

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> These only need to be built for MIPS guests.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/README                  | 11 -----------
>  tests/tcg/mips/README             |  7 +++++++
>  tests/tcg/{ => mips}/hello-mips.c |  0
>  3 files changed, 7 insertions(+), 11 deletions(-)
>  create mode 100644 tests/tcg/mips/README
>  rename tests/tcg/{ => mips}/hello-mips.c (100%)
> 
> diff --git a/tests/tcg/README b/tests/tcg/README
> index 625f2326e6..a5643d33e7 100644
> --- a/tests/tcg/README
> +++ b/tests/tcg/README
> @@ -3,17 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
>  built for all guest architectures that support linux-user executable,
>  or they are architecture specific.
>  
> -
> -
> -MIPS
> -====
> -
> -hello-mips
> -----------
> -
> -hello-mipsel
> -------------
> -
>  CRIS
>  ====
>  The testsuite for CRIS is in tests/tcg/cris.  You can run it
> diff --git a/tests/tcg/mips/README b/tests/tcg/mips/README
> new file mode 100644
> index 0000000000..e5bbc58ec5
> --- /dev/null
> +++ b/tests/tcg/mips/README
> @@ -0,0 +1,7 @@
> +MIPS
> +====
> +
> +hello-mips
> +----------
> +
> +A very simple inline assembly, write syscall based hello world
> diff --git a/tests/tcg/hello-mips.c b/tests/tcg/mips/hello-mips.c
> similarity index 100%
> rename from tests/tcg/hello-mips.c
> rename to tests/tcg/mips/hello-mips.c

tested with:

-- >8 --
diff --git a/configure b/configure
index c98eb01c39..aebe928b3c 100755
--- a/configure
+++ b/configure
@@ -455,6 +455,7 @@ docker="no"
 # cross compilers defaults, can be overridden with --cross-cc-ARCH
 cross_cc_aarch64="aarch64-linux-gnu-gcc"
 cross_cc_arm="arm-linux-gnueabihf-gcc"
+cross_cc_mips="mipsel-linux-gnu-gcc"
 cross_cc_powerpc="powerpc-linux-gnu-gcc"
 cross_cc_i386="i386-pc-linux-gnu-gcc"
 cross_cc_i386_cflags=""
@@ -6860,6 +6861,7 @@ case "$target_name" in
   mips|mipsel)
     TARGET_ARCH=mips
     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
+    target_compiler=$cross_cc_mips
   ;;
   mipsn32|mipsn32el)
     TARGET_ARCH=mips64
diff --git a/tests/tcg/mips/Makefile.target b/tests/tcg/mips/Makefile.target
new file mode 100644
index 0000000000..427aafc9e5
--- /dev/null
+++ b/tests/tcg/mips/Makefile.target
@@ -0,0 +1,6 @@
+# -*- Mode: makefile -*-
+#
+# MIPS specific tweaks
+
+hello-mips: CFLAGS+=-ffreestanding
+hello-mips: LDFLAGS+=-nostdlib
-- 

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets Alex Bennée
@ 2018-04-16  1:12   ` Philippe Mathieu-Daudé
  2018-04-16  1:52   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:12 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

Hi Alex,

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> Now all the build infrastructure is in place we can build tests for
> each guest that we support. That support mainly depends on having
> cross compilers installed or docker setup. To keep all the logic for
> that together we put the rules in tests/tcg/Makefile.include and
> include it from the main Makefile.target.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile.target            |  5 +++
>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 84 insertions(+)
>  create mode 100644 tests/tcg/Makefile.include
> 
> diff --git a/Makefile.target b/Makefile.target
> index d0ec77a307..a30fd40257 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -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
>  
> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
> new file mode 100644
> index 0000000000..cb8bb36026
> --- /dev/null
> +++ b/tests/tcg/Makefile.include
> @@ -0,0 +1,79 @@
> +# -*- Mode: makefile -*-
> +#
> +# TCG tests (per-target rules)
> +#
> +# This Makefile fragement is included from the per-target
> +# Makefile.target so will be invoked for each linux-user program we
> +# build. We have two options for compiling, either using a configured
> +# guest compiler or calling one of our docker images to do it for us.
> +#
> +
> +# The per ARCH makefile, if it exists holds extra information about
> +# useful docker images or alternative compiler flags. Include it if it
> +# exists
> +
> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include

What about Makefile.cross, cross.mak or even cross-$ARCH.mak?

> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
> +
> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
> +include $(ARCH_MAKEFILE)
> +endif
> +
> +GUEST_BUILD=
> +
> +# Support installed Cross Compilers
> +
> +ifdef CROSS_CC_GUEST
> +
> +.PHONY: cross-build-guest-tests
> +cross-build-guest-tests:
> +	$(call quiet-command, \
> +          (mkdir -p tests && cd tests && \
> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
> +
> +
> +GUEST_BUILD=cross-build-guest-tests
> +
> +endif
> +
> +# Support building with Docker
> +
> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
> +ifneq ($(DOCKER_IMAGE),)
> +
> +# We also need the Docker make rules to depend on
> +include $(SRC_PATH)/tests/docker/Makefile.include
> +
> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
> +		--cc $(DOCKER_CROSS_COMPILER) \
> +		-i qemu:$(DOCKER_IMAGE) \
> +		-s $(SRC_PATH) -- "
> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
> +
> +.PHONY: docker-build-guest-tests
> +docker-build-guest-tests: $(DOCKER_PREREQ)
> +	$(call quiet-command, \
> +          (mkdir -p tests && cd tests && \
> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
> +
> +GUEST_BUILD=docker-build-guest-tests
> +
> +endif
> +endif
> +
> +# Final targets
> +.PHONY: guest-tests
> +
> +ifneq ($(GUEST_BUILD),)
> +guest-tests: $(GUEST_BUILD)
> +else
> +guest-tests:
> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
> +endif
> +
> +# It doesn't mater if these don't exits
> +.PHONY: clean-guest-tests
> +clean-guest-tests:
> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
> 

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

* Re: [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm Alex Bennée
  2018-04-11 15:42   ` Thomas Huth
@ 2018-04-16  1:28   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:28 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel, Peter Maydell; +Cc: famz, cota

Hi Alex,

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> As hello-arm is a bare bones syscall test it needs specific compiler
> flags so it doesn't try and link against glibc.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/arm/Makefile.target | 6 ++++++
>  1 file changed, 6 insertions(+)
>  create mode 100644 tests/tcg/arm/Makefile.target
> 
> diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
> new file mode 100644
> index 0000000000..b7c146c88e
> --- /dev/null
> +++ b/tests/tcg/arm/Makefile.target
> @@ -0,0 +1,6 @@
> +# -*- Mode: makefile -*-
> +#
> +# ARM specific tweaks

                    ... (Thumb mode explicitly disabled)

> +
> +hello-arm: CFLAGS+=-marm -ffreestanding
> +hello-arm: LDFLAGS+=-nostdlib

What about enforcing ARM mode for the swi call by the _syscallX()
functions with:

-- >8 --
 #define _syscall0(type,name) \
+__attribute__((target("arm"))) \
 type name(void) { \
   long __res; \
   __asm__ __volatile__ (\
--
(and so for _syscall[1..5])

So main() Thumb mode can also be tested.

tested with the following tests/tcg/arm/Makefile.include:

-- >8 --
DOCKER_IMAGE=debian-armel-cross
DOCKER_CROSS_COMPILER=arm-linux-gnueabi-gcc
--

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

* Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir
  2018-04-16  1:02   ` Philippe Mathieu-Daudé
@ 2018-04-16  1:33     ` Philippe Mathieu-Daudé
  2018-04-16  8:56     ` Alex Bennée
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:33 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, Yongbok Kim, cota, Aurelien Jarno

On 04/15/2018 10:02 PM, Philippe Mathieu-Daudé wrote:
> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>> These only need to be built for MIPS guests.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/tcg/README                  | 11 -----------
>>  tests/tcg/mips/README             |  7 +++++++
>>  tests/tcg/{ => mips}/hello-mips.c |  0
>>  3 files changed, 7 insertions(+), 11 deletions(-)
>>  create mode 100644 tests/tcg/mips/README
>>  rename tests/tcg/{ => mips}/hello-mips.c (100%)
>>
>> diff --git a/tests/tcg/README b/tests/tcg/README
>> index 625f2326e6..a5643d33e7 100644
>> --- a/tests/tcg/README
>> +++ b/tests/tcg/README
>> @@ -3,17 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
>>  built for all guest architectures that support linux-user executable,
>>  or they are architecture specific.
>>  
>> -
>> -
>> -MIPS
>> -====
>> -
>> -hello-mips
>> -----------
>> -
>> -hello-mipsel
>> -------------
>> -
>>  CRIS
>>  ====
>>  The testsuite for CRIS is in tests/tcg/cris.  You can run it
>> diff --git a/tests/tcg/mips/README b/tests/tcg/mips/README
>> new file mode 100644
>> index 0000000000..e5bbc58ec5
>> --- /dev/null
>> +++ b/tests/tcg/mips/README
>> @@ -0,0 +1,7 @@
>> +MIPS
>> +====
>> +
>> +hello-mips
>> +----------
>> +
>> +A very simple inline assembly, write syscall based hello world
>> diff --git a/tests/tcg/hello-mips.c b/tests/tcg/mips/hello-mips.c
>> similarity index 100%
>> rename from tests/tcg/hello-mips.c
>> rename to tests/tcg/mips/hello-mips.c
> 
> tested with:
> 
> -- >8 --
> diff --git a/configure b/configure
> index c98eb01c39..aebe928b3c 100755
> --- a/configure
> +++ b/configure
> @@ -455,6 +455,7 @@ docker="no"
>  # cross compilers defaults, can be overridden with --cross-cc-ARCH
>  cross_cc_aarch64="aarch64-linux-gnu-gcc"
>  cross_cc_arm="arm-linux-gnueabihf-gcc"
> +cross_cc_mips="mipsel-linux-gnu-gcc"
>  cross_cc_powerpc="powerpc-linux-gnu-gcc"
>  cross_cc_i386="i386-pc-linux-gnu-gcc"
>  cross_cc_i386_cflags=""
> @@ -6860,6 +6861,7 @@ case "$target_name" in
>    mips|mipsel)
>      TARGET_ARCH=mips
>      echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
> +    target_compiler=$cross_cc_mips
>    ;;
>    mipsn32|mipsn32el)
>      TARGET_ARCH=mips64
> diff --git a/tests/tcg/mips/Makefile.target b/tests/tcg/mips/Makefile.target
> new file mode 100644
> index 0000000000..427aafc9e5
> --- /dev/null
> +++ b/tests/tcg/mips/Makefile.target
> @@ -0,0 +1,6 @@
> +# -*- Mode: makefile -*-
> +#
> +# MIPS specific tweaks
> +
> +hello-mips: CFLAGS+=-ffreestanding
> +hello-mips: LDFLAGS+=-nostdlib
> 

oh and tests/tcg/mips/Makefile.include:

-- >8 --
DOCKER_IMAGE=debian-mipsel-cross
DOCKER_CROSS_COMPILER=mipsel-linux-gnu-gcc
--

running "make tcg-tests-mips-linux-user" it works, but "make
tcg-tests-mipsel-linux-user" only build the multiarch tests.

Maybe we need some [mipsel, mips64, mips64el] => "mips" rule somewhere.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

* Re: [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x Alex Bennée
  2018-04-11  8:36   ` Cornelia Huck
@ 2018-04-16  1:33   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:33 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, Cornelia Huck, open list:S390, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> This doesn't add any additional tests but enables building the
> multiarch tests for s390x.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/tcg/s390x/Makefile.include | 2 ++
>  1 file changed, 2 insertions(+)
>  create mode 100644 tests/tcg/s390x/Makefile.include
> 
> diff --git a/tests/tcg/s390x/Makefile.include b/tests/tcg/s390x/Makefile.include
> new file mode 100644
> index 0000000000..1f58115d96
> --- /dev/null
> +++ b/tests/tcg/s390x/Makefile.include
> @@ -0,0 +1,2 @@
> +DOCKER_IMAGE=debian-s390x-cross
> +DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc
> 

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

* Re: [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64 Alex Bennée
@ 2018-04-16  1:36   ` Philippe Mathieu-Daudé
  2018-04-16  8:54     ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:36 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

Hi Alex,

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> Currently this just enables building the multiarch tests.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

"make tcg-tests-ppc64-linux-user" works indeed.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Do we care about ppc[32]?

> ---
>  tests/tcg/ppc64/Makefile.include | 2 ++
>  1 file changed, 2 insertions(+)
>  create mode 100644 tests/tcg/ppc64/Makefile.include
> 
> diff --git a/tests/tcg/ppc64/Makefile.include b/tests/tcg/ppc64/Makefile.include
> new file mode 100644
> index 0000000000..d71cfc9aa7
> --- /dev/null
> +++ b/tests/tcg/ppc64/Makefile.include
> @@ -0,0 +1,2 @@
> +DOCKER_IMAGE=debian-ppc64el-cross
> +DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc

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

* Re: [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand Alex Bennée
@ 2018-04-16  1:48   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:48 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: berrange, famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> From: Fam Zheng <famz@redhat.com>
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/docker/docker.py | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 1246ba9578..8733266153 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -390,6 +390,29 @@ class ImagesCommand(SubCommand):
>      def run(self, args, argv):
>          return Docker().command("images", argv, args.quiet)
>  
> +class CcCommand(SubCommand):
> +    """Compile sources with cc in images"""
> +    name = "cc"
> +
> +    def args(self, parser):
> +        parser.add_argument("--image", "-i", required=True,
> +                            help="The docker image in which to run cc")
> +        parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
> +                            help="""Extra paths to (ro) mount into container for
> +                            reading sources""")
> +
> +    def run(self, args, argv):
> +        if argv and argv[0] == "--":
> +            argv = argv[1:]
> +        cwd = os.getcwd()
> +        cmd = ["--rm", "-w", cwd,
> +               "-v", "%s:%s:rw" % (cwd, cwd)]
> +        for p in args.paths:
> +           cmd += ["-v", "%s:%s:ro,z" % (p, p)]
> +        cmd += [args.image, "cc"]
> +        cmd += argv
> +        return Docker().command("run", cmd, True)
> +
>  def main():
>      parser = argparse.ArgumentParser(description="A Docker helper",
>              usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
> 

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets Alex Bennée
  2018-04-16  1:12   ` Philippe Mathieu-Daudé
@ 2018-04-16  1:52   ` Philippe Mathieu-Daudé
  2018-04-16  8:53     ` Alex Bennée
  1 sibling, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:52 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> Now all the build infrastructure is in place we can build tests for
> each guest that we support. That support mainly depends on having
> cross compilers installed or docker setup. To keep all the logic for
> that together we put the rules in tests/tcg/Makefile.include and
> include it from the main Makefile.target.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  Makefile.target            |  5 +++
>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 84 insertions(+)
>  create mode 100644 tests/tcg/Makefile.include
> 
> diff --git a/Makefile.target b/Makefile.target
> index d0ec77a307..a30fd40257 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -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
>  
> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
> new file mode 100644
> index 0000000000..cb8bb36026
> --- /dev/null
> +++ b/tests/tcg/Makefile.include
> @@ -0,0 +1,79 @@
> +# -*- Mode: makefile -*-
> +#
> +# TCG tests (per-target rules)
> +#
> +# This Makefile fragement is included from the per-target
> +# Makefile.target so will be invoked for each linux-user program we
> +# build. We have two options for compiling, either using a configured
> +# guest compiler or calling one of our docker images to do it for us.
> +#
> +
> +# The per ARCH makefile, if it exists holds extra information about
> +# useful docker images or alternative compiler flags. Include it if it
> +# exists
> +
> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
> +
> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
> +include $(ARCH_MAKEFILE)
> +endif
> +
> +GUEST_BUILD=
> +
> +# Support installed Cross Compilers
> +
> +ifdef CROSS_CC_GUEST
> +
> +.PHONY: cross-build-guest-tests
> +cross-build-guest-tests:
> +	$(call quiet-command, \
> +          (mkdir -p tests && cd tests && \
> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
> +
> +
> +GUEST_BUILD=cross-build-guest-tests
> +
> +endif
> +
> +# Support building with Docker
> +
> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
> +ifneq ($(DOCKER_IMAGE),)
> +
> +# We also need the Docker make rules to depend on
> +include $(SRC_PATH)/tests/docker/Makefile.include
> +

Eventually:

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
> +		--cc $(DOCKER_CROSS_COMPILER) \
> +		-i qemu:$(DOCKER_IMAGE) \
> +		-s $(SRC_PATH) -- "

Should we check $(DOCKER_CROSS_COMPILER) is set?

> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
> +
> +.PHONY: docker-build-guest-tests
> +docker-build-guest-tests: $(DOCKER_PREREQ)
> +	$(call quiet-command, \
> +          (mkdir -p tests && cd tests && \
> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
> +
> +GUEST_BUILD=docker-build-guest-tests
> +
> +endif
> +endif
> +
> +# Final targets
> +.PHONY: guest-tests
> +
> +ifneq ($(GUEST_BUILD),)
> +guest-tests: $(GUEST_BUILD)
> +else
> +guest-tests:
> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
> +endif
> +
> +# It doesn't mater if these don't exits
> +.PHONY: clean-guest-tests
> +clean-guest-tests:
> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
> 

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

* Re: [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets
  2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets Alex Bennée
@ 2018-04-16  1:53   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  1:53 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:39 PM, Alex Bennée wrote:
> This will ensure all linux-user targets build their guest test
> programs.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/Makefile.include | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 3d2f0458ab..c402de901e 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -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
> @@ -916,6 +917,23 @@ 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 %,tcg-tests-%, $(LINUX_USER_TARGETS))
> +CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(LINUX_USER_TARGETS))
> +
> +tcg-tests-%:
> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" guest-tests,)
> +
> +clean-tcg-tests-%:
> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
> +
> +.PHONY: check-tcg
> +check-tcg: $(BUILD_TCG_TARGET_RULES)
> +
> +.PHONY: clean-tcg
> +clean-tcg: $(CLEAN_TCG_TARGET_RULES)
>  
>  # Other tests
>  
> @@ -958,7 +976,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
> 

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

* Re: [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO
  2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO Alex Bennée
@ 2018-04-16  2:04   ` Philippe Mathieu-Daudé
  2018-04-16  8:49     ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16  2:04 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:38 PM, Alex Bennée wrote:
> This allows us to specify cross compilers for our guests. This is
> useful for building test images/programs. Currently we re-run the
> compile test for each target. I couldn't think of a way to cache the
> value for a given arch without getting messier configure code.
> 
> The cross compiler for the guest is visible to each target as
> CROSS_CC_GUEST in config-target.mak.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/configure b/configure
> index b402befe94..b5f3b3fe29 100755
> --- a/configure
> +++ b/configure
> @@ -453,6 +453,13 @@ vxhs=""
>  libxml2=""
>  docker="no"
>  
> +# cross compilers defaults, can be overridden with --cross-cc-ARCH
> +cross_cc_aarch64="aarch64-linux-gnu-gcc"
> +cross_cc_arm="arm-linux-gnueabihf-gcc"
> +cross_cc_powerpc="powerpc-linux-gnu-gcc"

These seems distrib-specific... Should we add a case $distrib) ...?

> +
> +enabled_cross_compilers=""
> +
>  supported_cpu="no"
>  supported_os="no"
>  bogus_os="no"
> @@ -483,6 +490,11 @@ for opt do
>    ;;
>    --disable-debug-info) debug_info="no"
>    ;;
> +  --cross-cc-*[!a-zA-Z0-9_0]=*) error_exit "Passed bad --cross-cc-FOO option"
> +  ;;
> +  --cross-cc-*) cc_arch=${opt#--cross-cc-}
> +                eval "cross_cc_${cc_arch}=\$optarg"
> +  ;;
>    esac
>  done
>  # OS specific
> @@ -675,10 +687,12 @@ case "$cpu" in
>    i386|i486|i586|i686|i86pc|BePC)
>      cpu="i386"
>      supported_cpu="yes"
> +    cross_cc_i386=gcc
>    ;;
>    x86_64|amd64)
>      cpu="x86_64"
>      supported_cpu="yes"
> +    cross_cc_x86_64=gcc
>    ;;
>    armv*b|armv*l|arm)
>      cpu="arm"
> @@ -912,6 +926,8 @@ for opt do
>    ;;
>    --disable-debug-info)
>    ;;
> +  --cross-cc-*)
> +  ;;
>    --enable-modules)
>        modules="yes"
>    ;;
> @@ -6766,6 +6782,8 @@ case "$target" in
>      ;;
>  esac
>  
> +target_compiler=""
> +
>  mkdir -p $target_dir
>  echo "# Automatically generated by configure - do not modify" > $config_target_mak
>  
> @@ -6794,6 +6812,7 @@ case "$target_name" in
>      bflt="yes"
>      mttcg="yes"
>      gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
> +    target_compiler=$cross_cc_arm
>    ;;
>    aarch64|aarch64_be)
>      TARGET_ARCH=aarch64
> @@ -6801,6 +6820,7 @@ 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
>    ;;
>    cris)
>    ;;
> @@ -6842,6 +6862,7 @@ case "$target_name" in
>    ;;
>    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
> @@ -6916,6 +6937,25 @@ 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
> +
> +    cat > $TMPC << EOF
> +#include <stdio.h>
> +int main(void) {
> +    printf("Hello World!\n");
> +}
> +EOF
> +
> +    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
> +        target_compiler=""
> +    else
> +        enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
> +    fi
> +else
> +    target_compiler=""
> +fi
> +
>  symlink "$source_path/Makefile.target" "$target_dir/Makefile"
>  
>  upper() {
> @@ -6989,6 +7029,10 @@ 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
> +fi
> +
>  # generate QEMU_CFLAGS/LDFLAGS for targets
>  
>  cflags=""
> @@ -7111,6 +7155,12 @@ 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:"
> +    printf '%s\n' $enabled_cross_compilers | sort -u
> +fi
> +
>  if [ "$dtc_internal" = "yes" ]; then
>    echo "config-host.h: subdir-dtc" >> $config_host_mak
>  fi
> 

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

* Re: [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO
  2018-04-16  2:04   ` Philippe Mathieu-Daudé
@ 2018-04-16  8:49     ` Alex Bennée
  0 siblings, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  8:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 04/10/2018 04:38 PM, Alex Bennée wrote:
>> This allows us to specify cross compilers for our guests. This is
>> useful for building test images/programs. Currently we re-run the
>> compile test for each target. I couldn't think of a way to cache the
>> value for a given arch without getting messier configure code.
>> 
>> The cross compiler for the guest is visible to each target as
>> CROSS_CC_GUEST in config-target.mak.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 50 insertions(+)
>> 
>> diff --git a/configure b/configure
>> index b402befe94..b5f3b3fe29 100755
>> --- a/configure
>> +++ b/configure
>> @@ -453,6 +453,13 @@ vxhs=""
>>  libxml2=""
>>  docker="no"
>>  
>> +# cross compilers defaults, can be overridden with --cross-cc-ARCH
>> +cross_cc_aarch64="aarch64-linux-gnu-gcc"
>> +cross_cc_arm="arm-linux-gnueabihf-gcc"
>> +cross_cc_powerpc="powerpc-linux-gnu-gcc"
>
> These seems distrib-specific... Should we add a case $distrib) ...?

I think of this more as sensible defaults - I would expect most people
using local cross-compilers to be manually setting them up with the
--cross-cc-FOO flag.

>
>> +
>> +enabled_cross_compilers=""
>> +
>>  supported_cpu="no"
>>  supported_os="no"
>>  bogus_os="no"
>> @@ -483,6 +490,11 @@ for opt do
>>    ;;
>>    --disable-debug-info) debug_info="no"
>>    ;;
>> +  --cross-cc-*[!a-zA-Z0-9_0]=*) error_exit "Passed bad --cross-cc-FOO option"
>> +  ;;
>> +  --cross-cc-*) cc_arch=${opt#--cross-cc-}
>> +                eval "cross_cc_${cc_arch}=\$optarg"
>> +  ;;
>>    esac
>>  done
>>  # OS specific
>> @@ -675,10 +687,12 @@ case "$cpu" in
>>    i386|i486|i586|i686|i86pc|BePC)
>>      cpu="i386"
>>      supported_cpu="yes"
>> +    cross_cc_i386=gcc
>>    ;;
>>    x86_64|amd64)
>>      cpu="x86_64"
>>      supported_cpu="yes"
>> +    cross_cc_x86_64=gcc
>>    ;;
>>    armv*b|armv*l|arm)
>>      cpu="arm"
>> @@ -912,6 +926,8 @@ for opt do
>>    ;;
>>    --disable-debug-info)
>>    ;;
>> +  --cross-cc-*)
>> +  ;;
>>    --enable-modules)
>>        modules="yes"
>>    ;;
>> @@ -6766,6 +6782,8 @@ case "$target" in
>>      ;;
>>  esac
>>  
>> +target_compiler=""
>> +
>>  mkdir -p $target_dir
>>  echo "# Automatically generated by configure - do not modify" > $config_target_mak
>>  
>> @@ -6794,6 +6812,7 @@ case "$target_name" in
>>      bflt="yes"
>>      mttcg="yes"
>>      gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
>> +    target_compiler=$cross_cc_arm
>>    ;;
>>    aarch64|aarch64_be)
>>      TARGET_ARCH=aarch64
>> @@ -6801,6 +6820,7 @@ 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
>>    ;;
>>    cris)
>>    ;;
>> @@ -6842,6 +6862,7 @@ case "$target_name" in
>>    ;;
>>    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
>> @@ -6916,6 +6937,25 @@ 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
>> +
>> +    cat > $TMPC << EOF
>> +#include <stdio.h>
>> +int main(void) {
>> +    printf("Hello World!\n");
>> +}
>> +EOF
>> +
>> +    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
>> +        target_compiler=""
>> +    else
>> +        enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
>> +    fi
>> +else
>> +    target_compiler=""
>> +fi
>> +
>>  symlink "$source_path/Makefile.target" "$target_dir/Makefile"
>>  
>>  upper() {
>> @@ -6989,6 +7029,10 @@ 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
>> +fi
>> +
>>  # generate QEMU_CFLAGS/LDFLAGS for targets
>>  
>>  cflags=""
>> @@ -7111,6 +7155,12 @@ 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:"
>> +    printf '%s\n' $enabled_cross_compilers | sort -u
>> +fi
>> +
>>  if [ "$dtc_internal" = "yes" ]; then
>>    echo "config-host.h: subdir-dtc" >> $config_host_mak
>>  fi
>> 


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test
       [not found]     ` <3b680ef4-3304-99d5-75ef-c4d5d570bb3a@amsat.org>
@ 2018-04-16  8:51       ` Alex Bennée
  2018-05-25 10:21       ` Alex Bennée
  1 sibling, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  8:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 04/15/2018 09:07 PM, Philippe Mathieu-Daudé wrote:
>> Hi Fam, Alex,
>> 
>> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>>> From: Fam Zheng <famz@redhat.com>
>>>
>>> To keep the compiler happy, and to fit in our buildsys flags:
>>>
>>> - Make local functions "static"
>>> - #ifdef out unused functions
>>> - drop cutils/osdep dependencies
>>>
>>> Signed-off-by: Fam Zheng <famz@redhat.com>
>>> [AJB: drop cutils/osdep dependencies]
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>  tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
>>>  1 file changed, 21 insertions(+), 47 deletions(-)
>>>
>>> diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
>>> index 5070d31446..4457bd04ba 100644
>>> --- a/tests/tcg/multiarch/linux-test.c
>>> +++ b/tests/tcg/multiarch/linux-test.c
>>> @@ -16,7 +16,6 @@
>>>   *  You should have received a copy of the GNU General Public License
>>>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>>>   */
>>> -#define _GNU_SOURCE
>>>  #include <stdarg.h>
>>>  #include <stdlib.h>
>>>  #include <stdio.h>
>>> @@ -31,6 +30,7 @@
>>>  #include <utime.h>
>>>  #include <time.h>
>>>  #include <sys/time.h>
>>> +#include <sys/resource.h>
>>>  #include <sys/uio.h>
>>>  #include <sys/socket.h>
>>>  #include <netinet/in.h>
>>> @@ -39,13 +39,12 @@
>>>  #include <dirent.h>
>>>  #include <setjmp.h>
>>>  #include <sys/shm.h>
>>> -#include "qemu/cutils.h"
>>>  
>>>  #define TESTPATH "/tmp/linux-test.tmp"
>>>  #define TESTPORT 7654
>>>  #define STACK_SIZE 16384
>>>  
>>> -void error1(const char *filename, int line, const char *fmt, ...)
>>> +static void error1(const char *filename, int line, const char *fmt, ...)
>>>  {
>>>      va_list ap;
>>>      va_start(ap, fmt);
>>> @@ -56,7 +55,7 @@ void error1(const char *filename, int line, const char *fmt, ...)
>>>      exit(1);
>>>  }
>>>  
>>> -int __chk_error(const char *filename, int line, int ret)
>>> +static int __chk_error(const char *filename, int line, int ret)
>>>  {
>>>      if (ret < 0) {
>>>          error1(filename, line, "%m (ret=%d, errno=%d)",
>>> @@ -73,7 +72,7 @@ int __chk_error(const char *filename, int line, int ret)
>>>  
>>>  #define FILE_BUF_SIZE 300
>>>  
>>> -void test_file(void)
>>> +static void test_file(void)
>>>  {
>>>      int fd, i, len, ret;
>>>      uint8_t buf[FILE_BUF_SIZE];
>>> @@ -210,7 +209,7 @@ void test_file(void)
>>>      chk_error(rmdir(TESTPATH));
>>>  }
>>>  
>>> -void test_fork(void)
>>> +static void test_fork(void)
>>>  {
>>>      int pid, status;
>>>  
>>> @@ -224,7 +223,7 @@ void test_fork(void)
>>>          error("waitpid status=0x%x", status);
>>>  }
>>>  
>>> -void test_time(void)
>>> +static void test_time(void)
>>>  {
>>>      struct timeval tv, tv2;
>>>      struct timespec ts, rem;
>>> @@ -251,34 +250,7 @@ void test_time(void)
>>>          error("getrusage");
>>>  }
>>>  
>>> -void pstrcpy(char *buf, int buf_size, const char *str)
>>> -{
>>> -    int c;
>>> -    char *q = buf;
>>> -
>>> -    if (buf_size <= 0)
>>> -        return;
>>> -
>>> -    for(;;) {
>>> -        c = *str++;
>>> -        if (c == 0 || q >= buf + buf_size - 1)
>>> -            break;
>>> -        *q++ = c;
>>> -    }
>>> -    *q = '\0';
>>> -}
>>> -
>>> -/* strcat and truncate. */
>>> -char *pstrcat(char *buf, int buf_size, const char *s)
>>> -{
>>> -    int len;
>>> -    len = strlen(buf);
>>> -    if (len < buf_size)
>>> -        pstrcpy(buf + len, buf_size - len, s);
>>> -    return buf;
>>> -}
>>> -
>>> -int server_socket(void)
>>> +static int server_socket(void)
>>>  {
>>>      int val, fd;
>>>      struct sockaddr_in sockaddr;
>>> @@ -298,7 +270,7 @@ int server_socket(void)
>>>  
>>>  }
>>>  
>>> -int client_socket(void)
>>> +static int client_socket(void)
>>>  {
>>>      int fd;
>>>      struct sockaddr_in sockaddr;
>>> @@ -312,9 +284,9 @@ int client_socket(void)
>>>      return fd;
>>>  }
>>>  
>>> -const char socket_msg[] = "hello socket\n";
>>> +static const char socket_msg[] = "hello socket\n";
>>>  
>>> -void test_socket(void)
>>> +static void test_socket(void)
>>>  {
>>>      int server_fd, client_fd, fd, pid, ret, val;
>>>      struct sockaddr_in sockaddr;
>>> @@ -348,9 +320,10 @@ void test_socket(void)
>>>      chk_error(close(server_fd));
>>>  }
>>>  
>>> +#if 0
>> 
>> Why keep this now dead code?
>
> You can use: #ifdef LINUX_TEST_CLONE
>
> But this my be even better to move this chunk as a stand-alone test in a
> new file, linux-clone-test.c and add a make rule to only include it in
> the TEST_SRCS var when the host is able to run it.

There is certainly some cleaning up to the tests to do. I'll put it in a
separate patch though.

>
>> 
>>>  #define WCOUNT_MAX 512
>>>  
>>> -void test_pipe(void)
>>> +static void test_pipe(void)
>>>  {
>>>      fd_set rfds, wfds;
>>>      int fds[2], fd_max, ret;
>>> @@ -391,10 +364,10 @@ void test_pipe(void)
>>>      chk_error(close(fds[1]));
>>>  }
>>>  
>>> -int thread1_res;
>>> -int thread2_res;
>>> +static int thread1_res;
>>> +static int thread2_res;
>>>  
>>> -int thread1_func(void *arg)
>>> +static int thread1_func(void *arg)
>>>  {
>>>      int i;
>>>      for(i=0;i<5;i++) {
>>> @@ -404,7 +377,7 @@ int thread1_func(void *arg)
>>>      return 0;
>>>  }
>>>  
>>> -int thread2_func(void *arg)
>>> +static int thread2_func(void *arg)
>>>  {
>>>      int i;
>>>      for(i=0;i<6;i++) {
>>> @@ -435,27 +408,28 @@ void test_clone(void)
>>>          thread2_res != 6)
>>>          error("clone");
>>>  }
>>> +#endif
>>>  
>>>  /***********************************/
>>>  
>>>  volatile int alarm_count;
>>>  jmp_buf jmp_env;
>>>  
>>> -void sig_alarm(int sig)
>>> +static void sig_alarm(int sig)
>>>  {
>>>      if (sig != SIGALRM)
>>>          error("signal");
>>>      alarm_count++;
>>>  }
>>>  
>>> -void sig_segv(int sig, siginfo_t *info, void *puc)
>>> +static void sig_segv(int sig, siginfo_t *info, void *puc)
>>>  {
>>>      if (sig != SIGSEGV)
>>>          error("signal");
>>>      longjmp(jmp_env, 1);
>>>  }
>>>  
>>> -void test_signal(void)
>>> +static void test_signal(void)
>>>  {
>>>      struct sigaction act;
>>>      struct itimerval it, oit;
>>> @@ -510,7 +484,7 @@ void test_signal(void)
>>>  
>>>  #define SHM_SIZE 32768
>>>  
>>> -void test_shm(void)
>>> +static void test_shm(void)
>>>  {
>>>      void *ptr;
>>>      int shmid;
>>>


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-16  1:52   ` Philippe Mathieu-Daudé
@ 2018-04-16  8:53     ` Alex Bennée
  2018-04-16 10:24       ` Philippe Mathieu-Daudé
  2018-04-16 17:14       ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  8:53 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>> Now all the build infrastructure is in place we can build tests for
>> each guest that we support. That support mainly depends on having
>> cross compilers installed or docker setup. To keep all the logic for
>> that together we put the rules in tests/tcg/Makefile.include and
>> include it from the main Makefile.target.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  Makefile.target            |  5 +++
>>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 84 insertions(+)
>>  create mode 100644 tests/tcg/Makefile.include
>> 
>> diff --git a/Makefile.target b/Makefile.target
>> index d0ec77a307..a30fd40257 100644
>> --- a/Makefile.target
>> +++ b/Makefile.target
>> @@ -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
>>  
>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
>> new file mode 100644
>> index 0000000000..cb8bb36026
>> --- /dev/null
>> +++ b/tests/tcg/Makefile.include
>> @@ -0,0 +1,79 @@
>> +# -*- Mode: makefile -*-
>> +#
>> +# TCG tests (per-target rules)
>> +#
>> +# This Makefile fragement is included from the per-target
>> +# Makefile.target so will be invoked for each linux-user program we
>> +# build. We have two options for compiling, either using a configured
>> +# guest compiler or calling one of our docker images to do it for us.
>> +#
>> +
>> +# The per ARCH makefile, if it exists holds extra information about
>> +# useful docker images or alternative compiler flags. Include it if it
>> +# exists
>> +
>> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
>> +
>> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
>> +include $(ARCH_MAKEFILE)
>> +endif
>> +
>> +GUEST_BUILD=
>> +
>> +# Support installed Cross Compilers
>> +
>> +ifdef CROSS_CC_GUEST
>> +
>> +.PHONY: cross-build-guest-tests
>> +cross-build-guest-tests:
>> +	$(call quiet-command, \
>> +          (mkdir -p tests && cd tests && \
>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>> +
>> +
>> +GUEST_BUILD=cross-build-guest-tests
>> +
>> +endif
>> +
>> +# Support building with Docker
>> +
>> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>> +ifneq ($(DOCKER_IMAGE),)
>> +
>> +# We also need the Docker make rules to depend on
>> +include $(SRC_PATH)/tests/docker/Makefile.include
>> +
>
> Eventually:
>
> DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc
>
>> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>> +		--cc $(DOCKER_CROSS_COMPILER) \
>> +		-i qemu:$(DOCKER_IMAGE) \
>> +		-s $(SRC_PATH) -- "
>
> Should we check $(DOCKER_CROSS_COMPILER) is set?

Currently it's implied. It would be nice if there was an easy way just
to fish it out of the env of the docker image as they already have it
set there.

I've been trying quite hard to ensure all the tests can just use LD (see
the hoops I jump in i386 for this). Maybe a prefix config makes more
sense though....

>
>> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>> +
>> +.PHONY: docker-build-guest-tests
>> +docker-build-guest-tests: $(DOCKER_PREREQ)
>> +	$(call quiet-command, \
>> +          (mkdir -p tests && cd tests && \
>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>> +
>> +GUEST_BUILD=docker-build-guest-tests
>> +
>> +endif
>> +endif
>> +
>> +# Final targets
>> +.PHONY: guest-tests
>> +
>> +ifneq ($(GUEST_BUILD),)
>> +guest-tests: $(GUEST_BUILD)
>> +else
>> +guest-tests:
>> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
>> +endif
>> +
>> +# It doesn't mater if these don't exits
>> +.PHONY: clean-guest-tests
>> +clean-guest-tests:
>> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>> 


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64
  2018-04-16  1:36   ` Philippe Mathieu-Daudé
@ 2018-04-16  8:54     ` Alex Bennée
  0 siblings, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  8:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Alex,
>
> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>> Currently this just enables building the multiarch tests.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>
> "make tcg-tests-ppc64-linux-user" works indeed.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Do we care about ppc[32]?

Yes, certainly I'll get anything working that we can reasonably do with
our docker images.

>
>> ---
>>  tests/tcg/ppc64/Makefile.include | 2 ++
>>  1 file changed, 2 insertions(+)
>>  create mode 100644 tests/tcg/ppc64/Makefile.include
>> 
>> diff --git a/tests/tcg/ppc64/Makefile.include b/tests/tcg/ppc64/Makefile.include
>> new file mode 100644
>> index 0000000000..d71cfc9aa7
>> --- /dev/null
>> +++ b/tests/tcg/ppc64/Makefile.include
>> @@ -0,0 +1,2 @@
>> +DOCKER_IMAGE=debian-ppc64el-cross
>> +DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir
  2018-04-16  1:02   ` Philippe Mathieu-Daudé
  2018-04-16  1:33     ` Philippe Mathieu-Daudé
@ 2018-04-16  8:56     ` Alex Bennée
  2018-04-16 10:21       ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  8:56 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, famz, Yongbok Kim, cota, Aurelien Jarno


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>> These only need to be built for MIPS guests.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/tcg/README                  | 11 -----------
>>  tests/tcg/mips/README             |  7 +++++++
>>  tests/tcg/{ => mips}/hello-mips.c |  0
>>  3 files changed, 7 insertions(+), 11 deletions(-)
>>  create mode 100644 tests/tcg/mips/README
>>  rename tests/tcg/{ => mips}/hello-mips.c (100%)
>> 
>> diff --git a/tests/tcg/README b/tests/tcg/README
>> index 625f2326e6..a5643d33e7 100644
>> --- a/tests/tcg/README
>> +++ b/tests/tcg/README
>> @@ -3,17 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
>>  built for all guest architectures that support linux-user executable,
>>  or they are architecture specific.
>>  
>> -
>> -
>> -MIPS
>> -====
>> -
>> -hello-mips
>> -----------
>> -
>> -hello-mipsel
>> -------------
>> -
>>  CRIS
>>  ====
>>  The testsuite for CRIS is in tests/tcg/cris.  You can run it
>> diff --git a/tests/tcg/mips/README b/tests/tcg/mips/README
>> new file mode 100644
>> index 0000000000..e5bbc58ec5
>> --- /dev/null
>> +++ b/tests/tcg/mips/README
>> @@ -0,0 +1,7 @@
>> +MIPS
>> +====
>> +
>> +hello-mips
>> +----------
>> +
>> +A very simple inline assembly, write syscall based hello world
>> diff --git a/tests/tcg/hello-mips.c b/tests/tcg/mips/hello-mips.c
>> similarity index 100%
>> rename from tests/tcg/hello-mips.c
>> rename to tests/tcg/mips/hello-mips.c
>
> tested with:
>
> -- >8 --
> diff --git a/configure b/configure
> index c98eb01c39..aebe928b3c 100755
> --- a/configure
> +++ b/configure
> @@ -455,6 +455,7 @@ docker="no"
>  # cross compilers defaults, can be overridden with --cross-cc-ARCH
>  cross_cc_aarch64="aarch64-linux-gnu-gcc"
>  cross_cc_arm="arm-linux-gnueabihf-gcc"
> +cross_cc_mips="mipsel-linux-gnu-gcc"
>  cross_cc_powerpc="powerpc-linux-gnu-gcc"
>  cross_cc_i386="i386-pc-linux-gnu-gcc"
>  cross_cc_i386_cflags=""
> @@ -6860,6 +6861,7 @@ case "$target_name" in
>    mips|mipsel)
>      TARGET_ARCH=mips
>      echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
> +    target_compiler=$cross_cc_mips
>    ;;
>    mipsn32|mipsn32el)
>      TARGET_ARCH=mips64
> diff --git a/tests/tcg/mips/Makefile.target b/tests/tcg/mips/Makefile.target
> new file mode 100644
> index 0000000000..427aafc9e5
> --- /dev/null
> +++ b/tests/tcg/mips/Makefile.target
> @@ -0,0 +1,6 @@
> +# -*- Mode: makefile -*-
> +#
> +# MIPS specific tweaks
> +
> +hello-mips: CFLAGS+=-ffreestanding
> +hello-mips: LDFLAGS+=-nostdlib

I've jiggled things around a bit for v2 to include:

  # The order we include is important. We include multiarch, base arch and finally arch
  -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
  -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
 
So hopefully I don't have to split up the current MIPS dir and the
tcg/MIPS/Makefile.target will deal with all the variations.

-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386
  2018-04-16  0:11   ` Philippe Mathieu-Daudé
@ 2018-04-16  8:57     ` Alex Bennée
  0 siblings, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  8:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Fam, Alex,
>
> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>> From: Fam Zheng <famz@redhat.com>
>> 
>> We have -Werror=missing-prototype, add a dummy prototype to avoid that
>> warning.
>> 
>> Signed-off-by: Fam Zheng <famz@redhat.com>
>> ---
>>  tests/tcg/i386/hello-i386.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c
>> index fa00380de2..cfeb24b2f5 100644
>> --- a/tests/tcg/i386/hello-i386.c
>> +++ b/tests/tcg/i386/hello-i386.c
>> @@ -20,6 +20,7 @@ static inline int write(int fd, const char * buf, int len)
>>    return status;
>>  }
>>  
>> +void _start(void);
>
> What about adding that in a common base file include by all tcg tests?
> Such tests/tcg/include/tcg-common.h or better name...

For this I don't think it makes much sense. Not all linux-user tests are
quite so bare bones...

>
>>  void _start(void)
>>  {
>>      write(1, "Hello World\n", 12);
>> 


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir
  2018-04-16  0:05   ` Philippe Mathieu-Daudé
@ 2018-04-16  9:01     ` Alex Bennée
  0 siblings, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  9:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Alex,
>
> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>> We will want to build these for all supported guest architectures so
>> lets move them all into one place. We also drop test_path at this
>> point because it needs qemu utils and glib bits which is hard to
>> support for cross compiling.
>
> Can we keep it for the $target==$host case (or when NOT cross
> compiling)? Maybe move it to tests/tcg/host/test_path.c

I'd rather not have tests/tcg/ including anything from QEMU as that
implies more libraries and hence a trickier cross-compile environment.
That said I didn't actually dig into what exactly
init_paths("/tmp/qemu-test_path") was intended to achieve.

>
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/tcg/README                       |  10 +--
>>  tests/tcg/multiarch/README             |   1 +
>>  tests/tcg/{ => multiarch}/linux-test.c |   0
>>  tests/tcg/{ => multiarch}/sha1.c       |   0
>>  tests/tcg/{ => multiarch}/test-mmap.c  |   0
>>  tests/tcg/{ => multiarch}/testthread.c |   0
>>  tests/tcg/test_path.c                  | 157 ---------------------------------
>>  7 files changed, 5 insertions(+), 163 deletions(-)
>>  create mode 100644 tests/tcg/multiarch/README
>>  rename tests/tcg/{ => multiarch}/linux-test.c (100%)
>>  rename tests/tcg/{ => multiarch}/sha1.c (100%)
>>  rename tests/tcg/{ => multiarch}/test-mmap.c (100%)
>>  rename tests/tcg/{ => multiarch}/testthread.c (100%)
>>  delete mode 100644 tests/tcg/test_path.c
>> 
>> diff --git a/tests/tcg/README b/tests/tcg/README
>> index 5dcfb4852b..0890044cf0 100644
>> --- a/tests/tcg/README
>> +++ b/tests/tcg/README
>> @@ -1,9 +1,7 @@
>> -This directory contains various interesting programs for
>> -regression testing.
>> -
>> -The target "make test" runs the programs and, if applicable,
>> -runs "diff" to detect mismatches between output on the host and
>> -output on QEMU.
>> +This directory contains various interesting guest programs for
>> +regression testing. Tests are either multi-arch, meaning they can be
>> +built for all guest architectures that support linux-user executable,
>> +or they are architecture specific.
>>  
>>  i386
>>  ====
>> diff --git a/tests/tcg/multiarch/README b/tests/tcg/multiarch/README
>> new file mode 100644
>> index 0000000000..522c9d2ea3
>> --- /dev/null
>> +++ b/tests/tcg/multiarch/README
>> @@ -0,0 +1 @@
>> +Multi-architecture linux-user tests
>> diff --git a/tests/tcg/linux-test.c b/tests/tcg/multiarch/linux-test.c
>> similarity index 100%
>> rename from tests/tcg/linux-test.c
>> rename to tests/tcg/multiarch/linux-test.c
>> diff --git a/tests/tcg/sha1.c b/tests/tcg/multiarch/sha1.c
>> similarity index 100%
>> rename from tests/tcg/sha1.c
>> rename to tests/tcg/multiarch/sha1.c
>> diff --git a/tests/tcg/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
>> similarity index 100%
>> rename from tests/tcg/test-mmap.c
>> rename to tests/tcg/multiarch/test-mmap.c
>> diff --git a/tests/tcg/testthread.c b/tests/tcg/multiarch/testthread.c
>> similarity index 100%
>> rename from tests/tcg/testthread.c
>> rename to tests/tcg/multiarch/testthread.c
>> diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
>> deleted file mode 100644
>> index 1c29bce263..0000000000
>> --- a/tests/tcg/test_path.c
>> +++ /dev/null
>> @@ -1,157 +0,0 @@
>> -/* Test path override code */
>> -#include "config-host.h"
>> -#include "util/cutils.c"
>> -#include "util/hexdump.c"
>> -#include "util/iov.c"
>> -#include "util/path.c"
>> -#include "util/qemu-timer-common.c"
>> -#include <stdarg.h>
>> -#include <sys/stat.h>
>> -#include <fcntl.h>
>> -
>> -void qemu_log(const char *fmt, ...);
>> -
>> -/* Any log message kills the test. */
>> -void qemu_log(const char *fmt, ...)
>> -{
>> -    va_list ap;
>> -
>> -    fprintf(stderr, "FATAL: ");
>> -    va_start(ap, fmt);
>> -    vfprintf(stderr, fmt, ap);
>> -    va_end(ap);
>> -    exit(1);
>> -}
>> -
>> -#define NO_CHANGE(_path)						\
>> -	do {								\
>> -	    if (strcmp(path(_path), _path) != 0) return __LINE__;	\
>> -	} while(0)
>> -
>> -#define CHANGE_TO(_path, _newpath)					\
>> -	do {								\
>> -	    if (strcmp(path(_path), _newpath) != 0) return __LINE__;	\
>> -	} while(0)
>> -
>> -static void cleanup(void)
>> -{
>> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE2");
>> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE3");
>> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE4");
>> -    unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE5");
>> -    rmdir("/tmp/qemu-test_path/DIR1/DIR2");
>> -    rmdir("/tmp/qemu-test_path/DIR1/DIR3");
>> -    rmdir("/tmp/qemu-test_path/DIR1");
>> -    rmdir("/tmp/qemu-test_path");
>> -}
>> -
>> -static unsigned int do_test(void)
>> -{
>> -    if (mkdir("/tmp/qemu-test_path", 0700) != 0)
>> -	return __LINE__;
>> -
>> -    if (mkdir("/tmp/qemu-test_path/DIR1", 0700) != 0)
>> -	return __LINE__;
>> -
>> -    if (mkdir("/tmp/qemu-test_path/DIR1/DIR2", 0700) != 0)
>> -	return __LINE__;
>> -
>> -    if (mkdir("/tmp/qemu-test_path/DIR1/DIR3", 0700) != 0)
>> -	return __LINE__;
>> -
>> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE", 0600)) != 0)
>> -	return __LINE__;
>> -
>> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE2", 0600)) != 0)
>> -	return __LINE__;
>> -
>> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE3", 0600)) != 0)
>> -	return __LINE__;
>> -
>> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE4", 0600)) != 0)
>> -	return __LINE__;
>> -
>> -    if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE5", 0600)) != 0)
>> -	return __LINE__;
>> -
>> -    init_paths("/tmp/qemu-test_path");
>> -
>> -    NO_CHANGE("/tmp");
>> -    NO_CHANGE("/tmp/");
>> -    NO_CHANGE("/tmp/qemu-test_path");
>> -    NO_CHANGE("/tmp/qemu-test_path/");
>> -    NO_CHANGE("/tmp/qemu-test_path/D");
>> -    NO_CHANGE("/tmp/qemu-test_path/DI");
>> -    NO_CHANGE("/tmp/qemu-test_path/DIR");
>> -    NO_CHANGE("/tmp/qemu-test_path/DIR1");
>> -    NO_CHANGE("/tmp/qemu-test_path/DIR1/");
>> -
>> -    NO_CHANGE("/D");
>> -    NO_CHANGE("/DI");
>> -    NO_CHANGE("/DIR");
>> -    NO_CHANGE("/DIR2");
>> -    NO_CHANGE("/DIR1.");
>> -
>> -    CHANGE_TO("/DIR1", "/tmp/qemu-test_path/DIR1");
>> -    CHANGE_TO("/DIR1/", "/tmp/qemu-test_path/DIR1");
>> -
>> -    NO_CHANGE("/DIR1/D");
>> -    NO_CHANGE("/DIR1/DI");
>> -    NO_CHANGE("/DIR1/DIR");
>> -    NO_CHANGE("/DIR1/DIR1");
>> -
>> -    CHANGE_TO("/DIR1/DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
>> -    CHANGE_TO("/DIR1/DIR2/", "/tmp/qemu-test_path/DIR1/DIR2");
>> -
>> -    CHANGE_TO("/DIR1/DIR3", "/tmp/qemu-test_path/DIR1/DIR3");
>> -    CHANGE_TO("/DIR1/DIR3/", "/tmp/qemu-test_path/DIR1/DIR3");
>> -
>> -    NO_CHANGE("/DIR1/DIR2/F");
>> -    NO_CHANGE("/DIR1/DIR2/FI");
>> -    NO_CHANGE("/DIR1/DIR2/FIL");
>> -    NO_CHANGE("/DIR1/DIR2/FIL.");
>> -
>> -    CHANGE_TO("/DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/DIR1/DIR2/FILE2", "/tmp/qemu-test_path/DIR1/DIR2/FILE2");
>> -    CHANGE_TO("/DIR1/DIR2/FILE3", "/tmp/qemu-test_path/DIR1/DIR2/FILE3");
>> -    CHANGE_TO("/DIR1/DIR2/FILE4", "/tmp/qemu-test_path/DIR1/DIR2/FILE4");
>> -    CHANGE_TO("/DIR1/DIR2/FILE5", "/tmp/qemu-test_path/DIR1/DIR2/FILE5");
>> -
>> -    NO_CHANGE("/DIR1/DIR2/FILE6");
>> -    NO_CHANGE("/DIR1/DIR2/FILE/X");
>> -
>> -    CHANGE_TO("/DIR1/../DIR1", "/tmp/qemu-test_path/DIR1");
>> -    CHANGE_TO("/DIR1/../DIR1/", "/tmp/qemu-test_path/DIR1");
>> -    CHANGE_TO("/../DIR1", "/tmp/qemu-test_path/DIR1");
>> -    CHANGE_TO("/../DIR1/", "/tmp/qemu-test_path/DIR1");
>> -    CHANGE_TO("/DIR1/DIR2/../DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
>> -    CHANGE_TO("/DIR1/DIR2/../DIR2/../../DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/DIR1/DIR2/../DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -
>> -    NO_CHANGE("/DIR1/DIR2/../DIR1");
>> -    NO_CHANGE("/DIR1/DIR2/../FILE");
>> -
>> -    CHANGE_TO("/./DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/././DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/DIR1/./DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/DIR1/././DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/DIR1/DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/DIR1/DIR2/././FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -    CHANGE_TO("/./DIR1/./DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
>> -
>> -    return 0;
>> -}
>> -
>> -int main(int argc, char *argv[])
>> -{
>> -    int ret;
>> -
>> -    ret = do_test();
>> -    cleanup();
>> -    if (ret) {
>> -	fprintf(stderr, "test_path: failed on line %i\n", ret);
>> -	return 1;
>> -    }
>> -    return 0;
>> -}
>> 


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386
  2018-04-16  0:01   ` Philippe Mathieu-Daudé
@ 2018-04-16  9:02     ` Alex Bennée
  2018-04-16 10:30       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-16  9:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Alex,
>
> On 04/10/2018 04:38 PM, Alex Bennée wrote:
>> We should still be able to use the system cross compiler with the
>> appropriate flags on x86_64 hosts.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  configure | 23 +++++++++++++++--------
>>  1 file changed, 15 insertions(+), 8 deletions(-)
>> 
>> diff --git a/configure b/configure
>> index b5f3b3fe29..add87ff4d4 100755
>> --- a/configure
>> +++ b/configure
>> @@ -284,7 +284,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=""
>> @@ -457,6 +456,8 @@ docker="no"
>>  cross_cc_aarch64="aarch64-linux-gnu-gcc"
>>  cross_cc_arm="arm-linux-gnueabihf-gcc"
>>  cross_cc_powerpc="powerpc-linux-gnu-gcc"
>> +cross_cc_i386="i386-pc-linux-gnu-gcc"
>> +cross_cc_i386_cflags=""
>
> Can you keep this sorted? (arm < i386 < powerpc)

Sure.

>
> Thanks :)
>
>>  
>>  enabled_cross_compilers=""
>>  
>> @@ -687,12 +688,10 @@ case "$cpu" in
>
> What do you think about renaming $cpu -> host_cpu/target_cpu?

I'd rather avoid too much churn in configure. Maybe a separate clean-up
patch?

>
>>    i386|i486|i586|i686|i86pc|BePC)
>>      cpu="i386"
>>      supported_cpu="yes"
>> -    cross_cc_i386=gcc
>>    ;;
>>    x86_64|amd64)
>>      cpu="x86_64"
>>      supported_cpu="yes"
>> -    cross_cc_x86_64=gcc
>>    ;;
>>    armv*b|armv*l|arm)
>>      cpu="arm"
>> @@ -1435,7 +1434,6 @@ case "$cpu" in
>>      i386)
>>             CPU_CFLAGS="-m32"
>>             LDFLAGS="-m32 $LDFLAGS"
>> -           cc_i386='$(CC) -m32'
>>             ;;
>>      x86_64)
>>             # ??? Only extremely old AMD cpus do not have cmpxchg16b.
>> @@ -1443,12 +1441,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_i386=$cc
>> +           cross_cc_i386_cflags="-m32"
>>             ;;
>>      x32)
>>             CPU_CFLAGS="-mx32"
>>             LDFLAGS="-mx32 $LDFLAGS"
>> -           cc_i386='$(CC) -m32'
>> +           cross_cc_i386=$cc
>> +           cross_cc_i386_cflags="-m32"
>>             ;;
>>      # No special flags required for other host CPUs
>>  esac
>> @@ -6664,7 +6664,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
>> @@ -6783,6 +6782,7 @@ case "$target" in
>>  esac
>>  
>>  target_compiler=""
>> +target_compiler_cflags=""
>>  
>>  mkdir -p $target_dir
>>  echo "# Automatically generated by configure - do not modify" > $config_target_mak
>> @@ -6799,10 +6799,13 @@ 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_i386_cflags
>>    ;;
>>    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"
>> @@ -6947,7 +6950,7 @@ int main(void) {
>>  }
>>  EOF
>>  
>> -    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
>> +    if ! do_compiler $target_compiler $target_compiler_cflags -o $TMPE $TMPC -static ; then
>>          target_compiler=""
>>      else
>>          enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
>> @@ -7033,6 +7036,10 @@ if test -n "$target_compiler"; then
>>    echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
>>  fi
>>  
>> +if test -n "$target_compiler_cflags"; then
>> +  echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
>> +fi
>> +
>>  # generate QEMU_CFLAGS/LDFLAGS for targets
>>  
>>  cflags=""
>> 


-- 
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir
  2018-04-16  8:56     ` Alex Bennée
@ 2018-04-16 10:21       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16 10:21 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, famz, Yongbok Kim, cota, Aurelien Jarno

On 04/16/2018 05:56 AM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> 
>> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>>> These only need to be built for MIPS guests.
>>>
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>  tests/tcg/README                  | 11 -----------
>>>  tests/tcg/mips/README             |  7 +++++++
>>>  tests/tcg/{ => mips}/hello-mips.c |  0
>>>  3 files changed, 7 insertions(+), 11 deletions(-)
>>>  create mode 100644 tests/tcg/mips/README
>>>  rename tests/tcg/{ => mips}/hello-mips.c (100%)
>>>
>>> diff --git a/tests/tcg/README b/tests/tcg/README
>>> index 625f2326e6..a5643d33e7 100644
>>> --- a/tests/tcg/README
>>> +++ b/tests/tcg/README
>>> @@ -3,17 +3,6 @@ regression testing. Tests are either multi-arch, meaning they can be
>>>  built for all guest architectures that support linux-user executable,
>>>  or they are architecture specific.
>>>  
>>> -
>>> -
>>> -MIPS
>>> -====
>>> -
>>> -hello-mips
>>> -----------
>>> -
>>> -hello-mipsel
>>> -------------
>>> -
>>>  CRIS
>>>  ====
>>>  The testsuite for CRIS is in tests/tcg/cris.  You can run it
>>> diff --git a/tests/tcg/mips/README b/tests/tcg/mips/README
>>> new file mode 100644
>>> index 0000000000..e5bbc58ec5
>>> --- /dev/null
>>> +++ b/tests/tcg/mips/README
>>> @@ -0,0 +1,7 @@
>>> +MIPS
>>> +====
>>> +
>>> +hello-mips
>>> +----------
>>> +
>>> +A very simple inline assembly, write syscall based hello world
>>> diff --git a/tests/tcg/hello-mips.c b/tests/tcg/mips/hello-mips.c
>>> similarity index 100%
>>> rename from tests/tcg/hello-mips.c
>>> rename to tests/tcg/mips/hello-mips.c
>>
>> tested with:
>>
>> -- >8 --
>> diff --git a/configure b/configure
>> index c98eb01c39..aebe928b3c 100755
>> --- a/configure
>> +++ b/configure
>> @@ -455,6 +455,7 @@ docker="no"
>>  # cross compilers defaults, can be overridden with --cross-cc-ARCH
>>  cross_cc_aarch64="aarch64-linux-gnu-gcc"
>>  cross_cc_arm="arm-linux-gnueabihf-gcc"
>> +cross_cc_mips="mipsel-linux-gnu-gcc"
>>  cross_cc_powerpc="powerpc-linux-gnu-gcc"
>>  cross_cc_i386="i386-pc-linux-gnu-gcc"
>>  cross_cc_i386_cflags=""
>> @@ -6860,6 +6861,7 @@ case "$target_name" in
>>    mips|mipsel)
>>      TARGET_ARCH=mips
>>      echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
>> +    target_compiler=$cross_cc_mips
>>    ;;
>>    mipsn32|mipsn32el)
>>      TARGET_ARCH=mips64
>> diff --git a/tests/tcg/mips/Makefile.target b/tests/tcg/mips/Makefile.target
>> new file mode 100644
>> index 0000000000..427aafc9e5
>> --- /dev/null
>> +++ b/tests/tcg/mips/Makefile.target
>> @@ -0,0 +1,6 @@
>> +# -*- Mode: makefile -*-
>> +#
>> +# MIPS specific tweaks
>> +
>> +hello-mips: CFLAGS+=-ffreestanding
>> +hello-mips: LDFLAGS+=-nostdlib
> 
> I've jiggled things around a bit for v2 to include:
> 
>   # The order we include is important. We include multiarch, base arch and finally arch
>   -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
>   -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
>   -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
>  
> So hopefully I don't have to split up the current MIPS dir and the
> tcg/MIPS/Makefile.target will deal with all the variations.

Excellent, thanks :)

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-16  8:53     ` Alex Bennée
@ 2018-04-16 10:24       ` Philippe Mathieu-Daudé
  2018-04-16 17:14       ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16 10:24 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, famz, cota

On 04/16/2018 05:53 AM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> 
>> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>>> Now all the build infrastructure is in place we can build tests for
>>> each guest that we support. That support mainly depends on having
>>> cross compilers installed or docker setup. To keep all the logic for
>>> that together we put the rules in tests/tcg/Makefile.include and
>>> include it from the main Makefile.target.
>>>
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>  Makefile.target            |  5 +++
>>>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>>>  2 files changed, 84 insertions(+)
>>>  create mode 100644 tests/tcg/Makefile.include
>>>
>>> diff --git a/Makefile.target b/Makefile.target
>>> index d0ec77a307..a30fd40257 100644
>>> --- a/Makefile.target
>>> +++ b/Makefile.target
>>> @@ -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
>>>  
>>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
>>> new file mode 100644
>>> index 0000000000..cb8bb36026
>>> --- /dev/null
>>> +++ b/tests/tcg/Makefile.include
>>> @@ -0,0 +1,79 @@
>>> +# -*- Mode: makefile -*-
>>> +#
>>> +# TCG tests (per-target rules)
>>> +#
>>> +# This Makefile fragement is included from the per-target
>>> +# Makefile.target so will be invoked for each linux-user program we
>>> +# build. We have two options for compiling, either using a configured
>>> +# guest compiler or calling one of our docker images to do it for us.
>>> +#
>>> +
>>> +# The per ARCH makefile, if it exists holds extra information about
>>> +# useful docker images or alternative compiler flags. Include it if it
>>> +# exists
>>> +
>>> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>>> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
>>> +
>>> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
>>> +include $(ARCH_MAKEFILE)
>>> +endif
>>> +
>>> +GUEST_BUILD=
>>> +
>>> +# Support installed Cross Compilers
>>> +
>>> +ifdef CROSS_CC_GUEST
>>> +
>>> +.PHONY: cross-build-guest-tests
>>> +cross-build-guest-tests:
>>> +	$(call quiet-command, \
>>> +          (mkdir -p tests && cd tests && \
>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>>> +
>>> +
>>> +GUEST_BUILD=cross-build-guest-tests
>>> +
>>> +endif
>>> +
>>> +# Support building with Docker
>>> +
>>> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>>> +ifneq ($(DOCKER_IMAGE),)
>>> +
>>> +# We also need the Docker make rules to depend on
>>> +include $(SRC_PATH)/tests/docker/Makefile.include
>>> +
>>
>> Eventually:
>>
>> DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc
>>
>>> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>>> +		--cc $(DOCKER_CROSS_COMPILER) \
>>> +		-i qemu:$(DOCKER_IMAGE) \
>>> +		-s $(SRC_PATH) -- "
>>
>> Should we check $(DOCKER_CROSS_COMPILER) is set?
> 
> Currently it's implied. It would be nice if there was an easy way just
> to fish it out of the env of the docker image as they already have it
> set there.

What about splitting this out of Dockerfiles into a shell profile, so we
can source it from outside/inside of docker images?

> 
> I've been trying quite hard to ensure all the tests can just use LD (see
> the hoops I jump in i386 for this). Maybe a prefix config makes more
> sense though....
> 
>>
>>> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>>> +
>>> +.PHONY: docker-build-guest-tests
>>> +docker-build-guest-tests: $(DOCKER_PREREQ)
>>> +	$(call quiet-command, \
>>> +          (mkdir -p tests && cd tests && \
>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>>> +
>>> +GUEST_BUILD=docker-build-guest-tests
>>> +
>>> +endif
>>> +endif
>>> +
>>> +# Final targets
>>> +.PHONY: guest-tests
>>> +
>>> +ifneq ($(GUEST_BUILD),)
>>> +guest-tests: $(GUEST_BUILD)
>>> +else
>>> +guest-tests:
>>> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
>>> +endif
>>> +
>>> +# It doesn't mater if these don't exits
>>> +.PHONY: clean-guest-tests
>>> +clean-guest-tests:
>>> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>>>
> 
> 

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

* Re: [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386
  2018-04-16  9:02     ` Alex Bennée
@ 2018-04-16 10:30       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16 10:30 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, famz, cota

On 04/16/2018 06:02 AM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> 
>> Hi Alex,
>>
>> On 04/10/2018 04:38 PM, Alex Bennée wrote:
>>> We should still be able to use the system cross compiler with the
>>> appropriate flags on x86_64 hosts.
>>>
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>  configure | 23 +++++++++++++++--------
>>>  1 file changed, 15 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/configure b/configure
>>> index b5f3b3fe29..add87ff4d4 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -284,7 +284,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=""
>>> @@ -457,6 +456,8 @@ docker="no"
>>>  cross_cc_aarch64="aarch64-linux-gnu-gcc"
>>>  cross_cc_arm="arm-linux-gnueabihf-gcc"
>>>  cross_cc_powerpc="powerpc-linux-gnu-gcc"
>>> +cross_cc_i386="i386-pc-linux-gnu-gcc"
>>> +cross_cc_i386_cflags=""
>>
>> Can you keep this sorted? (arm < i386 < powerpc)
> 
> Sure.
> 
>>
>> Thanks :)
>>
>>>  
>>>  enabled_cross_compilers=""
>>>  
>>> @@ -687,12 +688,10 @@ case "$cpu" in
>>
>> What do you think about renaming $cpu -> host_cpu/target_cpu?
> 
> I'd rather avoid too much churn in configure. Maybe a separate clean-up
> patch?

Yeah me neither :S This is probably not be as trivial as it seems.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 
>>
>>>    i386|i486|i586|i686|i86pc|BePC)
>>>      cpu="i386"
>>>      supported_cpu="yes"
>>> -    cross_cc_i386=gcc
>>>    ;;
>>>    x86_64|amd64)
>>>      cpu="x86_64"
>>>      supported_cpu="yes"
>>> -    cross_cc_x86_64=gcc
>>>    ;;
>>>    armv*b|armv*l|arm)
>>>      cpu="arm"
>>> @@ -1435,7 +1434,6 @@ case "$cpu" in
>>>      i386)
>>>             CPU_CFLAGS="-m32"
>>>             LDFLAGS="-m32 $LDFLAGS"
>>> -           cc_i386='$(CC) -m32'
>>>             ;;
>>>      x86_64)
>>>             # ??? Only extremely old AMD cpus do not have cmpxchg16b.
>>> @@ -1443,12 +1441,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_i386=$cc
>>> +           cross_cc_i386_cflags="-m32"
>>>             ;;
>>>      x32)
>>>             CPU_CFLAGS="-mx32"
>>>             LDFLAGS="-mx32 $LDFLAGS"
>>> -           cc_i386='$(CC) -m32'
>>> +           cross_cc_i386=$cc
>>> +           cross_cc_i386_cflags="-m32"
>>>             ;;
>>>      # No special flags required for other host CPUs
>>>  esac
>>> @@ -6664,7 +6664,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
>>> @@ -6783,6 +6782,7 @@ case "$target" in
>>>  esac
>>>  
>>>  target_compiler=""
>>> +target_compiler_cflags=""
>>>  
>>>  mkdir -p $target_dir
>>>  echo "# Automatically generated by configure - do not modify" > $config_target_mak
>>> @@ -6799,10 +6799,13 @@ 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_i386_cflags
>>>    ;;
>>>    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"
>>> @@ -6947,7 +6950,7 @@ int main(void) {
>>>  }
>>>  EOF
>>>  
>>> -    if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then
>>> +    if ! do_compiler $target_compiler $target_compiler_cflags -o $TMPE $TMPC -static ; then
>>>          target_compiler=""
>>>      else
>>>          enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}"
>>> @@ -7033,6 +7036,10 @@ if test -n "$target_compiler"; then
>>>    echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
>>>  fi
>>>  
>>> +if test -n "$target_compiler_cflags"; then
>>> +  echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
>>> +fi
>>> +
>>>  # generate QEMU_CFLAGS/LDFLAGS for targets
>>>  
>>>  cflags=""
>>>
> 
> 

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

* Re: [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg
  2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
                   ` (24 preceding siblings ...)
  2018-04-10 20:07 ` [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg no-reply
@ 2018-04-16 10:37 ` Philippe Mathieu-Daudé
  25 siblings, 0 replies; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16 10:37 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: famz, cota

On 04/10/2018 04:38 PM, Alex Bennée wrote:
> Hi,
> 
> We've talked about fixing this up for a long time and there have been
> several RFC patches sent attempting to do that. This is yet another
> RFC but hopefully shows a way forward which can build on our docker
> support but also allow users to specify their own guest cross
> compilers.
> 
> So far I've built arm, aarch64, ppc64 and s390x but adding support for
> additional guests is simple, especially if we already have a docker
> cross compile setup.

The current docker setup is limited to x86_64 hosts (amd64) and doesn't
work with armhf/arm64 hosts.

Although armhf (arm32v7) is easier for end-user, I believe at some point
it'll be useful to support aarch64 (arm64v8) hosts and eventually s390x.

> I've weeded out any tests that linked with QEMU (testpath) and reduced
> the expectations of any tests/tcg test to just having access to libc.
> This is the lowest common denominator for anything that can reasonably
> be called a cross compiler.
> 
> The tests are all aimed at linux-user targets. We could probably come
> up with something for building bare-metal softmmu tests but I suspect
> that might be better served by using a different mechanism to import
> existing tests into our build (e.g. kvm-unit-tests).
> 
> Let's breakdown the series:
> 
> configure:
> 
> As we need make magic we move the detection of docker and cross
> compilers into configure. If any cross compiler is detected for a
> given target we set CROSS_CC_GUEST in each config-target.mak. A
> functioning cross compiler takes precedence over the docker fallback.
> I think this makes sense for individual target sub-maintainers as they
> likely already have a cross compile setup.
> 
> For docker we only set HAVE_USER_DOCKER in config-host.mak if the user
> can run docker without sudo. We still need match up a docker image and
> compiler once we build. This is handled by
> tests/tcg/$(ARCH)/Makefile.include.
> 
> docker:
> 
> I've extended Fam's original patches to allow a bit more flexibility
> for the "cc" command. I'm not overly wedded to using the docker.py
> wrapper, we could just construct the command directly in Make if we
> wanted to.
> 
> tests/tcg:
> 
> The top of the tree has been cleared out and everything moved into
> sub-directories. There is a new multiarch sub-directory which is built
> for every linux-user guest that has compiler support. Additional tests
> are then included from tests/tcg/$(ARCH)/*.c or manually
> added/modified by tests/tcg/$(ARCH)/Makefile.target.
> 
> Makefile:
> 
> As we are building tests/tcg for each target so Makefile.target now
> invokes a sub-make with tests/tcg/Makefile while in the appropriate
> build directory $(ARCH)-linux-user/tests/. The check-tcg and clean-tcg
> targets unroll into all the configured FOO-linux-user targets and will
> build the tests if cross compilation is available, otherwise the build
> is skipped without failing the make.
> 
> Running tests:
> 
> Currently this is done manually from the build directory:
> 
>   ./qemu-arm tests/hello-arm
> 
> However once we have everything converted it shouldn't be too hard to
> plumb into the normal make check sequence.
> 
> So what do people think? Is this a viable way to go forward?
> 
> Alex Bennée (20):
>   configure: add test for docker availability
>   configure: add support for --cross-cc-FOO
>   configure: move i386_cc to cross_cc_i386
>   docker: extend "cc" command to accept compiler
>   docker: allow "cc" command to run in user context
>   docker: Makefile.include introduce DOCKER_SCRIPT
>   tests/tcg: move architecture independent tests into subdir
>   tests/tcg: move i386 specific tests into subdir
>   tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c
>   tests/tcg/i386: fix test-i386
>   tests/tcg/i368: fix hello-i386
>   tests/tcg/i386: fix test-i386-fprem
>   tests/tcg: move ARM specific tests into subdir
>   tests/tcg/arm: fix hello-arm
>   tests/tcg: move MIPS specific tests into subdir
>   tests/tcg: enable building for s390x
>   tests/tcg: enable building for ppc64
>   tests/tcg/Makefile: update to be called from Makefile.target
>   Makefile.target: add (clean-)guest-tests targets
>   tests/Makefile.include: add (clean-)check-tcg targets
> 
> Fam Zheng (4):
>   Makefile: Rename TARGET_DIRS to TARGET_LIST
>   docker: Add "cc" subcommand
>   tests/tcg/multiarch: Build fix for linux-test
>   tests/tcg/i386: Build fix for hello-i386
> 
>  Makefile                                           |  20 +--
>  Makefile.target                                    |   5 +
>  configure                                          |  92 +++++++++-
>  scripts/create_config                              |   2 +-
>  tests/Makefile.include                             |  21 ++-
>  tests/docker/Makefile.include                      |  10 +-
>  tests/docker/docker.py                             |  40 +++++
>  tests/tcg/Makefile                                 | 185 +++++----------------
>  tests/tcg/Makefile.include                         |  79 +++++++++
>  tests/tcg/README                                   |  69 +-------
>  tests/tcg/arm/Makefile.target                      |   6 +
>  tests/tcg/arm/README                               |  11 ++
>  tests/tcg/{ => arm}/hello-arm.c                    |   0
>  tests/tcg/{ => arm}/test-arm-iwmmxt.s              |   0
>  tests/tcg/i386/Makefile.target                     |  35 ++++
>  tests/tcg/i386/README                              |  38 +++++
>  tests/tcg/{ => i386}/hello-i386.c                  |   1 +
>  tests/tcg/{ => i386}/pi_10.com                     | Bin
>  tests/tcg/{ => i386}/runcom.c                      |   0
>  tests/tcg/{ => i386}/test-i386-code16.S            |   0
>  tests/tcg/{ => i386}/test-i386-fprem.c             |   9 +-
>  tests/tcg/{ => i386}/test-i386-muldiv.h            |   0
>  tests/tcg/{ => i386}/test-i386-shift.h             |   0
>  tests/tcg/{ => i386}/test-i386-vm86.S              |   0
>  tests/tcg/{ => i386}/test-i386.c                   |   1 -
>  tests/tcg/{ => i386}/test-i386.h                   |   0
>  tests/tcg/mips/README                              |   7 +
>  tests/tcg/{ => mips}/hello-mips.c                  |   0
>  tests/tcg/multiarch/README                         |   1 +
>  tests/tcg/{ => multiarch}/linux-test.c             |  68 +++-----
>  tests/tcg/{ => multiarch}/sha1.c                   |   0
>  tests/tcg/{ => multiarch}/test-mmap.c              |   0
>  tests/tcg/{ => multiarch}/testthread.c             |   0
>  tests/tcg/ppc64/Makefile.include                   |   2 +
>  tests/tcg/s390x/Makefile.include                   |   2 +
>  tests/tcg/test_path.c                              | 157 -----------------
>  tests/tcg/{test-i386-ssse3.c => x86_64/test-sse.c} |   6 +-
>  37 files changed, 424 insertions(+), 443 deletions(-)
>  create mode 100644 tests/tcg/Makefile.include
>  create mode 100644 tests/tcg/arm/Makefile.target
>  create mode 100644 tests/tcg/arm/README
>  rename tests/tcg/{ => arm}/hello-arm.c (100%)
>  rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)
>  create mode 100644 tests/tcg/i386/Makefile.target
>  create mode 100644 tests/tcg/i386/README
>  rename tests/tcg/{ => i386}/hello-i386.c (96%)
>  rename tests/tcg/{ => i386}/pi_10.com (100%)
>  rename tests/tcg/{ => i386}/runcom.c (100%)
>  rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
>  rename tests/tcg/{ => i386}/test-i386-fprem.c (98%)
>  rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
>  rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
>  rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
>  rename tests/tcg/{ => i386}/test-i386.c (99%)
>  rename tests/tcg/{ => i386}/test-i386.h (100%)
>  create mode 100644 tests/tcg/mips/README
>  rename tests/tcg/{ => mips}/hello-mips.c (100%)
>  create mode 100644 tests/tcg/multiarch/README
>  rename tests/tcg/{ => multiarch}/linux-test.c (91%)
>  rename tests/tcg/{ => multiarch}/sha1.c (100%)
>  rename tests/tcg/{ => multiarch}/test-mmap.c (100%)
>  rename tests/tcg/{ => multiarch}/testthread.c (100%)
>  create mode 100644 tests/tcg/ppc64/Makefile.include
>  create mode 100644 tests/tcg/s390x/Makefile.include
>  delete mode 100644 tests/tcg/test_path.c
>  rename tests/tcg/{test-i386-ssse3.c => x86_64/test-sse.c} (93%)
> 

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-16  8:53     ` Alex Bennée
  2018-04-16 10:24       ` Philippe Mathieu-Daudé
@ 2018-04-16 17:14       ` Philippe Mathieu-Daudé
  2018-04-16 20:08         ` Alex Bennée
  1 sibling, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-16 17:14 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, famz, cota

On 04/16/2018 05:53 AM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> 
>> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>>> Now all the build infrastructure is in place we can build tests for
>>> each guest that we support. That support mainly depends on having
>>> cross compilers installed or docker setup. To keep all the logic for
>>> that together we put the rules in tests/tcg/Makefile.include and
>>> include it from the main Makefile.target.
>>>
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>  Makefile.target            |  5 +++
>>>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>>>  2 files changed, 84 insertions(+)
>>>  create mode 100644 tests/tcg/Makefile.include
>>>
>>> diff --git a/Makefile.target b/Makefile.target
>>> index d0ec77a307..a30fd40257 100644
>>> --- a/Makefile.target
>>> +++ b/Makefile.target
>>> @@ -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
>>>  
>>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
>>> new file mode 100644
>>> index 0000000000..cb8bb36026
>>> --- /dev/null
>>> +++ b/tests/tcg/Makefile.include
>>> @@ -0,0 +1,79 @@
>>> +# -*- Mode: makefile -*-
>>> +#
>>> +# TCG tests (per-target rules)
>>> +#
>>> +# This Makefile fragement is included from the per-target
>>> +# Makefile.target so will be invoked for each linux-user program we
>>> +# build. We have two options for compiling, either using a configured
>>> +# guest compiler or calling one of our docker images to do it for us.
>>> +#
>>> +
>>> +# The per ARCH makefile, if it exists holds extra information about
>>> +# useful docker images or alternative compiler flags. Include it if it
>>> +# exists
>>> +
>>> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>>> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
>>> +
>>> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
>>> +include $(ARCH_MAKEFILE)
>>> +endif
>>> +
>>> +GUEST_BUILD=
>>> +
>>> +# Support installed Cross Compilers
>>> +
>>> +ifdef CROSS_CC_GUEST
>>> +
>>> +.PHONY: cross-build-guest-tests
>>> +cross-build-guest-tests:
>>> +	$(call quiet-command, \
>>> +          (mkdir -p tests && cd tests && \
>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>>> +
>>> +
>>> +GUEST_BUILD=cross-build-guest-tests
>>> +
>>> +endif
>>> +
>>> +# Support building with Docker
>>> +
>>> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>>> +ifneq ($(DOCKER_IMAGE),)
>>> +
>>> +# We also need the Docker make rules to depend on
>>> +include $(SRC_PATH)/tests/docker/Makefile.include
>>> +
>>
>> Eventually:
>>
>> DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc
>>
>>> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>>> +		--cc $(DOCKER_CROSS_COMPILER) \
>>> +		-i qemu:$(DOCKER_IMAGE) \
>>> +		-s $(SRC_PATH) -- "
>>
>> Should we check $(DOCKER_CROSS_COMPILER) is set?
> 
> Currently it's implied. It would be nice if there was an easy way just
> to fish it out of the env of the docker image as they already have it
> set there.
> 
> I've been trying quite hard to ensure all the tests can just use LD (see
> the hoops I jump in i386 for this). Maybe a prefix config makes more
> sense though....

We might also need some CROSS_CFLAGS, i.e. for armeb we need to use
-mbig-endian. This would go in tests/tcg/$(TARGET_NAME)/Makefile.target

> 
>>
>>> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>>> +
>>> +.PHONY: docker-build-guest-tests
>>> +docker-build-guest-tests: $(DOCKER_PREREQ)
>>> +	$(call quiet-command, \
>>> +          (mkdir -p tests && cd tests && \
>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>>> +
>>> +GUEST_BUILD=docker-build-guest-tests
>>> +
>>> +endif
>>> +endif
>>> +
>>> +# Final targets
>>> +.PHONY: guest-tests
>>> +
>>> +ifneq ($(GUEST_BUILD),)
>>> +guest-tests: $(GUEST_BUILD)
>>> +else
>>> +guest-tests:
>>> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
>>> +endif
>>> +
>>> +# It doesn't mater if these don't exits
>>> +.PHONY: clean-guest-tests
>>> +clean-guest-tests:
>>> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>>>

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-16 17:14       ` Philippe Mathieu-Daudé
@ 2018-04-16 20:08         ` Alex Bennée
  2018-04-17 14:41           ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 83+ messages in thread
From: Alex Bennée @ 2018-04-16 20:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 04/16/2018 05:53 AM, Alex Bennée wrote:
>>
>> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
>>
>>> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>>>> Now all the build infrastructure is in place we can build tests for
>>>> each guest that we support. That support mainly depends on having
>>>> cross compilers installed or docker setup. To keep all the logic for
>>>> that together we put the rules in tests/tcg/Makefile.include and
>>>> include it from the main Makefile.target.
>>>>
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> ---
>>>>  Makefile.target            |  5 +++
>>>>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>  2 files changed, 84 insertions(+)
>>>>  create mode 100644 tests/tcg/Makefile.include
>>>>
>>>> diff --git a/Makefile.target b/Makefile.target
>>>> index d0ec77a307..a30fd40257 100644
>>>> --- a/Makefile.target
>>>> +++ b/Makefile.target
>>>> @@ -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
>>>>
>>>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
>>>> new file mode 100644
>>>> index 0000000000..cb8bb36026
>>>> --- /dev/null
>>>> +++ b/tests/tcg/Makefile.include
>>>> @@ -0,0 +1,79 @@
>>>> +# -*- Mode: makefile -*-
>>>> +#
>>>> +# TCG tests (per-target rules)
>>>> +#
>>>> +# This Makefile fragement is included from the per-target
>>>> +# Makefile.target so will be invoked for each linux-user program we
>>>> +# build. We have two options for compiling, either using a configured
>>>> +# guest compiler or calling one of our docker images to do it for us.
>>>> +#
>>>> +
>>>> +# The per ARCH makefile, if it exists holds extra information about
>>>> +# useful docker images or alternative compiler flags. Include it if it
>>>> +# exists
>>>> +
>>>> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>>>> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
>>>> +
>>>> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
>>>> +include $(ARCH_MAKEFILE)
>>>> +endif
>>>> +
>>>> +GUEST_BUILD=
>>>> +
>>>> +# Support installed Cross Compilers
>>>> +
>>>> +ifdef CROSS_CC_GUEST
>>>> +
>>>> +.PHONY: cross-build-guest-tests
>>>> +cross-build-guest-tests:
>>>> +	$(call quiet-command, \
>>>> +          (mkdir -p tests && cd tests && \
>>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
>>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>>>> +
>>>> +
>>>> +GUEST_BUILD=cross-build-guest-tests
>>>> +
>>>> +endif
>>>> +
>>>> +# Support building with Docker
>>>> +
>>>> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>>>> +ifneq ($(DOCKER_IMAGE),)
>>>> +
>>>> +# We also need the Docker make rules to depend on
>>>> +include $(SRC_PATH)/tests/docker/Makefile.include
>>>> +
>>>
>>> Eventually:
>>>
>>> DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc
>>>
>>>> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>>>> +		--cc $(DOCKER_CROSS_COMPILER) \
>>>> +		-i qemu:$(DOCKER_IMAGE) \
>>>> +		-s $(SRC_PATH) -- "
>>>
>>> Should we check $(DOCKER_CROSS_COMPILER) is set?
>>
>> Currently it's implied. It would be nice if there was an easy way just
>> to fish it out of the env of the docker image as they already have it
>> set there.
>>
>> I've been trying quite hard to ensure all the tests can just use LD (see
>> the hoops I jump in i386 for this). Maybe a prefix config makes more
>> sense though....
>
> We might also need some CROSS_CFLAGS, i.e. for armeb we need to use
> -mbig-endian. This would go in
> tests/tcg/$(TARGET_NAME)/Makefile.target

Yeah we can fish that out from config-target.mak

However I've run into problems with compiling things with -mbig-endian
as it forces the inclusion of something that seems to be missing in the
glibc-dev:


aarch64-linux-gnu-gcc -mbig-endian -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -static
In file included from /usr/aarch64-linux-gnu/include/features.h:391:0,
                 from /usr/aarch64-linux-gnu/include/stdio.h:27,
                 from config-temp/qemu-conf.c:1:
/usr/aarch64-linux-gnu/include/gnu/stubs.h:11:32: fatal error: gnu/stubs-lp64_be.h: No such file or directory
compilation terminated.

And they aren't packaged if the distro doesn't support the arch.

>
>>
>>>
>>>> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>>>> +
>>>> +.PHONY: docker-build-guest-tests
>>>> +docker-build-guest-tests: $(DOCKER_PREREQ)
>>>> +	$(call quiet-command, \
>>>> +          (mkdir -p tests && cd tests && \
>>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
>>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>>>> +
>>>> +GUEST_BUILD=docker-build-guest-tests
>>>> +
>>>> +endif
>>>> +endif
>>>> +
>>>> +# Final targets
>>>> +.PHONY: guest-tests
>>>> +
>>>> +ifneq ($(GUEST_BUILD),)
>>>> +guest-tests: $(GUEST_BUILD)
>>>> +else
>>>> +guest-tests:
>>>> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
>>>> +endif
>>>> +
>>>> +# It doesn't mater if these don't exits
>>>> +.PHONY: clean-guest-tests
>>>> +clean-guest-tests:
>>>> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>>>>


--
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-16 20:08         ` Alex Bennée
@ 2018-04-17 14:41           ` Philippe Mathieu-Daudé
  2018-04-17 15:09             ` Alex Bennée
  0 siblings, 1 reply; 83+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-17 14:41 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, famz, cota

Hi Alex

On 04/16/2018 05:08 PM, Alex Bennée wrote:
>>>>> Now all the build infrastructure is in place we can build tests for
>>>>> each guest that we support. That support mainly depends on having
>>>>> cross compilers installed or docker setup. To keep all the logic for
>>>>> that together we put the rules in tests/tcg/Makefile.include and
>>>>> include it from the main Makefile.target.
>>>>>
>>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>>> ---
>>>>>  Makefile.target            |  5 +++
>>>>>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>>  2 files changed, 84 insertions(+)
>>>>>  create mode 100644 tests/tcg/Makefile.include
>>>>>
>>>>> diff --git a/Makefile.target b/Makefile.target
>>>>> index d0ec77a307..a30fd40257 100644
>>>>> --- a/Makefile.target
>>>>> +++ b/Makefile.target
>>>>> @@ -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
>>>>>
>>>>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
>>>>> new file mode 100644
>>>>> index 0000000000..cb8bb36026
>>>>> --- /dev/null
>>>>> +++ b/tests/tcg/Makefile.include
>>>>> @@ -0,0 +1,79 @@
>>>>> +# -*- Mode: makefile -*-
>>>>> +#
>>>>> +# TCG tests (per-target rules)
>>>>> +#
>>>>> +# This Makefile fragement is included from the per-target
>>>>> +# Makefile.target so will be invoked for each linux-user program we
>>>>> +# build. We have two options for compiling, either using a configured
>>>>> +# guest compiler or calling one of our docker images to do it for us.
>>>>> +#
>>>>> +
>>>>> +# The per ARCH makefile, if it exists holds extra information about
>>>>> +# useful docker images or alternative compiler flags. Include it if it
>>>>> +# exists
>>>>> +
>>>>> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>>>>> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
>>>>> +
>>>>> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
>>>>> +include $(ARCH_MAKEFILE)
>>>>> +endif
>>>>> +
>>>>> +GUEST_BUILD=
>>>>> +
>>>>> +# Support installed Cross Compilers
>>>>> +
>>>>> +ifdef CROSS_CC_GUEST
>>>>> +
>>>>> +.PHONY: cross-build-guest-tests
>>>>> +cross-build-guest-tests:
>>>>> +	$(call quiet-command, \
>>>>> +          (mkdir -p tests && cd tests && \
>>>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
>>>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>>>>> +
>>>>> +
>>>>> +GUEST_BUILD=cross-build-guest-tests
>>>>> +
>>>>> +endif
>>>>> +
>>>>> +# Support building with Docker
>>>>> +
>>>>> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>>>>> +ifneq ($(DOCKER_IMAGE),)
>>>>> +
>>>>> +# We also need the Docker make rules to depend on
>>>>> +include $(SRC_PATH)/tests/docker/Makefile.include
>>>>> +
>>>>
>>>> Eventually:
>>>>
>>>> DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc
>>>>
>>>>> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>>>>> +		--cc $(DOCKER_CROSS_COMPILER) \
>>>>> +		-i qemu:$(DOCKER_IMAGE) \
>>>>> +		-s $(SRC_PATH) -- "
>>>>
>>>> Should we check $(DOCKER_CROSS_COMPILER) is set?
>>>
>>> Currently it's implied. It would be nice if there was an easy way just
>>> to fish it out of the env of the docker image as they already have it
>>> set there.
>>>
>>> I've been trying quite hard to ensure all the tests can just use LD (see
>>> the hoops I jump in i386 for this). Maybe a prefix config makes more
>>> sense though....
>>
>> We might also need some CROSS_CFLAGS, i.e. for armeb we need to use
>> -mbig-endian. This would go in
>> tests/tcg/$(TARGET_NAME)/Makefile.target
> 
> Yeah we can fish that out from config-target.mak
> 
> However I've run into problems with compiling things with -mbig-endian
> as it forces the inclusion of something that seems to be missing in the
> glibc-dev:
> 
> 
> aarch64-linux-gnu-gcc -mbig-endian -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -static
> In file included from /usr/aarch64-linux-gnu/include/features.h:391:0,
>                  from /usr/aarch64-linux-gnu/include/stdio.h:27,
>                  from config-temp/qemu-conf.c:1:
> /usr/aarch64-linux-gnu/include/gnu/stubs.h:11:32: fatal error: gnu/stubs-lp64_be.h: No such file or directory
> compilation terminated.
> 
> And they aren't packaged if the distro doesn't support the arch.

Oh I never tried BE on v8, but I'm successfully using it for v7, having
the following packages installed:

- gcc-arm-none-eabi
- gdb-arm-none-eabi
- libnewlib-arm-none-eabi
- binutils-arm-none-eabi

Indeed I'm not using the glibc but newlib, BE libs are here:

/usr/lib/arm-none-eabi/newlib/thumb/armv7-ar/fpu/vfpv3-d16/be

>>>>> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>>>>> +
>>>>> +.PHONY: docker-build-guest-tests
>>>>> +docker-build-guest-tests: $(DOCKER_PREREQ)
>>>>> +	$(call quiet-command, \
>>>>> +          (mkdir -p tests && cd tests && \
>>>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
>>>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>>>>> +
>>>>> +GUEST_BUILD=docker-build-guest-tests
>>>>> +
>>>>> +endif
>>>>> +endif
>>>>> +
>>>>> +# Final targets
>>>>> +.PHONY: guest-tests
>>>>> +
>>>>> +ifneq ($(GUEST_BUILD),)
>>>>> +guest-tests: $(GUEST_BUILD)
>>>>> +else
>>>>> +guest-tests:
>>>>> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
>>>>> +endif
>>>>> +
>>>>> +# It doesn't mater if these don't exits
>>>>> +.PHONY: clean-guest-tests
>>>>> +clean-guest-tests:
>>>>> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>>>>>
> 
> 
> --
> Alex Bennée
> 

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

* Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets
  2018-04-17 14:41           ` Philippe Mathieu-Daudé
@ 2018-04-17 15:09             ` Alex Bennée
  0 siblings, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-04-17 15:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Alex
>
> On 04/16/2018 05:08 PM, Alex Bennée wrote:
>>>>>> Now all the build infrastructure is in place we can build tests for
>>>>>> each guest that we support. That support mainly depends on having
>>>>>> cross compilers installed or docker setup. To keep all the logic for
>>>>>> that together we put the rules in tests/tcg/Makefile.include and
>>>>>> include it from the main Makefile.target.
>>>>>>
>>>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>>>> ---
>>>>>>  Makefile.target            |  5 +++
>>>>>>  tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>  2 files changed, 84 insertions(+)
>>>>>>  create mode 100644 tests/tcg/Makefile.include
>>>>>>
>>>>>> diff --git a/Makefile.target b/Makefile.target
>>>>>> index d0ec77a307..a30fd40257 100644
>>>>>> --- a/Makefile.target
>>>>>> +++ b/Makefile.target
>>>>>> @@ -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
>>>>>>
>>>>>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
>>>>>> new file mode 100644
>>>>>> index 0000000000..cb8bb36026
>>>>>> --- /dev/null
>>>>>> +++ b/tests/tcg/Makefile.include
>>>>>> @@ -0,0 +1,79 @@
>>>>>> +# -*- Mode: makefile -*-
>>>>>> +#
>>>>>> +# TCG tests (per-target rules)
>>>>>> +#
>>>>>> +# This Makefile fragement is included from the per-target
>>>>>> +# Makefile.target so will be invoked for each linux-user program we
>>>>>> +# build. We have two options for compiling, either using a configured
>>>>>> +# guest compiler or calling one of our docker images to do it for us.
>>>>>> +#
>>>>>> +
>>>>>> +# The per ARCH makefile, if it exists holds extra information about
>>>>>> +# useful docker images or alternative compiler flags. Include it if it
>>>>>> +# exists
>>>>>> +
>>>>>> +ARCH_MAKEFILE=$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>>>>>> +CHECK_INCLUDE=$(wildcard $(ARCH_MAKEFILE))
>>>>>> +
>>>>>> +ifeq ($(ARCH_MAKEFILE),$(CHECK_INCLUDE))
>>>>>> +include $(ARCH_MAKEFILE)
>>>>>> +endif
>>>>>> +
>>>>>> +GUEST_BUILD=
>>>>>> +
>>>>>> +# Support installed Cross Compilers
>>>>>> +
>>>>>> +ifdef CROSS_CC_GUEST
>>>>>> +
>>>>>> +.PHONY: cross-build-guest-tests
>>>>>> +cross-build-guest-tests:
>>>>>> +	$(call quiet-command, \
>>>>>> +          (mkdir -p tests && cd tests && \
>>>>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(CROSS_CC_GUEST)), \
>>>>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>>>>>> +
>>>>>> +
>>>>>> +GUEST_BUILD=cross-build-guest-tests
>>>>>> +
>>>>>> +endif
>>>>>> +
>>>>>> +# Support building with Docker
>>>>>> +
>>>>>> +ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>>>>>> +ifneq ($(DOCKER_IMAGE),)
>>>>>> +
>>>>>> +# We also need the Docker make rules to depend on
>>>>>> +include $(SRC_PATH)/tests/docker/Makefile.include
>>>>>> +
>>>>>
>>>>> Eventually:
>>>>>
>>>>> DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc
>>>>>
>>>>>> +DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>>>>>> +		--cc $(DOCKER_CROSS_COMPILER) \
>>>>>> +		-i qemu:$(DOCKER_IMAGE) \
>>>>>> +		-s $(SRC_PATH) -- "
>>>>>
>>>>> Should we check $(DOCKER_CROSS_COMPILER) is set?
>>>>
>>>> Currently it's implied. It would be nice if there was an easy way just
>>>> to fish it out of the env of the docker image as they already have it
>>>> set there.
>>>>
>>>> I've been trying quite hard to ensure all the tests can just use LD (see
>>>> the hoops I jump in i386 for this). Maybe a prefix config makes more
>>>> sense though....
>>>
>>> We might also need some CROSS_CFLAGS, i.e. for armeb we need to use
>>> -mbig-endian. This would go in
>>> tests/tcg/$(TARGET_NAME)/Makefile.target
>>
>> Yeah we can fish that out from config-target.mak
>>
>> However I've run into problems with compiling things with -mbig-endian
>> as it forces the inclusion of something that seems to be missing in the
>> glibc-dev:
>>
>>
>> aarch64-linux-gnu-gcc -mbig-endian -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -static
>> In file included from /usr/aarch64-linux-gnu/include/features.h:391:0,
>>                  from /usr/aarch64-linux-gnu/include/stdio.h:27,
>>                  from config-temp/qemu-conf.c:1:
>> /usr/aarch64-linux-gnu/include/gnu/stubs.h:11:32: fatal error: gnu/stubs-lp64_be.h: No such file or directory
>> compilation terminated.
>>
>> And they aren't packaged if the distro doesn't support the arch.
>
> Oh I never tried BE on v8, but I'm successfully using it for v7, having
> the following packages installed:
>
> - gcc-arm-none-eabi
> - gdb-arm-none-eabi
> - libnewlib-arm-none-eabi
> - binutils-arm-none-eabi
>
> Indeed I'm not using the glibc but newlib, BE libs are here:
>
> /usr/lib/arm-none-eabi/newlib/thumb/armv7-ar/fpu/vfpv3-d16/be

So maybe we need a docker-arm3264be-cross with newlib?

>
>>>>>> +DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>>>>>> +
>>>>>> +.PHONY: docker-build-guest-tests
>>>>>> +docker-build-guest-tests: $(DOCKER_PREREQ)
>>>>>> +	$(call quiet-command, \
>>>>>> +          (mkdir -p tests && cd tests && \
>>>>>> +	   make -f $(SRC_PATH)/tests/tcg/Makefile ARCH=$(TARGET_NAME) CC=$(DOCKER_COMPILE_CMD)), \
>>>>>> +	  "CROSS-BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>>>>>> +
>>>>>> +GUEST_BUILD=docker-build-guest-tests
>>>>>> +
>>>>>> +endif
>>>>>> +endif
>>>>>> +
>>>>>> +# Final targets
>>>>>> +.PHONY: guest-tests
>>>>>> +
>>>>>> +ifneq ($(GUEST_BUILD),)
>>>>>> +guest-tests: $(GUEST_BUILD)
>>>>>> +else
>>>>>> +guest-tests:
>>>>>> +	$(call quiet-command, /bin/true, "CROSS-BUILD", "$(TARGET_NAME) guest-tests SKIPPED")
>>>>>> +endif
>>>>>> +
>>>>>> +# It doesn't mater if these don't exits
>>>>>> +.PHONY: clean-guest-tests
>>>>>> +clean-guest-tests:
>>>>>> +	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>>>>>>
>>
>>
>> --
>> Alex Bennée
>>


--
Alex Bennée

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

* Re: [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test
       [not found]     ` <3b680ef4-3304-99d5-75ef-c4d5d570bb3a@amsat.org>
  2018-04-16  8:51       ` Alex Bennée
@ 2018-05-25 10:21       ` Alex Bennée
  1 sibling, 0 replies; 83+ messages in thread
From: Alex Bennée @ 2018-05-25 10:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, famz, cota


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 04/15/2018 09:07 PM, Philippe Mathieu-Daudé wrote:
>> Hi Fam, Alex,
>>
>> On 04/10/2018 04:39 PM, Alex Bennée wrote:
>>> From: Fam Zheng <famz@redhat.com>
>>>
>>> To keep the compiler happy, and to fit in our buildsys flags:
>>>
>>> - Make local functions "static"
>>> - #ifdef out unused functions
>>> - drop cutils/osdep dependencies
>>>
>>> Signed-off-by: Fam Zheng <famz@redhat.com>
>>> [AJB: drop cutils/osdep dependencies]
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>  tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
>>>  1 file changed, 21 insertions(+), 47 deletions(-)
>>>
>>> diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
>>> index 5070d31446..4457bd04ba 100644
>>> --- a/tests/tcg/multiarch/linux-test.c
>>> +++ b/tests/tcg/multiarch/linux-test.c
>>> @@ -16,7 +16,6 @@
>>>   *  You should have received a copy of the GNU General Public License
>>>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>>>   */
>>> -#define _GNU_SOURCE
>>>  #include <stdarg.h>
>>>  #include <stdlib.h>
>>>  #include <stdio.h>
>>> @@ -31,6 +30,7 @@
>>>  #include <utime.h>
>>>  #include <time.h>
>>>  #include <sys/time.h>
>>> +#include <sys/resource.h>
>>>  #include <sys/uio.h>
>>>  #include <sys/socket.h>
>>>  #include <netinet/in.h>
>>> @@ -39,13 +39,12 @@
>>>  #include <dirent.h>
>>>  #include <setjmp.h>
>>>  #include <sys/shm.h>
>>> -#include "qemu/cutils.h"
>>>
>>>  #define TESTPATH "/tmp/linux-test.tmp"
>>>  #define TESTPORT 7654
>>>  #define STACK_SIZE 16384
>>>
>>> -void error1(const char *filename, int line, const char *fmt, ...)
>>> +static void error1(const char *filename, int line, const char *fmt, ...)
>>>  {
>>>      va_list ap;
>>>      va_start(ap, fmt);
>>> @@ -56,7 +55,7 @@ void error1(const char *filename, int line, const char *fmt, ...)
>>>      exit(1);
>>>  }
>>>
>>> -int __chk_error(const char *filename, int line, int ret)
>>> +static int __chk_error(const char *filename, int line, int ret)
>>>  {
>>>      if (ret < 0) {
>>>          error1(filename, line, "%m (ret=%d, errno=%d)",
>>> @@ -73,7 +72,7 @@ int __chk_error(const char *filename, int line, int ret)
>>>
>>>  #define FILE_BUF_SIZE 300
>>>
>>> -void test_file(void)
>>> +static void test_file(void)
>>>  {
>>>      int fd, i, len, ret;
>>>      uint8_t buf[FILE_BUF_SIZE];
>>> @@ -210,7 +209,7 @@ void test_file(void)
>>>      chk_error(rmdir(TESTPATH));
>>>  }
>>>
>>> -void test_fork(void)
>>> +static void test_fork(void)
>>>  {
>>>      int pid, status;
>>>
>>> @@ -224,7 +223,7 @@ void test_fork(void)
>>>          error("waitpid status=0x%x", status);
>>>  }
>>>
>>> -void test_time(void)
>>> +static void test_time(void)
>>>  {
>>>      struct timeval tv, tv2;
>>>      struct timespec ts, rem;
>>> @@ -251,34 +250,7 @@ void test_time(void)
>>>          error("getrusage");
>>>  }
>>>
>>> -void pstrcpy(char *buf, int buf_size, const char *str)
>>> -{
>>> -    int c;
>>> -    char *q = buf;
>>> -
>>> -    if (buf_size <= 0)
>>> -        return;
>>> -
>>> -    for(;;) {
>>> -        c = *str++;
>>> -        if (c == 0 || q >= buf + buf_size - 1)
>>> -            break;
>>> -        *q++ = c;
>>> -    }
>>> -    *q = '\0';
>>> -}
>>> -
>>> -/* strcat and truncate. */
>>> -char *pstrcat(char *buf, int buf_size, const char *s)
>>> -{
>>> -    int len;
>>> -    len = strlen(buf);
>>> -    if (len < buf_size)
>>> -        pstrcpy(buf + len, buf_size - len, s);
>>> -    return buf;
>>> -}
>>> -
>>> -int server_socket(void)
>>> +static int server_socket(void)
>>>  {
>>>      int val, fd;
>>>      struct sockaddr_in sockaddr;
>>> @@ -298,7 +270,7 @@ int server_socket(void)
>>>
>>>  }
>>>
>>> -int client_socket(void)
>>> +static int client_socket(void)
>>>  {
>>>      int fd;
>>>      struct sockaddr_in sockaddr;
>>> @@ -312,9 +284,9 @@ int client_socket(void)
>>>      return fd;
>>>  }
>>>
>>> -const char socket_msg[] = "hello socket\n";
>>> +static const char socket_msg[] = "hello socket\n";
>>>
>>> -void test_socket(void)
>>> +static void test_socket(void)
>>>  {
>>>      int server_fd, client_fd, fd, pid, ret, val;
>>>      struct sockaddr_in sockaddr;
>>> @@ -348,9 +320,10 @@ void test_socket(void)
>>>      chk_error(close(server_fd));
>>>  }
>>>
>>> +#if 0
>>
>> Why keep this now dead code?
>
> You can use: #ifdef LINUX_TEST_CLONE
>
> But this my be even better to move this chunk as a stand-alone test in a
> new file, linux-clone-test.c and add a make rule to only include it in
> the TEST_SRCS var when the host is able to run it.

More of it gets un-#if 0'd in the follow-up patch. There is certainly
more clean-up to be done but for now I've just left it disabled. I think
splitting out a specific test-clone patch is a good follow-up candidate
though.

>
>>
>>>  #define WCOUNT_MAX 512
>>>
>>> -void test_pipe(void)
>>> +static void test_pipe(void)
>>>  {
>>>      fd_set rfds, wfds;
>>>      int fds[2], fd_max, ret;
>>> @@ -391,10 +364,10 @@ void test_pipe(void)
>>>      chk_error(close(fds[1]));
>>>  }
>>>
>>> -int thread1_res;
>>> -int thread2_res;
>>> +static int thread1_res;
>>> +static int thread2_res;
>>>
>>> -int thread1_func(void *arg)
>>> +static int thread1_func(void *arg)
>>>  {
>>>      int i;
>>>      for(i=0;i<5;i++) {
>>> @@ -404,7 +377,7 @@ int thread1_func(void *arg)
>>>      return 0;
>>>  }
>>>
>>> -int thread2_func(void *arg)
>>> +static int thread2_func(void *arg)
>>>  {
>>>      int i;
>>>      for(i=0;i<6;i++) {
>>> @@ -435,27 +408,28 @@ void test_clone(void)
>>>          thread2_res != 6)
>>>          error("clone");
>>>  }
>>> +#endif
>>>
>>>  /***********************************/
>>>
>>>  volatile int alarm_count;
>>>  jmp_buf jmp_env;
>>>
>>> -void sig_alarm(int sig)
>>> +static void sig_alarm(int sig)
>>>  {
>>>      if (sig != SIGALRM)
>>>          error("signal");
>>>      alarm_count++;
>>>  }
>>>
>>> -void sig_segv(int sig, siginfo_t *info, void *puc)
>>> +static void sig_segv(int sig, siginfo_t *info, void *puc)
>>>  {
>>>      if (sig != SIGSEGV)
>>>          error("signal");
>>>      longjmp(jmp_env, 1);
>>>  }
>>>
>>> -void test_signal(void)
>>> +static void test_signal(void)
>>>  {
>>>      struct sigaction act;
>>>      struct itimerval it, oit;
>>> @@ -510,7 +484,7 @@ void test_signal(void)
>>>
>>>  #define SHM_SIZE 32768
>>>
>>> -void test_shm(void)
>>> +static void test_shm(void)
>>>  {
>>>      void *ptr;
>>>      int shmid;
>>>


--
Alex Bennée

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

end of thread, other threads:[~2018-05-25 10:21 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10 19:38 [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg Alex Bennée
2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability Alex Bennée
2018-04-11  8:50   ` Fam Zheng
2018-04-11 10:58     ` Alex Bennée
2018-04-11 12:59       ` Fam Zheng
2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO Alex Bennée
2018-04-16  2:04   ` Philippe Mathieu-Daudé
2018-04-16  8:49     ` Alex Bennée
2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386 Alex Bennée
2018-04-16  0:01   ` Philippe Mathieu-Daudé
2018-04-16  9:02     ` Alex Bennée
2018-04-16 10:30       ` Philippe Mathieu-Daudé
2018-04-10 19:38 ` [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST Alex Bennée
2018-04-12 14:33   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand Alex Bennée
2018-04-16  1:48   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler Alex Bennée
2018-04-12  8:07   ` Fam Zheng
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context Alex Bennée
2018-04-12  8:08   ` Fam Zheng
2018-04-16  0:02   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT Alex Bennée
2018-04-11 15:10   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir Alex Bennée
2018-04-11 10:22   ` Thomas Huth
2018-04-16  0:05   ` Philippe Mathieu-Daudé
2018-04-16  9:01     ` Alex Bennée
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test Alex Bennée
2018-04-11 10:25   ` Thomas Huth
     [not found]   ` <4bc22552-25b4-2a04-dc73-dc17201a2251@amsat.org>
     [not found]     ` <3b680ef4-3304-99d5-75ef-c4d5d570bb3a@amsat.org>
2018-04-16  8:51       ` Alex Bennée
2018-05-25 10:21       ` Alex Bennée
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir Alex Bennée
2018-04-11 10:30   ` Thomas Huth
2018-04-16  0:08   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386 Alex Bennée
2018-04-11 10:30   ` Thomas Huth
2018-04-16  0:11   ` Philippe Mathieu-Daudé
2018-04-16  8:57     ` Alex Bennée
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c Alex Bennée
2018-04-11 15:33   ` Thomas Huth
2018-04-11 16:19     ` Alex Bennée
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386 Alex Bennée
2018-04-11 15:36   ` Thomas Huth
2018-04-16  0:13   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386 Alex Bennée
2018-04-11 15:38   ` Thomas Huth
2018-04-16  0:14   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem Alex Bennée
2018-04-11 15:14   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir Alex Bennée
2018-04-11 15:40   ` Thomas Huth
2018-04-16  0:14   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm Alex Bennée
2018-04-11 15:42   ` Thomas Huth
2018-04-16  1:28   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir Alex Bennée
2018-04-16  1:02   ` Philippe Mathieu-Daudé
2018-04-16  1:33     ` Philippe Mathieu-Daudé
2018-04-16  8:56     ` Alex Bennée
2018-04-16 10:21       ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x Alex Bennée
2018-04-11  8:36   ` Cornelia Huck
2018-04-16  1:33   ` Philippe Mathieu-Daudé
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64 Alex Bennée
2018-04-16  1:36   ` Philippe Mathieu-Daudé
2018-04-16  8:54     ` Alex Bennée
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target Alex Bennée
2018-04-12  8:13   ` Fam Zheng
2018-04-12  8:47     ` Alex Bennée
2018-04-12  9:14       ` Fam Zheng
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets Alex Bennée
2018-04-16  1:12   ` Philippe Mathieu-Daudé
2018-04-16  1:52   ` Philippe Mathieu-Daudé
2018-04-16  8:53     ` Alex Bennée
2018-04-16 10:24       ` Philippe Mathieu-Daudé
2018-04-16 17:14       ` Philippe Mathieu-Daudé
2018-04-16 20:08         ` Alex Bennée
2018-04-17 14:41           ` Philippe Mathieu-Daudé
2018-04-17 15:09             ` Alex Bennée
2018-04-10 19:39 ` [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets Alex Bennée
2018-04-16  1:53   ` Philippe Mathieu-Daudé
2018-04-10 20:07 ` [Qemu-devel] [PATCH v1 00/24] fix building of tests/tcg no-reply
2018-04-16 10:37 ` Philippe Mathieu-Daudé

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.