[RFC,4/5] app/test: define unit tests suites based on test macros
Checks
Commit Message
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.richardson@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
@@ -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
new file mode 100644
@@ -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
new file mode 100644
@@ -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])}")
@@ -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())