[Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery

Alex Bennée posted 57 patches 5 years, 10 months ago
Only 26 patches received!
.travis.yml                                        |    8 +
MAINTAINERS                                        |   15 +
Makefile.target                                    |    5 +
configure                                          |  133 +-
tests/Makefile.include                             |   38 +-
tests/docker/Makefile.include                      |   47 +-
tests/docker/docker.py                             |  112 +-
tests/docker/dockerfiles/debian-alpha-cross.docker |   12 +
tests/docker/dockerfiles/debian-apt-fake.sh        |   46 -
tests/docker/dockerfiles/debian-hppa-cross.docker  |   12 +
tests/docker/dockerfiles/debian-m68k-cross.docker  |   12 +
.../docker/dockerfiles/debian-mips64-cross.docker  |   12 +
.../docker/dockerfiles/debian-powerpc-cross.docker |   39 +-
.../docker/dockerfiles/debian-riscv64-cross.docker |   12 +
tests/docker/dockerfiles/debian-sh4-cross.docker   |   12 +
tests/docker/dockerfiles/debian-sid.docker         |   32 +
.../docker/dockerfiles/debian-sparc64-cross.docker |   12 +
tests/docker/dockerfiles/debian8.docker            |    3 -
tests/tcg/Makefile                                 |  219 +-
tests/tcg/Makefile.include                         |   88 +
tests/tcg/Makefile.probe                           |   31 +
tests/tcg/README                                   |   69 +-
tests/tcg/aarch64/Makefile.include                 |    8 +
tests/tcg/aarch64/Makefile.target                  |   17 +
tests/tcg/aarch64/fcvt.ref                         | 3268 ++++++++++++++++++++
tests/tcg/alpha/Makefile                           |   35 -
tests/tcg/alpha/Makefile.include                   |    2 +
tests/tcg/alpha/Makefile.target                    |   18 +
tests/tcg/alpha/crt.s                              |   26 -
tests/tcg/alpha/hello-alpha.c                      |    2 +
tests/tcg/alpha/test-cond.c                        |    1 +
tests/tcg/alpha/test-ovf.c                         |    2 +
tests/tcg/arm/Makefile.include                     |    8 +
tests/tcg/arm/Makefile.target                      |   32 +
tests/tcg/arm/README                               |   11 +
tests/tcg/arm/fcvt.c                               |  458 +++
tests/tcg/arm/fcvt.ref                             | 3268 ++++++++++++++++++++
tests/tcg/{ => arm}/hello-arm.c                    |    0
.../{test-arm-iwmmxt.s => arm/test-arm-iwmmxt.S}   |    0
tests/tcg/hppa/Makefile.include                    |    2 +
tests/tcg/hppa/Makefile.target                     |    6 +
tests/tcg/i386/Makefile.include                    |    9 +
tests/tcg/i386/Makefile.target                     |   52 +
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             |   12 +-
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                   |    7 +-
tests/tcg/{ => i386}/test-i386.h                   |    0
tests/tcg/m68k/Makefile.include                    |    2 +
tests/tcg/m68k/Makefile.target                     |    7 +
tests/tcg/mips/Makefile.include                    |   20 +
tests/tcg/mips/Makefile.target                     |   22 +
tests/tcg/mips/README                              |    7 +
tests/tcg/{ => mips}/hello-mips.c                  |    0
tests/tcg/multiarch/Makefile.target                |   36 +
tests/tcg/multiarch/README                         |    1 +
tests/tcg/{ => multiarch}/linux-test.c             |  150 +-
tests/tcg/{ => multiarch}/sha1.c                   |    0
tests/tcg/{ => multiarch}/test-mmap.c              |   40 +-
tests/tcg/{ => multiarch}/testthread.c             |    0
tests/tcg/ppc/Makefile.include                     |    7 +
tests/tcg/ppc/Makefile.target                      |   12 +
tests/tcg/riscv/Makefile.include                   |   10 +
tests/tcg/s390x/Makefile.include                   |    2 +
tests/tcg/sh4/Makefile.include                     |    4 +
tests/tcg/sh4/Makefile.target                      |    7 +
tests/tcg/sparc64/Makefile.include                 |    2 +
tests/tcg/sparc64/Makefile.target                  |   11 +
tests/tcg/test_path.c                              |  157 -
tests/tcg/x86_64/Makefile.target                   |   15 +
77 files changed, 8136 insertions(+), 628 deletions(-)
create mode 100644 tests/docker/dockerfiles/debian-alpha-cross.docker
delete mode 100755 tests/docker/dockerfiles/debian-apt-fake.sh
create mode 100644 tests/docker/dockerfiles/debian-hppa-cross.docker
create mode 100644 tests/docker/dockerfiles/debian-m68k-cross.docker
create mode 100644 tests/docker/dockerfiles/debian-mips64-cross.docker
create mode 100644 tests/docker/dockerfiles/debian-riscv64-cross.docker
create mode 100644 tests/docker/dockerfiles/debian-sh4-cross.docker
create mode 100644 tests/docker/dockerfiles/debian-sid.docker
create mode 100644 tests/docker/dockerfiles/debian-sparc64-cross.docker
create mode 100644 tests/tcg/Makefile.include
create mode 100644 tests/tcg/Makefile.probe
create mode 100644 tests/tcg/aarch64/Makefile.include
create mode 100644 tests/tcg/aarch64/Makefile.target
create mode 100644 tests/tcg/aarch64/fcvt.ref
delete mode 100644 tests/tcg/alpha/Makefile
create mode 100644 tests/tcg/alpha/Makefile.include
create mode 100644 tests/tcg/alpha/Makefile.target
delete mode 100644 tests/tcg/alpha/crt.s
create mode 100644 tests/tcg/arm/Makefile.include
create mode 100644 tests/tcg/arm/Makefile.target
create mode 100644 tests/tcg/arm/README
create mode 100644 tests/tcg/arm/fcvt.c
create mode 100644 tests/tcg/arm/fcvt.ref
rename tests/tcg/{ => arm}/hello-arm.c (100%)
rename tests/tcg/{test-arm-iwmmxt.s => arm/test-arm-iwmmxt.S} (100%)
create mode 100644 tests/tcg/hppa/Makefile.include
create mode 100644 tests/tcg/hppa/Makefile.target
create mode 100644 tests/tcg/i386/Makefile.include
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 (97%)
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 (99%)
rename tests/tcg/{ => i386}/test-i386.h (100%)
create mode 100644 tests/tcg/m68k/Makefile.include
create mode 100644 tests/tcg/m68k/Makefile.target
create mode 100644 tests/tcg/mips/Makefile.include
create mode 100644 tests/tcg/mips/Makefile.target
create mode 100644 tests/tcg/mips/README
rename tests/tcg/{ => mips}/hello-mips.c (100%)
create mode 100644 tests/tcg/multiarch/Makefile.target
create mode 100644 tests/tcg/multiarch/README
rename tests/tcg/{ => multiarch}/linux-test.c (81%)
rename tests/tcg/{ => multiarch}/sha1.c (100%)
rename tests/tcg/{ => multiarch}/test-mmap.c (93%)
rename tests/tcg/{ => multiarch}/testthread.c (100%)
create mode 100644 tests/tcg/ppc/Makefile.include
create mode 100644 tests/tcg/ppc/Makefile.target
create mode 100644 tests/tcg/riscv/Makefile.include
create mode 100644 tests/tcg/s390x/Makefile.include
create mode 100644 tests/tcg/sh4/Makefile.include
create mode 100644 tests/tcg/sh4/Makefile.target
create mode 100644 tests/tcg/sparc64/Makefile.include
create mode 100644 tests/tcg/sparc64/Makefile.target
delete mode 100644 tests/tcg/test_path.c
create mode 100644 tests/tcg/x86_64/Makefile.target
[Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Alex Bennée 5 years, 10 months ago
The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:

  Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)

are available in the Git repository at:

  https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2

for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:

  .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)

----------------------------------------------------------------
Add check-tcg machinary

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

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

----------------------------------------------------------------
Alex Bennée (55):
      docker: docker.py wrap StringIO import for python3
      configure: add support for --cross-cc-FOO
      configure: move i386_cc to cross_cc_i386
      configure: allow user to specify --cross-cc-cflags-foo=
      configure: set cross_cc_FOO for host compiler
      docker: Add "cc" subcommand
      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/multiarch: enable additional linux-test tests
      tests/tcg/multiarch: don't hard code paths/ports for linux-test
      tests/tcg/multiarch: move most output to stdout
      tests/tcg: move i386 specific tests into subdir
      tests/tcg: enable building for i386
      tests/tcg/i386: fix test-i386
      tests/tcg/i386: add runner for test-i386-fprem
      tests/tcg/x86_64: add Makefile.target
      tests/tcg/i386/test-i386: use modern vector_size attributes
      tests/tcg/i386/test-i386: fix printf format
      tests/tcg: move ARM specific tests into subdir
      tests/tcg: enable building for ARM
      tests/tcg/arm: fix up test-arm-iwmmxt test
      tests/tcg: enable building for AArch64
      tests/tcg/arm: add fcvt test cases for AArch32/64
      tests/tcg: move MIPS specific tests into subdir
      tests/tcg: enable building for MIPS
      tests/docker/Makefile.include: fix mipsel-cross dependancy
      tests/tcg/mips: include common mips hello-mips
      tests/tcg: enable building for s390x
      tests/tcg: enable building for ppc64
      tests/tcg: enable building for Alpha
      tests/tcg/alpha: add Alpha specific tests
      tests/tcg: enable building for HPPA
      tests/tcg: enable building for m68k
      tests/tcg: enable building for sh4
      tests/tcg: enable building for sparc64
      tests/tcg: enable building for mips64
      tests/tcg: enable building for RISCV64
      docker: move debian-powerpc-cross to sid based build
      tests/tcg: enable building for PowerPC
      tests/tcg/Makefile: update to be called from Makefile.target
      Makefile.target: add (clean-/build-)guest-tests targets
      tests/Makefile.include: add [build|clean|check]-tcg targets
      tests/tcg: add run, diff, and skip helper macros
      tests/tcg: override runners for broken tests
      tests/tcg/i386: extend timeout for runcom test
      tests: add top-level make dependency for docker builds
      docker: docker.py use "version" to probe usage
      docker: docker.py don't conflate checksums for extra_files
      docker: docker.py add check sub-command
      tests/Makefile: call sub-makes with SKIP_DOCKER_BUILD=1
      docker: docker.py adding age check command
      tests/docker/Makefile.include: only force SID to NOCACHE if old
      .travis.yml: add check-tcg test

Fam Zheng (2):
      tests/tcg/multiarch: Build fix for linux-test
      tests/tcg/i386: Build fix for hello-i386

 .travis.yml                                        |    8 +
 MAINTAINERS                                        |   15 +
 Makefile.target                                    |    5 +
 configure                                          |  133 +-
 tests/Makefile.include                             |   38 +-
 tests/docker/Makefile.include                      |   47 +-
 tests/docker/docker.py                             |  112 +-
 tests/docker/dockerfiles/debian-alpha-cross.docker |   12 +
 tests/docker/dockerfiles/debian-apt-fake.sh        |   46 -
 tests/docker/dockerfiles/debian-hppa-cross.docker  |   12 +
 tests/docker/dockerfiles/debian-m68k-cross.docker  |   12 +
 .../docker/dockerfiles/debian-mips64-cross.docker  |   12 +
 .../docker/dockerfiles/debian-powerpc-cross.docker |   39 +-
 .../docker/dockerfiles/debian-riscv64-cross.docker |   12 +
 tests/docker/dockerfiles/debian-sh4-cross.docker   |   12 +
 tests/docker/dockerfiles/debian-sid.docker         |   32 +
 .../docker/dockerfiles/debian-sparc64-cross.docker |   12 +
 tests/docker/dockerfiles/debian8.docker            |    3 -
 tests/tcg/Makefile                                 |  219 +-
 tests/tcg/Makefile.include                         |   88 +
 tests/tcg/Makefile.probe                           |   31 +
 tests/tcg/README                                   |   69 +-
 tests/tcg/aarch64/Makefile.include                 |    8 +
 tests/tcg/aarch64/Makefile.target                  |   17 +
 tests/tcg/aarch64/fcvt.ref                         | 3268 ++++++++++++++++++++
 tests/tcg/alpha/Makefile                           |   35 -
 tests/tcg/alpha/Makefile.include                   |    2 +
 tests/tcg/alpha/Makefile.target                    |   18 +
 tests/tcg/alpha/crt.s                              |   26 -
 tests/tcg/alpha/hello-alpha.c                      |    2 +
 tests/tcg/alpha/test-cond.c                        |    1 +
 tests/tcg/alpha/test-ovf.c                         |    2 +
 tests/tcg/arm/Makefile.include                     |    8 +
 tests/tcg/arm/Makefile.target                      |   32 +
 tests/tcg/arm/README                               |   11 +
 tests/tcg/arm/fcvt.c                               |  458 +++
 tests/tcg/arm/fcvt.ref                             | 3268 ++++++++++++++++++++
 tests/tcg/{ => arm}/hello-arm.c                    |    0
 .../{test-arm-iwmmxt.s => arm/test-arm-iwmmxt.S}   |    0
 tests/tcg/hppa/Makefile.include                    |    2 +
 tests/tcg/hppa/Makefile.target                     |    6 +
 tests/tcg/i386/Makefile.include                    |    9 +
 tests/tcg/i386/Makefile.target                     |   52 +
 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             |   12 +-
 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                   |    7 +-
 tests/tcg/{ => i386}/test-i386.h                   |    0
 tests/tcg/m68k/Makefile.include                    |    2 +
 tests/tcg/m68k/Makefile.target                     |    7 +
 tests/tcg/mips/Makefile.include                    |   20 +
 tests/tcg/mips/Makefile.target                     |   22 +
 tests/tcg/mips/README                              |    7 +
 tests/tcg/{ => mips}/hello-mips.c                  |    0
 tests/tcg/multiarch/Makefile.target                |   36 +
 tests/tcg/multiarch/README                         |    1 +
 tests/tcg/{ => multiarch}/linux-test.c             |  150 +-
 tests/tcg/{ => multiarch}/sha1.c                   |    0
 tests/tcg/{ => multiarch}/test-mmap.c              |   40 +-
 tests/tcg/{ => multiarch}/testthread.c             |    0
 tests/tcg/ppc/Makefile.include                     |    7 +
 tests/tcg/ppc/Makefile.target                      |   12 +
 tests/tcg/riscv/Makefile.include                   |   10 +
 tests/tcg/s390x/Makefile.include                   |    2 +
 tests/tcg/sh4/Makefile.include                     |    4 +
 tests/tcg/sh4/Makefile.target                      |    7 +
 tests/tcg/sparc64/Makefile.include                 |    2 +
 tests/tcg/sparc64/Makefile.target                  |   11 +
 tests/tcg/test_path.c                              |  157 -
 tests/tcg/x86_64/Makefile.target                   |   15 +
 77 files changed, 8136 insertions(+), 628 deletions(-)
 create mode 100644 tests/docker/dockerfiles/debian-alpha-cross.docker
 delete mode 100755 tests/docker/dockerfiles/debian-apt-fake.sh
 create mode 100644 tests/docker/dockerfiles/debian-hppa-cross.docker
 create mode 100644 tests/docker/dockerfiles/debian-m68k-cross.docker
 create mode 100644 tests/docker/dockerfiles/debian-mips64-cross.docker
 create mode 100644 tests/docker/dockerfiles/debian-riscv64-cross.docker
 create mode 100644 tests/docker/dockerfiles/debian-sh4-cross.docker
 create mode 100644 tests/docker/dockerfiles/debian-sid.docker
 create mode 100644 tests/docker/dockerfiles/debian-sparc64-cross.docker
 create mode 100644 tests/tcg/Makefile.include
 create mode 100644 tests/tcg/Makefile.probe
 create mode 100644 tests/tcg/aarch64/Makefile.include
 create mode 100644 tests/tcg/aarch64/Makefile.target
 create mode 100644 tests/tcg/aarch64/fcvt.ref
 delete mode 100644 tests/tcg/alpha/Makefile
 create mode 100644 tests/tcg/alpha/Makefile.include
 create mode 100644 tests/tcg/alpha/Makefile.target
 delete mode 100644 tests/tcg/alpha/crt.s
 create mode 100644 tests/tcg/arm/Makefile.include
 create mode 100644 tests/tcg/arm/Makefile.target
 create mode 100644 tests/tcg/arm/README
 create mode 100644 tests/tcg/arm/fcvt.c
 create mode 100644 tests/tcg/arm/fcvt.ref
 rename tests/tcg/{ => arm}/hello-arm.c (100%)
 rename tests/tcg/{test-arm-iwmmxt.s => arm/test-arm-iwmmxt.S} (100%)
 create mode 100644 tests/tcg/hppa/Makefile.include
 create mode 100644 tests/tcg/hppa/Makefile.target
 create mode 100644 tests/tcg/i386/Makefile.include
 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 (97%)
 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 (99%)
 rename tests/tcg/{ => i386}/test-i386.h (100%)
 create mode 100644 tests/tcg/m68k/Makefile.include
 create mode 100644 tests/tcg/m68k/Makefile.target
 create mode 100644 tests/tcg/mips/Makefile.include
 create mode 100644 tests/tcg/mips/Makefile.target
 create mode 100644 tests/tcg/mips/README
 rename tests/tcg/{ => mips}/hello-mips.c (100%)
 create mode 100644 tests/tcg/multiarch/Makefile.target
 create mode 100644 tests/tcg/multiarch/README
 rename tests/tcg/{ => multiarch}/linux-test.c (81%)
 rename tests/tcg/{ => multiarch}/sha1.c (100%)
 rename tests/tcg/{ => multiarch}/test-mmap.c (93%)
 rename tests/tcg/{ => multiarch}/testthread.c (100%)
 create mode 100644 tests/tcg/ppc/Makefile.include
 create mode 100644 tests/tcg/ppc/Makefile.target
 create mode 100644 tests/tcg/riscv/Makefile.include
 create mode 100644 tests/tcg/s390x/Makefile.include
 create mode 100644 tests/tcg/sh4/Makefile.include
 create mode 100644 tests/tcg/sh4/Makefile.target
 create mode 100644 tests/tcg/sparc64/Makefile.include
 create mode 100644 tests/tcg/sparc64/Makefile.target
 delete mode 100644 tests/tcg/test_path.c
 create mode 100644 tests/tcg/x86_64/Makefile.target

--
2.17.1


Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Peter Maydell 5 years, 10 months ago
On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>
>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>
> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>
>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>
> ----------------------------------------------------------------
> Add check-tcg machinary
>
> This restores the ability to run TCG smoke tests by using our docker
> infrastructure to support cross building simple tests. It represents
> the first step to making better cross-architecture testing available
> straight from the source tree ;-)
>
> v2
>   - fix quoting of target_compiler
>   - make docker.py Py3 safe
>   - tweak .travis.yml recipe
>   - don't probe docker when HAVE_USER_DOCKER not set

Weird build failure for linux/x86:

make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
Makefile:90: rules.mak: No such file or directory
Makefile:439: tests/Makefile.include: No such file or directory
cat: VERSION: No such file or directory
Makefile:1056: tests/docker/Makefile.include: No such file or directory
Makefile:1057: tests/vm/Makefile.include: No such file or directory
make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.

like it's failed to figure out the source directory.

This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
build, and it's also the one I do a 'make clean' on -- perhaps
build from clean has broken?

thanks
-- PMM

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Alex Bennée 5 years, 10 months ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
>> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>>
>>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>>
>> are available in the Git repository at:
>>
>>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>>
>> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>>
>>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>>
>> ----------------------------------------------------------------
>> Add check-tcg machinary
>>
>> This restores the ability to run TCG smoke tests by using our docker
>> infrastructure to support cross building simple tests. It represents
>> the first step to making better cross-architecture testing available
>> straight from the source tree ;-)
>>
>> v2
>>   - fix quoting of target_compiler
>>   - make docker.py Py3 safe
>>   - tweak .travis.yml recipe
>>   - don't probe docker when HAVE_USER_DOCKER not set
>
> Weird build failure for linux/x86:
>
> make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
> Makefile:90: rules.mak: No such file or directory
> Makefile:439: tests/Makefile.include: No such file or directory
> cat: VERSION: No such file or directory
> Makefile:1056: tests/docker/Makefile.include: No such file or directory
> Makefile:1057: tests/vm/Makefile.include: No such file or directory
> make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
> make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.
>
> like it's failed to figure out the source directory.
>
> This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
> build, and it's also the one I do a 'make clean' on -- perhaps
> build from clean has broken?

And you called a plain make to build it?

Let me see if I can reproduce.

>
> thanks
> -- PMM


--
Alex Bennée

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Alex Bennée 5 years, 10 months ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
>> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>>
>>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>>
>> are available in the Git repository at:
>>
>>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>>
>> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>>
>>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>>
>> ----------------------------------------------------------------
>> Add check-tcg machinary
>>
>> This restores the ability to run TCG smoke tests by using our docker
>> infrastructure to support cross building simple tests. It represents
>> the first step to making better cross-architecture testing available
>> straight from the source tree ;-)
>>
>> v2
>>   - fix quoting of target_compiler
>>   - make docker.py Py3 safe
>>   - tweak .travis.yml recipe
>>   - don't probe docker when HAVE_USER_DOCKER not set
>
> Weird build failure for linux/x86:
>
> make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
> Makefile:90: rules.mak: No such file or directory
> Makefile:439: tests/Makefile.include: No such file or directory
> cat: VERSION: No such file or directory
> Makefile:1056: tests/docker/Makefile.include: No such file or directory
> Makefile:1057: tests/vm/Makefile.include: No such file or directory
> make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
> make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.
>
> like it's failed to figure out the source directory.
>
> This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
> build, and it's also the one I do a 'make clean' on -- perhaps
> build from clean has broken?

Hmm I can't reproduce this. I've built a fresh 16.04 server image with
and with:

  # Configured with: './configure' '--cc=ccache gcc' '--enable-debug' '--python=python3'

both:
  make

and:
  make check-tcg

Work for me :-/

>
> thanks
> -- PMM


--
Alex Bennée

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Philippe Mathieu-Daudé 5 years, 10 months ago
Hi Alex,

On 06/21/2018 11:48 AM, Alex Bennée wrote:
> 
> Peter Maydell <peter.maydell@linaro.org> writes:
> 
>> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
>>> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>>>
>>>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>>>
>>> are available in the Git repository at:
>>>
>>>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>>>
>>> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>>>
>>>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>>>
>>> ----------------------------------------------------------------
>>> Add check-tcg machinary
>>>
>>> This restores the ability to run TCG smoke tests by using our docker
>>> infrastructure to support cross building simple tests. It represents
>>> the first step to making better cross-architecture testing available
>>> straight from the source tree ;-)
>>>
>>> v2
>>>   - fix quoting of target_compiler
>>>   - make docker.py Py3 safe
>>>   - tweak .travis.yml recipe
>>>   - don't probe docker when HAVE_USER_DOCKER not set
>>
>> Weird build failure for linux/x86:
>>
>> make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
>> Makefile:90: rules.mak: No such file or directory
>> Makefile:439: tests/Makefile.include: No such file or directory
>> cat: VERSION: No such file or directory
>> Makefile:1056: tests/docker/Makefile.include: No such file or directory
>> Makefile:1057: tests/vm/Makefile.include: No such file or directory
>> make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
>> make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.
>>
>> like it's failed to figure out the source directory.
>>
>> This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
>> build, and it's also the one I do a 'make clean' on -- perhaps
>> build from clean has broken?
> 
> Hmm I can't reproduce this. I've built a fresh 16.04 server image with
> and with:
> 
>   # Configured with: './configure' '--cc=ccache gcc' '--enable-debug' '--python=python3'
> 
> both:
>   make
> 
> and:
>   make check-tcg
> 
> Work for me :-/

Did you try rebuilding after a 'make clean'?

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Alex Bennée 5 years, 10 months ago
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Alex,
>
> On 06/21/2018 11:48 AM, Alex Bennée wrote:
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>>> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
>>>> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>>>>
>>>>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>>>>
>>>> are available in the Git repository at:
>>>>
>>>>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>>>>
>>>> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>>>>
>>>>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>>>>
>>>> ----------------------------------------------------------------
>>>> Add check-tcg machinary
>>>>
>>>> This restores the ability to run TCG smoke tests by using our docker
>>>> infrastructure to support cross building simple tests. It represents
>>>> the first step to making better cross-architecture testing available
>>>> straight from the source tree ;-)
>>>>
>>>> v2
>>>>   - fix quoting of target_compiler
>>>>   - make docker.py Py3 safe
>>>>   - tweak .travis.yml recipe
>>>>   - don't probe docker when HAVE_USER_DOCKER not set
>>>
>>> Weird build failure for linux/x86:
>>>
>>> make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
>>> Makefile:90: rules.mak: No such file or directory
>>> Makefile:439: tests/Makefile.include: No such file or directory
>>> cat: VERSION: No such file or directory
>>> Makefile:1056: tests/docker/Makefile.include: No such file or directory
>>> Makefile:1057: tests/vm/Makefile.include: No such file or directory
>>> make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
>>> make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.
>>>
>>> like it's failed to figure out the source directory.
>>>
>>> This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
>>> build, and it's also the one I do a 'make clean' on -- perhaps
>>> build from clean has broken?
>>
>> Hmm I can't reproduce this. I've built a fresh 16.04 server image with
>> and with:
>>
>>   # Configured with: './configure' '--cc=ccache gcc' '--enable-debug' '--python=python3'
>>
>> both:
>>   make
>>
>> and:
>>   make check-tcg
>>
>> Work for me :-/
>
> Did you try rebuilding after a 'make clean'?

Yep, both make clean, configure, make and make clean, make


--
Alex Bennée

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Philippe Mathieu-Daudé 5 years, 10 months ago
On 06/21/2018 12:12 PM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> 
>> Hi Alex,
>>
>> On 06/21/2018 11:48 AM, Alex Bennée wrote:
>>>
>>> Peter Maydell <peter.maydell@linaro.org> writes:
>>>
>>>> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
>>>>> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>>>>>
>>>>>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>>>>>
>>>>> are available in the Git repository at:
>>>>>
>>>>>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>>>>>
>>>>> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>>>>>
>>>>>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>>>>>
>>>>> ----------------------------------------------------------------
>>>>> Add check-tcg machinary
>>>>>
>>>>> This restores the ability to run TCG smoke tests by using our docker
>>>>> infrastructure to support cross building simple tests. It represents
>>>>> the first step to making better cross-architecture testing available
>>>>> straight from the source tree ;-)
>>>>>
>>>>> v2
>>>>>   - fix quoting of target_compiler
>>>>>   - make docker.py Py3 safe
>>>>>   - tweak .travis.yml recipe
>>>>>   - don't probe docker when HAVE_USER_DOCKER not set
>>>>
>>>> Weird build failure for linux/x86:
>>>>
>>>> make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'

This looks like an out-of-tree build.
I suppose SRC_PATH=.../qemu-for-merges/

>>>> Makefile:90: rules.mak: No such file or directory
>>>> Makefile:439: tests/Makefile.include: No such file or directory
>>>> cat: VERSION: No such file or directory
>>>> Makefile:1056: tests/docker/Makefile.include: No such file or directory
>>>> Makefile:1057: tests/vm/Makefile.include: No such file or directory
>>>> make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
>>>> make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.
>>>>
>>>> like it's failed to figure out the source directory.
>>>>
>>>> This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
>>>> build, and it's also the one I do a 'make clean' on -- perhaps
>>>> build from clean has broken?
>>>
>>> Hmm I can't reproduce this. I've built a fresh 16.04 server image with
>>> and with:
>>>
>>>   # Configured with: './configure' '--cc=ccache gcc' '--enable-debug' '--python=python3'
>>>
>>> both:
>>>   make
>>>
>>> and:
>>>   make check-tcg
>>>
>>> Work for me :-/
>>
>> Did you try rebuilding after a 'make clean'?
> 
> Yep, both make clean, configure, make and make clean, make

I can not reproduce neither using out-of-tree build with
../../configure '--cc=ccache gcc' '--enable-debug' '--python=python3'

I'll now test:

$ git checkout master
$ make clean
$ git checkout pull-tcg-testing-revivial-210618-2
$ make check-tcg

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Philippe Mathieu-Daudé 5 years, 10 months ago
On 06/21/2018 01:04 PM, Philippe Mathieu-Daudé wrote:
> On 06/21/2018 12:12 PM, Alex Bennée wrote:
>>
>> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
>>
>>> Hi Alex,
>>>
>>> On 06/21/2018 11:48 AM, Alex Bennée wrote:
>>>>
>>>> Peter Maydell <peter.maydell@linaro.org> writes:
>>>>
>>>>> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
>>>>>> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>>>>>>
>>>>>>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>>>>>>
>>>>>> are available in the Git repository at:
>>>>>>
>>>>>>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>>>>>>
>>>>>> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>>>>>>
>>>>>>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>>>>>>
>>>>>> ----------------------------------------------------------------
>>>>>> Add check-tcg machinary
>>>>>>
>>>>>> This restores the ability to run TCG smoke tests by using our docker
>>>>>> infrastructure to support cross building simple tests. It represents
>>>>>> the first step to making better cross-architecture testing available
>>>>>> straight from the source tree ;-)
>>>>>>
>>>>>> v2
>>>>>>   - fix quoting of target_compiler
>>>>>>   - make docker.py Py3 safe
>>>>>>   - tweak .travis.yml recipe
>>>>>>   - don't probe docker when HAVE_USER_DOCKER not set
>>>>>
>>>>> Weird build failure for linux/x86:
>>>>>
>>>>> make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
> 
> This looks like an out-of-tree build.
> I suppose SRC_PATH=.../qemu-for-merges/
> 
>>>>> Makefile:90: rules.mak: No such file or directory
>>>>> Makefile:439: tests/Makefile.include: No such file or directory
>>>>> cat: VERSION: No such file or directory
>>>>> Makefile:1056: tests/docker/Makefile.include: No such file or directory
>>>>> Makefile:1057: tests/vm/Makefile.include: No such file or directory
>>>>> make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/alldbg'
>>>>> make: *** No rule to make target 'tests/vm/Makefile.include'. Stop.
>>>>>
>>>>> like it's failed to figure out the source directory.
>>>>>
>>>>> This is my '--cc=ccache gcc' '--enable-debug' '--python=python3'
>>>>> build, and it's also the one I do a 'make clean' on -- perhaps
>>>>> build from clean has broken?
>>>>
>>>> Hmm I can't reproduce this. I've built a fresh 16.04 server image with
>>>> and with:
>>>>
>>>>   # Configured with: './configure' '--cc=ccache gcc' '--enable-debug' '--python=python3'
>>>>
>>>> both:
>>>>   make
>>>>
>>>> and:
>>>>   make check-tcg
>>>>
>>>> Work for me :-/
>>>
>>> Did you try rebuilding after a 'make clean'?
>>
>> Yep, both make clean, configure, make and make clean, make
> 
> I can not reproduce neither using out-of-tree build with
> ../../configure '--cc=ccache gcc' '--enable-debug' '--python=python3'
> 
> I'll now test:
> 
> $ git checkout master

$ make

> $ make clean
> $ git checkout pull-tcg-testing-revivial-210618-2
> $ make check-tcg

This worked ('clean' in previous branch).

I also tested 'clean' in new branch:

$ git checkout master
$ make
$ git checkout pull-tcg-testing-revivial-210618-2
$ make clean
$ make check-tcg

Eventually the previous branch was not 'master' but the last pull
request Peter tested, and the problem would be there or between this
branch and yours.

Re: [Qemu-devel] [PULL v2 00/57] add check-tcg and associated machinery
Posted by Peter Maydell 5 years, 10 months ago
On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
> The following changes since commit 46012db666990ff2eed1d3dc199ab8006439a93b:
>
>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180619' into staging (2018-06-20 09:51:30 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/stsquad/qemu.git tags/pull-tcg-testing-revivial-210618-2
>
> for you to fetch changes up to 65b26da485540ffcc1c46c9a0898f01912ee6b7a:
>
>   .travis.yml: add check-tcg test (2018-06-20 22:13:39 +0100)
>
> ----------------------------------------------------------------
> Add check-tcg machinary
>
> This restores the ability to run TCG smoke tests by using our docker
> infrastructure to support cross building simple tests. It represents
> the first step to making better cross-architecture testing available
> straight from the source tree ;-)
>
> v2
>   - fix quoting of target_compiler
>   - make docker.py Py3 safe
>   - tweak .travis.yml recipe
>   - don't probe docker when HAVE_USER_DOCKER not set
>
Applied, thanks.

-- PMM

[Qemu-devel] [PULL v2 01/57] docker: docker.py wrap StringIO import for python3
Posted by Alex Bennée 5 years, 10 months ago
Although the docker.py is nominally python2 we actually invoke it with
the configured python from the configure script.

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

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 306e14cf69..e4095270eb 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -26,7 +26,10 @@ import tempfile
 import re
 import signal
 from tarfile import TarFile, TarInfo
-from StringIO import StringIO
+try:
+    from StringIO import StringIO
+except ImportError:
+    from io import StringIO
 from shutil import copy, rmtree
 from pwd import getpwuid
 
-- 
2.17.1


Re: [Qemu-devel] [PULL v2 01/57] docker: docker.py wrap StringIO import for python3
Posted by Peter Maydell 5 years, 10 months ago
On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
> Although the docker.py is nominally python2 we actually invoke it with
> the configured python from the configure script.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 306e14cf69..e4095270eb 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -26,7 +26,10 @@ import tempfile
>  import re
>  import signal
>  from tarfile import TarFile, TarInfo
> -from StringIO import StringIO
> +try:
> +    from StringIO import StringIO
> +except ImportError:
> +    from io import StringIO
>  from shutil import copy, rmtree
>  from pwd import getpwuid

This is fairly trivial, but it is a new unreviewed patch:
would one of the python experts like to review it ?

thanks
-- PMM

Re: [Qemu-devel] [PULL v2 01/57] docker: docker.py wrap StringIO import for python3
Posted by Daniel P. Berrangé 5 years, 10 months ago
On Thu, Jun 21, 2018 at 09:49:55AM +0100, Peter Maydell wrote:
> On 21 June 2018 at 07:25, Alex Bennée <alex.bennee@linaro.org> wrote:
> > Although the docker.py is nominally python2 we actually invoke it with
> > the configured python from the configure script.
> >
> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> >
> > diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> > index 306e14cf69..e4095270eb 100755
> > --- a/tests/docker/docker.py
> > +++ b/tests/docker/docker.py
> > @@ -26,7 +26,10 @@ import tempfile
> >  import re
> >  import signal
> >  from tarfile import TarFile, TarInfo
> > -from StringIO import StringIO
> > +try:
> > +    from StringIO import StringIO
> > +except ImportError:
> > +    from io import StringIO
> >  from shutil import copy, rmtree
> >  from pwd import getpwuid
> 
> This is fairly trivial, but it is a new unreviewed patch:
> would one of the python experts like to review it ?

Yes, this is the normal fix for this particular scenario.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

[Qemu-devel] [PULL v2 02/57] configure: add support for --cross-cc-FOO
Posted by Alex Bennée 5 years, 10 months ago
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. This is quoted to handle the case
of --cc="ccache gcc".

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/configure b/configure
index a5fd46c9d4..ab189067cb 100755
--- a/configure
+++ b/configure
@@ -458,6 +458,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"
@@ -488,6 +495,11 @@ for opt do
   ;;
   --disable-debug-info) debug_info="no"
   ;;
+  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
+  ;;
+  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
+                eval "cross_cc_${cc_arch}=\$optarg"
+  ;;
   esac
 done
 # OS specific
@@ -676,30 +688,37 @@ case "$cpu" in
   ppc|ppc64|s390|s390x|sparc64|x32)
     cpu="$cpu"
     supported_cpu="yes"
+    eval "cross_cc_${cpu}=\$host_cc"
   ;;
   i386|i486|i586|i686|i86pc|BePC)
     cpu="i386"
     supported_cpu="yes"
+    cross_cc_i386=$host_cc
   ;;
   x86_64|amd64)
     cpu="x86_64"
     supported_cpu="yes"
+    cross_cc_x86_64=$host_cc
   ;;
   armv*b|armv*l|arm)
     cpu="arm"
     supported_cpu="yes"
+    cross_cc_arm=$host_cc
   ;;
   aarch64)
     cpu="aarch64"
     supported_cpu="yes"
+    cross_cc_aarch64=$host_cc
   ;;
   mips*)
     cpu="mips"
     supported_cpu="yes"
+    cross_cc_mips=$host_cc
   ;;
   sparc|sun4[cdmuv])
     cpu="sparc"
     supported_cpu="yes"
+    cross_cc_sparc=$host_cc
   ;;
   *)
     # This will result in either an error or falling back to TCI later
@@ -917,6 +936,8 @@ for opt do
   ;;
   --disable-debug-info)
   ;;
+  --cross-cc-*)
+  ;;
   --enable-modules)
       modules="yes"
   ;;
@@ -1501,6 +1522,7 @@ Advanced options (experts only):
   --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
   --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
   --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
+  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
   --make=MAKE              use specified make [$make]
   --install=INSTALL        use specified install [$install]
   --python=PYTHON          use specified python [$python]
@@ -6821,6 +6843,9 @@ case "$target" in
     ;;
 esac
 
+target_compiler=""
+target_compiler_static=""
+
 mkdir -p $target_dir
 echo "# Automatically generated by configure - do not modify" > $config_target_mak
 
@@ -6836,19 +6861,23 @@ 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
   ;;
   x86_64)
     TARGET_BASE_ARCH=i386
     gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
+    target_compiler=$cross_cc_x86_64
   ;;
   alpha)
     mttcg="yes"
+    target_compiler=$cross_cc_alpha
   ;;
   arm|armeb)
     TARGET_ARCH=arm
     bflt="yes"
     mttcg="yes"
     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
+    target_compiler=$cross_cc_arm
   ;;
   aarch64|aarch64_be)
     TARGET_ARCH=aarch64
@@ -6856,59 +6885,74 @@ 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)
+    target_compiler=$cross_cc_cris
   ;;
   hppa)
     mttcg="yes"
+    target_compiler=$cross_cc_hppa
   ;;
   lm32)
+    target_compiler=$cross_cc_lm32
   ;;
   m68k)
     bflt="yes"
     gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
+    target_compiler=$cross_cc_m68k
   ;;
   microblaze|microblazeel)
     TARGET_ARCH=microblaze
     bflt="yes"
     echo "TARGET_ABI32=y" >> $config_target_mak
+    target_compiler=$cross_cc_microblaze
   ;;
   mips|mipsel)
     TARGET_ARCH=mips
+    target_compiler=$cross_cc_mips
     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
   ;;
   mipsn32|mipsn32el)
     TARGET_ARCH=mips64
     TARGET_BASE_ARCH=mips
+    target_compiler=$cross_cc_mipsn32
     echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
     echo "TARGET_ABI32=y" >> $config_target_mak
   ;;
   mips64|mips64el)
     TARGET_ARCH=mips64
     TARGET_BASE_ARCH=mips
+    target_compiler=$cross_cc_mips64
     echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
   ;;
   moxie)
+    target_compiler=$cross_cc_moxie
   ;;
   nios2)
+    target_compiler=$cross_cc_nios2
   ;;
   or1k)
+    target_compiler=$cross_cc_or1k
     TARGET_ARCH=openrisc
     TARGET_BASE_ARCH=openrisc
   ;;
   ppc)
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
+    target_compiler=$cross_cc_powerpc
   ;;
   ppcemb)
     TARGET_BASE_ARCH=ppc
     TARGET_ABI_DIR=ppc
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
+    target_compiler=$cross_cc_ppcemb
   ;;
   ppc64)
     TARGET_BASE_ARCH=ppc
     TARGET_ABI_DIR=ppc
     mttcg=yes
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
+    target_compiler=$cross_cc_ppc64
   ;;
   ppc64le)
     TARGET_ARCH=ppc64
@@ -6916,6 +6960,7 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     mttcg=yes
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
+    target_compiler=$cross_cc_ppc64le
   ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
@@ -6923,45 +6968,57 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     echo "TARGET_ABI32=y" >> $config_target_mak
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
+    target_compiler=$cross_cc_ppc64abi32
   ;;
   riscv32)
     TARGET_BASE_ARCH=riscv
     TARGET_ABI_DIR=riscv
     mttcg=yes
+    target_compiler=$cross_cc_riscv32
   ;;
   riscv64)
     TARGET_BASE_ARCH=riscv
     TARGET_ABI_DIR=riscv
     mttcg=yes
+    target_compiler=$cross_cc_riscv64
   ;;
   sh4|sh4eb)
     TARGET_ARCH=sh4
     bflt="yes"
+    target_compiler=$cross_cc_sh4
   ;;
   sparc)
+    target_compiler=$cross_cc_sparc
   ;;
   sparc64)
     TARGET_BASE_ARCH=sparc
+    target_compiler=$cross_cc_sparc64
   ;;
   sparc32plus)
     TARGET_ARCH=sparc64
     TARGET_BASE_ARCH=sparc
     TARGET_ABI_DIR=sparc
+    target_compiler=$cross_cc_sparc32plus
     echo "TARGET_ABI32=y" >> $config_target_mak
   ;;
   s390x)
     mttcg=yes
     gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
+    target_compiler=$cross_cc_s390x
   ;;
   tilegx)
+    target_compiler=$cross_cc_tilegx
   ;;
   tricore)
+    target_compiler=$cross_cc_tricore
   ;;
   unicore32)
+    target_compiler=$cross_cc_unicore32
   ;;
   xtensa|xtensaeb)
     TARGET_ARCH=xtensa
     mttcg="yes"
+    target_compiler=$cross_cc_xtensa
   ;;
   *)
     error_exit "Unsupported target CPU"
@@ -6972,6 +7029,27 @@ if [ "$TARGET_BASE_ARCH" = "" ]; then
   TARGET_BASE_ARCH=$TARGET_ARCH
 fi
 
+# Do we have a cross compiler for this target?
+if has $target_compiler; then
+
+    write_c_skeleton
+
+    if ! do_compiler "$target_compiler" -o $TMPE $TMPC -static ; then
+        # For host systems we might get away with building without -static
+        if ! do_compiler "$target_compiler" -o $TMPE $TMPC ; then
+            target_compiler=""
+        else
+            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
+            target_compiler_static="n"
+        fi
+    else
+        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
+        target_compiler_static="y"
+    fi
+else
+    target_compiler=""
+fi
+
 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
 
 upper() {
@@ -7045,6 +7123,14 @@ if test "$target_bsd_user" = "yes" ; then
   echo "CONFIG_BSD_USER=y" >> $config_target_mak
 fi
 
+if test -n "$target_compiler"; then
+  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
+
+  if test -n "$target_compiler_static"; then
+      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
+  fi
+fi
+
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
 cflags=""
@@ -7167,6 +7253,11 @@ echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
 
 done # for target in $targets
 
+if test -n "$enabled_cross_compilers"; then
+    echo
+    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
+fi
+
 if [ "$fdt" = "git" ]; then
   echo "config-host.h: subdir-dtc" >> $config_host_mak
 fi
-- 
2.17.1


Re: [Qemu-devel] [PULL v2 02/57] configure: add support for --cross-cc-FOO
Posted by Peter Maydell 4 years, 8 months ago
On Thu, 21 Jun 2018 at 07:26, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> This allows us to specify cross compilers for our guests. This is
> useful for building test images/programs. Currently we re-run the
> compile test for each target. I couldn't think of a way to cache the
> value for a given arch without getting messier configure code.
>
> The cross compiler for the guest is visible to each target as
> CROSS_CC_GUEST in config-target.mak. This is quoted to handle the case
> of --cc="ccache gcc".
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Hi -- this is an old commit from last year, but I've just noticed
(by code inspection) a bug in it:

> diff --git a/configure b/configure
> index a5fd46c9d4..ab189067cb 100755
> --- a/configure
> +++ b/configure
> @@ -458,6 +458,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"
> @@ -488,6 +495,11 @@ for opt do
>    ;;
>    --disable-debug-info) debug_info="no"
>    ;;
> +  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
> +  ;;
> +  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
> +                eval "cross_cc_${cc_arch}=\$optarg"
> +  ;;
>    esac
>  done
>  # OS specific
> @@ -676,30 +688,37 @@ case "$cpu" in
>    ppc|ppc64|s390|s390x|sparc64|x32)
>      cpu="$cpu"
>      supported_cpu="yes"
> +    eval "cross_cc_${cpu}=\$host_cc"
>    ;;
>    i386|i486|i586|i686|i86pc|BePC)
>      cpu="i386"
>      supported_cpu="yes"
> +    cross_cc_i386=$host_cc
>    ;;

In the various arms of this switch, we use $host_cc.
Unfortunately, we don't process the --host-cc= option
until further down in the script, so this will only ever use
the default ("cc") even if the user tries to override it on
the configure command line. For this to work we need to
pull the handling of --host-cc= up into the "parse CC options
first" option handling code.

thanks
-- PMM

[Qemu-devel] [PULL v2 03/57] configure: move i386_cc to cross_cc_i386
Posted by Alex Bennée 5 years, 10 months ago
Also dont assume x86_64 compiler can build i386 binaries.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/configure b/configure
index ab189067cb..a5676cf15f 100755
--- a/configure
+++ b/configure
@@ -289,7 +289,6 @@ libs_softmmu=""
 libs_tools=""
 audio_pt_int=""
 audio_win_int=""
-cc_i386=i386-pc-linux-gnu-gcc
 libs_qga=""
 debug_info="yes"
 stack_protector=""
@@ -461,6 +460,8 @@ 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_i386="i386-pc-linux-gnu-gcc"
+cross_cc_cflags_i386=""
 cross_cc_powerpc="powerpc-linux-gnu-gcc"
 
 enabled_cross_compilers=""
@@ -1447,7 +1448,8 @@ case "$cpu" in
     i386)
            CPU_CFLAGS="-m32"
            LDFLAGS="-m32 $LDFLAGS"
-           cc_i386='$(CC) -m32'
+           cross_cc_i386=$cc
+           cross_cc_cflags_i386=$CPU_CFLAGS
            ;;
     x86_64)
            # ??? Only extremely old AMD cpus do not have cmpxchg16b.
@@ -1455,12 +1457,14 @@ case "$cpu" in
            # runtime and generate the fallback to serial emulation.
            CPU_CFLAGS="-m64 -mcx16"
            LDFLAGS="-m64 $LDFLAGS"
-           cc_i386='$(CC) -m32'
+           cross_cc_x86_64=$cc
+           cross_cc_cflags_x86_64=$CPU_CFLAGS
            ;;
     x32)
            CPU_CFLAGS="-mx32"
            LDFLAGS="-mx32 $LDFLAGS"
-           cc_i386='$(CC) -m32'
+           cross_cc_i386=$cc
+           cross_cc_cflags_i386="-m32"
            ;;
     # No special flags required for other host CPUs
 esac
@@ -6724,7 +6728,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
@@ -6845,6 +6848,7 @@ esac
 
 target_compiler=""
 target_compiler_static=""
+target_compiler_cflags=""
 
 mkdir -p $target_dir
 echo "# Automatically generated by configure - do not modify" > $config_target_mak
@@ -6862,6 +6866,7 @@ case "$target_name" in
   i386)
     gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
     target_compiler=$cross_cc_i386
+    target_compiler_cflags=$cross_cc_ccflags_i386
   ;;
   x86_64)
     TARGET_BASE_ARCH=i386
@@ -7034,9 +7039,9 @@ if has $target_compiler; then
 
     write_c_skeleton
 
-    if ! do_compiler "$target_compiler" -o $TMPE $TMPC -static ; then
+    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
         # For host systems we might get away with building without -static
-        if ! do_compiler "$target_compiler" -o $TMPE $TMPC ; then
+        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
             target_compiler=""
         else
             enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
@@ -7129,8 +7134,13 @@ if test -n "$target_compiler"; then
   if test -n "$target_compiler_static"; then
       echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
   fi
+
+  if test -n "$target_compiler_cflags"; then
+      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
+  fi
 fi
 
+
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
 cflags=""
-- 
2.17.1


[Qemu-devel] [PULL v2 04/57] configure: allow user to specify --cross-cc-cflags-foo=
Posted by Alex Bennée 5 years, 10 months ago
As an individual compiler may be able to support several targets with
the appropriate flags we need to expose this to the user as well.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/configure b/configure
index a5676cf15f..259938e177 100755
--- a/configure
+++ b/configure
@@ -459,10 +459,14 @@ docker="no"
 
 # cross compilers defaults, can be overridden with --cross-cc-ARCH
 cross_cc_aarch64="aarch64-linux-gnu-gcc"
+cross_cc_aarch64_be="$cross_cc_aarch64"
+cross_cc_cflags_aarch64_be="-mbig-endian"
 cross_cc_arm="arm-linux-gnueabihf-gcc"
+cross_cc_cflags_armeb="-mbig-endian"
 cross_cc_i386="i386-pc-linux-gnu-gcc"
 cross_cc_cflags_i386=""
 cross_cc_powerpc="powerpc-linux-gnu-gcc"
+cross_cc_powerpc="powerpc-linux-gnu-gcc"
 
 enabled_cross_compilers=""
 
@@ -498,6 +502,9 @@ for opt do
   ;;
   --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
   ;;
+  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
+                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
+  ;;
   --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
                 eval "cross_cc_${cc_arch}=\$optarg"
   ;;
@@ -1527,6 +1534,7 @@ Advanced options (experts only):
   --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
   --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
   --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
+  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
   --make=MAKE              use specified make [$make]
   --install=INSTALL        use specified install [$install]
   --python=PYTHON          use specified python [$python]
@@ -6883,6 +6891,7 @@ case "$target_name" in
     mttcg="yes"
     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
     target_compiler=$cross_cc_arm
+    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
   ;;
   aarch64|aarch64_be)
     TARGET_ARCH=aarch64
@@ -6891,6 +6900,7 @@ case "$target_name" in
     mttcg="yes"
     gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
     target_compiler=$cross_cc_aarch64
+    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
   ;;
   cris)
     target_compiler=$cross_cc_cris
-- 
2.17.1


[Qemu-devel] [PULL v2 05/57] configure: set cross_cc_FOO for host compiler
Posted by Alex Bennée 5 years, 10 months ago
We can build tests for the host system with the compiler that we have
selected.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/configure b/configure
index 259938e177..4d12cfbe3f 100755
--- a/configure
+++ b/configure
@@ -1431,26 +1431,38 @@ case "$cpu" in
     ppc)
            CPU_CFLAGS="-m32"
            LDFLAGS="-m32 $LDFLAGS"
+           cross_cc_powerpc=$cc
+           cross_cc_cflags_powerpc=$CPU_CFLAGS
            ;;
     ppc64)
            CPU_CFLAGS="-m64"
            LDFLAGS="-m64 $LDFLAGS"
+           cross_cc_ppc64=$cc
+           cross_cc_cflags_ppc64=$CPU_CFLAGS
            ;;
     sparc)
            CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
            LDFLAGS="-m32 -mv8plus $LDFLAGS"
+           cross_cc_sparc=$cc
+           cross_cc_cflags_sparc=$CPU_CFLAGS
            ;;
     sparc64)
            CPU_CFLAGS="-m64 -mcpu=ultrasparc"
            LDFLAGS="-m64 $LDFLAGS"
+           cross_cc_sparc64=$cc
+           cross_cc_cflags_sparc64=$CPU_CFLAGS
            ;;
     s390)
            CPU_CFLAGS="-m31"
            LDFLAGS="-m31 $LDFLAGS"
+           cross_cc_s390=$cc
+           cross_cc_cflags_s390=$CPU_CFLAGS
            ;;
     s390x)
            CPU_CFLAGS="-m64"
            LDFLAGS="-m64 $LDFLAGS"
+           cross_cc_s390x=$cc
+           cross_cc_cflags_s390x=$CPU_CFLAGS
            ;;
     i386)
            CPU_CFLAGS="-m32"
@@ -1471,7 +1483,7 @@ case "$cpu" in
            CPU_CFLAGS="-mx32"
            LDFLAGS="-mx32 $LDFLAGS"
            cross_cc_i386=$cc
-           cross_cc_cflags_i386="-m32"
+           cross_cc_cflags_i386=$CPU_CFLAGS
            ;;
     # No special flags required for other host CPUs
 esac
-- 
2.17.1


[Qemu-devel] [PULL v2 06/57] docker: Add "cc" subcommand
Posted by Alex Bennée 5 years, 10 months ago
Signed-off-by: Fam Zheng <famz@redhat.com>
[AJB: add if args.paths check]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index e4095270eb..42267bb94d 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -412,6 +412,31 @@ class ProbeCommand(SubCommand):
         return
 
 
+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)]
+        if args.paths:
+            for p in args.paths:
+                cmd += ["-v", "%s:%s:ro,z" % (p, p)]
+        cmd += [args.image, "cc"]
+        cmd += argv
+        return Docker().command("run", cmd, args.quiet)
+
+
 def main():
     parser = argparse.ArgumentParser(description="A Docker helper",
             usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
-- 
2.17.1


[Qemu-devel] [PULL v2 07/57] docker: extend "cc" command to accept compiler
Posted by Alex Bennée 5 years, 10 months ago
When calling our cross-compilation images we want to call something
other than the default cc.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Fam Zheng <famz@redhat.com>

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 42267bb94d..db1e2537f5 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -419,6 +419,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", default="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""")
@@ -432,7 +434,7 @@ class CcCommand(SubCommand):
         if args.paths:
             for p in args.paths:
                 cmd += ["-v", "%s:%s:ro,z" % (p, p)]
-        cmd += [args.image, "cc"]
+        cmd += [args.image, args.cc]
         cmd += argv
         return Docker().command("run", cmd, args.quiet)
 
-- 
2.17.1


[Qemu-devel] [PULL v2 08/57] docker: allow "cc" command to run in user context
Posted by Alex Bennée 5 years, 10 months ago
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index db1e2537f5..b28ad87034 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -421,6 +421,8 @@ class CcCommand(SubCommand):
                             help="The docker image in which to run cc")
         parser.add_argument("--cc", default="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""")
@@ -434,6 +436,8 @@ class CcCommand(SubCommand):
         if args.paths:
             for p in args.paths:
                 cmd += ["-v", "%s:%s:ro,z" % (p, p)]
+        if args.user:
+            cmd += ["-u", args.user]
         cmd += [args.image, args.cc]
         cmd += argv
         return Docker().command("run", cmd, args.quiet)
-- 
2.17.1


[Qemu-devel] [PULL v2 09/57] docker: Makefile.include introduce DOCKER_SCRIPT
Posted by Alex Bennée 5 years, 10 months ago
Define this in one place to make it easy to re-use.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 74fd51c22c..8afb383478 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -15,6 +15,8 @@ DOCKER_TESTS := $(notdir $(shell \
 
 DOCKER_TOOLS := travis
 
+DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py
+
 TESTS ?= %
 IMAGES ?= %
 
@@ -38,7 +40,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))\
@@ -133,11 +135,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) 					\
@@ -167,4 +169,4 @@ docker-run-%:
 	@$(MAKE) docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE)
 
 docker-clean:
-	$(call quiet-command, $(SRC_PATH)/tests/docker/docker.py clean)
+	$(call quiet-command, $(DOCKER_SCRIPT) clean)
-- 
2.17.1


[Qemu-devel] [PULL v2 11/57] tests/tcg/multiarch: Build fix for linux-test
Posted by Alex Bennée 5 years, 10 months ago
From: Fam Zheng <famz@redhat.com>

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

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

Signed-off-by: Fam Zheng <famz@redhat.com>
[AJB: drop cutils/osdep dependencies]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

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


[Qemu-devel] [PULL v2 12/57] tests/tcg/multiarch: enable additional linux-test tests
Posted by Alex Bennée 5 years, 10 months ago
Un-comment the remaining tests.

I removed the itimer value tests because I'm fairly sure a re-arming
timer will always have a different value in it when you grab it.

I've also fixed up the clone thread flags as QEMU will only allow a
clone to use flags which match glibc. However the test is still racey
so it remains disabled by default - it can be run by passing any
additional parameters on the command line.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index 4457bd04ba..6f2c531474 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -16,6 +16,7 @@
  *  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>
@@ -58,8 +59,8 @@ static void error1(const char *filename, int line, const char *fmt, ...)
 static int __chk_error(const char *filename, int line, int ret)
 {
     if (ret < 0) {
-        error1(filename, line, "%m (ret=%d, errno=%d)",
-               ret, errno);
+        error1(filename, line, "%m (ret=%d, errno=%d/%s)",
+               ret, errno, strerror(errno));
     }
     return ret;
 }
@@ -216,6 +217,7 @@ static void test_fork(void)
     pid = chk_error(fork());
     if (pid == 0) {
         /* child */
+        sleep(2);
         exit(2);
     }
     chk_error(waitpid(pid, &status, 0));
@@ -320,7 +322,6 @@ static void test_socket(void)
     chk_error(close(server_fd));
 }
 
-#if 0
 #define WCOUNT_MAX 512
 
 static void test_pipe(void)
@@ -355,7 +356,7 @@ static void test_pipe(void)
             }
             if (FD_ISSET(fds[1], &wfds)) {
                 ch = 'a';
-                chk_error(write(fds[0], &ch, 1));
+                chk_error(write(fds[1], &ch, 1));
                 wcount++;
             }
         }
@@ -387,28 +388,41 @@ static int thread2_func(void *arg)
     return 0;
 }
 
-void test_clone(void)
+static void wait_for_child(pid_t pid)
+{
+    int status;
+    chk_error(waitpid(pid, &status, 0));
+}
+
+/* For test_clone we must match the clone flags used by glibc, see
+ * CLONE_THREAD_FLAGS in the QEMU source code.
+ */
+static void test_clone(void)
 {
     uint8_t *stack1, *stack2;
-    int pid1, pid2, status1, status2;
+    pid_t pid1, pid2;
 
     stack1 = malloc(STACK_SIZE);
     pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE,
-                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1"));
+                           CLONE_VM | CLONE_FS | CLONE_FILES |
+                           CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM,
+                            "hello1"));
 
     stack2 = malloc(STACK_SIZE);
     pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE,
-                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2"));
+                           CLONE_VM | CLONE_FS | CLONE_FILES |
+                           CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM,
+                           "hello2"));
 
-    while (waitpid(pid1, &status1, 0) != pid1);
+    wait_for_child(pid1);
     free(stack1);
-    while (waitpid(pid2, &status2, 0) != pid2);
+    wait_for_child(pid2);
     free(stack2);
+
     if (thread1_res != 5 ||
         thread2_res != 6)
         error("clone");
 }
-#endif
 
 /***********************************/
 
@@ -449,12 +463,10 @@ static void test_signal(void)
     it.it_value.tv_usec = 10 * 1000;
     chk_error(setitimer(ITIMER_REAL, &it, NULL));
     chk_error(getitimer(ITIMER_REAL, &oit));
-    if (oit.it_value.tv_sec != it.it_value.tv_sec ||
-        oit.it_value.tv_usec != it.it_value.tv_usec)
-        error("itimer");
 
     while (alarm_count < 5) {
         usleep(10 * 1000);
+        getitimer(ITIMER_REAL, &oit);
     }
 
     it.it_interval.tv_sec = 0;
@@ -463,9 +475,6 @@ static void test_signal(void)
     it.it_value.tv_usec = 0;
     memset(&oit, 0xff, sizeof(oit));
     chk_error(setitimer(ITIMER_REAL, &it, &oit));
-    if (oit.it_value.tv_sec != 0 ||
-        oit.it_value.tv_usec != 10 * 1000)
-        error("setitimer");
 
     /* SIGSEGV test */
     act.sa_sigaction = sig_segv;
@@ -503,10 +512,16 @@ static void test_shm(void)
 int main(int argc, char **argv)
 {
     test_file();
+    test_pipe();
     test_fork();
     test_time();
     test_socket();
-    //    test_clone();
+
+    if (argc > 1) {
+        printf("test_clone still considered buggy\n");
+        test_clone();
+    }
+
     test_signal();
     test_shm();
     return 0;
-- 
2.17.1


[Qemu-devel] [PULL v2 13/57] tests/tcg/multiarch: don't hard code paths/ports for linux-test
Posted by Alex Bennée 5 years, 10 months ago
The fixed path and ports get in the way of running our tests and
builds in parallel. Instead of using TESTPATH we use mkdtemp() and
instead of a fixed port we allow the kernel to assign one and query it
afterwards.

Ideally test directory creation should be common functionally across
all TCG tests but this could complicate an already huge patch series
so we mark it as a TODO for next time.

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

diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index 6f2c531474..e80eccc0ce 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -40,9 +40,8 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <assert.h>
 
-#define TESTPATH "/tmp/linux-test.tmp"
-#define TESTPORT 7654
 #define STACK_SIZE 16384
 
 static void error1(const char *filename, int line, const char *fmt, ...)
@@ -85,19 +84,16 @@ static void test_file(void)
     struct iovec vecs[2];
     DIR *dir;
     struct dirent *de;
+    /* TODO: make common tempdir creation for tcg tests */
+    char template[] = "/tmp/linux-test-XXXXXX";
+    char *tmpdir = mkdtemp(template);
 
-    /* clean up, just in case */
-    unlink(TESTPATH "/file1");
-    unlink(TESTPATH "/file2");
-    unlink(TESTPATH "/file3");
-    rmdir(TESTPATH);
+    assert(tmpdir);
 
     if (getcwd(cur_dir, sizeof(cur_dir)) == NULL)
         error("getcwd");
 
-    chk_error(mkdir(TESTPATH, 0755));
-
-    chk_error(chdir(TESTPATH));
+    chk_error(chdir(tmpdir));
 
     /* open/read/write/close/readv/writev/lseek */
 
@@ -163,7 +159,7 @@ static void test_file(void)
         st.st_mtime != 1000)
         error("stat time");
 
-    chk_error(stat(TESTPATH, &st));
+    chk_error(stat(tmpdir, &st));
     if (!S_ISDIR(st.st_mode))
         error("stat mode");
 
@@ -185,7 +181,7 @@ static void test_file(void)
         error("stat mode");
 
     /* getdents */
-    dir = opendir(TESTPATH);
+    dir = opendir(tmpdir);
     if (!dir)
         error("opendir");
     len = 0;
@@ -207,7 +203,7 @@ static void test_file(void)
     chk_error(unlink("file3"));
     chk_error(unlink("file2"));
     chk_error(chdir(cur_dir));
-    chk_error(rmdir(TESTPATH));
+    chk_error(rmdir(tmpdir));
 }
 
 static void test_fork(void)
@@ -264,7 +260,7 @@ static int server_socket(void)
     chk_error(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)));
 
     sockaddr.sin_family = AF_INET;
-    sockaddr.sin_port = htons(TESTPORT);
+    sockaddr.sin_port = htons(0); /* choose random ephemeral port) */
     sockaddr.sin_addr.s_addr = 0;
     chk_error(bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)));
     chk_error(listen(fd, 0));
@@ -272,7 +268,7 @@ static int server_socket(void)
 
 }
 
-static int client_socket(void)
+static int client_socket(uint16_t port)
 {
     int fd;
     struct sockaddr_in sockaddr;
@@ -280,7 +276,7 @@ static int client_socket(void)
     /* server socket */
     fd = chk_error(socket(PF_INET, SOCK_STREAM, 0));
     sockaddr.sin_family = AF_INET;
-    sockaddr.sin_port = htons(TESTPORT);
+    sockaddr.sin_port = htons(port);
     inet_aton("127.0.0.1", &sockaddr.sin_addr);
     chk_error(connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)));
     return fd;
@@ -292,10 +288,17 @@ static void test_socket(void)
 {
     int server_fd, client_fd, fd, pid, ret, val;
     struct sockaddr_in sockaddr;
-    socklen_t len;
+    struct sockaddr_in server_addr;
+    socklen_t len, socklen;
+    uint16_t server_port;
     char buf[512];
 
     server_fd = server_socket();
+    /* find out what port we got */
+    socklen = sizeof(server_addr);
+    ret = getsockname(server_fd, &server_addr, &socklen);
+    chk_error(ret);
+    server_port = ntohs(server_addr.sin_port);
 
     /* test a few socket options */
     len = sizeof(val);
@@ -305,7 +308,7 @@ static void test_socket(void)
 
     pid = chk_error(fork());
     if (pid == 0) {
-        client_fd = client_socket();
+        client_fd = client_socket(server_port);
         send(client_fd, socket_msg, sizeof(socket_msg), 0);
         close(client_fd);
         exit(0);
-- 
2.17.1


[Qemu-devel] [PULL v2 14/57] tests/tcg/multiarch: move most output to stdout
Posted by Alex Bennée 5 years, 10 months ago
The default test run outputs to stdout so it can be re-directed.
Errors are still reported to stderr.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>

diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
index cdefadfa4c..5c0afe6e49 100644
--- a/tests/tcg/multiarch/test-mmap.c
+++ b/tests/tcg/multiarch/test-mmap.c
@@ -36,7 +36,7 @@
 do                                                             \
 {                                                              \
   if (!(x)) {                                                  \
-    fprintf (stderr, "FAILED at %s:%d\n", __FILE__, __LINE__); \
+    fprintf(stderr, "FAILED at %s:%d\n", __FILE__, __LINE__); \
     exit (EXIT_FAILURE);                                       \
   }                                                            \
 } while (0)
@@ -57,7 +57,7 @@ void check_aligned_anonymous_unfixed_mmaps(void)
 	uintptr_t p;
 	int i;
 
-	fprintf (stderr, "%s", __func__);
+	fprintf(stdout, "%s", __func__);
 	for (i = 0; i < 0x1fff; i++)
 	{
 		size_t len;
@@ -106,7 +106,7 @@ void check_aligned_anonymous_unfixed_mmaps(void)
 		munmap (p4, len);
 		munmap (p5, len);
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_large_anonymous_unfixed_mmap(void)
@@ -115,7 +115,7 @@ void check_large_anonymous_unfixed_mmap(void)
 	uintptr_t p;
 	size_t len;
 
-	fprintf (stderr, "%s", __func__);
+	fprintf(stdout, "%s", __func__);
 
 	len = 0x02000000;
 	p1 = mmap(NULL, len, PROT_READ, 
@@ -130,7 +130,7 @@ void check_large_anonymous_unfixed_mmap(void)
 	/* Make sure we can read from the entire area.  */
 	memcpy (dummybuf, p1, pagesize);
 	munmap (p1, len);
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_aligned_anonymous_unfixed_colliding_mmaps(void)
@@ -141,7 +141,7 @@ void check_aligned_anonymous_unfixed_colliding_mmaps(void)
 	uintptr_t p;
 	int i;
 
-	fprintf (stderr, "%s", __func__);
+	fprintf(stdout, "%s", __func__);
 	for (i = 0; i < 0x2fff; i++)
 	{
 		int nlen;
@@ -180,7 +180,7 @@ void check_aligned_anonymous_unfixed_colliding_mmaps(void)
 		munmap (p2, pagesize);
 		munmap (p3, nlen);
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_aligned_anonymous_fixed_mmaps(void)
@@ -194,7 +194,7 @@ void check_aligned_anonymous_fixed_mmaps(void)
 	addr = mmap(NULL, pagesize * 40, PROT_READ | PROT_WRITE, 
 		    MAP_PRIVATE | MAP_ANONYMOUS,
 		    -1, 0);
-	fprintf (stderr, "%s addr=%p", __func__, addr);
+	fprintf(stdout, "%s addr=%p", __func__, addr);
 	fail_unless (addr != MAP_FAILED);
 
 	for (i = 0; i < 40; i++)
@@ -212,7 +212,7 @@ void check_aligned_anonymous_fixed_mmaps(void)
 		munmap (p1, pagesize);
 		addr += pagesize;
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_aligned_anonymous_fixed_mmaps_collide_with_host(void)
@@ -225,8 +225,8 @@ void check_aligned_anonymous_fixed_mmaps_collide_with_host(void)
 	/* Find a suitable address to start with.  Right were the x86 hosts
 	 stack is.  */
 	addr = ((void *)0x80000000);
-	fprintf (stderr, "%s addr=%p", __func__, addr);
-	fprintf (stderr, "FIXME: QEMU fails to track pages used by the host.");
+	fprintf(stdout, "%s addr=%p", __func__, addr);
+	fprintf(stdout, "FIXME: QEMU fails to track pages used by the host.");
 
 	for (i = 0; i < 20; i++)
 	{
@@ -243,7 +243,7 @@ void check_aligned_anonymous_fixed_mmaps_collide_with_host(void)
 		munmap (p1, pagesize);
 		addr += pagesize;
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_file_unfixed_mmaps(void)
@@ -252,7 +252,7 @@ void check_file_unfixed_mmaps(void)
 	uintptr_t p;
 	int i;
 
-	fprintf (stderr, "%s", __func__);
+	fprintf(stdout, "%s", __func__);
 	for (i = 0; i < 0x10; i++)
 	{
 		size_t len;
@@ -294,7 +294,7 @@ void check_file_unfixed_mmaps(void)
 		munmap (p2, len);
 		munmap (p3, len);
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_file_unfixed_eof_mmaps(void)
@@ -304,7 +304,7 @@ void check_file_unfixed_eof_mmaps(void)
 	uintptr_t p;
 	int i;
 
-	fprintf (stderr, "%s", __func__);
+	fprintf(stdout, "%s", __func__);
 	for (i = 0; i < 0x10; i++)
 	{
 		p1 = mmap(NULL, pagesize, PROT_READ, 
@@ -327,7 +327,7 @@ void check_file_unfixed_eof_mmaps(void)
 		fail_unless (cp[pagesize - 4] == 0);
 		munmap (p1, pagesize);
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_file_fixed_eof_mmaps(void)
@@ -343,7 +343,7 @@ void check_file_fixed_eof_mmaps(void)
 		    MAP_PRIVATE | MAP_ANONYMOUS,
 		    -1, 0);
 
-	fprintf (stderr, "%s addr=%p", __func__, (void *)addr);
+	fprintf(stdout, "%s addr=%p", __func__, (void *)addr);
 	fail_unless (addr != MAP_FAILED);
 
 	for (i = 0; i < 0x10; i++)
@@ -371,7 +371,7 @@ void check_file_fixed_eof_mmaps(void)
 		munmap (p1, pagesize);
 		addr += pagesize;
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void check_file_fixed_mmaps(void)
@@ -384,7 +384,7 @@ void check_file_fixed_mmaps(void)
 	addr = mmap(NULL, pagesize * 40 * 4, PROT_READ, 
 		    MAP_PRIVATE | MAP_ANONYMOUS,
 		    -1, 0);
-	fprintf (stderr, "%s addr=%p", __func__, (void *)addr);
+	fprintf(stdout, "%s addr=%p", __func__, (void *)addr);
 	fail_unless (addr != MAP_FAILED);
 
 	for (i = 0; i < 40; i++)
@@ -426,7 +426,7 @@ void check_file_fixed_mmaps(void)
 		munmap (p4, pagesize);
 		addr += pagesize * 4;
 	}
-	fprintf (stderr, " passed\n");
+	fprintf(stdout, " passed\n");
 }
 
 void checked_write(int fd, const void *buf, size_t count)
-- 
2.17.1


[Qemu-devel] [PULL v2 17/57] tests/tcg/i386: Build fix for hello-i386
Posted by Alex Bennée 5 years, 10 months ago
From: Fam Zheng <famz@redhat.com>

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

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

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


[Qemu-devel] [PULL v2 18/57] tests/tcg/i386: fix test-i386
Posted by Alex Bennée 5 years, 10 months ago
We don't include anything from qemu itself for the build.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
index 9599204895..cae6a7773a 100644
--- a/tests/tcg/i386/test-i386.c
+++ b/tests/tcg/i386/test-i386.c
@@ -17,7 +17,6 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
-#include "qemu/compiler.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-- 
2.17.1


[Qemu-devel] [PULL v2 21/57] tests/tcg/i386/test-i386: use modern vector_size attributes
Posted by Alex Bennée 5 years, 10 months ago
The compiler complains about the old __mode__ style attributes.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
index cae6a7773a..caef4da176 100644
--- a/tests/tcg/i386/test-i386.c
+++ b/tests/tcg/i386/test-i386.c
@@ -2106,8 +2106,8 @@ static void test_enter(void)
 
 #ifdef TEST_SSE
 
-typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));
-typedef float __m128 __attribute__ ((__mode__(__V4SF__)));
+typedef int __m64 __attribute__ ((vector_size(8)));
+typedef float __m128 __attribute__ ((vector_size(16)));
 
 typedef union {
     double d[2];
-- 
2.17.1


[Qemu-devel] [PULL v2 22/57] tests/tcg/i386/test-i386: fix printf format
Posted by Alex Bennée 5 years, 10 months ago
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
index caef4da176..a29b41e764 100644
--- a/tests/tcg/i386/test-i386.c
+++ b/tests/tcg/i386/test-i386.c
@@ -2258,7 +2258,7 @@ SSE_OP(a ## sd);
         "pop %0\n"\
         : "=rm" (eflags)\
         : "x" (a.dq), "x" (b.dq));\
-    printf("%-9s: a=%f b=%f cc=%04x\n",\
+    printf("%-9s: a=%f b=%f cc=%04lx\n",\
            #op, a1, b1,\
            eflags & (CC_C | CC_P | CC_Z | CC_S | CC_O | CC_A));\
 }
-- 
2.17.1


[Qemu-devel] [PULL v2 25/57] tests/tcg/arm: fix up test-arm-iwmmxt test
Posted by Alex Bennée 5 years, 10 months ago
We need to rename the source file to a .S so we can do a single-line
assemble and link invocation. We also specify the additional CFLAGS
for the compile as it's a non-standard ARM binary.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
[rth: force fpu configuration]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
index 0312293dca..cadb385890 100644
--- a/tests/tcg/arm/Makefile.target
+++ b/tests/tcg/arm/Makefile.target
@@ -8,9 +8,14 @@ ARM_SRC=$(SRC_PATH)/tests/tcg/arm
 # Set search path for all sources
 VPATH 		+= $(ARM_SRC)
 
+TESTS += hello-arm test-arm-iwmmxt
 
 hello-arm: CFLAGS+=-marm -ffreestanding
 hello-arm: LDFLAGS+=-nostdlib
 
+test-arm-iwmmxt: CFLAGS+=-marm -march=iwmmxt -mabi=aapcs -mfpu=fpv4-sp-d16
+test-arm-iwmmxt: test-arm-iwmmxt.S
+	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+
 # On ARM Linux only supports 4k pages
 EXTRA_RUNS+=run-test-mmap-4096
diff --git a/tests/tcg/arm/test-arm-iwmmxt.s b/tests/tcg/arm/test-arm-iwmmxt.S
similarity index 100%
rename from tests/tcg/arm/test-arm-iwmmxt.s
rename to tests/tcg/arm/test-arm-iwmmxt.S
-- 
2.17.1


[Qemu-devel] [PULL v2 29/57] tests/tcg: enable building for MIPS
Posted by Alex Bennée 5 years, 10 months ago
This doesn't add any additional tests but enables building the
multiarch tests for MIPS using docker cross compilers. We don't have a
cross compiler for mips64 big endian though.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/tcg/mips/Makefile.include b/tests/tcg/mips/Makefile.include
new file mode 100644
index 0000000000..a9beceb623
--- /dev/null
+++ b/tests/tcg/mips/Makefile.include
@@ -0,0 +1,17 @@
+#
+# Makefile.include for all MIPs targets
+#
+# As Debian doesn't support mip64 in big endian mode the only way to
+# build BE is to pass a working cross compiler to ./configure
+#
+
+ifeq ($(TARGET_NAME),mips64el)
+DOCKER_IMAGE=debian-mips64el-cross
+DOCKER_CROSS_COMPILER=mips64el-linux-gnuabi64-gcc
+else ifeq ($(TARGET_NAME),mipsel)
+DOCKER_IMAGE=debian-mipsel-cross
+DOCKER_CROSS_COMPILER=mipsel-linux-gnu-gcc
+else ifeq ($(TARGET_NAME),mips)
+DOCKER_IMAGE=debian-mips-cross
+DOCKER_CROSS_COMPILER=mips-linux-gnu-gcc
+endif
-- 
2.17.1


[Qemu-devel] [PULL v2 30/57] tests/docker/Makefile.include: fix mipsel-cross dependancy
Posted by Alex Bennée 5 years, 10 months ago
This got broken in commit 4319db7 but generally only shows up when you
try and do massive parallel builds on fresh machines.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 8afb383478..4a2b028a3b 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -57,6 +57,7 @@ docker-image-debian-armel-cross: docker-image-debian9
 docker-image-debian-armhf-cross: docker-image-debian9
 docker-image-debian-arm64-cross: docker-image-debian9
 docker-image-debian-mips-cross: docker-image-debian9
+docker-image-debian-mipsel-cross: docker-image-debian9
 docker-image-debian-mips64el-cross: docker-image-debian9
 docker-image-debian-powerpc-cross: docker-image-debian8
 docker-image-debian-ppc64el-cross: docker-image-debian9
-- 
2.17.1


[Qemu-devel] [PULL v2 31/57] tests/tcg/mips: include common mips hello-mips
Posted by Alex Bennée 5 years, 10 months ago
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/tcg/mips/Makefile.target b/tests/tcg/mips/Makefile.target
new file mode 100644
index 0000000000..71f0c2dd53
--- /dev/null
+++ b/tests/tcg/mips/Makefile.target
@@ -0,0 +1,19 @@
+# -*- Mode: makefile -*-
+#
+# MIPS - included from tests/tcg/Makefile.target
+#
+
+MIPS_SRC=$(SRC_PATH)/tests/tcg/mips
+
+# Set search path for all sources
+VPATH 		+= $(MIPS_SRC)
+
+MIPS_TESTS=hello-mips
+
+TESTS += $(MIPS_TESTS)
+
+hello-mips: CFLAGS+=-ffreestanding
+hello-mips: LDFLAGS+=-nostdlib
+
+# For MIPS32 and 64 we have a bunch of extra tests in sub-directories
+# however they are intended for system tests.
-- 
2.17.1


[Qemu-devel] [PULL v2 32/57] tests/tcg: enable building for s390x
Posted by Alex Bennée 5 years, 10 months ago
This doesn't add any additional tests but enables building the
multiarch tests for s390x.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Hildenbrand <david@redhat.com>

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


[Qemu-devel] [PULL v2 33/57] tests/tcg: enable building for ppc64
Posted by Alex Bennée 5 years, 10 months ago
Currently this just enables building the multiarch tests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

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


[Qemu-devel] [PULL v2 46/57] tests/Makefile.include: add [build|clean|check]-tcg targets
Posted by Alex Bennée 5 years, 10 months ago
This will ensure all linux-user targets build their guest test
programs and ensure check-tcg will run the respective tests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/Makefile.include b/tests/Makefile.include
index ca91da26cb..5c401874e8 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -10,6 +10,7 @@ check-help:
 	@echo " $(MAKE) check-speed          Run qobject speed tests"
 	@echo " $(MAKE) check-qapi-schema    Run QAPI schema tests"
 	@echo " $(MAKE) check-block          Run block tests"
+	@echo " $(MAKE) check-tcg            Run TCG tests"
 	@echo " $(MAKE) check-report.html    Generates an HTML test report"
 	@echo " $(MAKE) check-clean          Clean the tests"
 	@echo
@@ -930,6 +931,30 @@ check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check
 check-report.html: check-report.xml
 	$(call quiet-command,gtester-report $< > $@,"GEN","$@")
 
+# Per guest TCG tests
+
+LINUX_USER_TARGETS=$(filter %-linux-user,$(TARGET_LIST))
+BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(LINUX_USER_TARGETS))
+CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(LINUX_USER_TARGETS))
+RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(LINUX_USER_TARGETS))
+
+build-tcg-tests-%:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" guest-tests,)
+
+run-tcg-tests-%: % build-tcg-tests-%
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" run-guest-tests,)
+
+clean-tcg-tests-%:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
+
+.PHONY: build-tcg
+build-tcg: $(BUILD_TCG_TARGET_RULES)
+
+.PHONY: check-tcg
+check-tcg: $(RUN_TCG_TARGET_RULES)
+
+.PHONY: clean-tcg
+clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 
 # Other tests
 
@@ -972,7 +997,6 @@ check-speed: $(patsubst %,check-%, $(check-speed-y))
 check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-qapi-schema check-unit check-qtest check-decodetree
 check-clean:
-	$(MAKE) -C tests/tcg clean
 	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
 	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
 	rm -f tests/test-qapi-gen-timestamp
-- 
2.17.1


[Qemu-devel] [PULL v2 49/57] tests/tcg/i386: extend timeout for runcom test
Posted by Alex Bennée 5 years, 10 months ago
The Travis hardware can be a little slow and the runcom test is fairly
heavy in calculating pi. Lets double the timeout so we don't trip up
during CI by mistake.

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

diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index 97b7c23cf1..c1997a1624 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -30,6 +30,7 @@ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386
 	   $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 # Specialist test runners
+run-runcom: TIMEOUT=30
 run-runcom: runcom pi_10.com
 	$(call run-test,$<,$(QEMU) ./runcom $(I386_SRC)/pi_10.com,"$< on $(TARGET_NAME)")
 
-- 
2.17.1


[Qemu-devel] [PULL v2 51/57] docker: docker.py use "version" to probe usage
Posted by Alex Bennée 5 years, 10 months ago
The "images" command is a fairly heavyweight command to run as it
involves searching the whole docker file-system inventory. On a
machine with a lot of images this makes start-up fairly expensive.

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

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index b28ad87034..e6437d64a7 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -52,7 +52,9 @@ def _guess_docker_command():
     commands = [["docker"], ["sudo", "-n", "docker"]]
     for cmd in commands:
         try:
-            if subprocess.call(cmd + ["images"],
+            # docker version will return the client details in stdout
+            # but still report a status of 1 if it can't contact the daemon
+            if subprocess.call(cmd + ["version"],
                                stdout=DEVNULL, stderr=DEVNULL) == 0:
                 return cmd
         except OSError:
-- 
2.17.1


[Qemu-devel] [PULL v2 52/57] docker: docker.py don't conflate checksums for extra_files
Posted by Alex Bennée 5 years, 10 months ago
This just gets confusing especially as the helper function doesn't
even take into account any extra files (or the executable). Currently
the actual check just ignores them and also passes the result through
_dockerfile_preprocess so we fix that too.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index e6437d64a7..6a9f2f224b 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -206,8 +206,10 @@ class Docker(object):
 
         tmp_df.write("\n")
         tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s" %
-                     _text_checksum("\n".join([dockerfile] +
-                                    extra_files_cksum)))
+                     _text_checksum(_dockerfile_preprocess(dockerfile)))
+        for f, c in extra_files_cksum:
+            tmp_df.write("LABEL com.qemu.%s-checksum=%s" % (f, c))
+
         tmp_df.flush()
 
         self._do_check(["build", "-t", tag, "-f", tmp_df.name] + argv + \
@@ -322,7 +324,7 @@ class BuildCommand(SubCommand):
                 _copy_binary_with_libs(args.include_executable, docker_dir)
             for filename in args.extra_files or []:
                 _copy_with_mkdir(filename, docker_dir)
-                cksum += [_file_checksum(filename)]
+                cksum += [(filename, _file_checksum(filename))]
 
             argv += ["--build-arg=" + k.lower() + "=" + v
                         for k, v in os.environ.iteritems()
-- 
2.17.1


[Qemu-devel] [PULL v2 53/57] docker: docker.py add check sub-command
Posted by Alex Bennée 5 years, 10 months ago
This command allows you to check if we need to re-build a docker
image. If the image isn't in the repository or the checksums don't
match then we return false and some text (for processing in
makefiles).

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

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 6a9f2f224b..e4f37820e0 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -184,8 +184,14 @@ class Docker(object):
                                        stderr=subprocess.STDOUT,
                                        **kwargs)
 
+    def inspect_tag(self, tag):
+        try:
+            return self._output(["inspect", tag])
+        except subprocess.CalledProcessError:
+            return None
+
     def get_image_dockerfile_checksum(self, tag):
-        resp = self._output(["inspect", tag])
+        resp = self.inspect_tag(tag)
         labels = json.loads(resp)[0]["Config"].get("Labels", {})
         return labels.get("com.qemu.dockerfile-checksum", "")
 
@@ -447,6 +453,36 @@ class CcCommand(SubCommand):
         return Docker().command("run", cmd, args.quiet)
 
 
+class CheckCommand(SubCommand):
+    """Check if we need to re-build a docker image out of a dockerfile.
+    Arguments: <tag> <dockerfile>"""
+    name = "check"
+
+    def args(self, parser):
+        parser.add_argument("tag",
+                            help="Image Tag")
+        parser.add_argument("dockerfile",
+                            help="Dockerfile name")
+
+    def run(self, args, argv):
+        dockerfile = open(args.dockerfile, "rb").read()
+        tag = args.tag
+
+        dkr = Docker()
+        info = dkr.inspect_tag(tag)
+        if info is None:
+            print("Image does not exist")
+            return 1
+
+        if dkr.image_matches_dockerfile(tag, dockerfile):
+            if not args.quiet:
+                print("Image is up to date")
+            return 0
+        else:
+            print("Image needs updating")
+            return 1
+
+
 def main():
     parser = argparse.ArgumentParser(description="A Docker helper",
             usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
-- 
2.17.1


[Qemu-devel] [PULL v2 55/57] docker: docker.py adding age check command
Posted by Alex Bennée 5 years, 10 months ago
This is useful for querying if an image is too old.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index e4f37820e0..b279836154 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -32,6 +32,7 @@ except ImportError:
     from io import StringIO
 from shutil import copy, rmtree
 from pwd import getpwuid
+from datetime import datetime,timedelta
 
 
 FILTERED_ENV_NAMES = ['ftp_proxy', 'http_proxy', 'https_proxy']
@@ -190,6 +191,9 @@ class Docker(object):
         except subprocess.CalledProcessError:
             return None
 
+    def get_image_creation_time(self, info):
+        return json.loads(info)[0]["Created"]
+
     def get_image_dockerfile_checksum(self, tag):
         resp = self.inspect_tag(tag)
         labels = json.loads(resp)[0]["Config"].get("Labels", {})
@@ -461,11 +465,14 @@ class CheckCommand(SubCommand):
     def args(self, parser):
         parser.add_argument("tag",
                             help="Image Tag")
-        parser.add_argument("dockerfile",
-                            help="Dockerfile name")
+        parser.add_argument("dockerfile", default=None,
+                            help="Dockerfile name", nargs='?')
+        parser.add_argument("--checktype", choices=["checksum", "age"],
+                            default="checksum", help="check type")
+        parser.add_argument("--olderthan", default=60, type=int,
+                            help="number of minutes")
 
     def run(self, args, argv):
-        dockerfile = open(args.dockerfile, "rb").read()
         tag = args.tag
 
         dkr = Docker()
@@ -474,13 +481,32 @@ class CheckCommand(SubCommand):
             print("Image does not exist")
             return 1
 
-        if dkr.image_matches_dockerfile(tag, dockerfile):
-            if not args.quiet:
-                print("Image is up to date")
-            return 0
-        else:
-            print("Image needs updating")
-            return 1
+        if args.checktype == "checksum":
+            if not args.dockerfile:
+                print("Need a dockerfile for tag:%s" % (tag))
+                return 1
+
+            dockerfile = open(args.dockerfile, "rb").read()
+
+            if dkr.image_matches_dockerfile(tag, dockerfile):
+                if not args.quiet:
+                    print("Image is up to date")
+                return 0
+            else:
+                print("Image needs updating")
+                return 1
+        elif args.checktype == "age":
+            timestr = dkr.get_image_creation_time(info).split(".")[0]
+            created = datetime.strptime(timestr, "%Y-%m-%dT%H:%M:%S")
+            past = datetime.now() - timedelta(minutes=args.olderthan)
+            if created < past:
+                print ("Image created @ %s more than %d minutes old" %
+                       (timestr, args.olderthan))
+                return 1
+            else:
+                if not args.quiet:
+                    print ("Image less than %d minutes old" % (args.olderthan))
+                return 0
 
 
 def main():
-- 
2.17.1


[Qemu-devel] [PULL v2 56/57] tests/docker/Makefile.include: only force SID to NOCACHE if old
Posted by Alex Bennée 5 years, 10 months ago
Now we can check the age of a docker image we can be a little more
intelligent about re-building Sid images and only force NOCACHE if
it is "old".

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

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index c0f09505bb..91d9665517 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -75,8 +75,14 @@ docker-image-debian-win64-cross: docker-image-debian8-mxe
 # force a re-build of the base image if we ever need to build one of
 # its children.
 ifndef SKIP_DOCKER_BUILD
+ifeq ($(HAVE_USER_DOCKER),y)
+SID_AGE=$(shell $(DOCKER_SCRIPT) check --checktype=age --olderthan=180 --quiet qemu:debian-sid)
+ifeq ($(SID_AGE),)
+else
 docker-image-debian-sid: NOCACHE=1
 endif
+endif
+endif
 
 docker-image-debian-alpha-cross: docker-image-debian-sid
 docker-image-debian-hppa-cross: docker-image-debian-sid
-- 
2.17.1


[Qemu-devel] [PULL v2 57/57] .travis.yml: add check-tcg test
Posted by Alex Bennée 5 years, 10 months ago
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

diff --git a/.travis.yml b/.travis.yml
index fabfe9ec34..bd66c18fed 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -153,3 +153,11 @@ matrix:
         - TEST_CMD=""
       before_script:
         - ./configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread -fuse-ld=gold" || { cat config.log && exit 1; }
+    - env:
+        - CONFIG="--disable-system --disable-docs"
+        - TEST_CMD="make check-tcg"
+      script:
+        - make ${MAKEFLAGS} && ${TEST_CMD} ${MAKEFLAGS}
+      sudo: required
+      dist: trusty
+      compiler: gcc
-- 
2.17.1