On Wed, 10 Jun 2026 00:47, Pierrick Bouvier <[email protected]>
wrote:
We add possibility to declare cflags for a given test. Since we want to
preserve the uniqueness of test binaries, we prevent repeating those
cflags later, for an existing binary.
This ensures one executable == one set of cflags, and if dev needs
duplication, they can use a custom 'exe_name' to override this.
Signed-off-by: Pierrick Bouvier <[email protected]>
---
Reviewed-by: Manos Pitsidianakis <[email protected]>
tests/tcg/meson.build | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
index bb0184732fd..ad56fdf4ab5 100644
--- a/tests/tcg/meson.build
+++ b/tests/tcg/meson.build
@@ -13,6 +13,7 @@ tcg_tests = {}
# 'src_file': {
# 'exe_name': ['provide an alternative binary name'],
# 'test_name': ['provide an alternative test name'],
+# 'cflags': ['cflags to compile test', ...],
# }
# },
# ...
@@ -20,7 +21,8 @@ tcg_tests = {}
# }
# }
#
-# Every test executable, identified by 'exe_name' is built only once.
+# Every test executable, identified by 'exe_name' is built only once, and we
+# ensure cflags are specified only once, on first declaration.
# Tests for a given src use the same executable by default, and their definition
# is guaranteed to be unique also. They can be duplicated by setting
'test_name'.
# Default name is derived from src if 'exe_name' and 'test_name' are omitted.
@@ -51,7 +53,7 @@ foreach target, plan: tcg_tests
foreach src, setup: t
# return a clear error if user mispell a setup entry
foreach key, _ : setup
- if key not in [
+ if key not in ['cflags',
'exe_name', 'test_name',
]
error('unknown tcg setup entry \'' + key + '\' for test ' + src)
@@ -80,6 +82,15 @@ foreach target, plan: tcg_tests
'specify a different \'test_name\'')
endif
+ cflags = []
+ if 'cflags' in setup
+ if exe_name in built_tests
+ error('test ' + exe_name + ' was already built with cflags: ' +
+ 'remove cflags or set \'exe_name\' (if cflags are different)')
+ endif
+ cflags = setup['cflags']
+ endif
+
# build executable if needed
if exe_name not in built_tests
exe = custom_target(exe_name,
@@ -89,7 +100,7 @@ foreach target, plan: tcg_tests
'-MMD', '-MF', '@DEPFILE@',
'-Wall', '-Werror',
'-O0', '-g', '-fno-strict-aliasing',
- ],
+ cflags],
depfile: exe_name + '.d',
output: exe_name + '.test',
build_by_default: false)
--
2.43.0