diff --git a/scripts/ci.requirements.txt b/scripts/ci.requirements.txt index 7525036441..296c1faaf0 100644 --- a/scripts/ci.requirements.txt +++ b/scripts/ci.requirements.txt @@ -17,3 +17,9 @@ pylint == 2.4.4; platform_system == 'Linux' # https://github.com/Mbed-TLS/mbedtls-framework/issues/50 # mypy 0.942 is the version in Ubuntu 22.04. mypy == 0.942; platform_system == 'Linux' + +# More requirements for scripts in the framework that might not work in +# older versions of Python. Note that requirements that are not available +# in the oldest version of Python on our CI must be annodated with +# "python >= ...". +-r ../framework/util/requirements.txt diff --git a/tests/scripts/check_committed_generated_files.py b/tests/scripts/check_committed_generated_files.py new file mode 100755 index 0000000000..eee4d92023 --- /dev/null +++ b/tests/scripts/check_committed_generated_files.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +""" +Check that TF-PSA-Crypto files that can be regenerated are up-to-date, or update them. +""" + +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +import scripts_path # pylint: disable=unused-import +from mbedtls_framework import config_macros +from mbedtls_framework import generate_files_helper + +GENERATORS = [ + config_macros.Current(shadow_missing_ok=True), +] + +if __name__ == '__main__': + generate_files_helper.main(generators=GENERATORS, + description=__doc__) diff --git a/tests/scripts/check_option_lists.py b/tests/scripts/check_option_lists.py deleted file mode 100755 index c9b643bb6d..0000000000 --- a/tests/scripts/check_option_lists.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python3 - -""" -Check that files with lists of config options are up-to-date, or update them. - -This script checks the following file: -scripts/data_files/config-options-current.txt -""" - -# Copyright The Mbed TLS Contributors -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later - -import argparse -import sys - -import scripts_path # pylint: disable=unused-import -from mbedtls_framework import config_macros - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - # For now this script only acts on one target file. - # If we check/update more files, we should add a way to select which - # file(s) to operate on. - parser.add_argument('--always-update', '-U', - action='store_true', - help=('Update target files unconditionally ' - '(overrides --update)')) - parser.add_argument('--update', '-u', - action='store_true', - help='Update target files if needed') - args = parser.parse_args() - data = config_macros.Current(shadow_missing_ok=True) - if args.update or args.always_update: - data.update_shadow_file(args.always_update) - else: - up_to_date = True - if not data.is_shadow_file_up_to_date(): - print(f'{data.shadow_file_path()} is out of date') - print(f'After adding or removing a config option, you need to run') - print(f'{sys.argv[0]} -u and commit the result.') - up_to_date = False - sys.exit(0 if up_to_date else 1) - -if __name__ == "__main__": - main() diff --git a/tests/scripts/components-basic-checks.sh b/tests/scripts/components-basic-checks.sh index 1e480dd12b..272efe2ae5 100644 --- a/tests/scripts/components-basic-checks.sh +++ b/tests/scripts/components-basic-checks.sh @@ -45,9 +45,21 @@ component_check_generated_files () { # This component ends with the generated files present in the source tree. # This is necessary for subsequent components! +} +support_check_committed_generated_files () { + # Add requirements on the Python installation here for + # the sake of check_committed_generated_files.py in mbedtls. + # + # Check the Python version, not the presence of the package, + # because the CI runs `all.sh --list-components` outside of the + # venv that has our desired packages. + : +} + +component_check_committed_generated_files () { msg "Check committed generated files" - tests/scripts/check_option_lists.py + tests/scripts/check_committed_generated_files.py } component_check_doxy_blocks () {