tests/functional: Prepare the meson build system for the functional tests

Provide a meson.build file for the upcoming python-based functional
tests, and add some wrapper glue targets to the tests/Makefile.include
file. We are going to use two "speed" modes for the functional tests:
The "quick" tests can be run at any time (i.e. also during "make check"),
while the "thorough" tests should only be run when running a
"make check-functional" test run (since these tests might download
additional assets from the internet).

The changes to the meson.build files are partly based on an earlier
patch by Ani Sinha.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240830133841.142644-12-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Thomas Huth 2024-08-30 15:38:05 +02:00
parent cf1f31089c
commit 1497377857
3 changed files with 93 additions and 0 deletions

View File

@ -9,6 +9,8 @@ check-help:
@echo "Individual test suites:"
@echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target"
@echo " $(MAKE) check-qtest Run qtest tests"
@echo " $(MAKE) check-functional Run python-based functional tests"
@echo " $(MAKE) check-functional-TARGET Run functional tests for a given target"
@echo " $(MAKE) check-unit Run qobject tests"
@echo " $(MAKE) check-qapi-schema Run QAPI schema tests"
@echo " $(MAKE) check-block Run block tests"
@ -152,6 +154,15 @@ check-acceptance-deprecated-warning:
check-acceptance: check-acceptance-deprecated-warning | check-avocado
FUNCTIONAL_TARGETS=$(patsubst %-softmmu,check-functional-%, $(filter %-softmmu,$(TARGETS)))
.PHONY: $(FUNCTIONAL_TARGETS)
$(FUNCTIONAL_TARGETS):
@$(MAKE) SPEED=thorough $(subst -functional,-func,$@)
.PHONY: check-functional
check-functional:
@$(MAKE) SPEED=thorough check-func check-func-quick
# Consolidated targets
.PHONY: check check-clean get-vm-images

View File

@ -0,0 +1,81 @@
# QEMU functional tests:
# Tests that are put in the 'quick' category are run by default during
# 'make check'. Everything that should not be run during 'make check'
# (e.g. tests that fetch assets from the internet) should be put into
# the 'thorough' category instead.
# Most tests run too slow with TCI enabled, so skip the functional tests there
if get_option('tcg_interpreter')
subdir_done()
endif
# Timeouts for individual tests that can be slow e.g. with debugging enabled
test_timeouts = {
}
tests_generic_system = [
]
tests_generic_linuxuser = [
]
tests_generic_bsduser = [
]
tests_x86_64_system_quick = [
]
tests_x86_64_system_thorough = [
]
foreach speed : ['quick', 'thorough']
foreach dir : target_dirs
target_base = dir.split('-')[0]
if dir.endswith('-softmmu')
sysmode = 'system'
test_emulator = emulators['qemu-system-' + target_base]
elif dir.endswith('-linux-user')
sysmode = 'linuxuser'
test_emulator = emulators['qemu-' + target_base]
elif dir.endswith('-bsd-user')
sysmode = 'bsduser'
test_emulator = emulators['qemu-' + target_base]
else
continue
endif
if speed == 'quick'
suites = ['func-quick', 'func-' + target_base]
target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \
+ get_variable('tests_generic_' + sysmode)
else
suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed]
target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, [])
endif
test_deps = roms
test_env = environment()
if have_tools
test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img')
test_deps += [qemu_img]
endif
test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
meson.current_source_dir())
foreach test : target_tests
test('func-@0@/@1@'.format(target_base, test),
python,
depends: [test_deps, test_emulator, emulator_modules],
env: test_env,
args: [meson.current_source_dir() / 'test_' + test + '.py'],
protocol: 'tap',
timeout: test_timeouts.get(test, 60),
priority: test_timeouts.get(test, 60),
suite: suites)
endforeach
endforeach
endforeach

View File

@ -85,3 +85,4 @@ subdir('unit')
subdir('qapi-schema')
subdir('qtest')
subdir('migration')
subdir('functional')