All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Gustavo Romero" <gustavo.romero@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-arm@nongnu.org, "Alexandre Iooss" <erdnaxe@crans.org>
Subject: Re: [PATCH v2 35/37] tests/tcg/meson.build: introduce cc_dockerfile
Date: Mon, 29 Jun 2026 23:34:33 -0700	[thread overview]
Message-ID: <e349d913-21fa-4b35-be24-e554356c1d2d@oss.qualcomm.com> (raw)
In-Reply-To: <20260626233918.158740-36-pierrick.bouvier@oss.qualcomm.com>

On 6/26/2026 4:39 PM, Pierrick Bouvier wrote:
> We allow target to declare a dockerfile containing required cc. We reuse
> tests/docker/docker.py, and correctly set dependencies for tests on
> original dockerfile.
> 
> In case we rely on docker, we do not build tests by default anymore.
>

Added (coming in v3) cc_docker_arch to specify host architecture for
which the image supports the given cc.

> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> ---
>  tests/tcg/meson.build | 52 ++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 47 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
> index 2a308d8ad32..eb6b65c0021 100644
> --- a/tests/tcg/meson.build
> +++ b/tests/tcg/meson.build
> @@ -1,6 +1,7 @@
>  cc_check_args = ['-xc', '/dev/null', '-o', '/dev/null', '-c']
>  env = find_program('env')
>  
> +docker_wrapper = find_program('../docker/docker.py')
>  gdb_progs = ['gdb-multiarch', 'gdb']
>  if config_host.has_key('GDB')
>    gdb_progs = [config_host['GDB'], gdb_progs]
> @@ -21,6 +22,7 @@ tcg_tests = {}
>  # {
>  #   'name_of_target': {
>  #     'cc': 'cross_compiler',
> +#     'cc_dockerfile': 'name_of_dockerfile',
>  #     'cc_feat_cflags': {
>  #       'name': ['feature cflags'],
>  #       ...
> @@ -75,6 +77,9 @@ if gdb.found()
>    endforeach
>  endif
>  
> +docker_supported = run_command(docker_wrapper, 'probe',
> +                               check: false).returncode() == 0
> +
>  # plugins come first, as we need to build the list
>  test_plugins = {}
>  subdir('plugins')
> @@ -120,6 +125,7 @@ endforeach
>  # Now let's go through all architectures
>  subdir('aarch64')
>  
> +image_targets = {}
>  # Finally, we can create all test executables and test targets
>  foreach target, plan: tcg_tests
>    if target.startswith('multiarch-')
> @@ -135,8 +141,8 @@ foreach target, plan: tcg_tests
>  
>    # return a clear error if user misspell a target entry
>    foreach key, _ : plan
> -    allowed = ['cc', 'cc_feat_cflags', 'folder', 'gdb_arch', 'gdb_feat_version',
> -               'qemu', 'tests']
> +    allowed = ['cc', 'cc_dockerfile', 'cc_feat_cflags', 'folder', 'gdb_arch',
> +               'gdb_feat_version', 'qemu', 'tests']
>      if key not in allowed
>        error('unknown tcg test plan entry \'' + key + '\' for target ' + target +
>              ' (possible: [' + ', '.join(allowed) + '])')
> @@ -144,6 +150,35 @@ foreach target, plan: tcg_tests
>    endforeach
>  
>    cc = find_program(plan['cc'], required : false)
> +  cc_from_system = cc.found()
> +  has_cc = cc.found()
> +  build_test_depends = []
> +  build_test_depend_files = []
> +
> +  if 'cc_dockerfile' in plan
> +    cc_dockerfile = plan['cc_dockerfile']
> +    dockerfile = files('..'/'docker'/'dockerfiles'/cc_dockerfile + '.docker')
> +    image_name = 'image-' + cc_dockerfile
> +    if cc_dockerfile not in image_targets
> +      cmd = [docker_wrapper, 'build', '-f', dockerfile, '-t', cc_dockerfile]
> +      t = custom_target(image_name, command: cmd,
> +                        build_by_default: false,
> +                        output: 'none')
> +      image_targets += {cc_dockerfile: t}
> +    endif
> +
> +    if docker_supported and not has_cc
> +      build_test_depends = image_targets[cc_dockerfile]
> +      build_test_depend_files = dockerfile
> +      mount = meson.project_source_root()
> +      mount = mount + ':' + mount
> +      here = meson.project_build_root()
> +      cc = [docker_wrapper, 'run', '-w', here, '-v', mount,
> +            cc_dockerfile, plan['cc']]
> +      has_cc = true
> +    endif
> +  endif
> +
>    folder = plan['folder']
>    gdb_arch = plan['gdb_arch']
>    qemu = plan['qemu']
> @@ -237,10 +272,14 @@ foreach target, plan: tcg_tests
>          cc_feat = setup['cc_feat']
>          if cc_feat not in cc_has_feat
>            avail = false
> -          if cc.found()
> +          if cc_from_system
> +            # check flag for host cc
>              cmd = run_command([cc, cc_check_args, cc_feat_cflags[cc_feat]],
>                                check: false)
>              avail = cmd.returncode() == 0
> +          elif has_cc
> +            # docker cc always have feature
> +            avail = true
>            endif
>            cc_has_feat += {cc_feat: avail}
>          endif
> @@ -252,12 +291,13 @@ foreach target, plan: tcg_tests
>          cflags += cc_feat_cflags[cc_feat]
>        endif
>  
> -      if not cc.found()
> +      if not has_cc
>          skip_test = 'compiler ' + plan['cc'] + ' not available'
>          built_tests += {exe_name: exe_name}
>        endif
>  
>        # build executable if needed
> +      # build by default only if cc comes from system
>        if exe_name not in built_tests
>          exe = custom_target(exe_name,
>                              input: file,
> @@ -269,7 +309,9 @@ foreach target, plan: tcg_tests
>                                        cflags],
>                              depfile: exe_name + '.d',
>                              output: exe_name + '.test',
> -                            build_by_default: true)
> +                            depends: build_test_depends,
> +                            depend_files: build_test_depend_files,
> +                            build_by_default: cc_from_system)
>          built_tests += {exe_name: exe}
>        endif
>  



  reply	other threads:[~2026-06-30  6:35 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 23:38 [PATCH v2 00/37] tests/tcg: run tests with meson Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 01/37] tests/tcg/multiarch/system/memory.c: remove unused variable Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 02/37] tests/tcg/multiarch/plugin/check-plugin-output.sh: take test output as input Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 03/37] tests/tcg/multiarch/plugin: rename check-plugin-output to regex-compare Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 04/37] tests/tcg: introduce meson.build Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 05/37] tests/tcg/meson.build: introduce exe_name Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 06/37] tests/tcg/meson.build: introduce test_name Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 07/37] tests/tcg/meson.build: introduce cflags Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 08/37] tests/tcg/meson.build: introduce qemu_args Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 09/37] tests/tcg/meson.build: introduce env_var Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 10/37] tests/tcg/plugins: build list of test_plugins Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 11/37] tests/tcg/meson.build: introduce plugin_test Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 12/37] tests/tcg/meson.build: test gdb support and introduce gdb_arch Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 13/37] tests/tcg/meson.build: introduce gdb_test Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 14/37] tests/tcg/meson.build: add default flag for testing compiler support Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 15/37] tests/tcg/meson.build: introduce wrapper Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 16/37] tests/tcg/meson.build: introduce expected_output Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 17/37] tests/tcg/meson.build: add wrapper run_and_check_forbidden_output Pierrick Bouvier
2026-06-26 23:38 ` [PATCH v2 18/37] tests/tcg/meson.build: add wrapper run_with_input Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 19/37] tests/tcg/meson.build: add wrapper record_replay Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 20/37] tests/tcg/meson.build: add wrapper check_plugin_output Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 21/37] tests/tcg/aarch64: add user tests Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 22/37] tests/tcg/aarch64: add system tests Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 23/37] tests/tcg/multiarch: declare user tests Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 24/37] tests/tcg/aarch64: add multiarch " Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 25/37] tests/tcg/multiarch: declare system tests Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 26/37] tests/tcg/aarch64: add multiarch " Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 27/37] tests/tcg/meson.build: add generic plugin tests Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 28/37] tests/tcg/meson.build: add logic to skip tests Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 29/37] tests/tcg/meson.build: introduce cc_feat and cc_feat_cflags Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 30/37] tests/tcg/meson.build: introduce gdb_feat and gdb_feat_version Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 31/37] tests/tcg/meson.build: move gdb_arch support check Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 32/37] tests/tcg/aarch64: delegate cc_feat and gdb_feat Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 33/37] tests/tcg/meson.build: let test infrastructure detect compiler Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 34/37] tests/docker/docker.py: return error code if probe fails Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 35/37] tests/tcg/meson.build: introduce cc_dockerfile Pierrick Bouvier
2026-06-30  6:34   ` Pierrick Bouvier [this message]
2026-06-26 23:39 ` [PATCH v2 36/37] tests/tcg/aarch64: add container support Pierrick Bouvier
2026-06-26 23:39 ` [PATCH v2 37/37] tests/tcg/meson.build: add top-level 'tcg-tests' target Pierrick Bouvier
2026-07-06 22:44 ` [PATCH v2 00/37] tests/tcg: run tests with meson Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e349d913-21fa-4b35-be24-e554356c1d2d@oss.qualcomm.com \
    --to=pierrick.bouvier@oss.qualcomm.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=erdnaxe@crans.org \
    --cc=gustavo.romero@linaro.org \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.