blob: 85731a1710c4857784771aa2d4ea0b5b32b864ca [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"
21 make neat
22 $FRAMEWORK/scripts/make_generated_files.py
23 $FRAMEWORK/scripts/make_generated_files.py --check
24 make neat
25
26 msg "Check files generated with make"
27 MBEDTLS_ROOT_DIR="$PWD"
Minos Galanakis85c78f52024-07-26 14:11:08 +010028 make 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
42 # Files for MS Visual Studio are not generated with cmake thus copy the
43 # ones generated with make to pacify make_generated_files.py check.
44 # Files for MS Visual Studio are rather on their way out thus not adding
45 # support for them with cmake.
46 cp -Rf visualc "$OUT_OF_SOURCE_DIR"
47
48 $FRAMEWORK/scripts/make_generated_files.py --root "$OUT_OF_SOURCE_DIR" --check
49
Ronald Cron4cd8fbb2025-03-17 15:33:43 +010050 cd $TF_PSA_CRYPTO_ROOT_DIR
Ronald Cronaa5c1592025-03-07 09:34:41 +010051 ./framework/scripts/make_generated_files.py --root "$OUT_OF_SOURCE_DIR/tf-psa-crypto" --check
Minos Galanakis85c78f52024-07-26 14:11:08 +010052
53 # This component ends with the generated files present in the source tree.
54 # This is necessary for subsequent components!
55}
56
57component_check_doxy_blocks () {
58 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Valerio Setti976b53f2024-12-10 10:49:14 +010059 ./framework/scripts/check-doxy-blocks.pl
Minos Galanakis85c78f52024-07-26 14:11:08 +010060}
61
62component_check_files () {
63 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Elena Uziunaite59fbed82024-11-25 12:25:30 +000064 framework/scripts/check_files.py
Minos Galanakis85c78f52024-07-26 14:11:08 +010065}
66
67component_check_changelog () {
68 msg "Check: changelog entries" # < 1s
69 rm -f ChangeLog.new
Valerio Setti976b53f2024-12-10 10:49:14 +010070 ./framework/scripts/assemble_changelog.py -o ChangeLog.new
Minos Galanakis85c78f52024-07-26 14:11:08 +010071 if [ -e ChangeLog.new ]; then
72 # Show the diff for information. It isn't an error if the diff is
73 # non-empty.
74 diff -u ChangeLog ChangeLog.new || true
75 rm ChangeLog.new
76 fi
77}
78
79component_check_names () {
80 msg "Check: declared and exported names (builds the library)" # < 3s
Valerio Settic9e32b42024-12-13 17:26:16 +010081 framework/scripts/check_names.py -v
Minos Galanakis85c78f52024-07-26 14:11:08 +010082}
83
84component_check_test_cases () {
85 msg "Check: test case descriptions" # < 1s
86 if [ $QUIET -eq 1 ]; then
87 opt='--quiet'
88 else
89 opt=''
90 fi
Gilles Peskine31467722024-10-03 18:52:58 +020091 framework/scripts/check_test_cases.py -q $opt
Minos Galanakis85c78f52024-07-26 14:11:08 +010092 unset opt
93}
94
Minos Galanakis85c78f52024-07-26 14:11:08 +010095component_check_doxygen_warnings () {
96 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Valerio Setti976b53f2024-12-10 10:49:14 +010097 ./framework/scripts/doxygen.sh
Minos Galanakis85c78f52024-07-26 14:11:08 +010098}
99
100component_check_code_style () {
101 msg "Check C code style"
Elena Uziunaitee0d3ffe2024-12-10 15:22:34 +0000102 ./framework/scripts/code_style.py
Minos Galanakis85c78f52024-07-26 14:11:08 +0100103}
104
Minos Galanakisf78447f2024-07-26 20:49:51 +0100105support_check_code_style () {
Minos Galanakis85c78f52024-07-26 14:11:08 +0100106 case $(uncrustify --version) in
107 *0.75.1*) true;;
108 *) false;;
109 esac
110}
111
112component_check_python_files () {
113 msg "Lint: Python scripts"
Valerio Setti976b53f2024-12-10 10:49:14 +0100114 ./framework/scripts/check-python-files.sh
Minos Galanakis85c78f52024-07-26 14:11:08 +0100115}
116
117component_check_test_helpers () {
118 msg "unit test: generate_test_code.py"
119 # unittest writes out mundane stuff like number or tests run on stderr.
120 # Our convention is to reserve stderr for actual errors, and write
121 # harmless info on stdout so it can be suppress with --quiet.
122 ./framework/scripts/test_generate_test_code.py 2>&1
123
124 msg "unit test: translate_ciphers.py"
Elena Uziunaite9669eea2024-10-08 16:41:15 +0100125 python3 -m unittest framework/scripts/translate_ciphers.py 2>&1
Minos Galanakis85c78f52024-07-26 14:11:08 +0100126}