This is a workaround for limitations with meson. We'd like to have each migration (sub)test registered with meson's test() function, but since they are all inside the single migration-test.c there's no way for meson to see the tests. We need an external way to generate the list of tests and pass it to meson.
We cannot call 'migration-test -l' because we'd need to build the migration-test binary first and while that is possible, there's no subsequent way to get the generated list into a meson variable for consumption. None of meson's routines support retrieving an arbitrary list of strings from a command at build (vs. configure) time. We also cannot use generators to have 'migration-test' write to a file because that would happen at build time and meson does not support reading from a file in the build directory. So the only approach left is to either have the list of tests committed into the source code or to grep the source code for the list. Committing the file would be harder to maintain and the test registration in migration-test.c is pretty static, so this patch uses the grep approach. But using python because it is more portable. Signed-off-by: Fabiano Rosas <faro...@suse.de> --- tests/qtest/gen_migration_tests_list.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/qtest/gen_migration_tests_list.py diff --git a/tests/qtest/gen_migration_tests_list.py b/tests/qtest/gen_migration_tests_list.py new file mode 100644 index 0000000000..5127f976fa --- /dev/null +++ b/tests/qtest/gen_migration_tests_list.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import re +import sys + +file_path = sys.argv[1] + +with open(file_path, 'r') as f: + for line in f.readlines(): + match = re.search('\"(/migration/.*)\"', line) + if match: + print(match.groups()[0]) -- 2.35.3