blob: df24b622d9a5636c8cc59bbbbdce8227047a3cf1 [file] [log] [blame]
Gilles Peskine3de7be82020-03-27 16:35:23 +01001#! /usr/bin/env bash
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002
Simon Butcher3ea7f522016-03-07 23:22:10 +00003# all.sh
4#
Bence Szépkúti1e148272020-08-07 13:07:28 +02005# Copyright The Mbed TLS Contributors
Dave Rodgman7ff79652023-11-03 12:04:52 +00006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Gilles Peskine192c72f2017-12-21 15:59:21 +01007
8
9
10################################################################
11#### Documentation
12################################################################
13
Simon Butcher3ea7f522016-03-07 23:22:10 +000014# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010015# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000016#
SimonB2e23c822016-04-16 21:54:39 +010017# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010018#
Gilles Peskine192c72f2017-12-21 15:59:21 +010019# Notes for users
20# ---------------
21#
SimonB2e23c822016-04-16 21:54:39 +010022# Warning: the test is destructive. It includes various build modes and
23# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010024# configuration. The following files must be committed into git:
25# * include/mbedtls/config.h
Gilles Peskine636c26a2020-03-04 20:46:15 +010026# * Makefile, library/Makefile, programs/Makefile, tests/Makefile,
27# programs/fuzz/Makefile
Gilles Peskine192c72f2017-12-21 15:59:21 +010028# After running this script, the CMake cache will be lost and CMake
29# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010030#
Gilles Peskine192c72f2017-12-21 15:59:21 +010031# The script assumes the presence of a number of tools:
32# * Basic Unix tools (Windows users note: a Unix-style find must be before
33# the Windows find in the PATH)
34# * Perl
35# * GNU Make
36# * CMake
37# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040038# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010039# * arm-gcc and mingw-gcc
40# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine549a9612023-08-27 21:39:21 +020041# * OpenSSL and GnuTLS command line tools, in suitable versions for the
42# interoperability tests. The following are the official versions at the
43# time of writing:
44# * GNUTLS_{CLI,SERV} = 3.4.10
45# * GNUTLS_NEXT_{CLI,SERV} = 3.7.2
46# * OPENSSL_LEGACY = 1.0.1j
47# * OPENSSL = 1.0.2g (without Debian/Ubuntu patches)
48# * OPENSSL_NEXT = 1.1.1a
Gilles Peskine192c72f2017-12-21 15:59:21 +010049# See the invocation of check_tools below for details.
50#
51# This script must be invoked from the toplevel directory of a git
52# working copy of Mbed TLS.
53#
Gilles Peskine7105a332020-03-28 18:50:43 +010054# The behavior on an error depends on whether --keep-going (alias -k)
55# is in effect.
56# * Without --keep-going: the script stops on the first error without
57# cleaning up. This lets you work in the configuration of the failing
58# component.
59# * With --keep-going: the script runs all requested components and
60# reports failures at the end. In particular the script always cleans
61# up on exit.
62#
Gilles Peskine192c72f2017-12-21 15:59:21 +010063# Note that the output is not saved. You may want to run
64# script -c tests/scripts/all.sh
65# or
66# tests/scripts/all.sh >all.log 2>&1
67#
68# Notes for maintainers
69# ---------------------
70#
Gilles Peskine8f073122018-11-27 15:58:47 +010071# The bulk of the code is organized into functions that follow one of the
72# following naming conventions:
73# * pre_XXX: things to do before running the tests, in order.
74# * component_XXX: independent components. They can be run in any order.
Gilles Peskinec70637a2019-01-09 22:29:17 +010075# * component_check_XXX: quick tests that aren't worth parallelizing.
76# * component_build_XXX: build things but don't run them.
77# * component_test_XXX: build and test.
Bence Szépkúti44043ed2023-12-15 17:05:15 +010078# * component_release_XXX: tests that the CI should skip during PR testing.
Gilles Peskine878cf602019-01-06 20:50:38 +000079# * support_XXX: if support_XXX exists and returns false then
80# component_XXX is not run by default.
Gilles Peskine8f073122018-11-27 15:58:47 +010081# * post_XXX: things to do after running the tests.
82# * other: miscellaneous support functions.
83#
Gilles Peskinec70637a2019-01-09 22:29:17 +010084# Each component must start by invoking `msg` with a short informative message.
85#
Gilles Peskine39a3b112020-03-28 21:27:40 +010086# Warning: due to the way bash detects errors, the failure of a command
87# inside 'if' or '!' is not detected. Use the 'not' function instead of '!'.
88#
Gilles Peskine7105a332020-03-28 18:50:43 +010089# Each component is executed in a separate shell process. The component
90# fails if any command in it returns a non-zero status.
91#
Gilles Peskinec70637a2019-01-09 22:29:17 +010092# The framework performs some cleanup tasks after each component. This
93# means that components can assume that the working directory is in a
94# cleaned-up state, and don't need to perform the cleanup themselves.
95# * Run `make clean`.
96# * Restore `include/mbedtks/config.h` from a backup made before running
97# the component.
Gilles Peskine636c26a2020-03-04 20:46:15 +010098# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`,
99# `tests/Makefile` and `programs/fuzz/Makefile` from git.
100# This cleans up after an in-tree use of CMake.
Gilles Peskinec70637a2019-01-09 22:29:17 +0100101#
Gilles Peskine192c72f2017-12-21 15:59:21 +0100102# The tests are roughly in order from fastest to slowest. This doesn't
103# have to be exact, but in general you should add slower tests towards
104# the end and fast checks near the beginning.
Gilles Peskine192c72f2017-12-21 15:59:21 +0100105
106
107
108################################################################
109#### Initialization and command line parsing
110################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100111
Gilles Peskine8ab29942020-03-28 18:50:49 +0100112# Abort on errors (even on the left-hand side of a pipe).
113# Treat uninitialised variables as errors.
114set -e -o pipefail -u
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100115
Gilles Peskine79598582022-08-30 21:02:44 +0200116# Enable ksh/bash extended file matching patterns
117shopt -s extglob
118
Gilles Peskine8f073122018-11-27 15:58:47 +0100119pre_check_environment () {
Gilles Peskinea16c2b12019-01-06 19:58:02 +0000120 if [ -d library -a -d include -a -d tests ]; then :; else
Gilles Peskinef08ca832023-09-12 19:21:54 +0200121 echo "Must be run from Mbed TLS root" >&2
Gilles Peskine8f073122018-11-27 15:58:47 +0100122 exit 1
123 fi
124}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100125
Gilles Peskine8f073122018-11-27 15:58:47 +0100126pre_initialize_variables () {
127 CONFIG_H='include/mbedtls/config.h'
John Durkopbd069d32020-10-31 22:14:03 -0700128 CRYPTO_CONFIG_H='include/psa/crypto_config.h'
Gilles Peskine24bdf022020-03-30 20:11:39 +0200129
130 # Files that are clobbered by some jobs will be backed up. Use a different
131 # suffix from auxiliary scripts so that all.sh and auxiliary scripts can
132 # independently decide when to remove the backup file.
133 backup_suffix='.all.bak'
134 # Files clobbered by config.py
135 files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H"
Gilles Peskineef64e7f2021-07-12 18:16:01 +0200136 # Files clobbered by in-tree cmake
137 files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200138
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200139 append_outcome=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100140 MEMORY=0
141 FORCE=0
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200142 QUIET=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100143 KEEP_GOING=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100144
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200145 # Seed value used with the --release-test option.
Manuel Pégourié-Gonnard54304472020-06-22 10:11:47 +0200146 #
147 # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if
148 # both values are kept in sync. If you change the value here because it
149 # breaks some tests, you'll definitely want to change it in
150 # basic-build-test.sh as well.
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200151 RELEASE_SEED=1
152
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200153 : ${MBEDTLS_TEST_OUTCOME_FILE=}
Gilles Peskine9004a172019-09-16 15:20:36 +0200154 : ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200155 export MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine9004a172019-09-16 15:20:36 +0200156 export MBEDTLS_TEST_PLATFORM
157
Jaeden Ameroc4cc2512019-01-30 15:35:44 +0000158 # Default commands, can be overridden by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100159 : ${OPENSSL:="openssl"}
160 : ${OPENSSL_LEGACY:="$OPENSSL"}
161 : ${OPENSSL_NEXT:="$OPENSSL"}
162 : ${GNUTLS_CLI:="gnutls-cli"}
163 : ${GNUTLS_SERV:="gnutls-serv"}
Gilles Peskine8f073122018-11-27 15:58:47 +0100164 : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
165 : ${ARMC5_BIN_DIR:=/usr/bin}
166 : ${ARMC6_BIN_DIR:=/usr/bin}
Gilles Peskine6d061342020-04-30 18:19:32 +0200167 : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200168 : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100169 : ${ARM_LINUX_GNUEABIHF_GCC_PREFIX:=arm-linux-gnueabihf-}
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100170 : ${AARCH64_LINUX_GNU_GCC_PREFIX:=aarch64-linux-gnu-}
Gowtham Suresh Kumarcc029af2023-08-01 09:48:32 +0100171 : ${CLANG_LATEST:="clang-latest"}
172 : ${CLANG_EARLIEST:="clang-earliest"}
173 : ${GCC_LATEST:="gcc-latest"}
174 : ${GCC_EARLIEST:="gcc-earliest"}
Andres AGdc192212016-08-31 17:33:13 +0100175
Gilles Peskine8f073122018-11-27 15:58:47 +0100176 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
Gilles Peskinea1fc4b52019-01-06 20:15:26 +0000177 if [ -z "${MAKEFLAGS+set}" ]; then
Gilles Peskine85229ac2021-09-30 18:24:21 +0200178 export MAKEFLAGS="-j$(all_sh_nproc)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100179 fi
Dave Rodgmane0a2f6d2023-12-18 19:53:25 +0000180 # if CC is not set, use clang by default (if present) to improve build times
181 if [ -z "${CC+set}" ] && (type clang > /dev/null 2>&1); then
Dave Rodgmane42c2352023-12-19 16:08:19 +0000182 export CC="clang"
Dave Rodgman62be4562023-12-18 18:34:50 +0000183 fi
Gilles Peskine878cf602019-01-06 20:50:38 +0000184
Gilles Peskinec761d8f2021-09-20 18:57:55 +0200185 # Include more verbose output for failing tests run by CMake or make
Jaeden Amerod48e9c72019-02-07 17:43:39 +0000186 export CTEST_OUTPUT_ON_FAILURE=1
187
Gilles Peskine8fd59422019-10-21 17:11:33 +0200188 # CFLAGS and LDFLAGS for Asan builds that don't use CMake
Manuel Pégourié-Gonnard717f2302022-11-30 10:42:03 +0100189 # default to -O2, use -Ox _after_ this if you want another level
Manuel Pégourié-Gonnard154b84e2022-11-28 13:12:10 +0100190 ASAN_CFLAGS='-O2 -Werror -fsanitize=address,undefined -fno-sanitize-recover=all'
Gilles Peskine8fd59422019-10-21 17:11:33 +0200191
Andrzej Kurekd95b8ed2023-06-27 10:02:09 -0400192 # Platform tests have an allocation that returns null
193 export ASAN_OPTIONS="allocator_may_return_null=1"
Andrzej Kurek6e4a9be2023-07-05 08:32:43 -0400194 export MSAN_OPTIONS="allocator_may_return_null=1"
Andrzej Kurekd95b8ed2023-06-27 10:02:09 -0400195
Gilles Peskine878cf602019-01-06 20:50:38 +0000196 # Gather the list of available components. These are the functions
197 # defined in this script whose name starts with "component_".
Gowtham Suresh Kumar13850f32023-07-28 16:41:21 +0100198 ALL_COMPONENTS=$(compgen -A function component_ | sed 's/component_//')
Gilles Peskine878cf602019-01-06 20:50:38 +0000199
Dave Rodgman8470d112024-01-16 17:33:34 +0000200 # Delay determining SUPPORTED_COMPONENTS until the command line options have a chance to override
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100201 # the commands set by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100202}
Andres AG38495a32016-07-12 16:54:33 +0100203
Dave Rodgman4cb98a92024-02-26 11:41:19 +0000204setup_quiet_wrappers()
205{
206 # Pick up "quiet" wrappers for make and cmake, which don't output very much
207 # unless there is an error. This reduces logging overhead in the CI.
208 #
209 # Note that the cmake wrapper breaks unless we use an absolute path here.
Dave Rodgmane2317642024-02-26 17:27:18 +0000210 if [[ -e ${PWD}/tests/scripts/quiet ]]; then
211 export PATH=${PWD}/tests/scripts/quiet:$PATH
Dave Rodgman4cb98a92024-02-26 11:41:19 +0000212 fi
213}
214
Gilles Peskinea28db922019-01-10 00:05:18 +0100215# Test whether the component $1 is included in the command line patterns.
216is_component_included()
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100217{
Gilles Peskine6702ce92021-08-06 11:35:17 +0200218 # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS
219 # only does word splitting.
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100220 set -f
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000221 for pattern in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100222 set +f
223 case ${1#component_} in $pattern) return 0;; esac
224 done
225 set +f
226 return 1
227}
Andres AG7770ea82016-10-10 15:46:20 +0100228
Simon Butcher41eeccf2016-09-07 00:07:09 +0100229usage()
Andres AGd9eba4b2016-08-26 14:42:14 +0100230{
Gilles Peskine709346a2017-12-10 23:43:39 +0100231 cat <<EOF
Gilles Peskine92525112018-11-27 18:15:35 +0100232Usage: $0 [OPTION]... [COMPONENT]...
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100233Run mbedtls release validation tests.
Gilles Peskine92525112018-11-27 18:15:35 +0100234By default, run all tests. With one or more COMPONENT, run only those.
Gilles Peskinea28db922019-01-10 00:05:18 +0100235COMPONENT can be the name of a component or a shell wildcard pattern.
236
237Examples:
238 $0 "check_*"
239 Run all sanity checks.
240 $0 --no-armcc --except test_memsan
241 Run everything except builds that require armcc and MemSan.
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100242
243Special options:
244 -h|--help Print this help and exit.
Gilles Peskine878cf602019-01-06 20:50:38 +0000245 --list-all-components List all available test components and exit.
246 --list-components List components supported on this platform and exit.
Gilles Peskine709346a2017-12-10 23:43:39 +0100247
248General options:
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200249 -q|--quiet Only output component names, and errors if any.
Gilles Peskine709346a2017-12-10 23:43:39 +0100250 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100251 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100252 -m|--memory Additional optional memory tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200253 --append-outcome Append to the outcome file (if used).
Gilles Peskine6d061342020-04-30 18:19:32 +0200254 --arm-none-eabi-gcc-prefix=<string>
255 Prefix for a cross-compiler for arm-none-eabi
256 (default: "${ARM_NONE_EABI_GCC_PREFIX}")
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200257 --arm-linux-gnueabi-gcc-prefix=<string>
258 Prefix for a cross-compiler for arm-linux-gnueabi
259 (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}")
Bence Szépkúti61da0dd2024-10-27 22:46:48 +0100260 --arm-linux-gnueabihf-gcc-prefix=<string>
261 Prefix for a cross-compiler for arm-linux-gnueabihf
262 (default: "${ARM_LINUX_GNUEABIHF_GCC_PREFIX}")
263 --aarch64-linux-gnu-gcc-prefix=<string>
264 Prefix for a cross-compiler for aarch64-linux-gnu
265 (default: "${AARCH64_LINUX_GNU_GCC_PREFIX}")
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100266 --armcc Run ARM Compiler builds (on by default).
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200267 --restore First clean up the build tree, restoring backed up
268 files. Do not run any components unless they are
269 explicitly specified.
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100270 --error-test Error test mode: run a failing function in addition
Gilles Peskinea25c5672021-08-05 15:11:33 +0200271 to any specified component. May be repeated.
Gilles Peskinea28db922019-01-10 00:05:18 +0100272 --except Exclude the COMPONENTs listed on the command line,
273 instead of running only those.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200274 --no-append-outcome Write a new outcome file and analyze it (default).
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100275 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100276 --no-force Refuse to overwrite modified files (default).
277 --no-keep-going Stop at the first error (default).
278 --no-memory No additional memory tests (default).
Shaun Case0e7791f2021-12-20 21:14:10 -0800279 --no-quiet Print full output from components.
Gilles Peskine709346a2017-12-10 23:43:39 +0100280 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200281 --outcome-file=<path> File where test outcomes are written (not done if
282 empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
Gilles Peskine38d81652018-03-21 08:40:26 +0100283 --random-seed Use a random seed value for randomized tests (default).
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200284 -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}.
Gilles Peskine709346a2017-12-10 23:43:39 +0100285 -s|--seed Integer seed value to use for this test run.
286
287Tool path options:
288 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
289 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100290 --clang-earliest=<Clang_earliest_path> Earliest version of clang available
291 --clang-latest=<Clang_latest_path> Latest version of clang available
292 --gcc-earliest=<GCC_earliest_path> Earliest version of GCC available
293 --gcc-latest=<GCC_latest_path> Latest version of GCC available
Gilles Peskine709346a2017-12-10 23:43:39 +0100294 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
295 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
Gilles Peskine709346a2017-12-10 23:43:39 +0100296 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
297 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100298 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100299EOF
SimonB2e23c822016-04-16 21:54:39 +0100300}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100301
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200302# Cleanup before/after running a component.
303# Remove built files as well as the cmake cache/config.
304# Does not remove generated source files.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100305cleanup()
306{
Gilles Peskine7c652162017-12-11 00:01:40 +0100307 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200308
Gilles Peskine31b07e22018-03-21 12:15:06 +0100309 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000310 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100311 -iname CMakeFiles -exec rm -rf {} \+ -o \
312 \( -iname cmake_install.cmake -o \
313 -iname CTestTestfile.cmake -o \
314 -iname CMakeCache.txt \) -exec rm {} \+
Ronald Crone3bdbd52024-06-12 10:04:22 +0200315 # Remove Makefiles generated by in-tree CMake builds
316 rm -f 3rdparty/Makefile 3rdparty/*/Makefile pkgconfig/Makefile
317 rm -f include/Makefile programs/!(fuzz)/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200318
Jaeden Ameroab83fdf2019-06-20 17:38:22 +0100319 # Remove any artifacts from the component_test_cmake_as_subdirectory test.
320 rm -rf programs/test/cmake_subproject/build
321 rm -f programs/test/cmake_subproject/Makefile
322 rm -f programs/test/cmake_subproject/cmake_subproject
323
Gilles Peskine24bdf022020-03-30 20:11:39 +0200324 # Restore files that may have been clobbered by the job
325 for x in $files_to_back_up; do
Gilles Peskine423dd132022-08-30 21:02:00 +0200326 if [[ -e "$x$backup_suffix" ]]; then
327 cp -p "$x$backup_suffix" "$x"
328 fi
Gilles Peskine24bdf022020-03-30 20:11:39 +0200329 done
330}
John Durkopbd069d32020-10-31 22:14:03 -0700331
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200332# Final cleanup when this script exits (except when exiting on a failure
333# in non-keep-going mode).
Gilles Peskine24bdf022020-03-30 20:11:39 +0200334final_cleanup () {
335 cleanup
336
337 for x in $files_to_back_up; do
338 rm -f "$x$backup_suffix"
339 done
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100340}
341
Gilles Peskine7c652162017-12-11 00:01:40 +0100342# Executed on exit. May be redefined depending on command line options.
343final_report () {
344 :
345}
346
347fatal_signal () {
Gilles Peskine24bdf022020-03-30 20:11:39 +0200348 final_cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100349 final_report $1
350 trap - $1
351 kill -$1 $$
352}
353
354trap 'fatal_signal HUP' HUP
355trap 'fatal_signal INT' INT
356trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200357
Gilles Peskine85229ac2021-09-30 18:24:21 +0200358# Number of processors on this machine. Used as the default setting
359# for parallel make.
360all_sh_nproc ()
361{
362 {
363 nproc || # Linux
364 sysctl -n hw.ncpuonline || # NetBSD, OpenBSD
365 sysctl -n hw.ncpu || # FreeBSD
366 echo 1
367 } 2>/dev/null
368}
369
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100370msg()
371{
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100372 if [ -n "${current_component:-}" ]; then
373 current_section="${current_component#component_}: $1"
374 else
375 current_section="$1"
376 fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200377
378 if [ $QUIET -eq 1 ]; then
379 return
380 fi
381
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100382 echo ""
383 echo "******************************************************************"
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100384 echo "* $current_section "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000385 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100386 echo "******************************************************************"
387}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100388
Gilles Peskine8f073122018-11-27 15:58:47 +0100389armc6_build_test()
390{
391 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100392
Gilles Peskine18487f62020-04-30 23:11:54 +0200393 msg "build: ARM Compiler 6 ($FLAGS)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100394 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
Dave Rodgman6cda3d32023-03-02 13:39:04 +0000395 WARNING_CFLAGS='-Werror -xc -std=c99' make lib
Gilles Peskine18487f62020-04-30 23:11:54 +0200396
397 msg "size: ARM Compiler 6 ($FLAGS)"
398 "$ARMC6_FROMELF" -z library/*.o
399
Gilles Peskine8f073122018-11-27 15:58:47 +0100400 make clean
401}
Andres AGa5cd9732016-10-17 15:23:10 +0100402
Andres AGd9eba4b2016-08-26 14:42:14 +0100403err_msg()
404{
405 echo "$1" >&2
406}
407
408check_tools()
409{
410 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000411 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100412 err_msg "$TOOL not found!"
413 exit 1
414 fi
415 done
416}
417
Gilles Peskine8f073122018-11-27 15:58:47 +0100418pre_parse_command_line () {
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000419 COMMAND_LINE_COMPONENTS=
Gilles Peskinea28db922019-01-10 00:05:18 +0100420 all_except=0
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100421 error_test=0
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100422 list_components=0
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200423 restore_first=0
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000424 no_armcc=
SimonB2e23c822016-04-16 21:54:39 +0100425
Jaeden Amero9b90f2e2018-11-02 18:34:17 +0000426 # Note that legacy options are ignored instead of being omitted from this
427 # list of options, so invocations that worked with previous version of
428 # all.sh will still run and work properly.
Gilles Peskine8f073122018-11-27 15:58:47 +0100429 while [ $# -gt 0 ]; do
Gilles Peskine55f7c942019-01-09 22:28:21 +0100430 case "$1" in
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200431 --append-outcome) append_outcome=1;;
Gilles Peskine6d061342020-04-30 18:19:32 +0200432 --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200433 --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";;
Bence Szépkúti61da0dd2024-10-27 22:46:48 +0100434 --arm-linux-gnueabihf-gcc-prefix) shift; ARM_LINUX_GNUEABIHF_GCC_PREFIX="$1";;
435 --aarch64-linux-gnu-gcc-prefix) shift; AARCH64_LINUX_GNU_GCC_PREFIX="$1";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000436 --armcc) no_armcc=;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100437 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
438 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100439 --clang-earliest) shift; CLANG_EARLIEST="$1";;
440 --clang-latest) shift; CLANG_LATEST="$1";;
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100441 --error-test) error_test=$((error_test + 1));;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000442 --except) all_except=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100443 --force|-f) FORCE=1;;
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100444 --gcc-earliest) shift; GCC_EARLIEST="$1";;
445 --gcc-latest) shift; GCC_LATEST="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100446 --gnutls-cli) shift; GNUTLS_CLI="$1";;
Gilles Peskine549a9612023-08-27 21:39:21 +0200447 --gnutls-legacy-cli) shift;; # ignored for backward compatibility
448 --gnutls-legacy-serv) shift;; # ignored for backward compatibility
Gilles Peskine55f7c942019-01-09 22:28:21 +0100449 --gnutls-serv) shift; GNUTLS_SERV="$1";;
450 --help|-h) usage; exit;;
451 --keep-going|-k) KEEP_GOING=1;;
Gilles Peskine878cf602019-01-06 20:50:38 +0000452 --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100453 --list-components) list_components=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100454 --memory|-m) MEMORY=1;;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200455 --no-append-outcome) append_outcome=0;;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000456 --no-armcc) no_armcc=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100457 --no-force) FORCE=0;;
458 --no-keep-going) KEEP_GOING=0;;
459 --no-memory) MEMORY=0;;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200460 --no-quiet) QUIET=0;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100461 --openssl) shift; OPENSSL="$1";;
462 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
463 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200464 --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100465 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200466 --quiet|-q) QUIET=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100467 --random-seed) unset SEED;;
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200468 --release-test|-r) SEED=$RELEASE_SEED;;
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200469 --restore) restore_first=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100470 --seed|-s) shift; SEED="$1";;
471 -*)
472 echo >&2 "Unknown option: $1"
473 echo >&2 "Run $0 --help for usage."
474 exit 120
475 ;;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000476 *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100477 esac
478 shift
Gilles Peskine8f073122018-11-27 15:58:47 +0100479 done
SimonB2e23c822016-04-16 21:54:39 +0100480
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100481 # Exclude components that are not supported on this platform.
482 SUPPORTED_COMPONENTS=
483 for component in $ALL_COMPONENTS; do
484 case $(type "support_$component" 2>&1) in
485 *' function'*)
486 if ! support_$component; then continue; fi;;
487 esac
488 SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
489 done
490
491 if [ $list_components -eq 1 ]; then
492 printf '%s\n' $SUPPORTED_COMPONENTS
493 exit
494 fi
495
Gilles Peskinea28db922019-01-10 00:05:18 +0100496 # With no list of components, run everything.
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200497 if [ -z "$COMMAND_LINE_COMPONENTS" ] && [ $restore_first -eq 0 ]; then
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000498 all_except=1
Andres AGdc192212016-08-31 17:33:13 +0100499 fi
500
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000501 # --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
502 # Ignore it if components are listed explicitly on the command line.
Gilles Peskinea28db922019-01-10 00:05:18 +0100503 if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000504 COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
SimonB2e23c822016-04-16 21:54:39 +0100505 fi
SimonB2e23c822016-04-16 21:54:39 +0100506
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200507 # Error out if an explicitly requested component doesn't exist.
Gilles Peskinee8056c52020-03-28 21:37:59 +0100508 if [ $all_except -eq 0 ]; then
509 unsupported=0
Gilles Peskine6702ce92021-08-06 11:35:17 +0200510 # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS
511 # only does word splitting.
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200512 set -f
Gilles Peskinee8056c52020-03-28 21:37:59 +0100513 for component in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200514 set +f
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200515 # If the requested name includes a wildcard character, don't
516 # check it. Accept wildcard patterns that don't match anything.
Gilles Peskinee8056c52020-03-28 21:37:59 +0100517 case $component in
518 *[*?\[]*) continue;;
519 esac
520 case " $SUPPORTED_COMPONENTS " in
521 *" $component "*) :;;
522 *)
523 echo >&2 "Component $component was explicitly requested, but is not known or not supported."
524 unsupported=$((unsupported + 1));;
525 esac
526 done
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200527 set +f
Gilles Peskinee8056c52020-03-28 21:37:59 +0100528 if [ $unsupported -ne 0 ]; then
529 exit 2
530 fi
531 fi
532
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000533 # Build the list of components to run.
Gilles Peskinea28db922019-01-10 00:05:18 +0100534 RUN_COMPONENTS=
535 for component in $SUPPORTED_COMPONENTS; do
536 if is_component_included "$component"; [ $? -eq $all_except ]; then
537 RUN_COMPONENTS="$RUN_COMPONENTS $component"
538 fi
539 done
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000540
541 unset all_except
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000542 unset no_armcc
Gilles Peskine8f073122018-11-27 15:58:47 +0100543}
SimonB2e23c822016-04-16 21:54:39 +0100544
Gilles Peskine8f073122018-11-27 15:58:47 +0100545pre_check_git () {
546 if [ $FORCE -eq 1 ]; then
Gilles Peskine53190e62019-01-09 23:17:35 +0100547 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +0100548 git checkout-index -f -q $CONFIG_H
549 cleanup
550 else
SimonB2e23c822016-04-16 21:54:39 +0100551
Gilles Peskine8f073122018-11-27 15:58:47 +0100552 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
553 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
554 echo "You can either delete this directory manually, or force the test by rerunning"
555 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
556 exit 1
557 fi
558
Gilles Peskined1174cf2019-01-09 22:30:01 +0100559 if ! git diff --quiet include/mbedtls/config.h; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100560 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
561 echo "You can either delete or preserve your work, or force the test by rerunning the"
562 echo "script as: $0 --force"
563 exit 1
564 fi
SimonB2e23c822016-04-16 21:54:39 +0100565 fi
Andrzej Kurekeb508712019-02-14 07:18:59 -0500566}
567
Gilles Peskineef64e7f2021-07-12 18:16:01 +0200568pre_restore_files () {
569 # If the makefiles have been generated by a framework such as cmake,
570 # restore them from git. If the makefiles look like modifications from
571 # the ones checked into git, take care not to modify them. Whatever
572 # this function leaves behind is what the script will restore before
573 # each component.
574 case "$(head -n1 Makefile)" in
575 *[Gg]enerated*)
576 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
577 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
578 ;;
579 esac
580}
581
Gilles Peskine24bdf022020-03-30 20:11:39 +0200582pre_back_up () {
583 for x in $files_to_back_up; do
584 cp -p "$x" "$x$backup_suffix"
585 done
586}
587
Gilles Peskine8f073122018-11-27 15:58:47 +0100588pre_setup_keep_going () {
Gilles Peskine7105a332020-03-28 18:50:43 +0100589 failure_count=0 # Number of failed components
590 last_failure_status=0 # Last failure status in this component
591
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100592 # See err_trap
593 previous_failure_status=0
594 previous_failed_command=
595 previous_failure_funcall_depth=0
Gilles Peskine39a3b112020-03-28 21:27:40 +0100596 unset report_failed_command
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100597
Gilles Peskine7c652162017-12-11 00:01:40 +0100598 start_red=
599 end_color=
600 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100601 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100602 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
603 start_red=$(printf '\033[31m')
604 end_color=$(printf '\033[0m')
605 ;;
606 esac
607 fi
Gilles Peskine7105a332020-03-28 18:50:43 +0100608
609 # Keep a summary of failures in a file. We'll print it out at the end.
610 failure_summary_file=$PWD/all-sh-failures-$$.log
611 : >"$failure_summary_file"
612
613 # Whether it makes sense to keep a component going after the specified
614 # command fails (test command) or not (configure or build).
Gilles Peskine6702ce92021-08-06 11:35:17 +0200615 # This function normally receives the failing simple command
616 # ($BASH_COMMAND) as an argument, but if $report_failed_command is set,
617 # this is passed instead.
Gilles Peskine7105a332020-03-28 18:50:43 +0100618 # This doesn't have to be 100% accurate: all failures are recorded anyway.
Gilles Peskine76d40fa2021-08-02 23:29:53 +0200619 # False positives result in running things that can't be expected to
620 # work. False negatives result in things not running after something else
621 # failed even though they might have given useful feedback.
Gilles Peskine7105a332020-03-28 18:50:43 +0100622 can_keep_going_after_failure () {
623 case "$1" in
624 "msg "*) false;;
Gilles Peskine76d40fa2021-08-02 23:29:53 +0200625 "cd "*) false;;
626 *make*[\ /]tests*) false;; # make tests, make CFLAGS=-I../tests, ...
627 *test*) true;; # make test, tests/stuff, env V=v tests/stuff, ...
628 *make*check*) true;;
629 "grep "*) true;;
630 "[ "*) true;;
631 "! "*) true;;
Gilles Peskine7105a332020-03-28 18:50:43 +0100632 *) false;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100633 esac
634 }
Gilles Peskine7105a332020-03-28 18:50:43 +0100635
636 # This function runs if there is any error in a component.
637 # It must either exit with a nonzero status, or set
638 # last_failure_status to a nonzero value.
639 err_trap () {
640 # Save $? (status of the failing command). This must be the very
641 # first thing, before $? is overridden.
642 last_failure_status=$?
Gilles Peskine39a3b112020-03-28 21:27:40 +0100643 failed_command=${report_failed_command-$BASH_COMMAND}
Gilles Peskine7105a332020-03-28 18:50:43 +0100644
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100645 if [[ $last_failure_status -eq $previous_failure_status &&
646 "$failed_command" == "$previous_failed_command" &&
647 ${#FUNCNAME[@]} == $((previous_failure_funcall_depth - 1)) ]]
648 then
649 # The same command failed twice in a row, but this time one level
650 # less deep in the function call stack. This happens when the last
651 # command of a function returns a nonzero status, and the function
652 # returns that same status. Ignore the second failure.
653 previous_failure_funcall_depth=${#FUNCNAME[@]}
654 return
655 fi
656 previous_failure_status=$last_failure_status
657 previous_failed_command=$failed_command
658 previous_failure_funcall_depth=${#FUNCNAME[@]}
659
Gilles Peskine7105a332020-03-28 18:50:43 +0100660 text="$current_section: $failed_command -> $last_failure_status"
661 echo "${start_red}^^^^$text^^^^${end_color}" >&2
662 echo "$text" >>"$failure_summary_file"
663
664 # If the command is fatal (configure or build command), stop this
665 # component. Otherwise (test command) keep the component running
666 # (run more tests from the same build).
667 if ! can_keep_going_after_failure "$failed_command"; then
668 exit $last_failure_status
669 fi
670 }
671
Gilles Peskine7c652162017-12-11 00:01:40 +0100672 final_report () {
673 if [ $failure_count -gt 0 ]; then
674 echo
675 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Gilles Peskine7105a332020-03-28 18:50:43 +0100676 echo "${start_red}FAILED: $failure_count components${end_color}"
677 cat "$failure_summary_file"
Gilles Peskine7c652162017-12-11 00:01:40 +0100678 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
679 elif [ -z "${1-}" ]; then
680 echo "SUCCESS :)"
681 fi
682 if [ -n "${1-}" ]; then
683 echo "Killed by SIG$1."
684 fi
Gilles Peskine7105a332020-03-28 18:50:43 +0100685 rm -f "$failure_summary_file"
686 if [ $failure_count -gt 0 ]; then
687 exit 1
688 fi
Gilles Peskine7c652162017-12-11 00:01:40 +0100689 }
Gilles Peskine8f073122018-11-27 15:58:47 +0100690}
691
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200692# record_status() and if_build_succeeded() are kept temporarily for backward
693# compatibility. Don't use them in new components.
Gilles Peskine7105a332020-03-28 18:50:43 +0100694record_status () {
695 "$@"
Gilles Peskine7c652162017-12-11 00:01:40 +0100696}
Gilles Peskine7c652162017-12-11 00:01:40 +0100697if_build_succeeded () {
Gilles Peskine7105a332020-03-28 18:50:43 +0100698 "$@"
Gilles Peskine7c652162017-12-11 00:01:40 +0100699}
700
Gilles Peskine39a3b112020-03-28 21:27:40 +0100701# '! true' does not trigger the ERR trap. Arrange to trigger it, with
702# a reasonably informative error message (not just "$@").
703not () {
704 if "$@"; then
705 report_failed_command="! $*"
706 false
707 unset report_failed_command
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200708 fi
709}
710
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200711pre_prepare_outcome_file () {
712 case "$MBEDTLS_TEST_OUTCOME_FILE" in
713 [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
714 esac
715 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then
716 rm -f "$MBEDTLS_TEST_OUTCOME_FILE"
717 fi
718}
719
Gilles Peskine8f073122018-11-27 15:58:47 +0100720pre_print_configuration () {
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200721 if [ $QUIET -eq 1 ]; then
722 return
723 fi
724
Gilles Peskine8f073122018-11-27 15:58:47 +0100725 msg "info: $0 configuration"
726 echo "MEMORY: $MEMORY"
727 echo "FORCE: $FORCE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200728 echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}"
Gilles Peskine8f073122018-11-27 15:58:47 +0100729 echo "SEED: ${SEED-"UNSET"}"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100730 echo
Gilles Peskine8f073122018-11-27 15:58:47 +0100731 echo "OPENSSL: $OPENSSL"
732 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
733 echo "OPENSSL_NEXT: $OPENSSL_NEXT"
734 echo "GNUTLS_CLI: $GNUTLS_CLI"
735 echo "GNUTLS_SERV: $GNUTLS_SERV"
Gilles Peskine8f073122018-11-27 15:58:47 +0100736 echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
737 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
738}
Andres AG7770ea82016-10-10 15:46:20 +0100739
Andres AGd9eba4b2016-08-26 14:42:14 +0100740# Make sure the tools we need are available.
Gilles Peskine8f073122018-11-27 15:58:47 +0100741pre_check_tools () {
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000742 # Build the list of variables to pass to output_env.sh.
743 set env
SimonB2e23c822016-04-16 21:54:39 +0100744
Gilles Peskine87964262019-01-06 22:40:00 +0000745 case " $RUN_COMPONENTS " in
746 # Require OpenSSL and GnuTLS if running any tests (as opposed to
747 # only doing builds). Not all tests run OpenSSL and GnuTLS, but this
748 # is a good enough approximation in practice.
Bence Szépkúticb89fbd2023-12-15 20:58:15 +0100749 *" test_"* | *" release_test_"*)
Gilles Peskine87964262019-01-06 22:40:00 +0000750 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh
751 # and ssl-opt.sh, we just export the variables they require.
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +0100752 export OPENSSL="$OPENSSL"
Gilles Peskine87964262019-01-06 22:40:00 +0000753 export GNUTLS_CLI="$GNUTLS_CLI"
754 export GNUTLS_SERV="$GNUTLS_SERV"
755 # Avoid passing --seed flag in every call to ssl-opt.sh
756 if [ -n "${SEED-}" ]; then
757 export SEED
758 fi
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000759 set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY"
760 set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000761 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
Gilles Peskine549a9612023-08-27 21:39:21 +0200762 "$GNUTLS_CLI" "$GNUTLS_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000763 ;;
764 esac
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200765
Gilles Peskine87964262019-01-06 22:40:00 +0000766 case " $RUN_COMPONENTS " in
767 *_doxygen[_\ ]*) check_tools "doxygen" "dot";;
768 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100769
Gilles Peskine87964262019-01-06 22:40:00 +0000770 case " $RUN_COMPONENTS " in
Gilles Peskine6d061342020-04-30 18:19:32 +0200771 *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";;
Gilles Peskine87964262019-01-06 22:40:00 +0000772 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100773
Gilles Peskine87964262019-01-06 22:40:00 +0000774 case " $RUN_COMPONENTS " in
775 *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";;
776 esac
777
778 case " $RUN_COMPONENTS " in
779 *" test_zeroize "*) check_tools "gdb";;
780 esac
781
782 case " $RUN_COMPONENTS " in
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000783 *_armcc*)
Gilles Peskine87964262019-01-06 22:40:00 +0000784 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
785 ARMC5_AR="$ARMC5_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200786 ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf"
Gilles Peskine87964262019-01-06 22:40:00 +0000787 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
788 ARMC6_AR="$ARMC6_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200789 ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf"
790 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \
791 "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000792 esac
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000793
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200794 # past this point, no call to check_tool, only printing output
795 if [ $QUIET -eq 1 ]; then
796 return
797 fi
798
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000799 msg "info: output_env.sh"
800 case $RUN_COMPONENTS in
801 *_armcc*)
802 set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;;
803 *) set "$@" RUN_ARMCC=0;;
804 esac
805 "$@" scripts/output_env.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100806}
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100807
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100808gcc_version() {
Bence Szépkúti26822ab2024-07-12 14:00:29 +0100809 gcc="$1"
810 if command -v "$gcc" > /dev/null ; then
811 "$gcc" --version | sed -En '1s/^[^ ]* \([^)]*\) ([0-9]+).*/\1/p'
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100812 else
Bence Szépkúti26822ab2024-07-12 14:00:29 +0100813 echo 0 # report version 0 for "no gcc"
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100814 fi
815}
816
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100817can_run_cc_output() {
818 cc="$1"
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100819 result=false
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100820 if type "$cc" >/dev/null 2>&1; then
821 testbin=$(mktemp)
822 if echo 'int main(void){return 0;}' | "$cc" -o "$testbin" -x c -; then
823 if "$testbin" 2>/dev/null; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100824 result=true
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100825 fi
826 fi
Bence Szépkúti08c14d12024-07-12 20:33:15 +0100827 rm -f "$testbin"
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100828 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100829 $result
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100830}
831
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100832can_run_arm_linux_gnueabi=
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100833can_run_arm_linux_gnueabi () {
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100834 if [ -z "$can_run_arm_linux_gnueabi" ]; then
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100835 if can_run_cc_output "${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc"; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100836 can_run_arm_linux_gnueabi=true
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100837 else
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100838 can_run_arm_linux_gnueabi=false
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100839 fi
840 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100841 $can_run_arm_linux_gnueabi
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100842}
843
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100844can_run_arm_linux_gnueabihf=
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100845can_run_arm_linux_gnueabihf () {
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100846 if [ -z "$can_run_arm_linux_gnueabihf" ]; then
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100847 if can_run_cc_output "${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc"; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100848 can_run_arm_linux_gnueabihf=true
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100849 else
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100850 can_run_arm_linux_gnueabihf=false
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100851 fi
852 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100853 $can_run_arm_linux_gnueabihf
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100854}
855
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100856can_run_aarch64_linux_gnu=
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100857can_run_aarch64_linux_gnu () {
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100858 if [ -z "$can_run_aarch64_linux_gnu" ]; then
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100859 if can_run_cc_output "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc"; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100860 can_run_aarch64_linux_gnu=true
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100861 else
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100862 can_run_aarch64_linux_gnu=false
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100863 fi
864 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100865 $can_run_aarch64_linux_gnu
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100866}
867
Gilles Peskine192c72f2017-12-21 15:59:21 +0100868
869
870################################################################
871#### Basic checks
872################################################################
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100873
874#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200875# Test Suites to be executed
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100876#
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100877# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200878# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100879# and/or are more likely to fail than others (eg I use Clang most of the
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200880# time, so start with a GCC build).
881# 2. Minimize total running time, by avoiding useless rebuilds
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100882#
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100883# Indicative running times are given for reference.
884
Gilles Peskine8f073122018-11-27 15:58:47 +0100885component_check_recursion () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200886 msg "Check: recursion.pl" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200887 tests/scripts/recursion.pl library/*.c
Gilles Peskine8f073122018-11-27 15:58:47 +0100888}
Janos Follathb72c6782016-07-19 14:54:17 +0100889
Gilles Peskine8f073122018-11-27 15:58:47 +0100890component_check_generated_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200891 msg "Check: freshness of generated source files" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200892 tests/scripts/check-generated-files.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100893}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200894
Gilles Peskine8f073122018-11-27 15:58:47 +0100895component_check_doxy_blocks () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200896 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200897 tests/scripts/check-doxy-blocks.pl
Gilles Peskine8f073122018-11-27 15:58:47 +0100898}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200899
Gilles Peskine8f073122018-11-27 15:58:47 +0100900component_check_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200901 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200902 tests/scripts/check_files.py
Gilles Peskine8f073122018-11-27 15:58:47 +0100903}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200904
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200905component_check_changelog () {
906 msg "Check: changelog entries" # < 1s
907 rm -f ChangeLog.new
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200908 scripts/assemble_changelog.py -o ChangeLog.new
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200909 if [ -e ChangeLog.new ]; then
910 # Show the diff for information. It isn't an error if the diff is
911 # non-empty.
912 diff -u ChangeLog ChangeLog.new || true
913 rm ChangeLog.new
914 fi
915}
916
Gilles Peskine8f073122018-11-27 15:58:47 +0100917component_check_names () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200918 msg "Check: declared and exported names (builds the library)" # < 3s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200919 tests/scripts/check_names.py -v
Gilles Peskine8f073122018-11-27 15:58:47 +0100920}
Darryl Greena07039c2018-03-13 16:48:16 +0000921
Gilles Peskine895868b2019-09-19 21:30:05 +0200922component_check_test_cases () {
923 msg "Check: test case descriptions" # < 1s
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200924 if [ $QUIET -eq 1 ]; then
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200925 opt='--quiet'
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200926 else
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200927 opt=''
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200928 fi
Gilles Peskine58987962022-12-15 14:46:31 +0100929 tests/scripts/check_test_cases.py -q $opt
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200930 unset opt
Gilles Peskine895868b2019-09-19 21:30:05 +0200931}
932
Gilles Peskine8f073122018-11-27 15:58:47 +0100933component_check_doxygen_warnings () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200934 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200935 tests/scripts/doxygen.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100936}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200937
Gilles Peskine192c72f2017-12-21 15:59:21 +0100938
Gilles Peskine636c26a2020-03-04 20:46:15 +0100939
Gilles Peskine192c72f2017-12-21 15:59:21 +0100940################################################################
941#### Build and test many configurations and targets
942################################################################
943
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200944component_test_default_out_of_box () {
945 msg "build: make, default config (out-of-box)" # ~1min
946 make
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200947 # Disable fancy stuff
948 unset MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200949
950 msg "test: main suites make, default config (out-of-box)" # ~10s
951 make test
952
953 msg "selftest: make, default config (out-of-box)" # ~10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200954 programs/test/selftest
Gilles Peskine93aaf2e2019-06-14 18:27:03 +0200955
956 msg "program demos: make, default config (out-of-box)" # ~10s
957 tests/scripts/run_demos.py
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200958}
959
Gilles Peskinea8cd2e62024-05-17 19:00:46 +0200960component_build_without_check_config () {
961 msg "build: full without check_config.h"
962 scripts/config.py full
963 sed -i '/#include.*check_config\.h/ s!^!//!' "$CONFIG_H"
964 make
965}
966
Gilles Peskine8f073122018-11-27 15:58:47 +0100967component_test_default_cmake_gcc_asan () {
968 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Gilles Peskine8f073122018-11-27 15:58:47 +0100969 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
970 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200971
Gilles Peskine8f073122018-11-27 15:58:47 +0100972 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
973 make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200974
Gilles Peskine93aaf2e2019-06-14 18:27:03 +0200975 msg "program demos (ASan build)" # ~10s
976 tests/scripts/run_demos.py
977
Gilles Peskine97bea012020-04-23 23:37:45 +0200978 msg "test: selftest (ASan build)" # ~ 10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200979 programs/test/selftest
Gilles Peskine97bea012020-04-23 23:37:45 +0200980
Gilles Peskineee8af062023-11-02 19:58:03 +0100981 msg "test: metatests (GCC, ASan build)"
David Horstmann1b421b12024-01-17 14:53:08 +0000982 tests/scripts/run-metatests.sh any asan poison
Gilles Peskineee8af062023-11-02 19:58:03 +0100983
Gilles Peskine8f073122018-11-27 15:58:47 +0100984 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200985 tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200986
Gilles Peskine8f073122018-11-27 15:58:47 +0100987 msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200988 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200989
990 msg "test: context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200991 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100992}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200993
Hanno Becker01635512019-02-26 14:27:09 +0000994component_test_full_cmake_gcc_asan () {
995 msg "build: full config, cmake, gcc, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200996 scripts/config.py full
Hanno Becker01635512019-02-26 14:27:09 +0000997 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
998 make
999
1000 msg "test: main suites (inc. selftests) (full config, ASan build)"
1001 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001002
Gilles Peskine97bea012020-04-23 23:37:45 +02001003 msg "test: selftest (ASan build)" # ~ 10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001004 programs/test/selftest
Gilles Peskine97bea012020-04-23 23:37:45 +02001005
Gilles Peskine636c26a2020-03-04 20:46:15 +01001006 msg "test: ssl-opt.sh (full config, ASan build)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001007 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001008
Manuel Pégourié-Gonnardb76606c2024-04-17 12:15:51 +02001009 msg "test: compat.sh all except legacy/next (full config, ASan build)"
1010 tests/compat.sh -e '^DES-CBC-\|-DES-CBC-\|ARIA\|CHACHA' \
1011 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
1012
1013 msg "test: compat.sh single-DES (full config, ASan build)"
1014 env OPENSSL="$OPENSSL_LEGACY" tests/compat.sh -e '^$' -f '^DES-CBC\|-DES-CBC-' \
1015 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
1016
1017 # ARIA and ChachaPoly are both (D)TLS 1.2 only
1018 msg "test: compat.sh ARIA + ChachaPoly (full config, ASan build)"
1019 env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' \
Manuel Pégourié-Gonnardde887ba2024-04-18 10:05:04 +02001020 -m 'tls12 dtls12'
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001021
1022 msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001023 tests/context-info.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001024}
1025
Ronald Cronc3623db2020-10-29 10:51:32 +01001026component_test_psa_crypto_key_id_encodes_owner () {
1027 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
1028 scripts/config.py full
1029 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1030 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1031 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1032 make
1033
1034 msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
1035 make test
1036}
1037
David Horstmann42015332024-03-13 15:42:31 +00001038component_test_psa_assume_exclusive_buffers () {
1039 msg "build: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan"
David Horstmanndda52ae2023-12-20 11:10:16 +00001040 scripts/config.py full
David Horstmann42015332024-03-13 15:42:31 +00001041 scripts/config.py set MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS
David Horstmanndda52ae2023-12-20 11:10:16 +00001042 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1043 make
1044
David Horstmann42015332024-03-13 15:42:31 +00001045 msg "test: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan"
David Horstmanndda52ae2023-12-20 11:10:16 +00001046 make test
1047}
1048
Gilles Peskine99a34622021-06-17 11:37:52 +02001049# check_renamed_symbols HEADER LIB
1050# Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol
1051# name is LIB.
1052check_renamed_symbols () {
1053 ! nm "$2" | sed 's/.* //' |
1054 grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")"
1055}
1056
Gilles Peskine984c19f2021-06-15 18:37:38 +02001057component_build_psa_crypto_spm () {
1058 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc"
1059 scripts/config.py full
1060 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1061 scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
1062 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1063 scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM
1064 # We can only compile, not link, since our test and sample programs
1065 # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM
1066 # is active.
1067 make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib
Gilles Peskine99a34622021-06-17 11:37:52 +02001068
1069 # Check that if a symbol is renamed by crypto_spe.h, the non-renamed
1070 # version is not present.
1071 echo "Checking for renamed symbols in the library"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001072 check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
Gilles Peskine984c19f2021-06-15 18:37:38 +02001073}
1074
Ronald Cron336678b2021-01-28 17:54:24 +01001075component_test_psa_crypto_client () {
1076 msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
1077 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1078 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
1079 scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT
1080 make
1081
1082 msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
1083 make test
1084}
1085
Gilles Peskine636c26a2020-03-04 20:46:15 +01001086component_test_zlib_make() {
1087 msg "build: zlib enabled, make"
1088 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
Gilles Peskine6fa69862021-10-05 09:36:03 +02001089 make ZLIB=1 CFLAGS='-Werror -O2'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001090
1091 msg "test: main suites (zlib, make)"
1092 make test
1093
1094 msg "test: ssl-opt.sh (zlib, make)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001095 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001096}
1097support_test_zlib_make () {
1098 base=support_test_zlib_$$
1099 cat <<'EOF' > ${base}.c
1100#include "zlib.h"
1101int main(void) { return 0; }
1102EOF
1103 gcc -o ${base}.exe ${base}.c -lz 2>/dev/null
1104 ret=$?
1105 rm -f ${base}.*
1106 return $ret
1107}
1108
1109component_test_zlib_cmake() {
Dave Rodgmandff18da2024-03-01 15:53:52 +00001110 # This is needed due to something parsing the output from make
1111 export VERBOSE_LOGS=1
1112
Gilles Peskine636c26a2020-03-04 20:46:15 +01001113 msg "build: zlib enabled, cmake"
1114 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
Gilles Peskine25319702021-10-07 19:34:57 +02001115 cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Release .
Gilles Peskine636c26a2020-03-04 20:46:15 +01001116 make
1117
1118 msg "test: main suites (zlib, cmake)"
1119 make test
1120
1121 msg "test: ssl-opt.sh (zlib, cmake)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001122 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001123}
1124support_test_zlib_cmake () {
1125 support_test_zlib_make "$@"
Manuel Pégourié-Gonnardf2e29022020-01-24 10:17:20 +01001126}
Manuel Pégourié-Gonnard95e04492020-01-02 11:45:12 +01001127
Jaeden Ameroc17f2932021-05-14 08:34:32 +01001128component_test_psa_crypto_rsa_no_genprime() {
1129 msg "build: default config minus MBEDTLS_GENPRIME"
1130 scripts/config.py unset MBEDTLS_GENPRIME
1131 make
1132
1133 msg "test: default config minus MBEDTLS_GENPRIME"
1134 make test
1135}
1136
Gilles Peskine782f4112018-11-27 16:11:09 +01001137component_test_ref_configs () {
1138 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
1139 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001140 tests/scripts/test-ref-configs.pl
Gilles Peskine782f4112018-11-27 16:11:09 +01001141}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02001142
Gilles Peskine8f073122018-11-27 15:58:47 +01001143component_test_sslv3 () {
1144 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001145 scripts/config.py set MBEDTLS_SSL_PROTO_SSL3
Gilles Peskine8f073122018-11-27 15:58:47 +01001146 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1147 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02001148
Gilles Peskine8f073122018-11-27 15:58:47 +01001149 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
1150 make test
Simon Butcher3ea7f522016-03-07 23:22:10 +00001151
Gilles Peskine8f073122018-11-27 15:58:47 +01001152 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskinec67c3b32023-08-27 21:33:41 +02001153 tests/compat.sh -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
Simon Butcher3ea7f522016-03-07 23:22:10 +00001154
Gilles Peskine8f073122018-11-27 15:58:47 +01001155 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001156 tests/ssl-opt.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001157
1158 msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001159 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001160}
Simon Butcher3ea7f522016-03-07 23:22:10 +00001161
Gilles Peskine8f073122018-11-27 15:58:47 +01001162component_test_no_renegotiation () {
1163 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001164 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine8f073122018-11-27 15:58:47 +01001165 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1166 make
Simon Butcher3ea7f522016-03-07 23:22:10 +00001167
Gilles Peskine8f073122018-11-27 15:58:47 +01001168 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
1169 make test
Hanno Becker134c2ab2017-10-12 15:29:50 +01001170
Gilles Peskine8f073122018-11-27 15:58:47 +01001171 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001172 tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001173}
Hanno Becker134c2ab2017-10-12 15:29:50 +01001174
Gilles Peskine56194432023-02-01 18:44:11 +01001175component_test_no_certs () {
1176 msg "build: full minus MBEDTLS_CERTS_C"
1177 scripts/config.py full
1178 scripts/config.py unset MBEDTLS_CERTS_C
1179 # Quick build+test (we're checking for stray uses of the test certs,
1180 # not expecting their absence to lead to subtle problems).
1181 make
1182
1183 msg "test: full minus MBEDTLS_CERTS_C - main suites"
1184 make test
1185}
1186
Gilles Peskine636c26a2020-03-04 20:46:15 +01001187component_test_no_pem_no_fs () {
1188 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
1189 scripts/config.py unset MBEDTLS_PEM_PARSE_C
1190 scripts/config.py unset MBEDTLS_FS_IO
1191 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
1192 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
1193 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1194 make
1195
1196 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
1197 make test
1198
1199 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001200 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001201}
1202
Gilles Peskine8f073122018-11-27 15:58:47 +01001203component_test_rsa_no_crt () {
1204 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001205 scripts/config.py set MBEDTLS_RSA_NO_CRT
Gilles Peskine8f073122018-11-27 15:58:47 +01001206 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1207 make
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +01001208
Gilles Peskine8f073122018-11-27 15:58:47 +01001209 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
1210 make test
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001211
Gilles Peskine8f073122018-11-27 15:58:47 +01001212 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001213 tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001214
Gilles Peskine8f073122018-11-27 15:58:47 +01001215 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001216 tests/compat.sh -t RSA
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001217
1218 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001219 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001220}
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001221
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001222component_test_no_ctr_drbg_classic () {
1223 msg "build: Full minus CTR_DRBG, classic crypto in TLS"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001224 scripts/config.py full
1225 scripts/config.py unset MBEDTLS_CTR_DRBG_C
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001226 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001227
1228 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1229 make
1230
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001231 msg "test: Full minus CTR_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001232 make test
1233
Gilles Peskineba749042021-01-13 20:02:03 +01001234 # In this configuration, the TLS test programs use HMAC_DRBG.
1235 # The SSL tests are slow, so run a small subset, just enough to get
1236 # confidence that the SSL code copes with HMAC_DRBG.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001237 msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001238 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
Gilles Peskineba749042021-01-13 20:02:03 +01001239
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001240 msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001241 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001242}
1243
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001244component_test_no_ctr_drbg_use_psa () {
1245 msg "build: Full minus CTR_DRBG, PSA crypto in TLS"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001246 scripts/config.py full
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001247 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1248 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001249
1250 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1251 make
1252
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001253 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites"
1254 make test
1255
1256 # In this configuration, the TLS test programs use HMAC_DRBG.
1257 # The SSL tests are slow, so run a small subset, just enough to get
1258 # confidence that the SSL code copes with HMAC_DRBG.
1259 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001260 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001261
1262 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001263 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001264}
1265
1266component_test_no_hmac_drbg_classic () {
1267 msg "build: Full minus HMAC_DRBG, classic crypto in TLS"
1268 scripts/config.py full
1269 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1270 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1271 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1272
1273 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1274 make
1275
1276 msg "test: Full minus HMAC_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001277 make test
1278
Gilles Peskinea2224342020-11-19 22:14:34 +01001279 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1280 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1281 # instead.
1282 # Test SSL with non-deterministic ECDSA. Only test features that
1283 # might be affected by how ECDSA signature is performed.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001284 msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001285 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
Gilles Peskinea2224342020-11-19 22:14:34 +01001286
1287 # To save time, only test one protocol version, since this part of
1288 # the protocol is identical in (D)TLS up to 1.2.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001289 msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001290 tests/compat.sh -m tls12 -t 'ECDSA'
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001291}
1292
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001293component_test_no_hmac_drbg_use_psa () {
1294 msg "build: Full minus HMAC_DRBG, PSA crypto in TLS"
1295 scripts/config.py full
1296 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1297 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1298 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1299
1300 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1301 make
1302
1303 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites"
1304 make test
1305
1306 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1307 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1308 # instead.
1309 # Test SSL with non-deterministic ECDSA. Only test features that
1310 # might be affected by how ECDSA signature is performed.
1311 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001312 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001313
1314 # To save time, only test one protocol version, since this part of
1315 # the protocol is identical in (D)TLS up to 1.2.
1316 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001317 tests/compat.sh -m tls12 -t 'ECDSA'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001318}
1319
1320component_test_psa_external_rng_no_drbg_classic () {
1321 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS"
1322 scripts/config.py full
1323 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1324 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001325 scripts/config.py unset MBEDTLS_ENTROPY_C
1326 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1327 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001328 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1329 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1330 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1331 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
Gilles Peskine8eb29432021-02-03 20:07:11 +01001332 # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG,
1333 # the SSL test programs don't have an RNG and can't work. Explicitly
1334 # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG.
1335 make CFLAGS="$ASAN_CFLAGS -O2 -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001336
1337 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites"
1338 make test
1339
Gilles Peskine8eb29432021-02-03 20:07:11 +01001340 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001341 tests/ssl-opt.sh -f 'Default'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001342}
1343
1344component_test_psa_external_rng_no_drbg_use_psa () {
1345 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS"
Gilles Peskinec109b372020-11-23 17:39:04 +01001346 scripts/config.py full
1347 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001348 scripts/config.py unset MBEDTLS_ENTROPY_C
1349 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1350 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskinec109b372020-11-23 17:39:04 +01001351 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1352 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1353 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1354 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1355 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1356
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001357 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites"
Gilles Peskinec109b372020-11-23 17:39:04 +01001358 make test
1359
Gilles Peskine8eb29432021-02-03 20:07:11 +01001360 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001361 tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001362}
1363
1364component_test_psa_external_rng_use_psa_crypto () {
1365 msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1366 scripts/config.py full
1367 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
1368 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1369 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1370 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1371
1372 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1373 make test
1374
Gilles Peskineba749042021-01-13 20:02:03 +01001375 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001376 tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001377}
1378
Gilles Peskine55e89982023-04-28 21:04:28 +02001379component_test_psa_inject_entropy () {
1380 msg "build: full + MBEDTLS_PSA_INJECT_ENTROPY"
1381 scripts/config.py full
1382 scripts/config.py set MBEDTLS_PSA_INJECT_ENTROPY
1383 scripts/config.py set MBEDTLS_ENTROPY_NV_SEED
1384 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
1385 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
1386 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_READ
1387 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_WRITE
1388 make CFLAGS="$ASAN_CFLAGS '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" LDFLAGS="$ASAN_CFLAGS"
1389
1390 msg "test: full + MBEDTLS_PSA_INJECT_ENTROPY"
1391 make test
1392}
1393
Manuel Pégourié-Gonnard1a3f9ed2020-05-19 12:38:31 +02001394component_test_ecp_no_internal_rng () {
1395 msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules"
1396 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1397 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1398 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1399 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1400 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG
1401 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1402
1403 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1404 make
1405
1406 msg "test: ECP_NO_INTERNAL_RNG, no DRBG module"
1407 make test
1408
1409 # no SSL tests as they all depend on having a DRBG
1410}
1411
Manuel Pégourié-Gonnard53fb66d2020-06-04 09:43:14 +02001412component_test_ecp_restartable_no_internal_rng () {
1413 msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG"
1414 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1415 scripts/config.py set MBEDTLS_ECP_RESTARTABLE
1416 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1417 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1418 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1419 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
1420 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1421
1422 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1423 make
1424
1425 msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module"
1426 make test
1427
1428 # no SSL tests as they all depend on having a DRBG
1429}
1430
Przemek Stekiele5352702022-10-05 11:37:54 +02001431component_test_tls1_2_default_stream_cipher_only () {
1432 msg "build: default with only stream cipher"
1433
1434 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C
1435 scripts/config.py unset MBEDTLS_GCM_C
1436 scripts/config.py unset MBEDTLS_CCM_C
1437 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1438 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1439 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1440 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1441 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1442 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1443 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
1444 # Modules that depend on AEAD
1445 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001446 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001447
1448 make
1449
1450 msg "test: default with only stream cipher"
1451 make test
1452
1453 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
1454}
1455
1456component_test_tls1_2_default_stream_cipher_only_use_psa () {
1457 msg "build: default with only stream cipher use psa"
1458
1459 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1460 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1461 scripts/config.py unset MBEDTLS_GCM_C
1462 scripts/config.py unset MBEDTLS_CCM_C
1463 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1464 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1465 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1466 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1467 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1468 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1469 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
1470 # Modules that depend on AEAD
1471 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001472 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001473
1474 make
1475
1476 msg "test: default with only stream cipher use psa"
1477 make test
1478
1479 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
1480}
1481
1482component_test_tls1_2_default_cbc_legacy_cipher_only () {
1483 msg "build: default with only CBC-legacy cipher"
1484
1485 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1486 scripts/config.py unset MBEDTLS_GCM_C
1487 scripts/config.py unset MBEDTLS_CCM_C
1488 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1489 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1490 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1491 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1492 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1493 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1494 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1495 # Modules that depend on AEAD
1496 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001497 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001498
1499 make
1500
1501 msg "test: default with only CBC-legacy cipher"
1502 make test
1503
1504 msg "test: default with only CBC-legacy cipher - ssl-opt.sh (subset)"
1505 tests/ssl-opt.sh -f "TLS 1.2"
1506}
1507
1508component_test_tls1_2_deafult_cbc_legacy_cipher_only_use_psa () {
1509 msg "build: default with only CBC-legacy cipher use psa"
1510
1511 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1512 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1513 scripts/config.py unset MBEDTLS_GCM_C
1514 scripts/config.py unset MBEDTLS_CCM_C
1515 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1516 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1517 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1518 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1519 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1520 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1521 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1522 # Modules that depend on AEAD
1523 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001524 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001525
1526 make
1527
1528 msg "test: default with only CBC-legacy cipher use psa"
1529 make test
1530
1531 msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)"
1532 tests/ssl-opt.sh -f "TLS 1.2"
1533}
1534
1535component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () {
1536 msg "build: default with only CBC-legacy and CBC-EtM ciphers"
1537
1538 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1539 scripts/config.py unset MBEDTLS_GCM_C
1540 scripts/config.py unset MBEDTLS_CCM_C
1541 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1542 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1543 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1544 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1545 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
1546 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1547 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1548 # Modules that depend on AEAD
1549 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001550 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001551
1552 make
1553
1554 msg "test: default with only CBC-legacy and CBC-EtM ciphers"
1555 make test
1556
1557 msg "test: default with only CBC-legacy and CBC-EtM ciphers - ssl-opt.sh (subset)"
1558 tests/ssl-opt.sh -f "TLS 1.2"
1559}
1560
1561component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa () {
1562 msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa"
1563
1564 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1565 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1566 scripts/config.py unset MBEDTLS_GCM_C
1567 scripts/config.py unset MBEDTLS_CCM_C
1568 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1569 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1570 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1571 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1572 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
1573 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1574 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1575 # Modules that depend on AEAD
1576 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001577 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001578
1579 make
1580
1581 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa"
1582 make test
1583
1584 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)"
1585 tests/ssl-opt.sh -f "TLS 1.2"
1586}
1587
Gilles Peskine636c26a2020-03-04 20:46:15 +01001588component_test_new_ecdh_context () {
1589 msg "build: new ECDH context (ASan build)" # ~ 6 min
1590 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1591 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1592 make
1593
1594 msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1595 make test
1596
1597 msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001598 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01001599
1600 msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1601 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001602 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001603}
1604
1605component_test_everest () {
1606 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
1607 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1608 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1609 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
1610 make
1611
1612 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1613 make test
1614
Gilles Peskineee8af062023-11-02 19:58:03 +01001615 msg "test: metatests (clang, ASan)"
David Horstmann1b421b12024-01-17 14:53:08 +00001616 tests/scripts/run-metatests.sh any asan poison
Gilles Peskineee8af062023-11-02 19:58:03 +01001617
Gilles Peskine636c26a2020-03-04 20:46:15 +01001618 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001619 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01001620
1621 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1622 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001623 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001624}
1625
Gilles Peskined3beca92020-07-03 00:15:37 +02001626component_test_everest_curve25519_only () {
1627 msg "build: Everest ECDH context, only Curve25519" # ~ 6 min
1628 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1629 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1630 scripts/config.py unset MBEDTLS_ECDSA_C
1631 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1632 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1633 # Disable all curves
1634 for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do
1635 scripts/config.py unset "$c"
1636 done
1637 scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED
1638
1639 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1640
1641 msg "test: Everest ECDH context, only Curve25519" # ~ 50s
1642 make test
1643}
1644
Gilles Peskine8f073122018-11-27 15:58:47 +01001645component_test_small_ssl_out_content_len () {
1646 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001647 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
1648 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01001649 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1650 make
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001651
Gilles Peskine8f073122018-11-27 15:58:47 +01001652 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001653 tests/ssl-opt.sh -f "Max fragment\|Large packet"
Gilles Peskine8f073122018-11-27 15:58:47 +01001654}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001655
Gilles Peskine8f073122018-11-27 15:58:47 +01001656component_test_small_ssl_in_content_len () {
1657 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001658 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
1659 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
Gilles Peskine8f073122018-11-27 15:58:47 +01001660 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1661 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001662
Gilles Peskine8f073122018-11-27 15:58:47 +01001663 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001664 tests/ssl-opt.sh -f "Max fragment"
Gilles Peskine8f073122018-11-27 15:58:47 +01001665}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001666
Gilles Peskine8f073122018-11-27 15:58:47 +01001667component_test_small_ssl_dtls_max_buffering () {
1668 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001669 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
Gilles Peskine8f073122018-11-27 15:58:47 +01001670 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1671 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001672
Gilles Peskine8f073122018-11-27 15:58:47 +01001673 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001674 tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
Gilles Peskine8f073122018-11-27 15:58:47 +01001675}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001676
Gilles Peskine8f073122018-11-27 15:58:47 +01001677component_test_small_mbedtls_ssl_dtls_max_buffering () {
1678 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
Gilles Peskine636c26a2020-03-04 20:46:15 +01001679 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
Gilles Peskine8f073122018-11-27 15:58:47 +01001680 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1681 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001682
Gilles Peskine8f073122018-11-27 15:58:47 +01001683 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001684 tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
Gilles Peskine8f073122018-11-27 15:58:47 +01001685}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001686
Gilles Peskine75cc7712019-09-06 19:47:17 +02001687component_test_psa_collect_statuses () {
1688 msg "build+test: psa_collect_statuses" # ~30s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001689 scripts/config.py full
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001690 tests/scripts/psa_collect_statuses.py
Gilles Peskine75cc7712019-09-06 19:47:17 +02001691 # Check that psa_crypto_init() succeeded at least once
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001692 grep -q '^0:psa_crypto_init:' tests/statuses.log
Gilles Peskine75cc7712019-09-06 19:47:17 +02001693 rm -f tests/statuses.log
1694}
1695
Gilles Peskine8f073122018-11-27 15:58:47 +01001696component_test_full_cmake_clang () {
1697 msg "build: cmake, full config, clang" # ~ 50s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001698 scripts/config.py full
Gilles Peskine83264be2022-10-30 21:02:40 +01001699 CC=clang CXX=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On -D TEST_CPP=1 .
Gilles Peskine8f073122018-11-27 15:58:47 +01001700 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001701
k-stachowiak0291cb72019-06-26 15:52:12 +02001702 msg "test: main suites (full config, clang)" # ~ 5s
Gilles Peskine8f073122018-11-27 15:58:47 +01001703 make test
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01001704
Gilles Peskine83264be2022-10-30 21:02:40 +01001705 msg "test: cpp_dummy_build (full config, clang)" # ~ 1s
1706 programs/test/cpp_dummy_build
1707
Gilles Peskineee8af062023-11-02 19:58:03 +01001708 msg "test: metatests (clang)"
Gilles Peskinee38eb792023-11-03 18:05:38 +01001709 tests/scripts/run-metatests.sh any pthread
Gilles Peskineee8af062023-11-02 19:58:03 +01001710
Gilles Peskine93aaf2e2019-06-14 18:27:03 +02001711 msg "program demos (full config, clang)" # ~10s
1712 tests/scripts/run_demos.py
1713
k-stachowiak0291cb72019-06-26 15:52:12 +02001714 msg "test: psa_constant_names (full config, clang)" # ~ 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001715 tests/scripts/test_psa_constant_names.py
Gilles Peskine69e8f7f2020-02-26 19:51:43 +01001716
Gilles Peskine8f073122018-11-27 15:58:47 +01001717 msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001718 tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Gilles Peskine8f073122018-11-27 15:58:47 +01001719}
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001720
Gilles Peskine9603a442022-11-29 16:01:41 +01001721skip_suites_without_constant_flow () {
1722 # Skip the test suites that don't have any constant-flow annotations.
1723 # This will need to be adjusted if we ever start declaring things as
1724 # secret from macros or functions inside tests/include or tests/src.
1725 SKIP_TEST_SUITES=$(
1726 git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' |
1727 sed 's/test_suite_//; s/\.function$//' |
1728 tr '\n' ,)
1729 export SKIP_TEST_SUITES
1730}
1731
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001732component_test_memsan_constant_flow () {
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001733 # This tests both (1) accesses to undefined memory, and (2) branches or
1734 # memory access depending on secret values. To distinguish between those:
1735 # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist?
1736 # - or alternatively, change the build type to MemSanDbg, which enables
1737 # origin tracking and nicer stack traces (which are useful for debugging
1738 # anyway), and check if the origin was TEST_CF_SECRET() or something else.
1739 msg "build: cmake MSan (clang), full config with constant flow testing"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001740 scripts/config.py full
1741 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
1742 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
1743 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1744 make
1745
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001746 msg "test: main suites (Msan + constant flow)"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001747 make test
1748}
1749
Bence Szépkútie1c6c4c2023-12-06 16:14:37 +01001750component_release_test_valgrind_constant_flow () {
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001751 # This tests both (1) everything that valgrind's memcheck usually checks
1752 # (heap buffer overflows, use of uninitialized memory, use-after-free,
1753 # etc.) and (2) branches or memory access depending on secret values,
1754 # which will be reported as uninitialized memory. To distinguish between
1755 # secret and actually uninitialized:
1756 # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist?
1757 # - or alternatively, build with debug info and manually run the offending
1758 # test suite with valgrind --track-origins=yes, then check if the origin
1759 # was TEST_CF_SECRET() or something else.
1760 msg "build: cmake release GCC, full config with constant flow testing"
1761 scripts/config.py full
1762 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND
Gilles Peskine9603a442022-11-29 16:01:41 +01001763 skip_suites_without_constant_flow
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001764 cmake -D CMAKE_BUILD_TYPE:String=Release .
1765 make
1766
1767 # this only shows a summary of the results (how many of each type)
1768 # details are left in Testing/<date>/DynamicAnalysis.xml
Gilles Peskine9603a442022-11-29 16:01:41 +01001769 msg "test: some suites (valgrind + constant flow)"
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001770 make memcheck
1771}
1772
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001773component_test_default_no_deprecated () {
Gilles Peskine8386ea22020-04-30 09:07:29 +02001774 # Test that removing the deprecated features from the default
1775 # configuration leaves something consistent.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001776 msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
1777 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
Dave Rodgman374b1882024-01-04 10:30:57 +00001778 make CFLAGS='-O -Werror -Wall -Wextra'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001779
1780 msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
1781 make test
1782}
1783
1784component_test_full_no_deprecated () {
Gilles Peskine30de2e82020-04-20 21:39:22 +02001785 msg "build: make, full_no_deprecated config" # ~ 30s
1786 scripts/config.py full_no_deprecated
Dave Rodgman374b1882024-01-04 10:30:57 +00001787 make CFLAGS='-O -Werror -Wall -Wextra'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001788
Gilles Peskine30de2e82020-04-20 21:39:22 +02001789 msg "test: make, full_no_deprecated config" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001790 make test
1791}
1792
Gilles Peskine8386ea22020-04-30 09:07:29 +02001793component_test_full_no_deprecated_deprecated_warning () {
1794 # Test that there is nothing deprecated in "full_no_deprecated".
1795 # A deprecated feature would trigger a warning (made fatal) from
1796 # MBEDTLS_DEPRECATED_WARNING.
Gilles Peskine30de2e82020-04-20 21:39:22 +02001797 msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
1798 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001799 scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
1800 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Dave Rodgman374b1882024-01-04 10:30:57 +00001801 make CFLAGS='-O -Werror -Wall -Wextra'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001802
Gilles Peskine30de2e82020-04-20 21:39:22 +02001803 msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001804 make test
1805}
1806
Gilles Peskine8386ea22020-04-30 09:07:29 +02001807component_test_full_deprecated_warning () {
1808 # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
1809 # with only certain whitelisted types of warnings.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001810 msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001811 scripts/config.py full
1812 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001813 # Expect warnings from '#warning' directives in check_config.h.
Dave Rodgman9d2c67f2023-12-19 14:07:15 +00001814 # Note that gcc is required to allow the use of -Wno-error=cpp, which allows us to
1815 # display #warning messages without them being treated as errors.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001816 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +01001817
Gilles Peskine8386ea22020-04-30 09:07:29 +02001818 msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
1819 # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
1820 # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001821 # Expect warnings from '#warning' directives in check_config.h and
1822 # from the use of deprecated functions in test suites.
1823 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -Wno-error=cpp -DMBEDTLS_TEST_DEPRECATED' tests
Gilles Peskine841b14b2019-11-26 17:37:37 +01001824
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001825 msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
1826 make test
Gilles Peskine93aaf2e2019-06-14 18:27:03 +02001827
1828 msg "program demos: full config + MBEDTLS_TEST_DEPRECATED" # ~10s
1829 tests/scripts/run_demos.py
Gilles Peskine8f073122018-11-27 15:58:47 +01001830}
Jaeden Ameroed93bdc2018-11-02 16:57:24 +00001831
Gilles Peskineec541fe2020-01-31 14:24:14 +01001832# Check that the specified libraries exist and are empty.
1833are_empty_libraries () {
1834 nm "$@" >/dev/null 2>/dev/null
1835 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
1836}
1837
1838component_build_crypto_default () {
1839 msg "build: make, crypto only"
1840 scripts/config.py crypto
Gilles Peskine6bb39152020-02-03 11:59:20 +01001841 make CFLAGS='-O1 -Werror'
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001842 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001843}
1844
1845component_build_crypto_full () {
1846 msg "build: make, crypto only, full config"
1847 scripts/config.py crypto_full
Gilles Peskine6bb39152020-02-03 11:59:20 +01001848 make CFLAGS='-O1 -Werror'
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001849 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001850}
1851
Gilles Peskine8df27482022-10-21 19:34:54 +02001852component_test_crypto_for_psa_service () {
Gilles Peskine21503df2022-10-11 21:05:06 +02001853 msg "build: make, config for PSA crypto service"
1854 scripts/config.py crypto
1855 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1856 # Disable things that are not needed for just cryptography, to
1857 # reach a configuration that would be typical for a PSA cryptography
1858 # service providing all implemented PSA algorithms.
1859 # System stuff
1860 scripts/config.py unset MBEDTLS_ERROR_C
1861 scripts/config.py unset MBEDTLS_TIMING_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001862 scripts/config.py unset MBEDTLS_VERSION_FEATURES
Gilles Peskine21503df2022-10-11 21:05:06 +02001863 # Crypto stuff with no PSA interface
1864 scripts/config.py unset MBEDTLS_BASE64_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001865 scripts/config.py unset MBEDTLS_BLOWFISH_C
1866 # Keep MBEDTLS_CIPHER_C because psa_crypto_cipher, CCM and GCM need it.
1867 # Keep MBEDTLS_MD_C because RSA and ECDSA need it, also HMAC_DRBG which
1868 # is needed for deterministic ECDSA.
1869 scripts/config.py unset MBEDTLS_ECJPAKE_C
1870 scripts/config.py unset MBEDTLS_HKDF_C # PSA's HKDF is independent
Gilles Peskine21503df2022-10-11 21:05:06 +02001871 scripts/config.py unset MBEDTLS_NIST_KW_C
1872 scripts/config.py unset MBEDTLS_PEM_PARSE_C
1873 scripts/config.py unset MBEDTLS_PEM_WRITE_C
1874 scripts/config.py unset MBEDTLS_PKCS12_C
1875 scripts/config.py unset MBEDTLS_PKCS5_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001876 # We keep MBEDTLS_PK_{,PARSE,WRITE}_C because PSA with RSA needs it.
1877 scripts/config.py unset MBEDTLS_XTEA_C
Gilles Peskine21503df2022-10-11 21:05:06 +02001878 make CFLAGS='-O1 -Werror' all test
1879 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1880}
1881
Gilles Peskineec541fe2020-01-31 14:24:14 +01001882component_build_crypto_baremetal () {
1883 msg "build: make, crypto only, baremetal config"
1884 scripts/config.py crypto_baremetal
David Horstmann3cb5e9b2021-11-30 11:40:54 +00001885 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001886 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001887}
Daniel Axtens6f63cc72020-09-02 21:30:13 +10001888support_build_crypto_baremetal () {
Daniel Axtens1a021af2020-08-31 14:22:58 +10001889 support_build_baremetal "$@"
1890}
1891
1892component_build_baremetal () {
1893 msg "build: make, baremetal config"
1894 scripts/config.py baremetal
David Horstmann3cb5e9b2021-11-30 11:40:54 +00001895 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
Daniel Axtens1a021af2020-08-31 14:22:58 +10001896}
1897support_build_baremetal () {
Daniel Axtens6f63cc72020-09-02 21:30:13 +10001898 # Older Glibc versions include time.h from other headers such as stdlib.h,
1899 # which makes the no-time.h-in-baremetal check fail. Ubuntu 16.04 has this
1900 # problem, Ubuntu 18.04 is ok.
1901 ! grep -q -F time.h /usr/include/x86_64-linux-gnu/sys/types.h
1902}
Gilles Peskineec541fe2020-01-31 14:24:14 +01001903
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001904# depends.py family of tests
Andrzej Kurek85d69302022-10-05 09:14:07 -04001905component_test_depends_py_cipher_id () {
1906 msg "test/build: depends.py cipher_id (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001907 tests/scripts/depends.py cipher_id --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001908}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001909
Andrzej Kurek85d69302022-10-05 09:14:07 -04001910component_test_depends_py_cipher_chaining () {
1911 msg "test/build: depends.py cipher_chaining (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001912 tests/scripts/depends.py cipher_chaining --unset-use-psa
John Durkopc14be902020-08-20 06:16:41 -07001913}
1914
Andrzej Kurek85d69302022-10-05 09:14:07 -04001915component_test_depends_py_cipher_padding () {
1916 msg "test/build: depends.py cipher_padding (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001917 tests/scripts/depends.py cipher_padding --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001918}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001919
Andrzej Kurek85d69302022-10-05 09:14:07 -04001920component_test_depends_py_curves () {
1921 msg "test/build: depends.py curves (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001922 tests/scripts/depends.py curves --unset-use-psa
John Durkop2ec2eaa2020-08-24 18:29:15 -07001923}
1924
Andrzej Kurek85d69302022-10-05 09:14:07 -04001925component_test_depends_py_hashes () {
1926 msg "test/build: depends.py hashes (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001927 tests/scripts/depends.py hashes --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001928}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001929
Andrzej Kurek85d69302022-10-05 09:14:07 -04001930component_test_depends_py_kex () {
1931 msg "test/build: depends.py kex (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001932 tests/scripts/depends.py kex --unset-use-psa
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001933}
1934
Andrzej Kurek85d69302022-10-05 09:14:07 -04001935component_test_depends_py_pkalgs () {
1936 msg "test/build: depends.py pkalgs (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001937 tests/scripts/depends.py pkalgs --unset-use-psa
1938}
1939
1940# PSA equivalents of the depends.py tests
1941component_test_depends_py_cipher_id_psa () {
1942 msg "test/build: depends.py cipher_id (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1943 tests/scripts/depends.py cipher_id
1944}
1945
1946component_test_depends_py_cipher_chaining_psa () {
1947 msg "test/build: depends.py cipher_chaining (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1948 tests/scripts/depends.py cipher_chaining
1949}
1950
1951component_test_depends_py_cipher_padding_psa () {
1952 msg "test/build: depends.py cipher_padding (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1953 tests/scripts/depends.py cipher_padding
1954}
1955
1956component_test_depends_py_curves_psa () {
1957 msg "test/build: depends.py curves (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1958 tests/scripts/depends.py curves
1959}
1960
1961component_test_depends_py_hashes_psa () {
1962 msg "test/build: depends.py hashes (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1963 tests/scripts/depends.py hashes
1964}
1965
1966component_test_depends_py_kex_psa () {
1967 msg "test/build: depends.py kex (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1968 tests/scripts/depends.py kex
1969}
1970
1971component_test_depends_py_pkalgs_psa () {
1972 msg "test/build: depends.py pkalgs (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
Andrzej Kurek85d69302022-10-05 09:14:07 -04001973 tests/scripts/depends.py pkalgs
Gilles Peskine8f073122018-11-27 15:58:47 +01001974}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001975
Dave Rodgman5fce4f62023-01-20 13:18:05 +00001976component_build_no_pk_rsa_alt_support () {
1977 msg "build: !MBEDTLS_PK_RSA_ALT_SUPPORT" # ~30s
1978
1979 scripts/config.py full
1980 scripts/config.py unset MBEDTLS_PK_RSA_ALT_SUPPORT
1981 scripts/config.py set MBEDTLS_RSA_C
1982 scripts/config.py set MBEDTLS_X509_CRT_WRITE_C
1983
1984 # Only compile - this is primarily to test for compile issues
Dave Rodgman374b1882024-01-04 10:30:57 +00001985 make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy'
Dave Rodgman5fce4f62023-01-20 13:18:05 +00001986}
1987
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001988component_test_no_use_psa_crypto_full_cmake_asan() {
1989 # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
Gilles Peskinedc3a1792019-09-03 11:42:04 +02001990 msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001991 scripts/config.py full
1992 scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
1993 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1994 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1995 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskinedc6d8382020-04-12 14:21:55 +02001996 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001997 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Manuel Pégourié-Gonnardd8167e82019-02-01 11:12:52 +01001998 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001999 make
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +02002000
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01002001 msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05002002 make test
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +02002003
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01002004 msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002005 tests/ssl-opt.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002006
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002007 msg "test: compat.sh all except legacy/next (full minus MBEDTLS_USE_PSA_CRYPTO)"
2008 tests/compat.sh -e '^DES-CBC-\|-DES-CBC-\|ARIA\|CHACHA' \
Manuel Pégourié-Gonnard2cd43a72024-04-09 23:01:09 +02002009 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
Gilles Peskinec67c3b32023-08-27 21:33:41 +02002010
2011 msg "test: compat.sh single-DES (full minus MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002012 env OPENSSL="$OPENSSL_LEGACY" tests/compat.sh -e '^$' -f '^DES-CBC\|-DES-CBC-' \
Manuel Pégourié-Gonnard2cd43a72024-04-09 23:01:09 +02002013 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002014
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002015 # ARIA and ChachaPoly are both (D)TLS 1.2 only
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01002016 msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002017 env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' \
Manuel Pégourié-Gonnardde887ba2024-04-18 10:05:04 +02002018 -m 'tls12 dtls12'
Andrzej Kurekde5a0072019-02-01 07:03:03 -05002019}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002020
Ronald Crond2c53e62021-09-13 09:38:05 +02002021component_test_psa_crypto_config_accel_ecdsa () {
2022 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
2023
2024 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2025 # partial support for cipher operations in the driver test library.
2026 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2027 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
Gilles Peskine62de7672022-04-21 11:05:16 +02002028 # Disable obsolete hashes (alternatively we could enable support for them
2029 # in the driver test library).
2030 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2031 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
Ronald Crond2c53e62021-09-13 09:38:05 +02002032
2033 # SHA384 needed for some ECDSA signature tests.
2034 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA512_C
2035
2036 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY"
2037 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2038 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2039
2040 # Restore test driver base configuration
2041 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA512_C
2042
2043 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2044 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2045 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2046 scripts/config.py unset MBEDTLS_ECDSA_C
2047 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
2048 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
2049
2050 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2051 make CFLAGS="$ASAN_CFLAGS -O -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2052
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002053 not grep mbedtls_ecdsa_ library/ecdsa.o
Ronald Crond2c53e62021-09-13 09:38:05 +02002054
2055 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
2056 make test
2057}
2058
2059component_test_psa_crypto_config_accel_rsa_signature () {
2060 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
2061
2062 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2063 # partial support for cipher operations in the driver test library.
2064 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2065 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2066
2067 # It seems it is not possible to remove only the support for RSA signature
2068 # in the library. Thus we have to remove all RSA support (signature and
2069 # encryption/decryption). AS there is no driver support for asymmetric
2070 # encryption/decryption so far remove RSA encryption/decryption from the
2071 # application algorithm list.
2072 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2073 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2074
2075 # Make sure both the library and the test library support the SHA hash
2076 # algorithms and only those ones (SHA256 is included by default). That way:
2077 # - the test library can compute the RSA signatures even in the case of a
2078 # composite RSA signature algorithm based on a SHA hash (no other hash
2079 # used in the unit tests).
2080 # - the dependency of RSA signature tests on PSA_WANT_ALG_SHA_xyz is
2081 # fulfilled as the hash SHA algorithm is supported by the library, and
2082 # thus the tests are run, not skipped.
2083 # - when testing a signature key with an algorithm wildcard built from
2084 # PSA_ALG_ANY_HASH as algorithm to test with the key, the chosen hash
2085 # algorithm based on the hashes supported by the library is also
2086 # supported by the test library.
2087 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2088 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2089 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2090 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160_C
2091
2092 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA1_C
2093 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA512_C
2094 # We need PEM parsing in the test library as well to support the import
2095 # of PEM encoded RSA keys.
2096 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_PEM_PARSE_C
2097 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_BASE64_C
2098
2099 loc_accel_list="ALG_RSA_PKCS1V15_SIGN ALG_RSA_PSS KEY_TYPE_RSA_KEY_PAIR KEY_TYPE_RSA_PUBLIC_KEY"
2100 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2101 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2102
2103 # Restore test driver base configuration
2104 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA1_C
2105 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA512_C
2106 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_PEM_PARSE_C
2107 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_BASE64_C
2108
2109
2110 # Mbed TLS library build
2111 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2112 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2113
2114 # Remove RSA support and its dependencies
2115 scripts/config.py unset MBEDTLS_PKCS1_V15
2116 scripts/config.py unset MBEDTLS_PKCS1_V21
2117 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
2118 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
2119 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
2120 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
2121 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
2122 scripts/config.py unset MBEDTLS_RSA_C
2123 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
2124
2125 scripts/config.py unset MBEDTLS_MD2_C
2126 scripts/config.py unset MBEDTLS_MD4_C
2127 scripts/config.py unset MBEDTLS_MD5_C
2128 scripts/config.py unset MBEDTLS_RIPEMD160_C
2129 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1
2130 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_1
2131 scripts/config.py unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
2132
2133 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2134 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2135
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002136 not grep mbedtls_rsa_rsassa_pkcs1_v15_sign library/rsa.o
2137 not grep mbedtls_rsa_rsassa_pss_sign_ext library/rsa.o
Ronald Crond2c53e62021-09-13 09:38:05 +02002138
2139 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
2140 make test
2141}
2142
Ronald Cronf7e483c2021-05-08 14:32:59 +02002143component_test_psa_crypto_config_accel_hash () {
2144 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2145
2146 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2147 # partial support for cipher operations in the driver test library.
2148 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2149 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2150
2151 loc_accel_list="ALG_MD4 ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512"
2152 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2153 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2154
2155 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2156 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2157 scripts/config.py unset MBEDTLS_MD2_C
2158 scripts/config.py unset MBEDTLS_MD4_C
2159 scripts/config.py unset MBEDTLS_MD5_C
2160 scripts/config.py unset MBEDTLS_RIPEMD160_C
2161 scripts/config.py unset MBEDTLS_SHA1_C
2162 # Don't unset MBEDTLS_SHA256_C as it is needed by PSA crypto core.
2163 scripts/config.py unset MBEDTLS_SHA512_C
2164 # Unset MBEDTLS_SSL_PROTO_SSL3, MBEDTLS_SSL_PROTO_TLS1 and MBEDTLS_SSL_PROTO_TLS1_1 as they depend on MBEDTLS_SHA1_C
2165 scripts/config.py unset MBEDTLS_SSL_PROTO_SSL3
2166 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1
2167 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_1
2168 # Unset MBEDTLS_SSL_CBC_RECORD_SPLITTING as it depends on MBEDTLS_SSL_PROTO_TLS1 in the default configuration.
2169 scripts/config.py unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
2170 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2171 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2172
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002173 not grep mbedtls_sha512_init library/sha512.o
2174 not grep mbedtls_sha1_init library/sha1.o
Ronald Cronf7e483c2021-05-08 14:32:59 +02002175
2176 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2177 make test
2178}
2179
Ronald Cron09623702021-10-18 11:26:01 +02002180component_test_psa_crypto_config_accel_cipher () {
2181 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated cipher"
2182
Gilles Peskine186331872022-04-12 15:58:03 +02002183 # This test case focuses on cipher+AEAD. We don't yet support all
2184 # combinations of configurations, so deactivate block-cipher-based MACs.
2185 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CMAC
2186
Ronald Cron09623702021-10-18 11:26:01 +02002187 loc_accel_list="ALG_CBC_NO_PADDING ALG_CBC_PKCS7 ALG_CTR ALG_CFB ALG_OFB ALG_XTS KEY_TYPE_DES"
2188 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2189 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2190
2191 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2192 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2193
2194 # There is no intended accelerator support for ALG STREAM_CIPHER and
2195 # ALG_ECB_NO_PADDING. Therefore, asking for them in the build implies the
2196 # inclusion of the Mbed TLS cipher operations. As we want to test here with
2197 # cipher operations solely supported by accelerators, disabled those
2198 # PSA configuration options.
2199 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2200 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
Ronald Cron09623702021-10-18 11:26:01 +02002201
2202 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2203 scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7
2204 scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR
2205 scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB
2206 scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB
2207 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2208 scripts/config.py unset MBEDTLS_DES_C
2209
2210 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2211 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2212
Gilles Peskine82143402024-06-19 15:09:27 +02002213 not grep mbedtls_des library/des.o
Ronald Cron09623702021-10-18 11:26:01 +02002214
2215 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2216 make test
2217}
2218
Przemek Stekiel8b56f232022-10-02 20:58:39 +02002219component_test_psa_crypto_config_accel_aead () {
2220 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2221
2222 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2223 # partial support for cipher operations in the driver test library.
2224 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2225 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2226
2227 loc_accel_list="ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 KEY_TYPE_AES KEY_TYPE_CHACHA20 KEY_TYPE_ARIA KEY_TYPE_CAMELLIA"
2228 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2229 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2230
2231 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2232 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2233
2234 scripts/config.py unset MBEDTLS_GCM_C
2235 scripts/config.py unset MBEDTLS_CCM_C
2236 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2237 # Features that depend on AEAD
2238 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
2239 scripts/config.py unset MBEDTLS_SSL_TICKET_C
2240
2241 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2242 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2243
2244 # There's a risk of something getting re-enabled via config_psa.h
2245 # make sure it did not happen.
2246 not grep mbedtls_ccm library/ccm.o
2247 not grep mbedtls_gcm library/gcm.o
2248 not grep mbedtls_chachapoly library/chachapoly.o
2249
2250 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2251 make test
2252}
2253
John Durkop4377bf72020-10-23 01:26:57 -07002254component_test_psa_crypto_config_no_driver() {
John Durkop4377bf72020-10-23 01:26:57 -07002255 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
2256 scripts/config.py full
2257 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2258 scripts/config.py unset MBEDTLS_PSA_CRYPTO_DRIVERS
2259 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkope7012c72020-10-26 09:55:01 -07002260 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkop4377bf72020-10-23 01:26:57 -07002261
2262 msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
John Durkopd8959392020-09-20 23:09:17 -07002263 make test
2264}
2265
Gilles Peskined4c85af2023-07-20 22:19:45 +02002266component_test_aead_chachapoly_disabled() {
2267 msg "build: full minus CHACHAPOLY"
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002268 scripts/config.py full
2269 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
Gilles Peskined4c85af2023-07-20 22:19:45 +02002270 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002271 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
2272
Gilles Peskined4c85af2023-07-20 22:19:45 +02002273 msg "test: full minus CHACHAPOLY"
2274 make test
2275}
2276
2277component_test_aead_only_ccm() {
2278 msg "build: full minus CHACHAPOLY and GCM"
2279 scripts/config.py full
2280 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2281 scripts/config.py unset MBEDTLS_GCM_C
2282 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
2283 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_GCM
2284 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
2285
2286 msg "test: full minus CHACHAPOLY and GCM"
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002287 make test
2288}
2289
John Durkopd0321952020-10-29 21:37:36 -07002290# This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002291component_build_psa_accel_alg_ecdh() {
Gilles Peskine168be012023-07-19 19:36:55 +02002292 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C"
John Durkopd0321952020-10-29 21:37:36 -07002293 scripts/config.py full
2294 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2295 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2296 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2297 scripts/config.py unset MBEDTLS_ECDH_C
2298 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
2299 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
2300 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
2301 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
2302 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
2303 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2304 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2305}
2306
John Durkopf4c4cb02020-10-28 20:09:55 -07002307# This should be renamed to test and updated once the accelerator ECC key pair code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002308component_build_psa_accel_key_type_ecc_key_pair() {
Gilles Peskine168be012023-07-19 19:36:55 +02002309 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR"
John Durkopf4c4cb02020-10-28 20:09:55 -07002310 scripts/config.py full
2311 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2312 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2313 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08002314 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1
John Durkop07cc04a2020-11-16 22:08:34 -08002315 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
John Durkopf4c4cb02020-10-28 20:09:55 -07002316 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkop9814fa22020-11-04 12:28:15 -08002317 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopf4c4cb02020-10-28 20:09:55 -07002318}
2319
2320# This should be renamed to test and updated once the accelerator ECC public key code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002321component_build_psa_accel_key_type_ecc_public_key() {
Gilles Peskine168be012023-07-19 19:36:55 +02002322 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY"
John Durkopf4c4cb02020-10-28 20:09:55 -07002323 scripts/config.py full
2324 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2325 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2326 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08002327 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
2328 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR
John Durkopf4c4cb02020-10-28 20:09:55 -07002329 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkop9814fa22020-11-04 12:28:15 -08002330 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopf4c4cb02020-10-28 20:09:55 -07002331}
2332
John Durkopd0321952020-10-29 21:37:36 -07002333# This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002334component_build_psa_accel_alg_hmac() {
Gilles Peskine168be012023-07-19 19:36:55 +02002335 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HMAC"
John Durkopd0321952020-10-29 21:37:36 -07002336 scripts/config.py full
2337 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2338 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2339 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2340 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2341 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2342}
2343
2344# This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002345component_build_psa_accel_alg_hkdf() {
Gilles Peskine168be012023-07-19 19:36:55 +02002346 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C"
John Durkopd0321952020-10-29 21:37:36 -07002347 scripts/config.py full
2348 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2349 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2350 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2351 scripts/config.py unset MBEDTLS_HKDF_C
John Durkopbd069d32020-10-31 22:14:03 -07002352 # Make sure to unset TLS1_3_EXPERIMENTAL since it requires HKDF_C and will not build properly without it.
2353 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
John Durkopd0321952020-10-29 21:37:36 -07002354 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2355 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2356}
2357
John Durkop1b7ee052020-11-27 08:51:22 -08002358# This should be renamed to test and updated once the accelerator MD2 code is in place and ready to test.
2359component_build_psa_accel_alg_md2() {
Gilles Peskine168be012023-07-19 19:36:55 +02002360 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD2 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002361 scripts/config.py full
2362 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2363 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2364 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2365 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2366 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2367 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2368 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2369 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2370 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2371 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2372 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2373 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2374 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD2 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2375}
2376
2377# This should be renamed to test and updated once the accelerator MD4 code is in place and ready to test.
2378component_build_psa_accel_alg_md4() {
Gilles Peskine168be012023-07-19 19:36:55 +02002379 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD4 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002380 scripts/config.py full
2381 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2382 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2383 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2384 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2385 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2386 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2387 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2388 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2389 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2390 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2391 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2392 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2393 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD4 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2394}
2395
2396# This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test.
2397component_build_psa_accel_alg_md5() {
Gilles Peskine168be012023-07-19 19:36:55 +02002398 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD5 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002399 scripts/config.py full
2400 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2401 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2402 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2403 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2404 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2405 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2406 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2407 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2408 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2409 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2410 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2411 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2412 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2413}
2414
2415# This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test.
2416component_build_psa_accel_alg_ripemd160() {
Gilles Peskine168be012023-07-19 19:36:55 +02002417 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RIPEMD160 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002418 scripts/config.py full
2419 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2420 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2421 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2422 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2423 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2424 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2425 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2426 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2427 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2428 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2429 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2430 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2431 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2432}
2433
2434# This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test.
2435component_build_psa_accel_alg_sha1() {
Gilles Peskine168be012023-07-19 19:36:55 +02002436 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_1 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002437 scripts/config.py full
2438 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2439 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2440 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2441 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2442 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2443 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2444 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2445 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2446 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2447 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2448 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2449 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2450 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2451}
2452
2453# This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test.
2454component_build_psa_accel_alg_sha224() {
Gilles Peskine168be012023-07-19 19:36:55 +02002455 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_224 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002456 scripts/config.py full
2457 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2458 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2459 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2460 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2461 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2462 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2463 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2464 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2465 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2466 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2467 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2468 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2469}
2470
2471# This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test.
2472component_build_psa_accel_alg_sha256() {
Gilles Peskine168be012023-07-19 19:36:55 +02002473 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_256 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002474 scripts/config.py full
2475 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2476 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2477 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2478 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2479 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2480 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2481 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2482 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2483 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2484 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2485 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2486 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2487 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2488}
2489
2490# This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test.
2491component_build_psa_accel_alg_sha384() {
Gilles Peskine168be012023-07-19 19:36:55 +02002492 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_384 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002493 scripts/config.py full
2494 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2495 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2496 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2497 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2498 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2499 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2500 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2501 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2502 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2503 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2504 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2505 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2506}
2507
2508# This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test.
2509component_build_psa_accel_alg_sha512() {
Gilles Peskine168be012023-07-19 19:36:55 +02002510 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_512 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002511 scripts/config.py full
2512 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2513 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2514 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2515 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2516 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2517 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2518 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2519 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2520 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2521 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2522 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2523 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2524 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2525}
2526
John Durkopd0321952020-10-29 21:37:36 -07002527# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002528component_build_psa_accel_alg_rsa_pkcs1v15_crypt() {
Gilles Peskine168be012023-07-19 19:36:55 +02002529 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
John Durkopd0321952020-10-29 21:37:36 -07002530 scripts/config.py full
2531 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2532 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2533 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkopbd069d32020-10-31 22:14:03 -07002534 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002535 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2536 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2537 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopd0321952020-10-29 21:37:36 -07002538 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkopbd069d32020-10-31 22:14:03 -07002539 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2540}
2541
2542# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002543component_build_psa_accel_alg_rsa_pkcs1v15_sign() {
Gilles Peskine168be012023-07-19 19:36:55 +02002544 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
John Durkopbd069d32020-10-31 22:14:03 -07002545 scripts/config.py full
2546 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2547 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2548 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2549 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002550 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2551 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2552 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07002553 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2554 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2555}
2556
2557# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002558component_build_psa_accel_alg_rsa_oaep() {
Gilles Peskine168be012023-07-19 19:36:55 +02002559 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
John Durkopbd069d32020-10-31 22:14:03 -07002560 scripts/config.py full
2561 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2562 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2563 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2564 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_OAEP 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002565 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2566 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2567 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07002568 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2569 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2570}
2571
2572# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002573component_build_psa_accel_alg_rsa_pss() {
Gilles Peskine168be012023-07-19 19:36:55 +02002574 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
John Durkopbd069d32020-10-31 22:14:03 -07002575 scripts/config.py full
2576 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2577 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2578 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2579 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002580 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2581 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2582 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
John Durkopbd069d32020-10-31 22:14:03 -07002583 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2584 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2585}
2586
2587# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002588component_build_psa_accel_key_type_rsa_key_pair() {
Gilles Peskine168be012023-07-19 19:36:55 +02002589 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + PSA_WANT_ALG_RSA_PSS"
John Durkopbd069d32020-10-31 22:14:03 -07002590 scripts/config.py full
2591 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2592 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2593 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2594 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
2595 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1
2596 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2597 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2598}
2599
2600# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002601component_build_psa_accel_key_type_rsa_public_key() {
Gilles Peskine168be012023-07-19 19:36:55 +02002602 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS"
John Durkopbd069d32020-10-31 22:14:03 -07002603 scripts/config.py full
2604 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2605 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2606 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2607 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
2608 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
2609 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2610 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopd0321952020-10-29 21:37:36 -07002611}
2612
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002613component_test_check_params_functionality () {
2614 msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002615 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002616 # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002617 scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
Ronald Crona1236142020-07-01 16:01:21 +02002618 make CC=gcc CFLAGS='-Werror -O1' all test
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002619}
2620
Gilles Peskineb28636b2019-01-02 19:06:24 +01002621component_test_check_params_without_platform () {
2622 msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002623 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002624 # Keep MBEDTLS_PARAM_FAILED as assert.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002625 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
2626 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
2627 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
2628 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
Gilles Peskine32e889d2020-04-12 23:43:28 +02002629 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002630 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
2631 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Gilles Peskine9c764bf2022-09-18 14:05:23 +02002632 scripts/config.py unset MBEDTLS_PLATFORM_VSNPRINTF_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002633 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
2634 scripts/config.py unset MBEDTLS_PLATFORM_C
Gilles Peskineb28636b2019-01-02 19:06:24 +01002635 make CC=gcc CFLAGS='-Werror -O1' all test
2636}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002637
Gilles Peskineb28636b2019-01-02 19:06:24 +01002638component_test_check_params_silent () {
2639 msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002640 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002641 # Set MBEDTLS_PARAM_FAILED to nothing.
Gilles Peskineb28636b2019-01-02 19:06:24 +01002642 sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
2643 make CC=gcc CFLAGS='-Werror -O1' all test
2644}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002645
Dave Rodgman173227d2023-06-29 09:29:00 +01002646component_build_aes_variations() { # ~45s
2647 msg "build: aes.o for all combinations of relevant config options"
Dave Rodgmanbf998282023-06-29 12:10:45 +01002648
Dave Rodgman173227d2023-06-29 09:29:00 +01002649 for a in set unset; do
2650 for b in set unset; do
2651 for c in set unset; do
2652 for d in set unset; do
2653 for e in set unset; do
2654 for f in set unset; do
2655 for g in set unset; do
Dave Rodgmanbf998282023-06-29 12:10:45 +01002656 echo ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT
2657 echo ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT
2658 echo ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES
2659 echo ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT
2660 echo ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT
2661 echo ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES
2662 echo ./scripts/config.py $g MBEDTLS_PADLOCK_C
Dave Rodgman173227d2023-06-29 09:29:00 +01002663
Dave Rodgmanbf998282023-06-29 12:10:45 +01002664 ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT
2665 ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT
2666 ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES
2667 ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT
2668 ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT
2669 ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES
2670 ./scripts/config.py $g MBEDTLS_PADLOCK_C
Dave Rodgman173227d2023-06-29 09:29:00 +01002671
Dave Rodgmanbf998282023-06-29 12:10:45 +01002672 rm -f library/aes.o
2673 make -C library aes.o CC="clang" CFLAGS="-O0 -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused"
Dave Rodgman173227d2023-06-29 09:29:00 +01002674 done
2675 done
2676 done
2677 done
2678 done
2679 done
2680 done
2681}
2682
Gilles Peskine8f073122018-11-27 15:58:47 +01002683component_test_no_platform () {
2684 # Full configuration build, without platform support, file IO and net sockets.
2685 # This should catch missing mbedtls_printf definitions, and by disabling file
2686 # IO, it should catch missing '#include <stdio.h>'
2687 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Paul Elliott68050372023-11-03 19:24:56 +00002688 scripts/config.py full_no_platform
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002689 scripts/config.py unset MBEDTLS_PLATFORM_C
2690 scripts/config.py unset MBEDTLS_NET_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002691 scripts/config.py unset MBEDTLS_FS_IO
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002692 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002693 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
2694 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Paul Elliott68050372023-11-03 19:24:56 +00002695 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine8f073122018-11-27 15:58:47 +01002696 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
2697 # to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002698 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
2699 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
Gilles Peskine8f073122018-11-27 15:58:47 +01002700}
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +00002701
Gilles Peskine8f073122018-11-27 15:58:47 +01002702component_build_no_std_function () {
2703 # catch compile bugs in _uninit functions
2704 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002705 scripts/config.py full
2706 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
2707 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002708 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine31fdda12021-10-08 11:45:47 +02002709 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine25319702021-10-07 19:34:57 +02002710 make
Gilles Peskine8f073122018-11-27 15:58:47 +01002711}
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +01002712
Gilles Peskine8f073122018-11-27 15:58:47 +01002713component_build_no_ssl_srv () {
2714 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002715 scripts/config.py full
2716 scripts/config.py unset MBEDTLS_SSL_SRV_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002717 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01002718}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02002719
Gilles Peskine8f073122018-11-27 15:58:47 +01002720component_build_no_ssl_cli () {
2721 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002722 scripts/config.py full
2723 scripts/config.py unset MBEDTLS_SSL_CLI_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002724 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01002725}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02002726
Gilles Peskine8f073122018-11-27 15:58:47 +01002727component_build_no_sockets () {
2728 # Note, C99 compliance can also be tested with the sockets support disabled,
2729 # as that requires a POSIX platform (which isn't the same as C99).
2730 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002731 scripts/config.py full
2732 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
2733 scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002734 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01002735}
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +02002736
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002737component_test_memory_buffer_allocator_backtrace () {
2738 msg "build: default config with memory buffer allocator and backtrace enabled"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002739 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2740 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2741 scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
2742 scripts/config.py set MBEDTLS_MEMORY_DEBUG
Dave Rodgman374b1882024-01-04 10:30:57 +00002743 cmake -DCMAKE_BUILD_TYPE:String=Release .
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002744 make
2745
2746 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
2747 make test
2748}
2749
2750component_test_memory_buffer_allocator () {
2751 msg "build: default config with memory buffer allocator"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002752 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2753 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
Dave Rodgman374b1882024-01-04 10:30:57 +00002754 cmake -DCMAKE_BUILD_TYPE:String=Release .
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002755 make
2756
2757 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2758 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01002759
2760 msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2761 # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002762 tests/ssl-opt.sh -e '^DTLS proxy'
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002763}
2764
Gilles Peskine8f073122018-11-27 15:58:47 +01002765component_test_no_max_fragment_length () {
2766 # Run max fragment length tests with MFL disabled
2767 msg "build: default config except MFL extension (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002768 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Gilles Peskine8f073122018-11-27 15:58:47 +01002769 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2770 make
Hanno Becker5175ac62017-09-18 15:36:25 +01002771
Gilles Peskine8f073122018-11-27 15:58:47 +01002772 msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002773 tests/ssl-opt.sh -f "Max fragment length"
Gilles Peskine8f073122018-11-27 15:58:47 +01002774}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002775
Hanno Becker545ced42019-02-19 11:10:48 +00002776component_test_asan_remove_peer_certificate () {
2777 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002778 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
Hanno Becker545ced42019-02-19 11:10:48 +00002779 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2780 make
2781
2782 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2783 make test
2784
2785 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002786 tests/ssl-opt.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002787
2788 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002789 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002790
2791 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002792 tests/context-info.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002793}
2794
Gilles Peskine8f073122018-11-27 15:58:47 +01002795component_test_no_max_fragment_length_small_ssl_out_content_len () {
2796 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002797 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2798 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
2799 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01002800 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2801 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10002802
Gilles Peskine8f073122018-11-27 15:58:47 +01002803 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002804 tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002805
2806 msg "test: context-info.sh (disabled MFL extension case)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002807 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01002808}
Angus Grattonc4dd0732018-04-11 16:28:39 +10002809
Darryl Greenaad82f92019-12-02 10:53:11 +00002810component_test_variable_ssl_in_out_buffer_len () {
2811 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
2812 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2813 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2814 make
2815
2816 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
2817 make test
2818
2819 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002820 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002821
2822 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002823 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002824}
2825
2826component_test_variable_ssl_in_out_buffer_len_CID () {
2827 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)"
2828 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2829 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
2830
2831 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2832 make
2833
2834 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID"
2835 make test
2836
2837 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002838 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002839
2840 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002841 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002842}
2843
2844component_test_variable_ssl_in_out_buffer_len_record_splitting () {
2845 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)"
2846 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2847 scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING
2848
2849 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2850 make
2851
2852 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING"
2853 make test
2854
2855 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002856 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002857
2858 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002859 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002860}
2861
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002862component_test_ssl_alloc_buffer_and_mfl () {
2863 msg "build: default config with memory buffer allocator and MFL extension"
2864 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2865 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2866 scripts/config.py set MBEDTLS_MEMORY_DEBUG
2867 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2868 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
Dave Rodgman374b1882024-01-04 10:30:57 +00002869 cmake -DCMAKE_BUILD_TYPE:String=Release .
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002870 make
2871
2872 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
2873 make test
2874
2875 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002876 tests/ssl-opt.sh -f "Handshake memory usage"
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002877}
2878
Gilles Peskine636c26a2020-03-04 20:46:15 +01002879component_test_when_no_ciphersuites_have_mac () {
2880 msg "build: when no ciphersuites have MAC"
2881 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
2882 scripts/config.py unset MBEDTLS_ARC4_C
2883 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2884 make
2885
2886 msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
2887 make test
2888
2889 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002890 tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
Gilles Peskine636c26a2020-03-04 20:46:15 +01002891}
2892
Gilles Peskine8f073122018-11-27 15:58:47 +01002893component_test_null_entropy () {
2894 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002895 scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY
2896 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
2897 scripts/config.py set MBEDTLS_ENTROPY_C
2898 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002899 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002900 scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT
2901 scripts/config.py unset MBEDTLS_HAVEGE_C
Gilles Peskine5fa32a72019-01-06 19:48:30 +00002902 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON .
Gilles Peskine8f073122018-11-27 15:58:47 +01002903 make
Janos Follath06c54002016-06-09 13:57:40 +01002904
Gilles Peskine8f073122018-11-27 15:58:47 +01002905 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
2906 make test
2907}
Janos Follath06c54002016-06-09 13:57:40 +01002908
Raoul Strackxa4e86142020-06-15 17:03:13 +02002909component_test_no_date_time () {
2910 msg "build: default config without MBEDTLS_HAVE_TIME_DATE"
2911 scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
Gilles Peskine31fdda12021-10-08 11:45:47 +02002912 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
Raoul Strackxa4e86142020-06-15 17:03:13 +02002913 make
2914
2915 msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites"
2916 make test
2917}
2918
Andrzej Kurekc890b222023-01-17 04:03:19 -05002919component_test_alt_timing() {
2920 msg "build: alternate timing implementation"
2921 scripts/config.py set MBEDTLS_TIMING_ALT
2922 make lib TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../tests/src/external_timing"
2923
2924 msg "test: MBEDTLS_TIMING_ALT - test suites"
2925 make test TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../tests/src/external_timing"
Andrzej Kurek3a261a42023-01-26 04:33:59 -05002926
2927 msg "selftest - MBEDTLS-TIMING_ALT"
2928 make programs TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../../tests/src/external_timing -I../tests/src/external_timing"
2929 programs/test/selftest
Andrzej Kurekc890b222023-01-17 04:03:19 -05002930}
2931
Gilles Peskine8f073122018-11-27 15:58:47 +01002932component_test_platform_calloc_macro () {
2933 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002934 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2935 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
2936 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
Gilles Peskine8f073122018-11-27 15:58:47 +01002937 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2938 make
Hanno Beckere5fecec2018-10-11 11:02:52 +01002939
Gilles Peskine8f073122018-11-27 15:58:47 +01002940 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
2941 make test
2942}
Hanno Beckere5fecec2018-10-11 11:02:52 +01002943
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002944component_test_malloc_0_null () {
2945 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002946 scripts/config.py full
Gilles Peskine2e70f1c2023-07-20 19:00:15 +02002947 make CC=gcc CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002948
2949 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
2950 make test
2951
2952 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
2953 # Just the calloc selftest. "make test" ran the others as part of the
2954 # test suites.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002955 programs/test/selftest calloc
Gilles Peskine765d2402020-02-11 18:26:34 +01002956
2957 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
2958 # Run a subset of the tests. The choice is a balance between coverage
2959 # and time (including time indirectly wasted due to flaky tests).
2960 # The current choice is to skip tests whose description includes
2961 # "proxy", which is an approximation of skipping tests that use the
2962 # UDP proxy, which tend to be slower and flakier.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002963 tests/ssl-opt.sh -e 'proxy'
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002964}
2965
Gilles Peskine8f073122018-11-27 15:58:47 +01002966component_test_aes_fewer_tables () {
2967 msg "build: default config with AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002968 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
Dave Rodgmance04f242024-01-04 10:34:31 +00002969 make CFLAGS='-O2 -Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002970
Gilles Peskine8f073122018-11-27 15:58:47 +01002971 msg "test: AES_FEWER_TABLES"
2972 make test
2973}
Hanno Becker83ebf782017-07-07 12:29:15 +01002974
Gilles Peskine8f073122018-11-27 15:58:47 +01002975component_test_aes_rom_tables () {
2976 msg "build: default config with AES_ROM_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002977 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Dave Rodgmance04f242024-01-04 10:34:31 +00002978 make CFLAGS='-O2 -Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002979
Gilles Peskine8f073122018-11-27 15:58:47 +01002980 msg "test: AES_ROM_TABLES"
2981 make test
2982}
Hanno Becker83ebf782017-07-07 12:29:15 +01002983
Gilles Peskine8f073122018-11-27 15:58:47 +01002984component_test_aes_fewer_tables_and_rom_tables () {
2985 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002986 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
2987 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Dave Rodgmance04f242024-01-04 10:34:31 +00002988 make CFLAGS='-O2 -Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002989
Gilles Peskine8f073122018-11-27 15:58:47 +01002990 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
2991 make test
2992}
2993
Gilles Peskine592f5912019-10-07 18:49:32 +02002994component_test_ctr_drbg_aes_256_sha_256 () {
2995 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002996 scripts/config.py full
2997 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2998 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02002999 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3000 make
3001
3002 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3003 make test
3004}
3005
3006component_test_ctr_drbg_aes_128_sha_512 () {
3007 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01003008 scripts/config.py full
3009 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3010 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
Gilles Peskine592f5912019-10-07 18:49:32 +02003011 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3012 make
3013
3014 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
3015 make test
3016}
3017
3018component_test_ctr_drbg_aes_128_sha_256 () {
3019 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01003020 scripts/config.py full
3021 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3022 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
3023 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02003024 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3025 make
3026
3027 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3028 make test
3029}
3030
Gilles Peskinef96aefe2019-07-24 14:58:38 +02003031component_test_se_default () {
3032 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003033 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine004206c2019-10-21 17:11:33 +02003034 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinef96aefe2019-07-24 14:58:38 +02003035
3036 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
3037 make test
3038}
3039
Steven Cooremand57203d2020-07-16 20:28:59 +02003040component_test_psa_crypto_drivers () {
Gilles Peskine8d77ec22023-07-26 18:45:20 +02003041 msg "build: full + test drivers dispatching to builtins"
Steven Cooreman753f9732021-03-15 11:38:44 +01003042 scripts/config.py full
Steven Cooremand57203d2020-07-16 20:28:59 +02003043 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
Gilles Peskinefe0acc62021-09-20 19:20:04 +02003044 loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL"
3045 loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
Ronald Cron17b3afc2020-12-10 18:17:09 +01003046 loc_cflags="${loc_cflags} -I../tests/include -O2"
3047
3048 make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
Steven Cooremand57203d2020-07-16 20:28:59 +02003049
Gilles Peskine8d77ec22023-07-26 18:45:20 +02003050 msg "test: full + test drivers dispatching to builtins"
Steven Cooremand57203d2020-07-16 20:28:59 +02003051 make test
3052}
3053
Gilles Peskine8f073122018-11-27 15:58:47 +01003054component_test_make_shared () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003055 msg "build/test: make shared" # ~ 40s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04003056 make SHARED=1 all check
Gilles Peskine56c01612019-07-03 20:43:32 +02003057 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskine27482f12021-11-04 12:52:14 +01003058 programs/test/dlopen_demo.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003059}
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +02003060
Gilles Peskinecf740502019-07-03 20:43:05 +02003061component_test_cmake_shared () {
3062 msg "build/test: cmake shared" # ~ 2min
3063 cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
3064 make
Gilles Peskine56c01612019-07-03 20:43:32 +02003065 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskinecf740502019-07-03 20:43:05 +02003066 make test
Gilles Peskine27482f12021-11-04 12:52:14 +01003067 programs/test/dlopen_demo.sh
Gilles Peskinecf740502019-07-03 20:43:05 +02003068}
3069
Gilles Peskineec10bf12019-09-20 19:56:06 +02003070test_build_opt () {
3071 info=$1 cc=$2; shift 2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003072 $cc --version
Gilles Peskineec10bf12019-09-20 19:56:06 +02003073 for opt in "$@"; do
3074 msg "build/test: $cc $opt, $info" # ~ 30s
Gilles Peskinee094a182020-04-14 20:08:41 +02003075 make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Gilles Peskineec10bf12019-09-20 19:56:06 +02003076 # We're confident enough in compilers to not run _all_ the tests,
3077 # but at least run the unit tests. In particular, runs with
3078 # optimizations use inline assembly whereas runs with -O0
3079 # skip inline assembly.
3080 make test # ~30s
3081 make clean
3082 done
3083}
3084
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003085# For FreeBSD we invoke the function by name so this condition is added
3086# to disable the existing test_clang_opt function for linux.
3087if [[ $(uname) != "Linux" ]]; then
3088 component_test_clang_opt () {
3089 scripts/config.py full
3090 test_build_opt 'full config' clang -O0 -Os -O2
3091 }
3092fi
3093
3094component_test_clang_latest_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01003095 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003096 test_build_opt 'full config' "$CLANG_LATEST" -O0 -Os -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003097}
3098support_test_clang_latest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003099 type "$CLANG_LATEST" >/dev/null 2>/dev/null
Gilles Peskineec10bf12019-09-20 19:56:06 +02003100}
3101
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003102component_test_clang_earliest_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01003103 scripts/config.py full
Gilles Peskinebfe4fc62024-06-19 16:30:36 +02003104 test_build_opt 'full config' "$CLANG_EARLIEST" -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003105}
3106support_test_clang_earliest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003107 type "$CLANG_EARLIEST" >/dev/null 2>/dev/null
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003108}
3109
3110component_test_gcc_latest_opt () {
3111 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003112 test_build_opt 'full config' "$GCC_LATEST" -O0 -Os -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003113}
3114support_test_gcc_latest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003115 type "$GCC_LATEST" >/dev/null 2>/dev/null
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003116}
3117
3118component_test_gcc_earliest_opt () {
3119 scripts/config.py full
Gilles Peskinebfe4fc62024-06-19 16:30:36 +02003120 test_build_opt 'full config' "$GCC_EARLIEST" -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003121}
3122support_test_gcc_earliest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003123 type "$GCC_EARLIEST" >/dev/null 2>/dev/null
Gilles Peskineec10bf12019-09-20 19:56:06 +02003124}
3125
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02003126component_build_mbedtls_config_file () {
3127 msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
Gilles Peskine6af9dc92022-04-07 20:55:57 +02003128 scripts/config.py -w full_config.h full
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02003129 echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
3130 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
Gilles Peskine932b30b2022-04-13 23:23:21 +02003131 # Make sure this feature is enabled. We'll disable it in the next phase.
Gilles Peskine036a9bb2022-04-07 21:06:41 +02003132 programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3133 make clean
3134
3135 msg "build: make with MBEDTLS_CONFIG_FILE + MBEDTLS_USER_CONFIG_FILE"
3136 # In the user config, disable one feature (for simplicity, pick a feature
3137 # that nothing else depends on).
3138 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3139 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"' -DMBEDTLS_USER_CONFIG_FILE='\"user_config.h\"'"
3140 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3141
3142 rm -f user_config.h full_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003143}
3144
Gilles Peskine690a2ef2022-04-07 21:59:14 +02003145component_build_psa_config_file () {
3146 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE" # ~40s
3147 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
3148 cp "$CRYPTO_CONFIG_H" psa_test_config.h
3149 echo '#error "MBEDTLS_PSA_CRYPTO_CONFIG_FILE is not working"' >"$CRYPTO_CONFIG_H"
3150 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"'"
Gilles Peskine932b30b2022-04-13 23:23:21 +02003151 # Make sure this feature is enabled. We'll disable it in the next phase.
Gilles Peskine690a2ef2022-04-07 21:59:14 +02003152 programs/test/query_compile_time_config MBEDTLS_CMAC_C
3153 make clean
3154
3155 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE + MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE" # ~40s
3156 # In the user config, disable one feature, which will reflect on the
3157 # mbedtls configuration so we can query it with query_compile_time_config.
3158 echo '#undef PSA_WANT_ALG_CMAC' >psa_user_config.h
3159 scripts/config.py unset MBEDTLS_CMAC_C
3160 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"' -DMBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE='\"psa_user_config.h\"'"
3161 not programs/test/query_compile_time_config MBEDTLS_CMAC_C
3162
3163 rm -f psa_test_config.h psa_user_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003164}
3165
Gilles Peskine8f073122018-11-27 15:58:47 +01003166component_test_m32_o0 () {
Gilles Peskinea0c51fb2021-10-07 19:27:16 +02003167 # Build without optimization, so as to use portable C code (in a 32-bit
3168 # build) and not the i386-specific inline assembly.
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003169 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003170 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02003171 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01003172
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003173 msg "test: i386, make, gcc -O0 (ASan build)"
3174 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01003175}
Gilles Peskine878cf602019-01-06 20:50:38 +00003176support_test_m32_o0 () {
3177 case $(uname -m) in
Pengyu Lva89b3672022-10-21 10:50:26 +00003178 amd64|x86_64) true;;
Gilles Peskine878cf602019-01-06 20:50:38 +00003179 *) false;;
3180 esac
3181}
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003182
Gilles Peskine6fa69862021-10-05 09:36:03 +02003183component_test_m32_o2 () {
3184 # Build with optimization, to use the i386 specific inline assembly
3185 # and go faster for tests.
3186 msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003187 scripts/config.py full
Gilles Peskine6fa69862021-10-05 09:36:03 +02003188 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003189
Gilles Peskine6fa69862021-10-05 09:36:03 +02003190 msg "test: i386, make, gcc -O2 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003191 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01003192
Gilles Peskine6fa69862021-10-05 09:36:03 +02003193 msg "test ssl-opt.sh, i386, make, gcc-O2"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003194 tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003195}
Gilles Peskine3daa83e2021-10-07 19:25:29 +02003196support_test_m32_o2 () {
Gilles Peskine878cf602019-01-06 20:50:38 +00003197 support_test_m32_o0 "$@"
3198}
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003199
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003200component_test_m32_everest () {
3201 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003202 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
3203 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
Gilles Peskine8fd59422019-10-21 17:11:33 +02003204 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003205
3206 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
3207 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01003208
3209 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003210 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01003211
3212 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
3213 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003214 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003215}
3216support_test_m32_everest () {
3217 support_test_m32_o0 "$@"
3218}
3219
Gilles Peskine8f073122018-11-27 15:58:47 +01003220component_test_mx32 () {
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003221 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003222 scripts/config.py full
Dave Rodgmance04f242024-01-04 10:34:31 +00003223 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003224
3225 msg "test: 64-bit ILP32, make, gcc"
3226 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01003227}
Gilles Peskine878cf602019-01-06 20:50:38 +00003228support_test_mx32 () {
3229 case $(uname -m) in
3230 amd64|x86_64) true;;
3231 *) false;;
3232 esac
3233}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003234
Peter Kolbus60c6da22018-12-27 06:59:04 -06003235component_test_min_mpi_window_size () {
3236 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003237 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
Peter Kolbus60c6da22018-12-27 06:59:04 -06003238 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3239 make
3240
3241 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
3242 make test
3243}
3244
Gilles Peskine8f073122018-11-27 15:58:47 +01003245component_test_have_int32 () {
3246 msg "build: gcc, force 32-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003247 scripts/config.py unset MBEDTLS_HAVE_ASM
3248 scripts/config.py unset MBEDTLS_AESNI_C
3249 scripts/config.py unset MBEDTLS_PADLOCK_C
Dave Rodgmance04f242024-01-04 10:34:31 +00003250 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01003251
Gilles Peskine8f073122018-11-27 15:58:47 +01003252 msg "test: gcc, force 32-bit bignum limbs"
3253 make test
3254}
Andres Amaya Garciafe843a32017-07-20 13:21:34 +01003255
Gilles Peskine8f073122018-11-27 15:58:47 +01003256component_test_have_int64 () {
3257 msg "build: gcc, force 64-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003258 scripts/config.py unset MBEDTLS_HAVE_ASM
3259 scripts/config.py unset MBEDTLS_AESNI_C
3260 scripts/config.py unset MBEDTLS_PADLOCK_C
Dave Rodgmance04f242024-01-04 10:34:31 +00003261 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Gilles Peskine14c3c062018-01-29 21:25:12 +01003262
Gilles Peskine8f073122018-11-27 15:58:47 +01003263 msg "test: gcc, force 64-bit bignum limbs"
3264 make test
3265}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003266
Gilles Peskine8f073122018-11-27 15:58:47 +01003267component_test_no_udbl_division () {
3268 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003269 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003270 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine8f073122018-11-27 15:58:47 +01003271 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003272
Gilles Peskine8f073122018-11-27 15:58:47 +01003273 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
3274 make test
3275}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003276
Gilles Peskine8f073122018-11-27 15:58:47 +01003277component_test_no_64bit_multiplication () {
3278 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003279 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003280 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine8f073122018-11-27 15:58:47 +01003281 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003282
Gilles Peskine8f073122018-11-27 15:58:47 +01003283 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
3284 make test
3285}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003286
Gilles Peskine3809f5f2020-11-09 15:40:05 +01003287component_test_no_strings () {
3288 msg "build: no strings" # ~10s
3289 scripts/config.py full
3290 # Disable options that activate a large amount of string constants.
3291 scripts/config.py unset MBEDTLS_DEBUG_C
3292 scripts/config.py unset MBEDTLS_ERROR_C
3293 scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY
3294 scripts/config.py unset MBEDTLS_VERSION_FEATURES
3295 make CFLAGS='-Werror -Os'
3296
3297 msg "test: no strings" # ~ 10s
3298 make test
3299}
3300
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003301component_test_arm_linux_gnueabi_gcc_arm5vte () {
3302 # Mimic Debian armel port
Bence Szépkútif92112d2024-07-18 15:56:15 +02003303 msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, default config" # ~4m
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003304 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1'
3305
Bence Szépkútif92112d2024-07-18 15:56:15 +02003306 msg "test: main suites make, default config (out-of-box)" # ~7m 40s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003307 make test
3308
Bence Szépkútif92112d2024-07-18 15:56:15 +02003309 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003310 programs/test/selftest
3311
Bence Szépkútif92112d2024-07-18 15:56:15 +02003312 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003313 tests/scripts/run_demos.py
3314}
3315
3316support_test_arm_linux_gnueabi_gcc_arm5vte () {
3317 can_run_arm_linux_gnueabi
3318}
3319
Bence Szépkúti478730e2024-07-18 16:08:22 +02003320# The hard float ABI is not implemented for Thumb 1, so use gnueabi
3321# Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
3322component_test_arm_linux_gnueabi_gcc_thumb_1_opt_0 () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003323 msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -O0, thumb 1, default config" # ~2m 10s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003324 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O0 -mcpu=arm1136j-s -mthumb'
3325
Bence Szépkútif92112d2024-07-18 15:56:15 +02003326 msg "test: main suites make, default config (out-of-box)" # ~36m
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003327 make test
3328
3329 msg "selftest: make, default config (out-of-box)" # ~10s
3330 programs/test/selftest
3331
Bence Szépkútif92112d2024-07-18 15:56:15 +02003332 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003333 tests/scripts/run_demos.py
Bence Szépkúti478730e2024-07-18 16:08:22 +02003334}
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003335
Bence Szépkúti478730e2024-07-18 16:08:22 +02003336support_test_arm_linux_gnueabi_gcc_thumb_1_opt_0 () {
3337 can_run_arm_linux_gnueabi
3338}
3339
3340component_test_arm_linux_gnueabi_gcc_thumb_1_opt_s () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003341 msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -Os, thumb 1, default config" # ~3m 10s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003342 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -Os -mcpu=arm1136j-s -mthumb'
3343
Bence Szépkútif92112d2024-07-18 15:56:15 +02003344 msg "test: main suites make, default config (out-of-box)" # ~21m 10s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003345 make test
3346
Bence Szépkútif92112d2024-07-18 15:56:15 +02003347 msg "selftest: make, default config (out-of-box)" # ~2s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003348 programs/test/selftest
3349
Bence Szépkútif92112d2024-07-18 15:56:15 +02003350 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003351 tests/scripts/run_demos.py
3352}
3353
Bence Szépkúti478730e2024-07-18 16:08:22 +02003354support_test_arm_linux_gnueabi_gcc_thumb_1_opt_s () {
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003355 can_run_arm_linux_gnueabi
3356}
3357
3358component_test_arm_linux_gnueabihf_gcc_armv7 () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003359 msg "test: ${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc -O2, A32, default config" # ~4m 30s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003360 make CC="${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O2 -march=armv7-a -marm'
3361
Bence Szépkútif92112d2024-07-18 15:56:15 +02003362 msg "test: main suites make, default config (out-of-box)" # ~3m 30s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003363 make test
3364
Bence Szépkútif92112d2024-07-18 15:56:15 +02003365 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003366 programs/test/selftest
3367
Bence Szépkútif92112d2024-07-18 15:56:15 +02003368 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003369 tests/scripts/run_demos.py
3370}
3371
3372support_test_arm_linux_gnueabihf_gcc_armv7 () {
3373 can_run_arm_linux_gnueabihf
3374}
3375
3376component_test_arm_linux_gnueabihf_gcc_thumb_2 () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003377 msg "test: ${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc -Os, thumb 2, default config" # ~4m
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003378 make CC="${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -Os -march=armv7-a -mthumb'
3379
Bence Szépkútif92112d2024-07-18 15:56:15 +02003380 msg "test: main suites make, default config (out-of-box)" # ~3m 40s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003381 make test
3382
Bence Szépkútif92112d2024-07-18 15:56:15 +02003383 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003384 programs/test/selftest
3385
Bence Szépkútif92112d2024-07-18 15:56:15 +02003386 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003387 tests/scripts/run_demos.py
3388}
3389
3390support_test_arm_linux_gnueabihf_gcc_thumb_2 () {
3391 can_run_arm_linux_gnueabihf
3392}
3393
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003394component_test_aarch64_linux_gnu_gcc () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003395 msg "test: ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc -O2, default config" # ~3m 50s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003396 make CC="${AARCH64_LINUX_GNU_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O2'
3397
Bence Szépkútif92112d2024-07-18 15:56:15 +02003398 msg "test: main suites make, default config (out-of-box)" # ~1m 50s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003399 make test
3400
Bence Szépkútif92112d2024-07-18 15:56:15 +02003401 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003402 programs/test/selftest
3403
Bence Szépkútif92112d2024-07-18 15:56:15 +02003404 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003405 tests/scripts/run_demos.py
3406}
3407
3408support_test_aarch64_linux_gnu_gcc () {
Bence Szépkútib14dd762024-10-27 22:31:13 +01003409 # Minimum version of GCC for MBEDTLS_AESCE_C is 6.0
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003410 [ "$(gcc_version "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc")" -ge 6 ] && can_run_aarch64_linux_gnu
3411}
3412
Gilles Peskine8f073122018-11-27 15:58:47 +01003413component_build_arm_none_eabi_gcc () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003414 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003415 scripts/config.py baremetal
Gilles Peskineaeedd742020-09-02 11:03:04 +02003416 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -O1' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003417
Gilles Peskine60d99472021-09-01 20:00:33 +02003418 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug"
Gilles Peskine18487f62020-04-30 23:11:54 +02003419 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003420}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003421
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003422component_build_arm_linux_gnueabi_gcc_arm5vte () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003423 msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003424 scripts/config.py baremetal
Gilles Peskine2c897d72019-08-09 16:05:05 +02003425 # Build for a target platform that's close to what Debian uses
3426 # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
Dave Rodgman52af7692022-03-31 14:27:24 +01003427 # See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments.
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003428 # Build everything including programs, see for example
Dave Rodgman52af7692022-03-31 14:27:24 +01003429 # https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003430 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te'
3431
Gilles Peskine60d99472021-09-01 20:00:33 +02003432 msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003433 ${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o
3434}
3435support_build_arm_linux_gnueabi_gcc_arm5vte () {
3436 type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
3437}
3438
3439component_build_arm_none_eabi_gcc_arm5vte () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003440 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003441 scripts/config.py baremetal
3442 # This is an imperfect substitute for
3443 # component_build_arm_linux_gnueabi_gcc_arm5vte
Manuel Pégourié-Gonnard9a260a62021-07-06 09:44:59 +02003444 # in case the gcc-arm-linux-gnueabi toolchain is not available
Gilles Peskineaeedd742020-09-02 11:03:04 +02003445 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003446
Gilles Peskine60d99472021-09-01 20:00:33 +02003447 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
Gilles Peskine18487f62020-04-30 23:11:54 +02003448 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine93e4e032019-08-05 11:34:25 +02003449}
3450
Gilles Peskine6e2fb862020-04-30 23:00:53 +02003451component_build_arm_none_eabi_gcc_m0plus () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003452 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s
3453 scripts/config.py baremetal_size
Gilles Peskineaeedd742020-09-02 11:03:04 +02003454 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003455
Gilles Peskine60d99472021-09-01 20:00:33 +02003456 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size"
Gilles Peskine18487f62020-04-30 23:11:54 +02003457 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine6e2fb862020-04-30 23:00:53 +02003458}
3459
Gilles Peskine8f073122018-11-27 15:58:47 +01003460component_build_arm_none_eabi_gcc_no_udbl_division () {
Gilles Peskine6d061342020-04-30 18:19:32 +02003461 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003462 scripts/config.py baremetal
3463 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskineaeedd742020-09-02 11:03:04 +02003464 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01003465 echo "Checking that software 64-bit division is not required"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003466 not grep __aeabi_uldiv library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003467}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003468
Gilles Peskine8f073122018-11-27 15:58:47 +01003469component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
Gilles Peskine6d061342020-04-30 18:19:32 +02003470 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003471 scripts/config.py baremetal
3472 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskineaeedd742020-09-02 11:03:04 +02003473 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01003474 echo "Checking that software 64-bit multiplication is not required"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003475 not grep __aeabi_lmul library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003476}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003477
Dave Rodgman43ea9ab2023-06-02 10:26:24 -04003478component_build_arm_clang_thumb () {
3479 # ~ 30s
3480
3481 scripts/config.py baremetal
3482
3483 msg "build: clang thumb 2, make"
3484 make clean
3485 make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib
3486
3487 # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
3488 msg "build: clang thumb 1 -O0, make"
3489 make clean
3490 make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
3491
3492 msg "build: clang thumb 1 -Os, make"
3493 make clean
3494 make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
3495}
3496
Gilles Peskine8f073122018-11-27 15:58:47 +01003497component_build_armcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02003498 msg "build: ARM Compiler 5"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003499 scripts/config.py baremetal
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003500 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003501
3502 msg "size: ARM Compiler 5"
3503 "$ARMC5_FROMELF" -z library/*.o
3504
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003505 make clean
Andres AG87bb5772016-09-27 15:05:15 +01003506
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003507 # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0.
3508
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003509 # ARM Compiler 6 - Target ARMv7-A
3510 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02003511
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003512 # ARM Compiler 6 - Target ARMv7-M
3513 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02003514
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003515 # ARM Compiler 6 - Target ARMv8-A - AArch32
3516 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02003517
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003518 # ARM Compiler 6 - Target ARMv8-M
3519 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02003520
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003521 # ARM Compiler 6 - Target ARMv8-A - AArch64
3522 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003523
3524 # ARM Compiler 6 - Target Cortex-M0 - no optimisation
3525 armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0"
3526
3527 # ARM Compiler 6 - Target Cortex-M0
3528 armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0"
Gilles Peskine8f073122018-11-27 15:58:47 +01003529}
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003530
Pengyu Lvd216c042023-03-03 18:23:35 +08003531support_build_armcc () {
3532 armc5_cc="$ARMC5_BIN_DIR/armcc"
3533 armc6_cc="$ARMC6_BIN_DIR/armclang"
3534 (check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1)
3535}
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01003536
Manuel Pégourié-Gonnarddd8807f2020-02-26 09:56:27 +01003537component_build_ssl_hw_record_accel() {
3538 msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled"
3539 scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL
3540 make CFLAGS='-Werror -O1'
3541}
3542
Hanno Beckera711f6e2020-05-04 12:03:51 +01003543component_test_tls13_experimental () {
3544 msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
3545 scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
3546 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3547 make
3548 msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
3549 make test
3550}
3551
Gilles Peskine8f073122018-11-27 15:58:47 +01003552component_build_mingw () {
3553 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Gilles Peskinec61187f2024-06-19 16:34:29 +02003554 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Hanno Beckere963efa2018-01-03 10:03:43 +00003555
Gilles Peskine8f073122018-11-27 15:58:47 +01003556 # note Make tests only builds the tests, but doesn't run them
Gilles Peskinec61187f2024-06-19 16:34:29 +02003557 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror' WINDOWS_BUILD=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01003558 make WINDOWS_BUILD=1 clean
Gilles Peskine2a458da2017-05-12 15:26:58 +02003559
Gilles Peskine8f073122018-11-27 15:58:47 +01003560 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskinec61187f2024-06-19 16:34:29 +02003561 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
3562 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01003563 make WINDOWS_BUILD=1 clean
Pengyu Lvb2ca0322023-10-19 17:17:19 +08003564
3565 msg "build: Windows cross build - mingw64, make (Library only, AESNI intrinsics)" # ~ 30s
Gilles Peskinec61187f2024-06-19 16:34:29 +02003566 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 lib
Pengyu Lve6cbec82023-10-20 09:49:01 +08003567 make WINDOWS_BUILD=1 clean
3568
3569 msg "build: Windows cross build - mingw64, make (Library only, default config without MBEDTLS_AESNI_C)" # ~ 30s
3570 ./scripts/config.py unset MBEDTLS_AESNI_C
Gilles Peskinec61187f2024-06-19 16:34:29 +02003571 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib
Pengyu Lve6cbec82023-10-20 09:49:01 +08003572 make WINDOWS_BUILD=1 clean
Gilles Peskinec61187f2024-06-19 16:34:29 +02003573}
3574
Jaeden Amero117b8a42019-04-17 15:19:26 +01003575support_build_mingw() {
Pengyu Lva19ce122023-02-24 15:38:52 +08003576 case $(i686-w64-mingw32-gcc -dumpversion 2>/dev/null) in
3577 [0-5]*|"") false;;
Jaeden Amero117b8a42019-04-17 15:19:26 +01003578 *) true;;
3579 esac
3580}
Simon Butcher91aef332016-11-17 09:20:50 +00003581
Gilles Peskine8f073122018-11-27 15:58:47 +01003582component_test_memsan () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003583 msg "build: MSan (clang)" # ~ 1 min 20s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003584 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003585 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
3586 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02003587
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003588 msg "test: main suites (MSan)" # ~ 10s
3589 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003590
Gilles Peskineee8af062023-11-02 19:58:03 +01003591 msg "test: metatests (MSan)"
3592 tests/scripts/run-metatests.sh any msan
3593
Gilles Peskine93aaf2e2019-06-14 18:27:03 +02003594 msg "program demos (MSan)" # ~20s
3595 tests/scripts/run_demos.py
3596
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003597 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003598 tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003599
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003600 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003601
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003602 if [ "$MEMORY" -gt 0 ]; then
3603 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003604 tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003605 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01003606}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003607
Bence Szépkútie1c6c4c2023-12-06 16:14:37 +01003608component_release_test_valgrind () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003609 msg "build: Release (clang)"
Gilles Peskine619b73d2022-11-29 16:45:30 +01003610 # default config, in particular without MBEDTLS_USE_PSA_CRYPTO
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003611 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
3612 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003613
Gilles Peskine619b73d2022-11-29 16:45:30 +01003614 msg "test: main suites, Valgrind (default config)"
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003615 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003616
Gilles Peskine636c26a2020-03-04 20:46:15 +01003617 # Optional parts (slow; currently broken on OS X because programs don't
3618 # seem to receive signals under valgrind on OS X).
Gilles Peskine619b73d2022-11-29 16:45:30 +01003619 # These optional parts don't run on the CI.
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003620 if [ "$MEMORY" -gt 0 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003621 msg "test: ssl-opt.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003622 tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003623 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003624
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003625 if [ "$MEMORY" -gt 1 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003626 msg "test: compat.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003627 tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003628 fi
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02003629
3630 if [ "$MEMORY" -gt 0 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003631 msg "test: context-info.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003632 tests/context-info.sh --memcheck
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02003633 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01003634}
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003635
Bence Szépkútie1c6c4c2023-12-06 16:14:37 +01003636component_release_test_valgrind_psa () {
Gilles Peskine619b73d2022-11-29 16:45:30 +01003637 msg "build: Release, full (clang)"
3638 # full config, in particular with MBEDTLS_USE_PSA_CRYPTO
3639 scripts/config.py full
3640 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
3641 make
3642
3643 msg "test: main suites, Valgrind (full config)"
3644 make memcheck
3645}
3646
Paul Elliott2ab9a7a2021-11-25 17:29:40 +00003647support_test_cmake_out_of_source () {
3648 distrib_id=""
3649 distrib_ver=""
3650 distrib_ver_minor=""
3651 distrib_ver_major=""
3652
3653 # Attempt to parse lsb-release to find out distribution and version. If not
3654 # found this should fail safe (test is supported).
3655 if [[ -f /etc/lsb-release ]]; then
3656
3657 while read -r lsb_line; do
3658 case "$lsb_line" in
3659 "DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};;
3660 "DISTRIB_RELEASE"*) distrib_ver=${lsb_line/#DISTRIB_RELEASE=};;
3661 esac
3662 done < /etc/lsb-release
3663
3664 distrib_ver_major="${distrib_ver%%.*}"
3665 distrib_ver="${distrib_ver#*.}"
3666 distrib_ver_minor="${distrib_ver%%.*}"
3667 fi
3668
3669 # Running the out of source CMake test on Ubuntu 16.04 using more than one
3670 # processor (as the CI does) can create a race condition whereby the build
3671 # fails to see a generated file, despite that file actually having been
3672 # generated. This problem appears to go away with 18.04 or newer, so make
3673 # the out of source tests unsupported on Ubuntu 16.04.
3674 [ "$distrib_id" != "Ubuntu" ] || [ "$distrib_ver_major" -gt 16 ]
3675}
3676
Gilles Peskine8f073122018-11-27 15:58:47 +01003677component_test_cmake_out_of_source () {
3678 msg "build: cmake 'out-of-source' build"
Gilles Peskine8f073122018-11-27 15:58:47 +01003679 MBEDTLS_ROOT_DIR="$PWD"
3680 mkdir "$OUT_OF_SOURCE_DIR"
3681 cd "$OUT_OF_SOURCE_DIR"
Gilles Peskine25319702021-10-07 19:34:57 +02003682 cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +01003683 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003684
Gilles Peskine8f073122018-11-27 15:58:47 +01003685 msg "test: cmake 'out-of-source' build"
3686 make test
3687 # Test an SSL option that requires an auxiliary script in test/scripts/.
3688 # Also ensure that there are no error messages such as
3689 # "No such file or directory", which would indicate that some required
3690 # file is missing (ssl-opt.sh tolerates the absence of some files so
3691 # may exit with status 0 but emit errors).
Gilles Peskinee8133cb2022-04-15 22:43:38 +02003692 ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' >ssl-opt.out 2>ssl-opt.err
3693 grep PASS ssl-opt.out
Gilles Peskine0a7984f2020-03-28 18:56:09 +01003694 cat ssl-opt.err >&2
3695 # If ssl-opt.err is non-empty, record an error and keep going.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003696 [ ! -s ssl-opt.err ]
Gilles Peskinee8133cb2022-04-15 22:43:38 +02003697 rm ssl-opt.out ssl-opt.err
Gilles Peskine8f073122018-11-27 15:58:47 +01003698 cd "$MBEDTLS_ROOT_DIR"
3699 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +01003700}
Andres AGdc192212016-08-31 17:33:13 +01003701
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003702component_test_cmake_as_subdirectory () {
3703 msg "build: cmake 'as-subdirectory' build"
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003704 cd programs/test/cmake_subproject
3705 cmake .
3706 make
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003707 ./cmake_subproject
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003708}
Gilles Peskineca9cfca2022-02-04 00:21:12 +01003709support_test_cmake_as_subdirectory () {
3710 support_test_cmake_out_of_source
3711}
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003712
David Horstmann175afbd2023-01-12 14:17:01 +00003713component_build_cmake_custom_config_file () {
David Horstmann67622312023-01-31 10:34:44 +00003714 # Make a copy of config file to use for the in-tree test
3715 cp "$CONFIG_H" include/mbedtls_config_in_tree_copy.h
David Horstmann175afbd2023-01-12 14:17:01 +00003716
3717 MBEDTLS_ROOT_DIR="$PWD"
3718 mkdir "$OUT_OF_SOURCE_DIR"
3719 cd "$OUT_OF_SOURCE_DIR"
3720
David Horstmann67622312023-01-31 10:34:44 +00003721 # Build once to get the generated files (which need an intact config file)
David Horstmann175afbd2023-01-12 14:17:01 +00003722 cmake "$MBEDTLS_ROOT_DIR"
3723 make
3724
3725 msg "build: cmake with -DMBEDTLS_CONFIG_FILE"
3726 scripts/config.py -w full_config.h full
David Horstmann67622312023-01-31 10:34:44 +00003727 echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003728 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h "$MBEDTLS_ROOT_DIR"
3729 make
3730
3731 msg "build: cmake with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
3732 # In the user config, disable one feature (for simplicity, pick a feature
3733 # that nothing else depends on).
3734 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3735
3736 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h "$MBEDTLS_ROOT_DIR"
3737 make
3738 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3739
3740 rm -f user_config.h full_config.h
3741
3742 cd "$MBEDTLS_ROOT_DIR"
3743 rm -rf "$OUT_OF_SOURCE_DIR"
3744
3745 # Now repeat the test for an in-tree build:
3746
David Horstmann67622312023-01-31 10:34:44 +00003747 # Restore config for the in-tree test
3748 mv include/mbedtls_config_in_tree_copy.h "$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003749
David Horstmann67622312023-01-31 10:34:44 +00003750 # Build once to get the generated files (which need an intact config)
David Horstmann175afbd2023-01-12 14:17:01 +00003751 cmake .
3752 make
3753
3754 msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE"
3755 scripts/config.py -w full_config.h full
David Horstmann67622312023-01-31 10:34:44 +00003756 echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003757 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h .
3758 make
3759
3760 msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
3761 # In the user config, disable one feature (for simplicity, pick a feature
3762 # that nothing else depends on).
3763 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3764
3765 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h .
3766 make
3767 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3768
3769 rm -f user_config.h full_config.h
3770}
3771support_build_cmake_custom_config_file () {
3772 support_test_cmake_out_of_source
3773}
3774
3775
Tom Cosgrove51170622023-09-01 10:40:15 +01003776component_build_zeroize_checks () {
3777 msg "build: check for obviously wrong calls to mbedtls_platform_zeroize()"
3778
3779 scripts/config.py full
3780
3781 # Only compile - we're looking for sizeof-pointer-memaccess warnings
Dave Rodgman374b1882024-01-04 10:30:57 +00003782 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-zeroize-memset.h\"' -DMBEDTLS_TEST_DEFINES_ZEROIZE -Werror -Wsizeof-pointer-memaccess"
Tom Cosgrove51170622023-09-01 10:40:15 +01003783}
3784
3785
Gilles Peskine8f073122018-11-27 15:58:47 +01003786component_test_zeroize () {
3787 # Test that the function mbedtls_platform_zeroize() is not optimized away by
3788 # different combinations of compilers and optimization flags by using an
3789 # auxiliary GDB script. Unfortunately, GDB does not return error values to the
3790 # system in all cases that the script fails, so we must manually search the
3791 # output to check whether the pass string is present and no failure strings
3792 # were printed.
Andres AGdc192212016-08-31 17:33:13 +01003793
Gilles Peskine4976e822019-01-06 19:52:22 +00003794 # Don't try to disable ASLR. We don't care about ASLR here. We do care
3795 # about a spurious message if Gdb tries and fails, so suppress that.
3796 gdb_disable_aslr=
3797 if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
3798 gdb_disable_aslr='set disable-randomization off'
3799 fi
3800
Gilles Peskine8f073122018-11-27 15:58:47 +01003801 for optimization_flag in -O2 -O3 -Ofast -Os; do
Gilles Peskine55f7c942019-01-09 22:28:21 +01003802 for compiler in clang gcc; do
3803 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
3804 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003805 gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
3806 grep "The buffer was correctly zeroized" test_zeroize.log
3807 not grep -i "error" test_zeroize.log
Gilles Peskine55f7c942019-01-09 22:28:21 +01003808 rm -f test_zeroize.log
3809 make clean
3810 done
Andres Amaya Garcia29673812017-10-25 10:35:51 +01003811 done
Gilles Peskine8f073122018-11-27 15:58:47 +01003812}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003813
Bence Szépkúti9f849112021-10-19 15:05:36 +02003814component_test_psa_compliance () {
Dave Rodgmanb0660c22023-12-18 19:55:40 +00003815 # The arch tests build with gcc, so require use of gcc here to link properly
Bence Szépkútic1e79fd2021-11-11 20:13:14 +01003816 msg "build: make, default config + CMAC, libmbedcrypto.a only"
3817 scripts/config.py set MBEDTLS_CMAC_C
Dave Rodgmanb0660c22023-12-18 19:55:40 +00003818 CC=gcc make -C library libmbedcrypto.a
Bence Szépkúti9f849112021-10-19 15:05:36 +02003819
3820 msg "unit test: test_psa_compliance.py"
Dave Rodgman5b00fb12023-12-18 22:29:56 +00003821 CC=gcc ./tests/scripts/test_psa_compliance.py
Bence Szépkúti9f849112021-10-19 15:05:36 +02003822}
3823
3824support_test_psa_compliance () {
Bence Szépkútid6cf0892021-11-03 11:36:09 +01003825 # psa-compliance-tests only supports CMake >= 3.10.0
Bence Szépkútiab796e62021-10-25 19:29:07 +02003826 ver="$(cmake --version)"
3827 ver="${ver#cmake version }"
3828 ver_major="${ver%%.*}"
3829
3830 ver="${ver#*.}"
3831 ver_minor="${ver%%.*}"
3832
3833 [ "$ver_major" -eq 3 ] && [ "$ver_minor" -ge 10 ]
Bence Szépkúti9f849112021-10-19 15:05:36 +02003834}
3835
Gilles Peskineb9e56fb2022-12-09 12:23:35 +01003836component_check_code_style () {
3837 msg "Check C code style"
3838 ./scripts/code_style.py
David Horstmanne09c4762022-11-10 18:30:52 +00003839}
3840
Gilles Peskineb9e56fb2022-12-09 12:23:35 +01003841support_check_code_style() {
David Horstmanne09c4762022-11-10 18:30:52 +00003842 case $(uncrustify --version) in
3843 *0.75.1*) true;;
3844 *) false;;
3845 esac
3846}
3847
Gilles Peskine8f073122018-11-27 15:58:47 +01003848component_check_python_files () {
3849 msg "Lint: Python scripts"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003850 tests/scripts/check-python-files.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003851}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003852
Gilles Peskine8f073122018-11-27 15:58:47 +01003853component_check_generate_test_code () {
3854 msg "uint test: generate_test_code.py"
Manuel Pégourié-Gonnarddfb114a2020-06-02 11:40:08 +02003855 # unittest writes out mundane stuff like number or tests run on stderr.
3856 # Our convention is to reserve stderr for actual errors, and write
3857 # harmless info on stdout so it can be suppress with --quiet.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003858 ./tests/scripts/test_generate_test_code.py 2>&1
Gilles Peskine8f073122018-11-27 15:58:47 +01003859}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003860
3861################################################################
3862#### Termination
3863################################################################
3864
Gilles Peskine8f073122018-11-27 15:58:47 +01003865post_report () {
3866 msg "Done, cleaning up"
Gilles Peskine24bdf022020-03-30 20:11:39 +02003867 final_cleanup
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003868
Gilles Peskine8f073122018-11-27 15:58:47 +01003869 final_report
3870}
3871
3872
3873
3874################################################################
3875#### Run all the things
3876################################################################
3877
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003878# Function invoked by --error-test to test error reporting.
3879pseudo_component_error_test () {
Gilles Peskine202e9b42021-08-02 23:28:00 +02003880 msg "Testing error reporting $error_test_i"
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003881 if [ $KEEP_GOING -ne 0 ]; then
3882 echo "Expect three failing commands."
3883 fi
Gilles Peskine202e9b42021-08-02 23:28:00 +02003884 # If the component doesn't run in a subshell, changing error_test_i to an
3885 # invalid integer will cause an error in the loop that runs this function.
3886 error_test_i=this_should_not_be_used_since_the_component_runs_in_a_subshell
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003887 # Expected error: 'grep non_existent /dev/null -> 1'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003888 grep non_existent /dev/null
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003889 # Expected error: '! grep -q . tests/scripts/all.sh -> 1'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003890 not grep -q . "$0"
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003891 # Expected error: 'make unknown_target -> 2'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003892 make unknown_target
3893 false "this should not be executed"
3894}
3895
Gilles Peskinee48351a2018-11-27 16:06:30 +01003896# Run one component and clean up afterwards.
Gilles Peskine8f073122018-11-27 15:58:47 +01003897run_component () {
Gilles Peskineffcdeff2018-12-04 12:49:28 +01003898 current_component="$1"
Gilles Peskine9004a172019-09-16 15:20:36 +02003899 export MBEDTLS_TEST_CONFIGURATION="$current_component"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003900
3901 # Unconditionally create a seedfile that's sufficiently long.
3902 # Do this before each component, because a previous component may
3903 # have messed it up or shortened it.
Gilles Peskinef3133362021-07-08 19:03:50 +02003904 local dd_cmd
3905 dd_cmd=(dd if=/dev/urandom of=./tests/seedfile bs=64 count=1)
3906 case $OSTYPE in
3907 linux*|freebsd*|openbsd*|darwin*) dd_cmd+=(status=none)
3908 esac
3909 "${dd_cmd[@]}"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003910
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003911 # Run the component in a subshell, with error trapping and output
3912 # redirection set up based on the relevant options.
Gilles Peskine7105a332020-03-28 18:50:43 +01003913 if [ $KEEP_GOING -eq 1 ]; then
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003914 # We want to keep running if the subshell fails, so 'set -e' must
3915 # be off when the subshell runs.
Gilles Peskine7105a332020-03-28 18:50:43 +01003916 set +e
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02003917 fi
Gilles Peskine7105a332020-03-28 18:50:43 +01003918 (
3919 if [ $QUIET -eq 1 ]; then
3920 # msg() will be silenced, so just print the component name here.
3921 echo "${current_component#component_}"
3922 exec >/dev/null
3923 fi
3924 if [ $KEEP_GOING -eq 1 ]; then
3925 # Keep "set -e" off, and run an ERR trap instead to record failures.
3926 set -E
3927 trap err_trap ERR
3928 fi
3929 # The next line is what runs the component
3930 "$@"
3931 if [ $KEEP_GOING -eq 1 ]; then
3932 trap - ERR
3933 exit $last_failure_status
3934 fi
3935 )
3936 component_status=$?
3937 if [ $KEEP_GOING -eq 1 ]; then
3938 set -e
3939 if [ $component_status -ne 0 ]; then
3940 failure_count=$((failure_count + 1))
3941 fi
3942 fi
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003943
3944 # Restore the build tree to a clean state.
Gilles Peskinee48351a2018-11-27 16:06:30 +01003945 cleanup
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +02003946 unset current_component
Gilles Peskine8f073122018-11-27 15:58:47 +01003947}
3948
3949# Preliminary setup
3950pre_check_environment
3951pre_initialize_variables
3952pre_parse_command_line "$@"
Gilles Peskine348fb9a2018-11-27 17:04:29 +01003953
Dave Rodgman4cb98a92024-02-26 11:41:19 +00003954setup_quiet_wrappers
Gilles Peskine878cf602019-01-06 20:50:38 +00003955pre_check_git
Gilles Peskineef64e7f2021-07-12 18:16:01 +02003956pre_restore_files
Gilles Peskine24bdf022020-03-30 20:11:39 +02003957pre_back_up
Andrzej Kurekeb508712019-02-14 07:18:59 -05003958
Gilles Peskine878cf602019-01-06 20:50:38 +00003959build_status=0
3960if [ $KEEP_GOING -eq 1 ]; then
3961 pre_setup_keep_going
Gilles Peskine8f073122018-11-27 15:58:47 +01003962fi
Gilles Peskine67ffdaf2019-09-16 15:55:46 +02003963pre_prepare_outcome_file
Gilles Peskine878cf602019-01-06 20:50:38 +00003964pre_print_configuration
3965pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003966cleanup
3967
Gilles Peskinebeb3a812019-01-06 22:11:25 +00003968# Run the requested tests.
Gilles Peskine202e9b42021-08-02 23:28:00 +02003969for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003970 run_component pseudo_component_error_test
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003971done
Gilles Peskine202e9b42021-08-02 23:28:00 +02003972unset error_test_i
Gilles Peskinebeb3a812019-01-06 22:11:25 +00003973for component in $RUN_COMPONENTS; do
3974 run_component "component_$component"
3975done
Gilles Peskine8f073122018-11-27 15:58:47 +01003976
3977# We're done.
Gilles Peskine878cf602019-01-06 20:50:38 +00003978post_report