Pierrick Bouvier <[email protected]> writes:

> On 7/15/2026 10:36 AM, Alex Bennée wrote:
>> Pierrick Bouvier <[email protected]> writes:
>> 
>>> It's now built-in meson, which offers targets check-tcg and check-tcg-*.
>>>
>>> Tested-by: Alex Bennée <[email protected]>
>>> Signed-off-by: Pierrick Bouvier <[email protected]>
>>> ---
>>>  tests/Makefile.include | 68 ++----------------------------------------
>>>  1 file changed, 2 insertions(+), 66 deletions(-)
>>>
>>> diff --git a/tests/Makefile.include b/tests/Makefile.include
>>> index 494d0109f26..9f82552ab54 100644
>>> --- a/tests/Makefile.include
>>> +++ b/tests/Makefile.include
>>> @@ -19,9 +19,7 @@ check-help:
>>>  ifneq ($(filter $(all-check-targets), check-softfloat),)
>>>     @echo " $(MAKE) check-softfloat               Run FPU emulation tests"
>>>     @echo " $(MAKE) check-tcg                     Run TCG tests"
>>> -   @echo " $(MAKE) run-tcg-tests-TARGET          Run TCG tests for a given 
>>> target"
>>> -   @echo
>>> -   @echo "The variable TCG_TEST_FILTER will select the subset of matching 
>>> tests."
>>> +   @echo " $(MAKE) check-tcg-TARGET              Run TCG tests for a given 
>>> target"
>>>  endif
>>>     @echo
>>>     @echo " $(MAKE) check-report.junit.xml        Generates an aggregated 
>>> XML test report"
>>> @@ -40,67 +38,6 @@ export SRC_PATH
>>>  
>>>  SPEED = quick
>>>  
>>> -
>>> -# TCG_TESTS_WITH_COMPILERS represents the test targets we have cross 
>>> compiler
>>> -# support for, CONFIGURED_TCG_TARGETS it what meson has finally
>>> -# configured having rejected stuff we can't build.
>>> -CONFIGURED_TCG_TARGETS=$(patsubst %-config-target.h, %, $(wildcard 
>>> *-config-target.h))
>>> -
>>> -# This is the intersection of what tests we can build and is configured
>>> -TCG_TESTS_TARGETS=$(filter $(CONFIGURED_TCG_TARGETS), 
>>> $(TCG_TESTS_WITH_COMPILERS))
>>> -
>>> -# Per guest TCG tests
>>> -BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, 
>>> $(TCG_TESTS_TARGETS))
>>> -CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, 
>>> $(TCG_TESTS_TARGETS))
>>> -DISTCLEAN_TCG_TARGET_RULES=$(patsubst %,distclean-tcg-tests-%, 
>>> $(TCG_TESTS_TARGETS))
>>> -RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TCG_TESTS_TARGETS))
>>> -
>>> -$(foreach TARGET,$(TCG_TESTS_TARGETS), \
>>> -        $(eval $(BUILD_DIR)/tests/tcg/config-$(TARGET).mak: 
>>> config-host.mak))
>>> -
>>> -# $1 = the stem (e.g., arm-softmmu or x86_64-linux-user)
>>> -get-qemu-bin = $(if $(findstring softmmu,$1),qemu-system-$(subst 
>>> -softmmu,,$1),qemu-$(subst -linux-user,,$1))
>>> -
>>> -$(foreach TARGET,$(TCG_TESTS_TARGETS), \
>>> -        $(eval .ninja-goals.run-tcg-tests-$(TARGET) += $(call 
>>> get-qemu-bin,$(TARGET))))
>>> -
>>> -.PHONY: $(TCG_TESTS_TARGETS:%=build-tcg-tests-%)
>>> -$(TCG_TESTS_TARGETS:%=build-tcg-tests-%): build-tcg-tests-%: 
>>> $(BUILD_DIR)/tests/tcg/config-%.mak
>>> -   $(call quiet-command, \
>>> -            $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS), \
>>> -        "BUILD","$* guest-tests")
>>> -
>>> -.PHONY: $(TCG_TESTS_TARGETS:%=run-tcg-tests-%)
>>> -$(TCG_TESTS_TARGETS:%=run-tcg-tests-%): run-tcg-tests-%: build-tcg-tests-%
>>> -   $(call quiet-command, \
>>> -           $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) SPEED=$(SPEED) 
>>> TCG_TEST_FILTER=$(TCG_TEST_FILTER) run, \
>>> -        "RUN", "$* guest-tests")
>>> -
>>> -.PHONY: $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%)
>>> -$(TCG_TESTS_TARGETS:%=clean-tcg-tests-%): clean-tcg-tests-%:
>>> -   $(call quiet-command, \
>>> -           $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) clean, \
>>> -        "CLEAN", "$* guest-tests")
>>> -
>>> -.PHONY: $(TCG_TESTS_TARGETS:%=distclean-tcg-tests-%)
>>> -$(TCG_TESTS_TARGETS:%=distclean-tcg-tests-%): distclean-tcg-tests-%:
>>> -   $(call quiet-command, \
>>> -           $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) distclean, \
>>> -        "CLEAN", "$* guest-tests")
>>> -
>>> -.PHONY: build-tcg
>>> -build-tcg: $(BUILD_TCG_TARGET_RULES)
>>> -
>>> -.PHONY: check-tcg
>>> -.ninja-goals.check-tcg = all test-plugins
>>> -check-tcg: $(RUN_TCG_TARGET_RULES)
>>> -
>>> -.PHONY: clean-tcg
>>> -clean-tcg: $(CLEAN_TCG_TARGET_RULES)
>> 
>> We still need a clean-tcg or similar rule to force a rebuild of the
>> tests without killing the whole build dir.
>>
>
> It was needed before, since we only had partial dependencies.
> But now considering that all dependencies are correctly tracked, what's
> the use case?
> - If a test is mtime modified, it rebuilds the test.
> - If a dockerfile is mtime modified, associated tests are rebuilt.
> - If docker.py is modified, it will rebuild tests transitively.
> - If cflags are modified, test will be rebuilt also.
> - All input of a test (.h, .c, ...) are all tracked.
> - If user installs a cross compiler or remove podman/docker, next meson
> configuration will identify this and rebuild all associated tests.
>
> In case you find a missing dep, we just need to add it in meson. clean
> is not needed anymore.

OK I was testing the changing of the cross compiler and I noticed its
not reported in the config summary if we have the fallback to
podman/docker.

I suspect the logic here:

  # snarf the cross-compilation information for tests
  summary_info = {}
  have_cross = false
  foreach target: target_dirs
    tcg_mak = meson.current_build_dir() / 'tests/tcg' / target / 
'config-target.mak'
    if fs.exists(tcg_mak)
      config_cross_tcg = keyval.load(tcg_mak)
      if 'CC' in config_cross_tcg
        summary_info += {config_cross_tcg['TARGET_NAME']: 
config_cross_tcg['CC']}
        have_cross = true
      endif
    endif
  endforeach
  if have_cross
    summary(summary_info, bool_yn: true, section: 'Cross compilers')
  endif

needs to be cleaned up.

>
>>> -
>>> -.PHONY: distclean-tcg
>>> -distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES)
>>> -
>>>  # Build up our target list from the filtered list of ninja targets
>>>  TARGETS=$(patsubst libqemu-%.a, %, $(filter libqemu-%.a, $(ninja-targets)))
>>>  
>>> @@ -128,7 +65,6 @@ check-build: run-ninja
>>>  check-clean:
>>>     rm -rf $(BUILD_DIR)/tests/functional
>>>  
>>> -clean: check-clean clean-tcg
>>> -distclean: distclean-tcg
>>> +clean: check-clean

I wonder if check-clean is redundant as well now if the functional test
dependencies are properly encoded.

>>>  
>>>  endif
>> 

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

Reply via email to