From e12e7f47de986686c257e549841de557f9851f77 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Fri, 15 Oct 2021 19:10:15 +0100 Subject: [PATCH] Get generated data file list from script Use the generate_psa_tests.py script to generate the list of test data files used as output files by cmake. Do this by introducing a new option --list-for-cmake that prints a semicolon-separated list of the data files with no terminating newline (since this is how a cmake list is represented). Replace the hard-coded output file list with a variable generated by the script using this option. Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 13 ++++++++++--- tests/scripts/generate_psa_tests.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6d54d7c57..ef41f2996 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,11 +17,18 @@ endif() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) if(DEV_MODE) + execute_process( + COMMAND + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + --list-for-cmake + --directory ${CMAKE_CURRENT_BINARY_DIR}/suites + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/.. + OUTPUT_VARIABLE + TEST_SUITE_DATA_FILES) add_custom_command( OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_not_supported.generated.data - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.current.data - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.v0.data + ${TEST_SUITE_DATA_FILES} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. COMMAND diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 260a4c4c9..16e27ee6b 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -699,6 +699,8 @@ def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--list', action='store_true', help='List available targets and exit') + parser.add_argument('--list-for-cmake', action='store_true', + help='Print \';\'-separated list of available targets and exit') parser.add_argument('--directory', metavar='DIR', help='Output directory (default: tests/suites)') parser.add_argument('targets', nargs='*', metavar='TARGET', @@ -710,6 +712,15 @@ def main(args): for name in sorted(generator.TARGETS): print(generator.filename_for(name)) return + # List in a cmake list format (i.e. ';'-separated) + if options.list_for_cmake: + filenames = [] + for name in sorted(generator.TARGETS): + if ';' in generator.filename_for(name): + raise ValueError('Cannot pass filename containing \';\' to cmake: ' + name) + filenames.append(generator.filename_for(name)) + print(';'.join(filenames), end='') + return if options.targets: # Allow "-" as a special case so you can run # ``generate_psa_tests.py - $targets`` and it works uniformly whether