This should trigger the building of the docker image when the user calls "make check-tcg" or one of the arch specific targets such as "make check-tcg-m68k-linux-user".
We still keep the internal meson dependency so individual tests can launched and the docker build verified. Signed-off-by: Alex Bennée <[email protected]> --- scripts/mtest2make.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py index 383ea68b16d..ab894d90d47 100644 --- a/scripts/mtest2make.py +++ b/scripts/mtest2make.py @@ -14,6 +14,7 @@ class Suite(object): def __init__(self): self.deps = set() self.speeds = set() + self.docker_deps = set() def names(self, base): return [f'{base}-{speed}' for speed in self.speeds] @@ -40,7 +41,22 @@ def names(self, base): introspect = json.load(sys.stdin) -def process_tests(test, targets, suites): +targets = {t['id']: [os.path.relpath(f) for f in t['filename']] + for t in introspect['targets']} + +# collect the docker images uses by the tests. This is totally a hacky +# heuristic that fishes the images out of the test custom commands by +# looking for the qemu/image pattern. +targets_docker = {} +for t in introspect['targets']: + for src in t.get('target_sources', []): + for arg in src.get('compiler', []): + if arg.startswith('qemu/'): + img = arg.split('/', 1)[1] + targets_docker[t['id']] = f'docker-image-{img}' + break + +def process_tests(test, targets, targets_docker, suites): executable = test['cmd'][0] try: executable = os.path.relpath(executable) @@ -51,6 +67,8 @@ def process_tests(test, targets, suites): deps = itertools.chain.from_iterable(deps) deps = list(deps) + docker_deps = [targets_docker[x] for x in test['depends'] if x in targets_docker] + test_suites = test['suite'] or ['default'] for s in test_suites: # The suite name in the introspection info is "PROJECT" or "PROJECT:SUITE" @@ -59,6 +77,7 @@ def process_tests(test, targets, suites): if s == 'slow' or s == 'thorough': continue suites[s].deps.update(deps) + suites[s].docker_deps.update(docker_deps) if s.endswith('-slow'): s = s[:-5] suites[s].speeds.add('slow') @@ -81,6 +100,9 @@ def emit_prolog(suites, prefix): print(f'all-{prefix}-xml = {all_xml}') print(f'.PHONY: {prefix} do-meson-{prefix} {prefix}-report.junit.xml $(all-{prefix}-targets) $(all-{prefix}-xml)') print(f'ninja-cmd-goals += $(foreach s, $(.{prefix}.mtest-suites), $(.{prefix}-$s.deps))') + print(f'docker-cmd-goals += $(foreach s, $(.{prefix}.mtest-suites), $(.{prefix}-$s.docker-deps))') + print(f'docker-cmd-goals += $(foreach g, $(MAKECMDGOALS), $(.docker-goals.$g))') + print(f'run-ninja: $(sort $(docker-cmd-goals))') print(f'{prefix}-build: run-ninja') print(f'{prefix} $(all-{prefix}-targets): do-meson-{prefix}') print(f'do-meson-{prefix}: run-ninja; $(if $(MAKE.n),,+)$(MESON) test $(.{prefix}.mtestargs)') @@ -93,6 +115,10 @@ def emit_suite(name, suite, prefix): print() print(f'.{prefix}-{tgtname}.deps = {deps}') print(f'.ninja-goals.check-build += $(.{prefix}-{tgtname}.deps)') + if suite.docker_deps: + docker_deps = ' '.join(sorted(suite.docker_deps)) + print(f'.{prefix}-{tgtname}.docker-deps = {docker_deps}') + print(f'.docker-goals.check-build += $(.{prefix}-{tgtname}.docker-deps)') names = ' '.join(sorted(suite.names(name))) targets = f'{prefix}-{tgtname} {prefix}-report-{tgtname}.junit.xml' @@ -105,19 +131,16 @@ def emit_suite(name, suite, prefix): print(f".{prefix}.mtest-suites += {name} $(call .speed.$(SPEED), {names})") print(f'endif') -targets = {t['id']: [os.path.relpath(f) for f in t['filename']] - for t in introspect['targets']} - testsuites = defaultdict(Suite) for test in introspect['tests']: - process_tests(test, targets, testsuites) + process_tests(test, targets, targets_docker, testsuites) emit_prolog(testsuites, 'check') for name, suite in testsuites.items(): emit_suite(name, suite, 'check') benchsuites = defaultdict(Suite) for test in introspect['benchmarks']: - process_tests(test, targets, benchsuites) + process_tests(test, targets, targets_docker, benchsuites) emit_prolog(benchsuites, 'bench') for name, suite in benchsuites.items(): emit_suite(name, suite, 'bench') -- 2.47.3
