Skip to contentSkip to conversation

fix building of tests/tcg

PATCH Superseded Alex Bennée 6 participants 83 messages Apr 10, 2018 – May 25, 2018 2 messages not in the archive Kbuild

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover fix building of tests/tcg

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%)
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/24 configure: add test for docker availability

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.

---
 configure | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
configure +23 -0
index 4d0e92c96c..b402befe94 100755
@@ -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
Signature · 1 line
2.16.2
#2 lore raw

Re: [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability

Quoted 29 lines · 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.

---
 configure | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
configure +5 -0
index 4d0e92c96c..b402befe94 100755
@@ -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

configure EOF · line 5413

Quoted 10 lines
configure +10 -0
+# 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

Quoted 28 lines
configure +8 -0
+    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
Signature · 1 line
2.16.2
#3 lore raw

Re: [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability

Quoted 26 lines · Fam Zheng
Quoted 25 lines · 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.

---
 configure | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
configure +1 -0
index 4d0e92c96c..b402befe94 100755
@@ -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
 
Quoted 16 lines
Quoted 4 lines
configure +4 -0
+##########################################
+# Docker and cross-compiler support
+#
+# This is specifically for building test

configure EOF · line 5413

Quoted 10 lines
configure +10 -0
+# 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

#4 lore raw

Re: [Qemu-devel] [PATCH v1 01/24] configure: add test for docker availability

Quoted 46 lines · Alex Bennée
Quoted 26 lines · Fam Zheng
Quoted 25 lines · 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.

---
 configure | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
configure +1 -0
index 4d0e92c96c..b402befe94 100755
@@ -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
 
Quoted 16 lines
Quoted 4 lines
configure +4 -0
+##########################################
+# Docker and cross-compiler support
+#
+# This is specifically for building test

configure EOF · line 5413

Quoted 10 lines
configure +10 -0
+# 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?

Quoted 8 lines

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

#5 lore raw

PATCH 2/24 configure: add support for --cross-cc-FOO

In reply to 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.

---
 configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
configure +50 -0
index b402befe94..b5f3b3fe29 100755
@@ -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
Signature · 1 line
2.16.2
#6 lore raw

Re: [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO

Quoted 18 lines · 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.

---
 configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
configure +0 -0
index b402befe94..b5f3b3fe29 100755

configure vxhs="" · line 459

Quoted 7 lines
configure +4 -0
@@ -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) ...?

Quoted 124 lines
configure +46 -0
+
+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
#7 lore raw

Re: [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO

Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 21 lines · 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.

---
 configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
configure +0 -0
index b402befe94..b5f3b3fe29 100755
@@ -453,6 +453,13 @@ vxhs=""
 libxml2=""
 docker="no"
 
Quoted 6 lines

configure vxhs="" · line 459

Quoted 4 lines
configure +4 -0
+# 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.

Quoted 125 lines
Quoted 125 lines
configure +46 -0
+
+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
Signature · 1 line
Alex Bennée
#8 lore raw

PATCH 3/24 configure: move i386_cc to cross_cc_i386

In reply to Alex Bennée

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

---
 configure | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
configure +15 -8
index b5f3b3fe29..add87ff4d4 100755
@@ -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=""
Signature · 1 line
2.16.2
#9 lore raw

Re: [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386

Hi Alex,

Quoted 21 lines · Alex Bennée

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

---
 configure | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
configure +0 -1
index b5f3b3fe29..add87ff4d4 100755
@@ -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=""

configure docker="no" · line 460

Quoted 5 lines
configure +2 -0
@@ -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 :)

configure case "$cpu" in

Quoted 4 lines
configure +0 -0
 enabled_cross_compilers=""
 
@@ -687,12 +688,10 @@ case "$cpu" in

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

Quoted 88 lines
configure +13 -7
   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=""
#10 lore raw

Re: [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386

Quoted 23 lines · Philippe Mathieu-Daudé

Hi Alex,

Quoted 20 lines · Alex Bennée

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

---
 configure | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
configure +0 -1
index b5f3b3fe29..add87ff4d4 100755
@@ -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=""
Quoted 8 lines

configure docker="no" · line 460

Quoted 6 lines
configure +2 -0
@@ -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.

Quoted 9 lines

Thanks :)

configure case "$cpu" in

Quoted 4 lines
configure +0 -0
 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?

Quoted 89 lines
Quoted 89 lines
configure +13 -7
   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=""
Signature · 1 line
Alex Bennée
#11 lore raw

Re: [Qemu-devel] [PATCH v1 03/24] configure: move i386_cc to cross_cc_i386

Quoted 41 lines · Alex Bennée
Quoted 23 lines · Philippe Mathieu-Daudé

Hi Alex,

Quoted 20 lines · Alex Bennée

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

---
 configure | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
configure +0 -1
index b5f3b3fe29..add87ff4d4 100755
@@ -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=""
Quoted 8 lines

configure docker="no" · line 460

Quoted 6 lines
configure +2 -0
@@ -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.

Quoted 4 lines

Thanks :)

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

configure case "$cpu" in

Quoted 3 lines

enabled_cross_compilers=""

configure +0 -0
@@ -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.

Quoted 92 lines
Quoted 90 lines
Quoted 90 lines
configure +13 -7
   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=""
#12 lore raw

PATCH 4/24 Makefile: Rename TARGET_DIRS to TARGET_LIST

In reply to Alex Bennée

From: Fam Zheng <[email protected]>

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

---
 Makefile               | 20 ++++++++++----------
 configure              |  2 +-
 scripts/create_config  |  2 +-
 tests/Makefile.include |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)
Makefile +10 -10
index 727ef118f3..2c54cd8345 100644
@@ -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:'
configure +1 -1
index add87ff4d4..5a41c87cc3 100755
@@ -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
scripts/create_config +1 -1
index d727e5e36e..58948a67a4 100755
@@ -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
tests/Makefile.include +1 -1
index 3b9a5e31a2..3d2f0458ab 100644
@@ -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))
Signature · 1 line
2.16.2
Reviewed-by Tested-by on v1 4/24
#13 lore raw

Re: [Qemu-devel] [PATCH v1 04/24] Makefile: Rename TARGET_DIRS to TARGET_LIST

Quoted 6 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

Quoted 121 lines
---
 Makefile               | 20 ++++++++++----------
 configure              |  2 +-
 scripts/create_config  |  2 +-
 tests/Makefile.include |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)
Makefile +10 -10
index 727ef118f3..2c54cd8345 100644
@@ -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:'
configure +1 -1
index add87ff4d4..5a41c87cc3 100755
@@ -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
scripts/create_config +1 -1
index d727e5e36e..58948a67a4 100755
@@ -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
tests/Makefile.include +1 -1
index 3b9a5e31a2..3d2f0458ab 100644
@@ -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))
#14 lore raw

PATCH 5/24 docker: Add "cc" subcommand

In reply to Alex Bennée

From: Fam Zheng <[email protected]>

---
 tests/docker/docker.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
tests/docker/docker.py +23 -0
index 1246ba9578..8733266153 100755
@@ -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]))
Signature · 1 line
2.16.2
Reviewed-by Tested-by on v1 5/24
#15 lore raw

Re: [Qemu-devel] [PATCH v1 05/24] docker: Add "cc" subcommand

Quoted 3 lines · Alex Bennée

From: Fam Zheng <[email protected]>

Quoted 39 lines
---
 tests/docker/docker.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
tests/docker/docker.py +23 -0
index 1246ba9578..8733266153 100755
@@ -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]))
#16 lore raw

PATCH 6/24 docker: extend "cc" command to accept compiler

In reply to Alex Bennée

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

---
 tests/docker/docker.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
tests/docker/docker.py +15 -3
index 8733266153..9444f4bea4 100755
@@ -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)
 
Signature · 1 line
2.16.2
#17 lore raw

Re: [Qemu-devel] [PATCH v1 06/24] docker: extend "cc" command to accept compiler

Quoted 2 lines · Alex Bennée

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

Makes sense to me!

Quoted 11 lines
---
 tests/docker/docker.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
tests/docker/docker.py +0 -0
index 8733266153..9444f4bea4 100755

tests/docker/docker.py class CcCommand(SubCommand): · line 401

Quoted 5 lines
tests/docker/docker.py +2 -0
@@ -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.

Quoted 4 lines
tests/docker/docker.py +0 -0
         parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
                             help="""Extra paths to (ro) mount into container for
                             reading sources""")

tests/docker/docker.py class CcCommand(SubCommand): · line 415

Quoted 10 lines
tests/docker/docker.py +4 -3
@@ -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

Quoted 15 lines
tests/docker/docker.py +9 -0
+
+        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)
 
Signature · 1 line
2.16.2
#18 lore raw

PATCH 7/24 docker: allow "cc" command to run in user context

In reply to Alex Bennée
---
 tests/docker/docker.py | 5 +++++
 1 file changed, 5 insertions(+)
tests/docker/docker.py +5 -0
index 9444f4bea4..f79213044d 100755
@@ -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
Signature · 1 line
2.16.2
Reviewed-by on v1 7/24
#19 lore raw

Re: [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context

Quoted 31 lines · Alex Bennée
---
 tests/docker/docker.py | 5 +++++
 1 file changed, 5 insertions(+)
tests/docker/docker.py +5 -0
index 9444f4bea4..f79213044d 100755
@@ -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
Signature · 1 line
2.16.2
Reviewed-by Tested-by on v1 7/24
#20 lore raw

Re: [Qemu-devel] [PATCH v1 07/24] docker: allow "cc" command to run in user context

In reply to Alex Bennée
Quoted 1 line · Alex Bennée
Quoted 28 lines
---
 tests/docker/docker.py | 5 +++++
 1 file changed, 5 insertions(+)
tests/docker/docker.py +5 -0
index 9444f4bea4..f79213044d 100755
@@ -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
#21 lore raw

PATCH 8/24 docker: Makefile.include introduce DOCKER_SCRIPT

In reply to Alex Bennée

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

---
 tests/docker/Makefile.include | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tests/docker/Makefile.include +6 -4
index de87341528..6a5aa9ec71 100644
@@ -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)
Signature · 1 line
2.16.2
Reviewed-by on v1 8/24
#22 lore raw

Re: [Qemu-devel] [PATCH v1 08/24] docker: Makefile.include introduce DOCKER_SCRIPT

Quoted 3 lines · Alex Bennée

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

Quoted 47 lines
---
 tests/docker/Makefile.include | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tests/docker/Makefile.include +6 -4
index de87341528..6a5aa9ec71 100644
@@ -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)
#23 lore raw

PATCH 9/24 tests/tcg: move architecture independent tests into subdir

In reply to 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.

---
 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
tests/tcg/README +4 -6
index 5dcfb4852b..0890044cf0 100644
@@ -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
 ====
tests/tcg/multiarch/README new file +1 -0
new file mode 100644
index 0000000000..522c9d2ea3
@@ -0,0 +1 @@
+Multi-architecture linux-user tests
tests/tcg/multiarch/linux-test.c renamed from tests/tcg/linux-test.c +0 -0
similarity index 100%
rename from tests/tcg/linux-test.c
rename to tests/tcg/multiarch/linux-test.c
tests/tcg/multiarch/sha1.c renamed from tests/tcg/sha1.c +0 -0
similarity index 100%
rename from tests/tcg/sha1.c
rename to tests/tcg/multiarch/sha1.c
tests/tcg/multiarch/test-mmap.c renamed from tests/tcg/test-mmap.c +0 -0
similarity index 100%
rename from tests/tcg/test-mmap.c
rename to tests/tcg/multiarch/test-mmap.c
tests/tcg/multiarch/testthread.c renamed from tests/tcg/testthread.c +0 -0
similarity index 100%
rename from tests/tcg/testthread.c
rename to tests/tcg/multiarch/testthread.c
tests/tcg/test_path.c deleted +0 -157

157 lines not on this page · raw message

Signature · 1 line
2.16.2
Reviewed-by on v1 9/24
#24 lore raw

Re: [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir

Quoted 6 lines · 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.

Quoted 15 lines
---
 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
#25 lore raw

Re: [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir

In reply to Alex Bennée

Hi Alex,

Quoted 4 lines · 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.

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

Quoted 223 lines
---
 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
tests/tcg/README +4 -6
index 5dcfb4852b..0890044cf0 100644
@@ -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
 ====
tests/tcg/multiarch/README new file +1 -0
new file mode 100644
index 0000000000..522c9d2ea3
@@ -0,0 +1 @@
+Multi-architecture linux-user tests
tests/tcg/multiarch/linux-test.c renamed from tests/tcg/linux-test.c +0 -0
similarity index 100%
rename from tests/tcg/linux-test.c
rename to tests/tcg/multiarch/linux-test.c
tests/tcg/multiarch/sha1.c renamed from tests/tcg/sha1.c +0 -0
similarity index 100%
rename from tests/tcg/sha1.c
rename to tests/tcg/multiarch/sha1.c
tests/tcg/multiarch/test-mmap.c renamed from tests/tcg/test-mmap.c +0 -0
similarity index 100%
rename from tests/tcg/test-mmap.c
rename to tests/tcg/multiarch/test-mmap.c
tests/tcg/multiarch/testthread.c renamed from tests/tcg/testthread.c +0 -0
similarity index 100%
rename from tests/tcg/testthread.c
rename to tests/tcg/multiarch/testthread.c
tests/tcg/test_path.c deleted +0 -157
deleted file mode 100644
index 1c29bce263..0000000000
@@ -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;
-}
#26 lore raw

Re: [Qemu-devel] [PATCH v1 09/24] tests/tcg: move architecture independent tests into subdir

Quoted 10 lines · Philippe Mathieu-Daudé

Hi Alex,

Quoted 4 lines · 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.

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.

Quoted 224 lines
Quoted 224 lines
---
 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
tests/tcg/README +4 -6
index 5dcfb4852b..0890044cf0 100644
@@ -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
 ====
tests/tcg/multiarch/README new file +1 -0
new file mode 100644
index 0000000000..522c9d2ea3
@@ -0,0 +1 @@
+Multi-architecture linux-user tests
tests/tcg/multiarch/linux-test.c renamed from tests/tcg/linux-test.c +0 -0
similarity index 100%
rename from tests/tcg/linux-test.c
rename to tests/tcg/multiarch/linux-test.c
tests/tcg/multiarch/sha1.c renamed from tests/tcg/sha1.c +0 -0
similarity index 100%
rename from tests/tcg/sha1.c
rename to tests/tcg/multiarch/sha1.c
tests/tcg/multiarch/test-mmap.c renamed from tests/tcg/test-mmap.c +0 -0
similarity index 100%
rename from tests/tcg/test-mmap.c
rename to tests/tcg/multiarch/test-mmap.c
tests/tcg/multiarch/testthread.c renamed from tests/tcg/testthread.c +0 -0
similarity index 100%
rename from tests/tcg/testthread.c
rename to tests/tcg/multiarch/testthread.c
tests/tcg/test_path.c deleted +0 -157
deleted file mode 100644
index 1c29bce263..0000000000
@@ -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;
-}
Signature · 1 line
Alex Bennée
#27 lore raw

PATCH 10/24 tests/tcg/multiarch: Build fix for linux-test

In reply to Alex Bennée

From: Fam Zheng <[email protected]>

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

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

[AJB: drop cutils/osdep dependencies]
---
 tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
 1 file changed, 21 insertions(+), 47 deletions(-)
tests/tcg/multiarch/linux-test.c +21 -47
index 5070d31446..4457bd04ba 100644
@@ -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;
Signature · 1 line
2.16.2
Reviewed-by on v1 10/24
#28 lore raw

Re: [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test

Quoted 8 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

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

Quoted 6 lines
[AJB: drop cutils/osdep dependencies]
---
 tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
 1 file changed, 21 insertions(+), 47 deletions(-)

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#31 lore raw

Re: [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test

Quoted 155 lines · Philippe Mathieu-Daudé
Quoted 150 lines · Philippe Mathieu-Daudé

Hi Fam, Alex,

Quoted 147 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

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

[AJB: drop cutils/osdep dependencies]
---
 tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
 1 file changed, 21 insertions(+), 47 deletions(-)
tests/tcg/multiarch/linux-test.c +10 -38
index 5070d31446..4457bd04ba 100644
@@ -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));
 }
 
Quoted 3 lines

tests/tcg/multiarch/linux-test.c void test_socket(void) · line 323

Quoted 1 line
tests/tcg/multiarch/linux-test.c +1 -0
+#if 0

Why keep this now dead code?

Quoted 5 lines

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.

Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
tests/tcg/multiarch/linux-test.c +10 -9
 #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;
Signature · 1 line
Alex Bennée
#32 lore raw

Re: [Qemu-devel] [PATCH v1 10/24] tests/tcg/multiarch: Build fix for linux-test

In reply to a message not in the archive
Quoted 155 lines · Philippe Mathieu-Daudé
Quoted 150 lines · Philippe Mathieu-Daudé

Hi Fam, Alex,

Quoted 147 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

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

[AJB: drop cutils/osdep dependencies]
---
 tests/tcg/multiarch/linux-test.c | 68 +++++++++++++---------------------------
 1 file changed, 21 insertions(+), 47 deletions(-)
tests/tcg/multiarch/linux-test.c +10 -38
index 5070d31446..4457bd04ba 100644
@@ -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));
 }
 
Quoted 3 lines

tests/tcg/multiarch/linux-test.c void test_socket(void) · line 323

Quoted 1 line
tests/tcg/multiarch/linux-test.c +1 -0
+#if 0

Why keep this now dead code?

Quoted 5 lines

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.

Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
tests/tcg/multiarch/linux-test.c +9 -8
 #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)
 
Quoted 8 lines
Quoted 8 lines

tests/tcg/multiarch/linux-test.c void test_signal(void) · line 490

Quoted 8 lines
tests/tcg/multiarch/linux-test.c +1 -1
 #define SHM_SIZE 32768
 
-void test_shm(void)
+static void test_shm(void)
 {
     void *ptr;
     int shmid;

--
Alex Bennée

#33 lore raw

PATCH 11/24 tests/tcg: move i386 specific tests into subdir

In reply to 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.

---
 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%)
tests/tcg/README +0 -39
index 0890044cf0..469504c4cb 100644
@@ -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
tests/tcg/i386/Makefile.target new file +10 -0
new file mode 100644
index 0000000000..7dbb7992e7
@@ -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
tests/tcg/i386/README new file +38 -0
new file mode 100644
index 0000000000..7a0a47bf27
@@ -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
+----------
tests/tcg/i386/hello-i386.c renamed from tests/tcg/hello-i386.c +0 -0
similarity index 100%
rename from tests/tcg/hello-i386.c
rename to tests/tcg/i386/hello-i386.c
tests/tcg/i386/pi_10.com renamed from tests/tcg/pi_10.com +0 -0
similarity index 100%
rename from tests/tcg/pi_10.com
rename to tests/tcg/i386/pi_10.com
tests/tcg/i386/runcom.c renamed from tests/tcg/runcom.c +0 -0
similarity index 100%
rename from tests/tcg/runcom.c
rename to tests/tcg/i386/runcom.c
tests/tcg/i386/test-i386-code16.S renamed from tests/tcg/test-i386-code16.S +0 -0
similarity index 100%
rename from tests/tcg/test-i386-code16.S
rename to tests/tcg/i386/test-i386-code16.S
tests/tcg/i386/test-i386-fprem.c renamed from tests/tcg/test-i386-fprem.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386-fprem.c
rename to tests/tcg/i386/test-i386-fprem.c
tests/tcg/i386/test-i386-muldiv.h renamed from tests/tcg/test-i386-muldiv.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386-muldiv.h
rename to tests/tcg/i386/test-i386-muldiv.h
tests/tcg/i386/test-i386-shift.h renamed from tests/tcg/test-i386-shift.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386-shift.h
rename to tests/tcg/i386/test-i386-shift.h
tests/tcg/i386/test-i386-ssse3.c renamed from tests/tcg/test-i386-ssse3.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386-ssse3.c
rename to tests/tcg/i386/test-i386-ssse3.c
tests/tcg/i386/test-i386-vm86.S renamed from tests/tcg/test-i386-vm86.S +0 -0
similarity index 100%
rename from tests/tcg/test-i386-vm86.S
rename to tests/tcg/i386/test-i386-vm86.S
tests/tcg/i386/test-i386.c renamed from tests/tcg/test-i386.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386.c
rename to tests/tcg/i386/test-i386.c
tests/tcg/i386/test-i386.h renamed from tests/tcg/test-i386.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386.h
rename to tests/tcg/i386/test-i386.h
Signature · 1 line
2.16.2
Reviewed-by on v1 11/24
#34 lore raw

Re: [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir

Quoted 5 lines · 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.

Quoted 13 lines
---
 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 Tested-by on v1 11/24
#35 lore raw

Re: [Qemu-devel] [PATCH v1 11/24] tests/tcg: move i386 specific tests into subdir

In reply to Alex Bennée
Quoted 2 lines · 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

Mak[e]file

Quoted 3 lines

tests/tcg/Makefile.

Quoted 185 lines
---
 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%)
tests/tcg/README +0 -39
index 0890044cf0..469504c4cb 100644
@@ -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
tests/tcg/i386/Makefile.target new file +10 -0
new file mode 100644
index 0000000000..7dbb7992e7
@@ -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
tests/tcg/i386/README new file +38 -0
new file mode 100644
index 0000000000..7a0a47bf27
@@ -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
+----------
tests/tcg/i386/hello-i386.c renamed from tests/tcg/hello-i386.c +0 -0
similarity index 100%
rename from tests/tcg/hello-i386.c
rename to tests/tcg/i386/hello-i386.c
tests/tcg/i386/pi_10.com renamed from tests/tcg/pi_10.com +0 -0
similarity index 100%
rename from tests/tcg/pi_10.com
rename to tests/tcg/i386/pi_10.com
tests/tcg/i386/runcom.c renamed from tests/tcg/runcom.c +0 -0
similarity index 100%
rename from tests/tcg/runcom.c
rename to tests/tcg/i386/runcom.c
tests/tcg/i386/test-i386-code16.S renamed from tests/tcg/test-i386-code16.S +0 -0
similarity index 100%
rename from tests/tcg/test-i386-code16.S
rename to tests/tcg/i386/test-i386-code16.S
tests/tcg/i386/test-i386-fprem.c renamed from tests/tcg/test-i386-fprem.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386-fprem.c
rename to tests/tcg/i386/test-i386-fprem.c
tests/tcg/i386/test-i386-muldiv.h renamed from tests/tcg/test-i386-muldiv.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386-muldiv.h
rename to tests/tcg/i386/test-i386-muldiv.h
tests/tcg/i386/test-i386-shift.h renamed from tests/tcg/test-i386-shift.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386-shift.h
rename to tests/tcg/i386/test-i386-shift.h
tests/tcg/i386/test-i386-ssse3.c renamed from tests/tcg/test-i386-ssse3.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386-ssse3.c
rename to tests/tcg/i386/test-i386-ssse3.c
tests/tcg/i386/test-i386-vm86.S renamed from tests/tcg/test-i386-vm86.S +0 -0
similarity index 100%
rename from tests/tcg/test-i386-vm86.S
rename to tests/tcg/i386/test-i386-vm86.S
tests/tcg/i386/test-i386.c renamed from tests/tcg/test-i386.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386.c
rename to tests/tcg/i386/test-i386.c
tests/tcg/i386/test-i386.h renamed from tests/tcg/test-i386.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386.h
rename to tests/tcg/i386/test-i386.h
#36 lore raw

PATCH 12/24 tests/tcg/i386: Build fix for hello-i386

In reply to Alex Bennée

From: Fam Zheng <[email protected]>

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

---
 tests/tcg/i386/hello-i386.c | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/i386/hello-i386.c +1 -0
index fa00380de2..cfeb24b2f5 100644
@@ -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);
Signature · 1 line
2.16.2
Reviewed-by on v1 12/24
#37 lore raw

Re: [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386

Quoted 16 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

---
 tests/tcg/i386/hello-i386.c | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/i386/hello-i386.c +0 -0
index fa00380de2..cfeb24b2f5 100644

tests/tcg/i386/hello-i386.c static inline int write(int fd, const char * buf, int len) · line 26

Quoted 7 lines
tests/tcg/i386/hello-i386.c +1 -0
@@ -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);
#38 lore raw

Re: [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386

In reply to Alex Bennée

Hi Fam, Alex,

Quoted 15 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

---
 tests/tcg/i386/hello-i386.c | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/i386/hello-i386.c +0 -0
index fa00380de2..cfeb24b2f5 100644

tests/tcg/i386/hello-i386.c static inline int write(int fd, const char * buf, int len) · line 23

Quoted 4 lines
tests/tcg/i386/hello-i386.c +1 -0
@@ -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...

Quoted 4 lines
tests/tcg/i386/hello-i386.c +0 -0
 void _start(void)
 {
     write(1, "Hello World\n", 12);
#39 lore raw

Re: [Qemu-devel] [PATCH v1 12/24] tests/tcg/i386: Build fix for hello-i386

Quoted 21 lines · Philippe Mathieu-Daudé

Hi Fam, Alex,

Quoted 18 lines · Alex Bennée

From: Fam Zheng <[email protected]>

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

---
 tests/tcg/i386/hello-i386.c | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/i386/hello-i386.c +0 -0
index fa00380de2..cfeb24b2f5 100644
@@ -20,6 +20,7 @@ static inline int write(int fd, const char * buf, int len)
   return status;
 }
 
Quoted 4 lines

tests/tcg/i386/hello-i386.c static inline int write(int fd, const char * buf, int len) · line 23

Quoted 1 line
tests/tcg/i386/hello-i386.c +1 -0
+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...

Quoted 5 lines
Quoted 5 lines
tests/tcg/i386/hello-i386.c +0 -0
 void _start(void)
 {
     write(1, "Hello World\n", 12);
Signature · 1 line
Alex Bennée
#40 lore raw

PATCH 13/24 tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c

In reply to 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.

---
 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%)
tests/tcg/x86_64/test-sse.c renamed from tests/tcg/i386/test-i386-ssse3.c +2 -4
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
@@ -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;
 }
Signature · 1 line
2.16.2
#41 lore raw

Re: [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c

Quoted 9 lines · 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.

---
 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

#42 lore raw

Re: [Qemu-devel] [PATCH v1 13/24] tests/tcg/i386: move test-i386-sse.c to tests/tcg/x86_64/test-sse.c

Quoted 11 lines · Thomas Huth
Quoted 9 lines · 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.

---
 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%)
Quoted 4 lines

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

#43 lore raw

PATCH 14/24 tests/tcg/i386: fix test-i386

In reply to 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.

---
 tests/tcg/i386/Makefile.target | 19 +++++++++++++++++++
 tests/tcg/i386/test-i386.c     |  1 -
 2 files changed, 19 insertions(+), 1 deletion(-)
tests/tcg/i386/Makefile.target +19 -0
index 7dbb7992e7..1df69e0dab 100644
@@ -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 $@
+
tests/tcg/i386/test-i386.c +0 -1
index 9599204895..cae6a7773a 100644
@@ -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>
Signature · 1 line
2.16.2
Reviewed-by on v1 14/24
#44 lore raw

Re: [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386

Quoted 9 lines · 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.

---
 tests/tcg/i386/Makefile.target | 19 +++++++++++++++++++
 tests/tcg/i386/test-i386.c     |  1 -
 2 files changed, 19 insertions(+), 1 deletion(-)
Reviewed-by Tested-by on v1 14/24
#45 lore raw

Re: [Qemu-devel] [PATCH v1 14/24] tests/tcg/i386: fix test-i386

In reply to Alex Bennée
Quoted 5 lines · 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.

Quoted 45 lines
---
 tests/tcg/i386/Makefile.target | 19 +++++++++++++++++++
 tests/tcg/i386/test-i386.c     |  1 -
 2 files changed, 19 insertions(+), 1 deletion(-)
tests/tcg/i386/Makefile.target +19 -0
index 7dbb7992e7..1df69e0dab 100644
@@ -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 $@
+
tests/tcg/i386/test-i386.c +0 -1
index 9599204895..cae6a7773a 100644
@@ -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>
#46 lore raw

PATCH 15/24 tests/tcg/i368: fix hello-i386

In reply to Alex Bennée

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

---
 tests/tcg/i386/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
tests/tcg/i386/Makefile.target +6 -0
index 1df69e0dab..44803c0382 100644
@@ -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
 #
Signature · 1 line
2.16.2
Reviewed-by on v1 15/24
#47 lore raw

Re: [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386

Quoted 15 lines · Alex Bennée

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

---
 tests/tcg/i386/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
tests/tcg/i386/Makefile.target +0 -0
index 1df69e0dab..44803c0382 100644
@@ -9,6 +9,12 @@ CFLAGS+=$(CROSS_CC_GUEST_CFLAGS)
 endif
 endif

tests/tcg/i386/Makefile.target CFLAGS+=$(CROSS_CC_GUEST_CFLAGS) · line 20

Quoted 10 lines
tests/tcg/i386/Makefile.target +6 -0
 
+#
+# 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 Tested-by on v1 15/24
#48 lore raw

Re: [Qemu-devel] [PATCH v1 15/24] tests/tcg/i368: fix hello-i386

In reply to Alex Bennée
Quoted 3 lines · Alex Bennée

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

Quoted 22 lines
---
 tests/tcg/i386/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
tests/tcg/i386/Makefile.target +6 -0
index 1df69e0dab..44803c0382 100644
@@ -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
 #
#49 lore raw

PATCH 16/24 tests/tcg/i386: fix test-i386-fprem

In reply to Alex Bennée

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

---
 tests/tcg/i386/test-i386-fprem.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tests/tcg/i386/test-i386-fprem.c +6 -3
index 1a71623204..771dc07433 100644
@@ -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
Signature · 1 line
2.16.2
Reviewed-by on v1 16/24
#50 lore raw

Re: [Qemu-devel] [PATCH v1 16/24] tests/tcg/i386: fix test-i386-fprem

Quoted 3 lines · Alex Bennée

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

Quoted 39 lines
---
 tests/tcg/i386/test-i386-fprem.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tests/tcg/i386/test-i386-fprem.c +6 -3
index 1a71623204..771dc07433 100644
@@ -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
#51 lore raw

PATCH 17/24 tests/tcg: move ARM specific tests into subdir

In reply to Alex Bennée

These only need to be built for ARM guests.

---
 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%)
tests/tcg/README +0 -9
index 469504c4cb..625f2326e6 100644
@@ -5,15 +5,6 @@ or they are architecture specific.
 
 
 
-ARM
-===
-
-hello-arm
----------
-
-test-arm-iwmmxt
----------------
-
 MIPS
 ====
 
tests/tcg/arm/README new file +11 -0
new file mode 100644
index 0000000000..e6307116e2
@@ -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
tests/tcg/arm/hello-arm.c renamed from tests/tcg/hello-arm.c +0 -0
similarity index 100%
rename from tests/tcg/hello-arm.c
rename to tests/tcg/arm/hello-arm.c
tests/tcg/arm/test-arm-iwmmxt.s renamed from tests/tcg/test-arm-iwmmxt.s +0 -0
similarity index 100%
rename from tests/tcg/test-arm-iwmmxt.s
rename to tests/tcg/arm/test-arm-iwmmxt.s
Signature · 1 line
2.16.2
Reviewed-by on v1 17/24
#52 lore raw

Re: [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir

Quoted 12 lines · Alex Bennée

These only need to be built for ARM guests.

---
 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 Tested-by on v1 17/24
#53 lore raw

Re: [Qemu-devel] [PATCH v1 17/24] tests/tcg: move ARM specific tests into subdir

In reply to Alex Bennée
Quoted 3 lines · Alex Bennée

These only need to be built for ARM guests.

Quoted 56 lines
---
 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%)
tests/tcg/README +0 -9
index 469504c4cb..625f2326e6 100644
@@ -5,15 +5,6 @@ or they are architecture specific.
 
 
 
-ARM
-===
-
-hello-arm
----------
-
-test-arm-iwmmxt
----------------
-
 MIPS
 ====
 
tests/tcg/arm/README new file +11 -0
new file mode 100644
index 0000000000..e6307116e2
@@ -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
tests/tcg/arm/hello-arm.c renamed from tests/tcg/hello-arm.c +0 -0
similarity index 100%
rename from tests/tcg/hello-arm.c
rename to tests/tcg/arm/hello-arm.c
tests/tcg/arm/test-arm-iwmmxt.s renamed from tests/tcg/test-arm-iwmmxt.s +0 -0
similarity index 100%
rename from tests/tcg/test-arm-iwmmxt.s
rename to tests/tcg/arm/test-arm-iwmmxt.s
#54 lore raw

PATCH 18/24 tests/tcg/arm: fix hello-arm

In reply to 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.

---
 tests/tcg/arm/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 tests/tcg/arm/Makefile.target
tests/tcg/arm/Makefile.target new file +6 -0
new file mode 100644
index 0000000000..b7c146c88e
@@ -0,0 +1,6 @@
+# -*- Mode: makefile -*-
+#
+# ARM specific tweaks
+
+hello-arm: CFLAGS+=-marm -ffreestanding
+hello-arm: LDFLAGS+=-nostdlib
Signature · 1 line
2.16.2
Reviewed-by on v1 18/24
#55 lore raw

Re: [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm

Quoted 8 lines · 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.

---
 tests/tcg/arm/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 tests/tcg/arm/Makefile.target
Reviewed-by Tested-by on v1 18/24
#56 lore raw

Re: [Qemu-devel] [PATCH v1 18/24] tests/tcg/arm: fix hello-arm

In reply to Alex Bennée

Hi Alex,

Quoted 15 lines · 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.

---
 tests/tcg/arm/Makefile.target | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 tests/tcg/arm/Makefile.target
tests/tcg/arm/Makefile.target new file +0 -0
new file mode 100644
index 0000000000..b7c146c88e

tests/tcg/arm/Makefile.target line 3

Quoted 3 lines
tests/tcg/arm/Makefile.target new file +3 -0
@@ -0,0 +1,6 @@
+# -*- Mode: makefile -*-
+#
+# ARM specific tweaks

... (Thumb mode explicitly disabled)

tests/tcg/arm/Makefile.target line 6

Quoted 3 lines
tests/tcg/arm/Makefile.target new file +3 -0
+
+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
--

#57 lore raw

PATCH 19/24 tests/tcg: move MIPS specific tests into subdir

In reply to Alex Bennée

These only need to be built for MIPS guests.

---
 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%)
tests/tcg/README +0 -11
index 625f2326e6..a5643d33e7 100644
@@ -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
tests/tcg/mips/README new file +7 -0
new file mode 100644
index 0000000000..e5bbc58ec5
@@ -0,0 +1,7 @@
+MIPS
+====
+
+hello-mips
+----------
+
+A very simple inline assembly, write syscall based hello world
tests/tcg/mips/hello-mips.c renamed from tests/tcg/hello-mips.c +0 -0
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c
Signature · 1 line
2.16.2
#58 lore raw

Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir

tests/tcg/mips/hello-mips.c

Quoted 50 lines · Alex Bennée

These only need to be built for MIPS guests.

---
 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%)
tests/tcg/README +0 -11
index 625f2326e6..a5643d33e7 100644
@@ -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
tests/tcg/mips/README new file +7 -0
new file mode 100644
index 0000000000..e5bbc58ec5
@@ -0,0 +1,7 @@
+MIPS
+====
+
+hello-mips
+----------
+
+A very simple inline assembly, write syscall based hello world
tests/tcg/mips/hello-mips.c renamed from tests/tcg/hello-mips.c +0 -0
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c

tested with:

-- >8 --

configure +2 -0
index c98eb01c39..aebe928b3c 100755
@@ -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
tests/tcg/mips/Makefile.target new file +6 -0
new file mode 100644
index 0000000000..427aafc9e5
@@ -0,0 +1,6 @@
+# -*- Mode: makefile -*-
+#
+# MIPS specific tweaks
+
+hello-mips: CFLAGS+=-ffreestanding
+hello-mips: LDFLAGS+=-nostdlib
Signature · 2 lines
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by Tested-by
#59 lore raw

Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir

Quoted 82 lines · Philippe Mathieu-Daudé

tests/tcg/mips/hello-mips.c

Quoted 50 lines · Alex Bennée

These only need to be built for MIPS guests.

---
 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%)
tests/tcg/README +0 -11
index 625f2326e6..a5643d33e7 100644
@@ -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
tests/tcg/mips/README new file +7 -0
new file mode 100644
index 0000000000..e5bbc58ec5
@@ -0,0 +1,7 @@
+MIPS
+====
+
+hello-mips
+----------
+
+A very simple inline assembly, write syscall based hello world
tests/tcg/mips/hello-mips.c renamed from tests/tcg/hello-mips.c +0 -0
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c

tested with:

-- >8 --

configure +2 -0
index c98eb01c39..aebe928b3c 100755
@@ -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
tests/tcg/mips/Makefile.target new file +0 -0
new file mode 100644
index 0000000000..427aafc9e5

tests/tcg/mips/Makefile.target line 6

Quoted 6 lines
tests/tcg/mips/Makefile.target new file +6 -0
@@ -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.

#60 lore raw

Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir

In reply to Philippe Mathieu-Daudé
Quoted 81 lines · Philippe Mathieu-Daudé

tests/tcg/mips/hello-mips.c

Quoted 50 lines · Alex Bennée

These only need to be built for MIPS guests.

---
 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%)
tests/tcg/README +0 -11
index 625f2326e6..a5643d33e7 100644
@@ -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
tests/tcg/mips/README new file +7 -0
new file mode 100644
index 0000000000..e5bbc58ec5
@@ -0,0 +1,7 @@
+MIPS
+====
+
+hello-mips
+----------
+
+A very simple inline assembly, write syscall based hello world
tests/tcg/mips/hello-mips.c renamed from tests/tcg/hello-mips.c +0 -0
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c

tested with:

-- >8 --

configure +2 -0
index c98eb01c39..aebe928b3c 100755
@@ -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
tests/tcg/mips/Makefile.target new file +0 -0
new file mode 100644
index 0000000000..427aafc9e5

tests/tcg/mips/Makefile.target line 6

Quoted 6 lines
tests/tcg/mips/Makefile.target new file +6 -0
@@ -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.

Signature · 1 line
Alex Bennée
#61 lore raw

Re: [Qemu-devel] [PATCH v1 19/24] tests/tcg: move MIPS specific tests into subdir

Quoted 93 lines · Alex Bennée
Quoted 81 lines · Philippe Mathieu-Daudé

tests/tcg/mips/hello-mips.c

Quoted 50 lines · Alex Bennée

These only need to be built for MIPS guests.

---
 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%)
tests/tcg/README +0 -11
index 625f2326e6..a5643d33e7 100644
@@ -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
tests/tcg/mips/README new file +7 -0
new file mode 100644
index 0000000000..e5bbc58ec5
@@ -0,0 +1,7 @@
+MIPS
+====
+
+hello-mips
+----------
+
+A very simple inline assembly, write syscall based hello world
tests/tcg/mips/hello-mips.c renamed from tests/tcg/hello-mips.c +0 -0
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c

tested with:

-- >8 --

configure +2 -0
index c98eb01c39..aebe928b3c 100755
@@ -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
tests/tcg/mips/Makefile.target new file +0 -0
new file mode 100644
index 0000000000..427aafc9e5

tests/tcg/mips/Makefile.target line 6

Quoted 6 lines
tests/tcg/mips/Makefile.target new file +6 -0
@@ -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:

Quoted 7 lines
  # 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 :)

#62 lore raw

PATCH 20/24 tests/tcg: enable building for s390x

In reply to Alex Bennée

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

---
 tests/tcg/s390x/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/s390x/Makefile.include
tests/tcg/s390x/Makefile.include new file +2 -0
new file mode 100644
index 0000000000..1f58115d96
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-s390x-cross
+DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc
Signature · 1 line
2.16.2
Acked-by on v1 20/24
#63 lore raw

Re: [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x

Quoted 15 lines · On Tue, 10 Apr 2018 20:39:15 +0100 Alex Bennée <[email protected]> wrote:

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

---
 tests/tcg/s390x/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/s390x/Makefile.include
tests/tcg/s390x/Makefile.include new file +0 -0
new file mode 100644
index 0000000000..1f58115d96

tests/tcg/s390x/Makefile.include line 2

Quoted 2 lines
tests/tcg/s390x/Makefile.include new file +2 -0
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-s390x-cross
+DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc
Reviewed-by Tested-by on v1 20/24
#64 lore raw

Re: [Qemu-devel] [PATCH v1 20/24] tests/tcg: enable building for s390x

In reply to Alex Bennée
Quoted 4 lines · Alex Bennée

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

Quoted 14 lines
---
 tests/tcg/s390x/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/s390x/Makefile.include
tests/tcg/s390x/Makefile.include new file +2 -0
new file mode 100644
index 0000000000..1f58115d96
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-s390x-cross
+DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc
#65 lore raw

PATCH 21/24 tests/tcg: enable building for ppc64

In reply to Alex Bennée

Currently this just enables building the multiarch tests.

---
 tests/tcg/ppc64/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/ppc64/Makefile.include
tests/tcg/ppc64/Makefile.include new file +2 -0
new file mode 100644
index 0000000000..d71cfc9aa7
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-ppc64el-cross
+DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc
Signature · 1 line
2.16.2
Reviewed-by Tested-by on v1 21/24
#66 lore raw

Re: [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64

Hi Alex,

Quoted 3 lines · Alex Bennée

Currently this just enables building the multiarch tests.

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

Do we care about ppc[32]?

Quoted 13 lines
---
 tests/tcg/ppc64/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/ppc64/Makefile.include
tests/tcg/ppc64/Makefile.include new file +2 -0
new file mode 100644
index 0000000000..d71cfc9aa7
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-ppc64el-cross
+DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc
#67 lore raw

Re: [Qemu-devel] [PATCH v1 21/24] tests/tcg: enable building for ppc64

Quoted 5 lines · Philippe Mathieu-Daudé

Hi Alex,

Quoted 2 lines · Alex Bennée

Currently this just enables building the multiarch tests.

Quoted 8 lines
Quoted 1 line

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

Do we care about ppc[32]?

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

Quoted 14 lines
Quoted 14 lines
---
 tests/tcg/ppc64/Makefile.include | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tests/tcg/ppc64/Makefile.include
tests/tcg/ppc64/Makefile.include new file +2 -0
new file mode 100644
index 0000000000..d71cfc9aa7
@@ -0,0 +1,2 @@
+DOCKER_IMAGE=debian-ppc64el-cross
+DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc
Signature · 1 line
Alex Bennée
#68 lore raw

PATCH 22/24 tests/tcg/Makefile: update to be called from Makefile.target

In reply to 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.

---
 tests/tcg/Makefile | 185 ++++++++++++-----------------------------------------
 1 file changed, 42 insertions(+), 143 deletions(-)
tests/tcg/Makefile +42 -143
index 89e3342f3d..2bba0d2a32 100644
@@ -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
Signature · 1 line
2.16.2
#69 lore raw

Re: [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target

Quoted 193 lines · 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.

---
 tests/tcg/Makefile | 185 ++++++++++++-----------------------------------------
 1 file changed, 42 insertions(+), 143 deletions(-)
tests/tcg/Makefile +37 -125
index 89e3342f3d..2bba0d2a32 100644
@@ -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 $@ $<
-

tests/tcg/Makefile line 48

Quoted 10 lines
tests/tcg/Makefile +1 -9
-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

Quoted 19 lines
tests/tcg/Makefile +4 -9
-# 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
Signature · 1 line
2.16.2
#70 lore raw

Re: [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target

Quoted 199 lines · Fam Zheng
Quoted 198 lines · 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.

---
 tests/tcg/Makefile | 185 ++++++++++++-----------------------------------------
 1 file changed, 42 insertions(+), 143 deletions(-)
tests/tcg/Makefile +37 -130
index 89e3342f3d..2bba0d2a32 100644
@@ -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
Quoted 8 lines

tests/tcg/Makefile line 48

Quoted 5 lines
tests/tcg/Makefile +1 -4
-	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?

Quoted 15 lines

Fam

Quoted 12 lines
tests/tcg/Makefile +3 -6
-# 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)
 
Quoted 7 lines
Quoted 7 lines
tests/tcg/Makefile +1 -4
-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

#71 lore raw

Re: [Qemu-devel] [PATCH v1 22/24] tests/tcg/Makefile: update to be called from Makefile.target

Quoted 9 lines · Alex Bennée
Quoted 4 lines · Fam Zheng
Quoted 1 line

+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

#72 lore raw

PATCH 23/24 Makefile.target: add (clean-)guest-tests targets

In reply to 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
2.16.2
#73 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

Hi Alex,

Quoted 40 lines · 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +5 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -0,0 +1,79 @@
+# -*- Mode: makefile -*-
+#
+# TCG tests (per-target rules)
+#
+# This Makefile fragement is included from the per-target

tests/tcg/Makefile.include line 15

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+# 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?

Quoted 65 lines
tests/tcg/Makefile.include new file +64 -0
+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"
#74 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

In reply to Alex Bennée
Quoted 72 lines · 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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?

Quoted 29 lines
tests/tcg/Makefile.include new file +28 -0
+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"
#75 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

Quoted 86 lines · Philippe Mathieu-Daudé
Quoted 72 lines · 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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:

Quoted 8 lines

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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....

Quoted 30 lines
Quoted 30 lines
tests/tcg/Makefile.include new file +28 -0
+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"
Signature · 1 line
Alex Bennée
#76 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

Quoted 98 lines · Alex Bennée
Quoted 86 lines · Philippe Mathieu-Daudé
Quoted 72 lines · 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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:

Quoted 8 lines

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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?

Quoted 3 lines

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?

Quoted 37 lines

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....

Quoted 30 lines
Quoted 30 lines
tests/tcg/Makefile.include new file +28 -0
+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"
#77 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

In reply to Alex Bennée
Quoted 98 lines · Alex Bennée
Quoted 86 lines · Philippe Mathieu-Daudé
Quoted 72 lines · 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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:

Quoted 8 lines

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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?

Quoted 7 lines

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

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
tests/tcg/Makefile.include new file +28 -0
+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"
#78 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

Quoted 103 lines · Philippe Mathieu-Daudé
Quoted 102 lines · Alex Bennée
Quoted 86 lines · Philippe Mathieu-Daudé
Quoted 72 lines · 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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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:

Quoted 8 lines

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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.

Quoted 7 lines
Quoted 3 lines

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.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
tests/tcg/Makefile.include new file +21 -0
+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:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

tests/tcg/Makefile.include line 79

Quoted 8 lines
tests/tcg/Makefile.include new file +7 -0
+	$(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

#79 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

Hi Alex

Quoted 113 lines · Alex Bennée
Quoted 98 lines
Quoted 98 lines
Quoted 85 lines
Quoted 72 lines

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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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:

Quoted 8 lines

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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.

Quoted 7 lines
Quoted 3 lines

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:

Quoted 8 lines

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

Quoted 34 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
tests/tcg/Makefile.include new file +21 -0
+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:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

tests/tcg/Makefile.include line 79

Quoted 8 lines
tests/tcg/Makefile.include new file +7 -0
+	$(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

#80 lore raw

Re: [Qemu-devel] [PATCH v1 23/24] Makefile.target: add (clean-)guest-tests targets

Quoted 128 lines · Philippe Mathieu-Daudé

Hi Alex

Quoted 113 lines · Alex Bennée
Quoted 98 lines
Quoted 98 lines
Quoted 85 lines
Quoted 72 lines

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.

---
 Makefile.target            |  5 +++
 tests/tcg/Makefile.include | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
Makefile.target +5 -0
index d0ec77a307..a30fd40257 100644
@@ -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
 
tests/tcg/Makefile.include new file +37 -0
new file mode 100644
index 0000000000..cb8bb36026
@@ -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
+

tests/tcg/Makefile.include line 47

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+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:

Quoted 8 lines

DOCKER_CROSS_COMPILER ?= $(DOCKER_CROSS_COMPILER_PREFIX)-gcc

tests/tcg/Makefile.include line 51

Quoted 4 lines
tests/tcg/Makefile.include new file +4 -0
+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.

Quoted 7 lines
Quoted 3 lines

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:

Quoted 8 lines

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:

Quoted 8 lines

- 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?

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
tests/tcg/Makefile.include new file +26 -0
+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
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

tests/tcg/Makefile.include line 79

Quoted 3 lines
tests/tcg/Makefile.include new file +2 -0
+clean-guest-tests:
+	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"

--
Alex Bennée

--
Alex Bennée

#81 lore raw

PATCH 24/24 tests/Makefile.include: add (clean-)check-tcg targets

In reply to Alex Bennée

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

---
 tests/Makefile.include | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
tests/Makefile.include +18 -1
index 3d2f0458ab..c402de901e 100644
@@ -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
Signature · 1 line
2.16.2
Reviewed-by Tested-by on v1 24/24
#82 lore raw

Re: [Qemu-devel] [PATCH v1 24/24] tests/Makefile.include: add (clean-)check-tcg targets

Quoted 4 lines · Alex Bennée

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

Quoted 49 lines
---
 tests/Makefile.include | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
tests/Makefile.include +18 -1
index 3d2f0458ab..c402de901e 100644
@@ -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
#83 lore raw
In reply to Alex Bennée
This series seems to have some coding style problems. See output below for more information:

Hi,

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

Type: series
Message-id: [email protected]
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/[email protected] -> patchew/[email protected]
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 [email protected]

#84 lore raw
In reply to Alex Bennée
Quoted 11 lines · 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.

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.

Quoted 156 lines

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%)