Rather than having the test suites listed out in the meson.build files and having to have them enabled/disabled selectively based on what libs are being built, pull the tests to run from the source files which were added to the build.
Signed-off-by: Bruce Richardson <bruce.richard...@intel.com> --- app/meson.build | 7 ++++++- app/test/suites/meson.build | 29 +++++++++++++++++++++++++++++ buildtools/get-test-suites.py | 24 ++++++++++++++++++++++++ buildtools/meson.build | 1 + 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 app/test/suites/meson.build create mode 100644 buildtools/get-test-suites.py diff --git a/app/meson.build b/app/meson.build index 0d8b618e7f..c14dc80892 100644 --- a/app/meson.build +++ b/app/meson.build @@ -101,7 +101,7 @@ foreach app:apps link_libs = dpdk_static_libraries + dpdk_drivers endif - executable('dpdk-' + name, + exec = executable('dpdk-' + name, sources, c_args: cflags, link_args: ldflags, @@ -110,4 +110,9 @@ foreach app:apps include_directories: includes, install_rpath: join_paths(get_option('prefix'), driver_install_path), install: true) + if name == 'test' + dpdk_test = exec + autotest_sources = sources + subdir('test/suites') # define the pre-canned test suites + endif endforeach diff --git a/app/test/suites/meson.build b/app/test/suites/meson.build new file mode 100644 index 0000000000..135620578c --- /dev/null +++ b/app/test/suites/meson.build @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2023 Intel Corporation + +# some perf tests (eg: memcpy perf autotest)take very long +# to complete, so timeout to 10 minutes +timeout_seconds = 600 + +# process source files to determine the different unit test suites +# - fast_tests +# - perf_tests +# - driver_tests +test_suites = run_command(get_test_suites_cmd, autotest_sources).stdout().strip().split() +foreach suite:test_suites + suite = suite.split('=') + suite_name = suite[0] + suite_tests = suite[1].split(',') + if suite_name == 'fast-tests' + # special fast-test handling here + + else + foreach t: suite_tests + test(t, dpdk_test, + args: ['--', t], + timeout: timeout_seconds, + is_parallel: false, + suite: suite_name) + endforeach + endif +endforeach diff --git a/buildtools/get-test-suites.py b/buildtools/get-test-suites.py new file mode 100644 index 0000000000..43cde80970 --- /dev/null +++ b/buildtools/get-test-suites.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2023 Intel Corporation + +import sys +import re + +input_list = sys.argv[1:] +test_def_regex = re.compile("REGISTER_([A-Z]+)_TEST\s*\(\s*([a-z0-9_]+)") +test_suites = {} + +for fname in input_list: + with open(fname) as f: + contents = [ln for ln in f.readlines() if test_def_regex.match(ln.strip())] + for ln in contents: + (test_suite, test_name) = test_def_regex.match(ln).group(1, 2) + suite_name = f"{test_suite.lower()}-tests" + if suite_name in test_suites: + test_suites[suite_name].append(test_name) + else: + test_suites[suite_name] = [test_name] + +for suite in test_suites.keys(): + print(f"{suite}={','.join(test_suites[suite])}") diff --git a/buildtools/meson.build b/buildtools/meson.build index e1c600e40f..12e4b36165 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -18,6 +18,7 @@ map_to_win_cmd = py3 + files('map_to_win.py') sphinx_wrapper = py3 + files('call-sphinx-build.py') get_cpu_count_cmd = py3 + files('get-cpu-count.py') get_numa_count_cmd = py3 + files('get-numa-count.py') +get_test_suites_cmd = py3 + files('get-test-suites.py') binutils_avx512_check = (py3 + files('binutils-avx512-check.py') + [objdump] + cc.cmd_array()) -- 2.39.2