blob: e791ad065c59e73efe5a4433e2abc261316b96cd [file] [log] [blame]
Minos Galanakis6aab5b72024-07-25 14:24:37 +01001# components-basic-checks.sh
2#
3# Copyright The Mbed TLS Contributors
4# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5
Minos Galanakis609f7492024-07-31 16:39:28 +01006# This file contains test components that are executed by all.sh
Minos Galanakis6aab5b72024-07-25 14:24:37 +01007
8################################################################
9#### Basic checks
10################################################################
11
Minos Galanakis85c78f52024-07-26 14:11:08 +010012component_check_recursion () {
13 msg "Check: recursion.pl" # < 1s
Valerio Setti976b53f2024-12-10 10:49:14 +010014 ./framework/scripts/recursion.pl library/*.c
15 ./framework/scripts/recursion.pl ${PSA_CORE_PATH}/*.c
16 ./framework/scripts/recursion.pl ${BUILTIN_SRC_PATH}/*.c
Minos Galanakis85c78f52024-07-26 14:11:08 +010017}
18
19component_check_generated_files () {
Ronald Cronaa5c1592025-03-07 09:34:41 +010020 msg "Check make_generated_files.py consistency"
Ronald Cron401f20f2025-09-02 14:50:10 +020021 $MAKE_COMMAND neat
Ronald Cronaa5c1592025-03-07 09:34:41 +010022 $FRAMEWORK/scripts/make_generated_files.py
23 $FRAMEWORK/scripts/make_generated_files.py --check
Ronald Cron401f20f2025-09-02 14:50:10 +020024 $MAKE_COMMAND neat
Ronald Cronaa5c1592025-03-07 09:34:41 +010025
26 msg "Check files generated with make"
27 MBEDTLS_ROOT_DIR="$PWD"
Ronald Cron401f20f2025-09-02 14:50:10 +020028 $MAKE_COMMAND generated_files
Ronald Cronaa5c1592025-03-07 09:34:41 +010029 $FRAMEWORK/scripts/make_generated_files.py --check
Minos Galanakis85c78f52024-07-26 14:11:08 +010030
Ronald Cron4cd8fbb2025-03-17 15:33:43 +010031 cd $TF_PSA_CRYPTO_ROOT_DIR
Ronald Cronaa5c1592025-03-07 09:34:41 +010032 ./framework/scripts/make_generated_files.py --check
Minos Galanakis85c78f52024-07-26 14:11:08 +010033
Ronald Cronaa5c1592025-03-07 09:34:41 +010034 msg "Check files generated with cmake"
35 cd "$MBEDTLS_ROOT_DIR"
36 mkdir "$OUT_OF_SOURCE_DIR"
37 cd "$OUT_OF_SOURCE_DIR"
38 cmake -D GEN_FILES=ON "$MBEDTLS_ROOT_DIR"
39 make
40 cd "$MBEDTLS_ROOT_DIR"
41
Ronald Cronaa5c1592025-03-07 09:34:41 +010042 $FRAMEWORK/scripts/make_generated_files.py --root "$OUT_OF_SOURCE_DIR" --check
43
Ronald Cron4cd8fbb2025-03-17 15:33:43 +010044 cd $TF_PSA_CRYPTO_ROOT_DIR
Ronald Cronaa5c1592025-03-07 09:34:41 +010045 ./framework/scripts/make_generated_files.py --root "$OUT_OF_SOURCE_DIR/tf-psa-crypto" --check
Minos Galanakis85c78f52024-07-26 14:11:08 +010046
47 # This component ends with the generated files present in the source tree.
48 # This is necessary for subsequent components!
49}
50
51component_check_doxy_blocks () {
52 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Valerio Setti976b53f2024-12-10 10:49:14 +010053 ./framework/scripts/check-doxy-blocks.pl
Minos Galanakis85c78f52024-07-26 14:11:08 +010054}
55
56component_check_files () {
57 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Elena Uziunaite59fbed82024-11-25 12:25:30 +000058 framework/scripts/check_files.py
Minos Galanakis85c78f52024-07-26 14:11:08 +010059}
60
61component_check_changelog () {
62 msg "Check: changelog entries" # < 1s
63 rm -f ChangeLog.new
Valerio Setti976b53f2024-12-10 10:49:14 +010064 ./framework/scripts/assemble_changelog.py -o ChangeLog.new
Minos Galanakis85c78f52024-07-26 14:11:08 +010065 if [ -e ChangeLog.new ]; then
66 # Show the diff for information. It isn't an error if the diff is
67 # non-empty.
68 diff -u ChangeLog ChangeLog.new || true
69 rm ChangeLog.new
70 fi
71}
72
73component_check_names () {
74 msg "Check: declared and exported names (builds the library)" # < 3s
Valerio Settic9e32b42024-12-13 17:26:16 +010075 framework/scripts/check_names.py -v
Minos Galanakis85c78f52024-07-26 14:11:08 +010076}
77
78component_check_test_cases () {
79 msg "Check: test case descriptions" # < 1s
80 if [ $QUIET -eq 1 ]; then
81 opt='--quiet'
82 else
83 opt=''
84 fi
Gilles Peskine31467722024-10-03 18:52:58 +020085 framework/scripts/check_test_cases.py -q $opt
Minos Galanakis85c78f52024-07-26 14:11:08 +010086 unset opt
87}
88
Minos Galanakis85c78f52024-07-26 14:11:08 +010089component_check_doxygen_warnings () {
90 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Valerio Setti976b53f2024-12-10 10:49:14 +010091 ./framework/scripts/doxygen.sh
Minos Galanakis85c78f52024-07-26 14:11:08 +010092}
93
94component_check_code_style () {
95 msg "Check C code style"
Elena Uziunaitee0d3ffe2024-12-10 15:22:34 +000096 ./framework/scripts/code_style.py
Minos Galanakis85c78f52024-07-26 14:11:08 +010097}
98
Minos Galanakisf78447f2024-07-26 20:49:51 +010099support_check_code_style () {
Minos Galanakis85c78f52024-07-26 14:11:08 +0100100 case $(uncrustify --version) in
101 *0.75.1*) true;;
102 *) false;;
103 esac
104}
105
106component_check_python_files () {
107 msg "Lint: Python scripts"
Valerio Setti976b53f2024-12-10 10:49:14 +0100108 ./framework/scripts/check-python-files.sh
Minos Galanakis85c78f52024-07-26 14:11:08 +0100109}
110
111component_check_test_helpers () {
112 msg "unit test: generate_test_code.py"
113 # unittest writes out mundane stuff like number or tests run on stderr.
114 # Our convention is to reserve stderr for actual errors, and write
115 # harmless info on stdout so it can be suppress with --quiet.
116 ./framework/scripts/test_generate_test_code.py 2>&1
117
118 msg "unit test: translate_ciphers.py"
Elena Uziunaite9669eea2024-10-08 16:41:15 +0100119 python3 -m unittest framework/scripts/translate_ciphers.py 2>&1
Gilles Peskine01def642025-04-25 18:30:47 +0200120
121 msg "unit test: generate_config_checks.py"
122 tests/scripts/test_config_checks.py 2>&1
Minos Galanakis85c78f52024-07-26 14:11:08 +0100123}