make check-block a meson test
cover make check-block a meson test
This series makes "meson test" run the block layer tests, reporting their outcome in the same way as the other TAP tests.
Based-on: <[email protected]>
Paolo Bonzini (4):
scripts/mtest2make: add support for SPEED=thorough
build: make check-block a meson test
qemu-iotests: require at least an argument to check-block.sh
check-block: replace -makecheck with TAP output
meson.build | 5 ++-- scripts/mtest2make.py | 20 ++++++++++--- tests/Makefile.include | 16 ++--------- tests/check-block.sh | 45 +++++++++++++---------------- tests/meson.build | 1 + tests/qemu-iotests/check | 6 ++-- tests/qemu-iotests/meson.build | 30 +++++++++++++++++++ tests/qemu-iotests/testenv.py | 30 +++++++++---------- tests/qemu-iotests/testrunner.py | 49 +++++++++++++++++--------------- 9 files changed, 117 insertions(+), 85 deletions(-) create mode 100644 tests/qemu-iotests/meson.build
Signature · 1 line
2.33.1
PATCH 1/4 scripts/mtest2make: add support for SPEED=thorough
--- meson.build | 5 +++-- scripts/mtest2make.py | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-)
meson.build +3 -2
@@ -3,8 +3,9 @@ project('qemu', ['c'], meson_version: '>=0.58.2', 'b_staticpic=false', 'stdsplit=false'], version: files('VERSION')) -add_test_setup('quick', exclude_suites: 'slow', is_default: true) -add_test_setup('slow', env: ['G_TEST_SLOW=1', 'SPEED=slow']) +add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true) +add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) +add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough']) not_found = dependency('', required: false) keyval = import('keyval')
scripts/mtest2make.py +7 -3
@@ -23,8 +23,9 @@ def names(self, base): print(''' SPEED = quick -.speed.quick = $(foreach s,$(sort $(filter-out %-slow, $1)), --suite $s) -.speed.slow = $(foreach s,$(sort $1), --suite $s) +.speed.quick = $(foreach s,$(sort $(filter-out %-slow %-thorough, $1)), --suite $s) +.speed.slow = $(foreach s,$(sort $(filter-out %-thorough, $1)), --suite $s) +.speed.thorough = $(foreach s,$(sort $1), --suite $s) .mtestargs = --no-rebuild -t 0 ifneq ($(SPEED), quick)
@@ -52,11 +53,14 @@ def process_tests(test, targets, suites): for s in test_suites: # The suite name in the introspection info is "PROJECT:SUITE" s = s.split(':')[1] - if s == 'slow': + if s == 'slow' or s == 'thorough': continue if s.endswith('-slow'): s = s[:-5] suites[s].speeds.append('slow') + if s.endswith('-thorough'): + s = s[:-9] + suites[s].speeds.append('thorough') suites[s].deps.update(deps) def emit_prolog(suites, prefix):
Signature · 1 line
2.33.1
PATCH 2/4 build: make check-block a meson test
In reply to Paolo Bonzini"meson test" can be asked to run tests verbosely; this makes it usable also for qemu-iotests's own harness, and it lets "make check-block" reuse mtest2make.py's infrastructure to find and build test dependencies.
Adjust check-block.sh to use the standard exit code that reports a test as skipped. Alternatively, in the future we could make it produce TAP output, which is consistent with all other "make check" tests.
--- meson.build | 6 +++--- scripts/mtest2make.py | 10 +++++++++- tests/Makefile.include | 16 +++------------- tests/check-block.sh | 28 +++++++++++++--------------- tests/meson.build | 1 + tests/qemu-iotests/meson.build | 29 +++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 tests/qemu-iotests/meson.build
meson.build +3 -3
@@ -3,9 +3,9 @@ project('qemu', ['c'], meson_version: '>=0.58.2', 'b_staticpic=false', 'stdsplit=false'], version: files('VERSION')) -add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true) -add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) -add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough']) +add_test_setup('quick', exclude_suites: ['block', 'slow', 'thorough'], is_default: true) +add_test_setup('slow', exclude_suites: ['block', 'thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) +add_test_setup('thorough', exclude_suites: ['block'], env: ['G_TEST_SLOW=1', 'SPEED=thorough']) not_found = dependency('', required: false) keyval = import('keyval')
scripts/mtest2make.py +9 -1
@@ -79,7 +79,7 @@ def emit_prolog(suites, prefix): print(f'{prefix}-report.junit.xml $(all-{prefix}-xml): {prefix}-report%.junit.xml: run-ninja') print(f'\t$(MAKE) {prefix}$* MTESTARGS="$(MTESTARGS) --logbase {prefix}-report$*" && ln -f meson-logs/$@ .') -def emit_suite(name, suite, prefix): +def emit_suite_deps(name, suite, prefix): deps = ' '.join(suite.deps) targets = f'{prefix}-{name} {prefix}-report-{name}.junit.xml {prefix} {prefix}-report.junit.xml' print()
@@ -87,6 +87,10 @@ def emit_suite(name, suite, prefix): print(f'ifneq ($(filter {prefix}-build {targets}, $(MAKECMDGOALS)),)') print(f'.{prefix}.build-suites += {name}') print(f'endif') + +def emit_suite(name, suite, prefix): + emit_suite_deps(name, suite, prefix) + targets = f'{prefix}-{name} {prefix}-report-{name}.junit.xml {prefix} {prefix}-report.junit.xml' print(f'ifneq ($(filter {targets}, $(MAKECMDGOALS)),)') print(f'.{prefix}.mtest-suites += ' + ' '.join(suite.names(name))) print(f'endif')
@@ -97,6 +101,10 @@ def emit_suite(name, suite, prefix): testsuites = defaultdict(Suite) for test in introspect['tests']: process_tests(test, targets, testsuites) +# HACK: check-block is a separate target so that it runs with --verbose; +# only write the dependencies +emit_suite_deps('block', testsuites['block'], 'check') +del testsuites['block'] emit_prolog(testsuites, 'check') for name, suite in testsuites.items(): emit_suite(name, suite, 'check')
tests/Makefile.include +3 -13
@@ -156,19 +156,9 @@ check: ifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy) check: check-block -export PYTHON - -ifneq ($(filter check check-block check-build, $(MAKECMDGOALS)),) -ninja-cmd-goals += \ - qemu-img$(EXESUF) \ - qemu-io$(EXESUF) \ - qemu-nbd$(EXESUF) \ - storage-daemon/qemu-storage-daemon$(EXESUF) \ - $(filter qemu-system-%, $(ninja-targets)) -endif - -check-block: $(SRC_PATH)/tests/check-block.sh run-ninja - @$< +check-block: run-ninja + $(if $(MAKE.n),,+)$(MESON) test $(MTESTARGS) $(.mtestargs) --verbose \ + --logbase iotestslog $(call .speed.$(SPEED), block block-slow block-thorough) endif check-build: run-ninja
tests/check-block.sh +13 -15
@@ -1,6 +1,6 @@ #!/bin/sh -# Honor the SPEED environment variable, just like we do it for the qtests. +# Honor the SPEED environment variable, just like we do it for "meson test" if [ "$SPEED" = "slow" ]; then format_list="raw qcow2" group=
@@ -16,9 +16,13 @@ if [ "$#" -ne 0 ]; then format_list="$@" fi +skip() { + echo "$*" + exit 77 +} + if grep -q "CONFIG_GPROF=y" config-host.mak 2>/dev/null ; then - echo "GPROF is enabled ==> Not running the qemu-iotests." - exit 0 + skip "GPROF is enabled ==> Not running the qemu-iotests." fi # Disable tests with any sanitizer except for specific ones
@@ -36,36 +40,30 @@ for j in ${ALLOWED_SANITIZE_FLAGS}; do done if echo ${SANITIZE_FLAGS} | grep -q "\-fsanitize" 2>/dev/null; then # Have a sanitize flag that is not allowed, stop - echo "Sanitizers are enabled ==> Not running the qemu-iotests." - exit 0 + skip "Sanitizers are enabled ==> Not running the qemu-iotests." fi if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then - echo "No qemu-system binary available ==> Not running the qemu-iotests." - exit 0 + skip "No qemu-system binary available ==> Not running the qemu-iotests." fi if ! command -v bash >/dev/null 2>&1 ; then - echo "bash not available ==> Not running the qemu-iotests." - exit 0 + skip "bash not available ==> Not running the qemu-iotests." fi if LANG=C bash --version | grep -q 'GNU bash, version [123]' ; then - echo "bash version too old ==> Not running the qemu-iotests." - exit 0 + skip "bash version too old ==> Not running the qemu-iotests." fi if ! (sed --version | grep 'GNU sed') > /dev/null 2>&1 ; then if ! command -v gsed >/dev/null 2>&1; then - echo "GNU sed not available ==> Not running the qemu-iotests." - exit 0 + skip "GNU sed not available ==> Not running the qemu-iotests." fi else # Double-check that we're not using BusyBox' sed which says # that "This is not GNU sed version 4.0" ... if sed --version | grep -q 'not GNU sed' ; then - echo "BusyBox sed not supported ==> Not running the qemu-iotests." - exit 0 + skip "BusyBox sed not supported ==> Not running the qemu-iotests." fi fi
tests/meson.build +1 -0
@@ -1,6 +1,7 @@ py3 = import('python').find_installation() subdir('bench') +subdir('qemu-iotests') test_qapi_outputs = [ 'qapi-builtin-types.c',
tests/qemu-iotests/meson.build new file +29 -0
@@ -0,0 +1,29 @@ +if have_tools + qemu_iotests_binaries = [qemu_img, qemu_io, qemu_nbd, qsd] + qemu_iotests_env = {'PYTHON': python.full_path()} + qemu_iotests_formats = { + 'raw': 'quick', + 'qcow2': 'slow', + 'qed': 'thorough', + 'vmdk': 'thorough', + 'vpc': 'thorough' + } + + foreach k, v : emulators + if k.startswith('qemu-system-') + qemu_iotests_binaries += v + endif + endforeach + foreach format, speed: qemu_iotests_formats + if speed == 'quick' + suites = 'block' + else + suites = ['block-' + speed, speed] + endif + test('qemu-iotests ' + format, sh, args: [files('../check-block.sh'), format], + depends: qemu_iotests_binaries, env: qemu_iotests_env, + suite: suites, + timeout: 0, + is_parallel: false) + endforeach +endif
Signature · 1 line
2.33.1
Re: [PATCH 2/4] build: make check-block a meson test
Quoted 18 lines · Paolo Bonzini
"meson test" can be asked to run tests verbosely; this makes it usable also for qemu-iotests's own harness, and it lets "make check-block" reuse mtest2make.py's infrastructure to find and build test dependencies.
Adjust
check-block.shto use the standard exit code that reports a test as skipped. Alternatively, in the future we could make it produce TAP output, which is consistent with all other "make check" tests.Signed-off-by Paolo Bonzini <[email protected]>--- meson.build | 6 +++--- scripts/mtest2make.py | 10 +++++++++- tests/Makefile.include | 16 +++------------- tests/check-block.sh | 28 +++++++++++++--------------- tests/meson.build | 1 + tests/qemu-iotests/meson.build | 29 +++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 32 deletions(-)create mode 100644 tests/qemu-iotests/meson.build
[...]
Quoted 6 lines
tests/qemu-iotests/meson.build new file +0
-0
tests/qemu-iotests/meson.build line 10
Quoted 10 lines
tests/qemu-iotests/meson.build new file +10
-0@@ -0,0 +1,29 @@ +if have_tools + qemu_iotests_binaries = [qemu_img, qemu_io, qemu_nbd, qsd] + qemu_iotests_env = {'PYTHON': python.full_path()} + qemu_iotests_formats = { + 'raw': 'quick', + 'qcow2': 'slow', + 'qed': 'thorough', + 'vmdk': 'thorough', + 'vpc': 'thorough' + }
I think the default behavior for "quick" should be to test with qcow2 - most iotests require that format and that's what we're currently using with "make check-block" by default... i.e. please swap raw and qcow2 here.
Thomas
Re: [PATCH 2/4] build: make check-block a meson test
Quoted 10 lines · Thomas Huth
Quoted 8 lines
+
qemu_iotests_formats= {
+ 'raw': 'quick',
+ 'qcow2': 'slow',
+ 'qed': 'thorough',
+ 'vmdk': 'thorough',
+ 'vpc': 'thorough'
+ }I think the default behavior for "quick" should be to test with qcow2 - most iotests require that format and that's what we're currently using with "make check-block" by default... i.e. please swap raw and qcow2 here.
You're right, also the tests should be disable on non-POSIX systems.
Paolo
PATCH 3/4 qemu-iotests: require at least an argument to check-block.sh
In reply to Paolo BonziniThis is anyway how check-block.sh is used in practice, and by removing the list of formats in the script we avoid duplication between meson.build and check-block.sh.
--- tests/check-block.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
tests/check-block.sh +9 -12
@@ -1,19 +1,16 @@ #!/bin/sh -# Honor the SPEED environment variable, just like we do it for "meson test" -if [ "$SPEED" = "slow" ]; then - format_list="raw qcow2" - group= -elif [ "$SPEED" = "thorough" ]; then - format_list="raw qcow2 qed vmdk vpc" - group= -else - format_list=qcow2 - group="-g auto" +if [ "$#" -eq 0 ]; then + echo "Usage: $0 fmt..." >&2 + exit 99 fi -if [ "$#" -ne 0 ]; then - format_list="$@" +# Honor the SPEED environment variable, just like we do it for "meson test" +format_list="$@" +if [ "$SPEED" = "slow" ] || [ "$SPEED" = "thorough" ]; then + group= +else + group="-g auto" fi skip() {
Signature · 1 line
2.33.1
PATCH 4/4 check-block: replace -makecheck with TAP output
In reply to Paolo BonziniLet "meson test" take care of showing the results of the individual tests, consistently with other output from "make check V=1".
--- tests/check-block.sh | 6 ++-- tests/qemu-iotests/check | 6 ++-- tests/qemu-iotests/meson.build | 1 + tests/qemu-iotests/testenv.py | 30 +++++++++---------- tests/qemu-iotests/testrunner.py | 49 +++++++++++++++++--------------- 5 files changed, 48 insertions(+), 44 deletions(-)
tests/check-block.sh +3 -3
@@ -14,8 +14,8 @@ else fi skip() { - echo "$*" - exit 77 + echo "1..0 #SKIP $*" + exit 0 } if grep -q "CONFIG_GPROF=y" config-host.mak 2>/dev/null ; then
@@ -79,7 +79,7 @@ JOBS=$(echo "$MAKEFLAGS" | sed -n 's/\(^\|.* \)-j\([0-9]\+\)\( .*\|$\)/-j \2/p') ret=0 for fmt in $format_list ; do - ${PYTHON} ./check $JOBS -makecheck -$fmt $group || ret=1 + ${PYTHON} ./check $JOBS -tap -$fmt $group || ret=1 done exit $ret
tests/qemu-iotests/check +3 -3
@@ -32,8 +32,6 @@ def make_argparser() -> argparse.ArgumentParser: p.add_argument('-n', '--dry-run', action='store_true', help='show me, do not run tests') - p.add_argument('-makecheck', action='store_true', - help='pretty print output for make check') p.add_argument('-j', dest='jobs', type=int, default=1, help='run tests in multiple parallel jobs')
@@ -53,6 +51,8 @@ def make_argparser() -> argparse.ArgumentParser: p.add_argument('--color', choices=['on', 'off', 'auto'], default='auto', help="use terminal colors. The default " "'auto' value means use colors if terminal stdout detected") + p.add_argument('-tap', action='store_true', + help='produce TAP output') g_env = p.add_argument_group('test environment options') mg = g_env.add_mutually_exclusive_group()
@@ -164,7 +164,7 @@ if __name__ == '__main__': if args.dry_run: print('\n'.join(tests)) else: - with TestRunner(env, makecheck=args.makecheck, + with TestRunner(env, tap=args.tap, color=args.color) as tr: paths = [os.path.join(env.source_iotests, t) for t in tests] ok = tr.run_tests(paths, args.jobs)
tests/qemu-iotests/meson.build +1 -0
@@ -22,6 +22,7 @@ if have_tools endif test('qemu-iotests ' + format, sh, args: [files('../check-block.sh'), format], depends: qemu_iotests_binaries, env: qemu_iotests_env, + protocol: 'tap', suite: suites, timeout: 0, is_parallel: false)
tests/qemu-iotests/testenv.py +15 -15
@@ -287,21 +287,21 @@ def __enter__(self) -> 'TestEnv': def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: self.close() - def print_env(self) -> None: + def print_env(self, prefix: str = '') -> None: template = """\ -QEMU -- "{QEMU_PROG}" {QEMU_OPTIONS} -QEMU_IMG -- "{QEMU_IMG_PROG}" {QEMU_IMG_OPTIONS} -QEMU_IO -- "{QEMU_IO_PROG}" {QEMU_IO_OPTIONS} -QEMU_NBD -- "{QEMU_NBD_PROG}" {QEMU_NBD_OPTIONS} -IMGFMT -- {IMGFMT}{imgopts} -IMGPROTO -- {IMGPROTO} -PLATFORM -- {platform} -TEST_DIR -- {TEST_DIR} -SOCK_DIR -- {SOCK_DIR} -GDB_OPTIONS -- {GDB_OPTIONS} -VALGRIND_QEMU -- {VALGRIND_QEMU} -PRINT_QEMU_OUTPUT -- {PRINT_QEMU} -""" +{prefix}QEMU -- "{QEMU_PROG}" {QEMU_OPTIONS} +{prefix}QEMU_IMG -- "{QEMU_IMG_PROG}" {QEMU_IMG_OPTIONS} +{prefix}QEMU_IO -- "{QEMU_IO_PROG}" {QEMU_IO_OPTIONS} +{prefix}QEMU_NBD -- "{QEMU_NBD_PROG}" {QEMU_NBD_OPTIONS} +{prefix}IMGFMT -- {IMGFMT}{imgopts} +{prefix}IMGPROTO -- {IMGPROTO} +{prefix}PLATFORM -- {platform} +{prefix}TEST_DIR -- {TEST_DIR} +{prefix}SOCK_DIR -- {SOCK_DIR} +{prefix}GDB_OPTIONS -- {GDB_OPTIONS} +{prefix}VALGRIND_QEMU -- {VALGRIND_QEMU} +{prefix}PRINT_QEMU_OUTPUT -- {PRINT_QEMU} +{prefix}""" args = collections.defaultdict(str, self.get_env())
@@ -310,5 +310,5 @@ def print_env(self) -> None: u = os.uname() args['platform'] = f'{u.sysname}/{u.machine} {u.nodename} {u.release}' - + args['prefix'] = prefix print(template.format_map(args))
tests/qemu-iotests/testrunner.py +26 -23
87 lines not on this page · raw message
Signature · 1 line
2.33.1