meson: Annotate each test() with 'suite'

A test case can be part of a test suite (just like we already
have 'syntax-check'). This then allows developers to run only a
subset of tests. For instance - when using valgrind test setup
(`meson test -C _build/ --setup valgrind`) it makes zero sense to
run syntax-check tests or other script based tests (e.g.
check-augeas-*, check-remote_protocol, etc.). What does makes
sense is to run compiled binaries.

Strictly speaking, reaching that goal is as trivial as annotating
only those compiled tests (declared in tests/meson.build) and
running them selectively:

  meson test -C _build/ --setup valgrind --suite $TAG

But it may be also desirable to run test scripts separately.

Therefore, introduce two new tags: 'bin' for compiled tests, and
'script' for script based tests and annotate each test()
accordingly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2023-07-15 07:52:43 +02:00
parent 3cde509f1a
commit 7ba20863a7
6 changed files with 23 additions and 3 deletions

View File

@ -16,7 +16,7 @@ by running
:: ::
$ meson test --setup valgrind $ meson test --setup valgrind --suite bin
`Valgrind <https://valgrind.org/>`__ is a test that checks for `Valgrind <https://valgrind.org/>`__ is a test that checks for
memory management issues, such as leaks or use of uninitialized memory management issues, such as leaks or use of uninitialized

View File

@ -126,4 +126,5 @@ test(
'--nonet', '--noout', docs_html_paths, '--nonet', '--noout', docs_html_paths,
], ],
depends: docs_html_dep, depends: docs_html_dep,
suite: 'script'
) )

View File

@ -360,4 +360,5 @@ test(
meson.project_build_root() / 'docs' meson.project_build_root() / 'docs'
], ],
env: runutf8, env: runutf8,
suite: 'script'
) )

View File

@ -110,4 +110,5 @@ test(
python3_prog, python3_prog,
args: [ check_aclperms_prog.full_path(), access_perm_h, files('viraccessperm.c') ], args: [ check_aclperms_prog.full_path(), access_perm_h, files('viraccessperm.c') ],
env: runutf8, env: runutf8,
suite: 'script'
) )

View File

@ -923,6 +923,7 @@ if host_machine.system() == 'linux'
python3_prog, python3_prog,
args: [ check_symfile_prog.full_path(), libvirt_syms, libvirt_lib ], args: [ check_symfile_prog.full_path(), libvirt_syms, libvirt_lib ],
env: runutf8, env: runutf8,
suite: 'script'
) )
if conf.has('WITH_REMOTE') if conf.has('WITH_REMOTE')
@ -931,6 +932,7 @@ if host_machine.system() == 'linux'
python3_prog, python3_prog,
args: [ check_symfile_prog.full_path(), libvirt_admin_syms, libvirt_admin_lib ], args: [ check_symfile_prog.full_path(), libvirt_admin_syms, libvirt_admin_lib ],
env: runutf8, env: runutf8,
suite: 'script'
) )
endif endif
endif endif
@ -944,6 +946,7 @@ test(
files(sym_files, used_sym_files), files(sym_files, used_sym_files),
], ],
env: runutf8, env: runutf8,
suite: 'script'
) )
test( test(
@ -955,6 +958,7 @@ test(
libvirt_admin_private_syms, libvirt_admin_private_syms,
], ],
env: runutf8, env: runutf8,
suite: 'script'
) )
test( test(
@ -965,6 +969,7 @@ test(
files('libvirt_public.syms'), libvirt_qemu_syms, libvirt_lxc_syms, files('libvirt_public.syms'), libvirt_qemu_syms, libvirt_lxc_syms,
], ],
env: runutf8, env: runutf8,
suite: 'script'
) )
test( test(
@ -974,6 +979,7 @@ test(
check_drivername_prog.full_path(), libvirt_admin_public_syms, check_drivername_prog.full_path(), libvirt_admin_public_syms,
], ],
env: runutf8, env: runutf8,
suite: 'script'
) )
test( test(
@ -981,6 +987,7 @@ test(
python3_prog, python3_prog,
args: [ check_driverimpls_prog.full_path(), driver_source_files ], args: [ check_driverimpls_prog.full_path(), driver_source_files ],
env: runutf8, env: runutf8,
suite: 'script'
) )
test( test(
@ -988,6 +995,7 @@ test(
python3_prog, python3_prog,
args: [ check_aclrules_prog.full_path(), files('remote/remote_protocol.x'), stateful_driver_source_files ], args: [ check_aclrules_prog.full_path(), files('remote/remote_protocol.x'), stateful_driver_source_files ],
env: runutf8, env: runutf8,
suite: 'script'
) )
if augparse_prog.found() if augparse_prog.found()
@ -1000,6 +1008,7 @@ if augparse_prog.found()
'-I', data['builddir'], '-I', data['builddir'],
data['file'].full_path(), data['file'].full_path(),
], ],
suite: 'script'
) )
endforeach endforeach
endif endif
@ -1020,6 +1029,7 @@ if pdwtags_prog.found() and cc.get_id() != 'clang'
], ],
env: runutf8, env: runutf8,
depends: [ lib ], depends: [ lib ],
suite: 'script'
) )
endforeach endforeach
endif endif

View File

@ -595,7 +595,14 @@ foreach data : tests
# default meson timeout # default meson timeout
timeout = 30 timeout = 30
endif endif
test(data['name'], test_bin, env: tests_env, timeout: timeout, depends: tests_deps) test(
data['name'],
test_bin,
env: tests_env,
timeout: timeout,
depends: tests_deps,
suite: 'bin'
)
endforeach endforeach
@ -695,7 +702,7 @@ endif
foreach name : test_scripts foreach name : test_scripts
script = find_program(name) script = find_program(name)
test(name, script, env: tests_env) test(name, script, env: tests_env, suite: 'script')
endforeach endforeach
testenv = runutf8 testenv = runutf8