blob: c3b6bf9a5a1bc33e7b0b114bfcd5b099e5ab4b3b [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
Manuel Pégourié-Gonnarda674e982024-10-29 10:55:23 +010040# * ArmCC 6 (aka armclang), 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}
Gilles Peskine8f073122018-11-27 15:58:47 +0100165 : ${ARMC6_BIN_DIR:=/usr/bin}
Gilles Peskine6d061342020-04-30 18:19:32 +0200166 : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200167 : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100168 : ${ARM_LINUX_GNUEABIHF_GCC_PREFIX:=arm-linux-gnueabihf-}
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100169 : ${AARCH64_LINUX_GNU_GCC_PREFIX:=aarch64-linux-gnu-}
Gowtham Suresh Kumarcc029af2023-08-01 09:48:32 +0100170 : ${CLANG_LATEST:="clang-latest"}
171 : ${CLANG_EARLIEST:="clang-earliest"}
172 : ${GCC_LATEST:="gcc-latest"}
173 : ${GCC_EARLIEST:="gcc-earliest"}
Andres AGdc192212016-08-31 17:33:13 +0100174
Gilles Peskine8f073122018-11-27 15:58:47 +0100175 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
Gilles Peskinea1fc4b52019-01-06 20:15:26 +0000176 if [ -z "${MAKEFLAGS+set}" ]; then
Gilles Peskine85229ac2021-09-30 18:24:21 +0200177 export MAKEFLAGS="-j$(all_sh_nproc)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100178 fi
Dave Rodgmane0a2f6d2023-12-18 19:53:25 +0000179 # if CC is not set, use clang by default (if present) to improve build times
180 if [ -z "${CC+set}" ] && (type clang > /dev/null 2>&1); then
Dave Rodgmane42c2352023-12-19 16:08:19 +0000181 export CC="clang"
Dave Rodgman62be4562023-12-18 18:34:50 +0000182 fi
Gilles Peskine878cf602019-01-06 20:50:38 +0000183
Gilles Peskinec761d8f2021-09-20 18:57:55 +0200184 # Include more verbose output for failing tests run by CMake or make
Jaeden Amerod48e9c72019-02-07 17:43:39 +0000185 export CTEST_OUTPUT_ON_FAILURE=1
186
Gilles Peskine8fd59422019-10-21 17:11:33 +0200187 # CFLAGS and LDFLAGS for Asan builds that don't use CMake
Manuel Pégourié-Gonnard717f2302022-11-30 10:42:03 +0100188 # default to -O2, use -Ox _after_ this if you want another level
Manuel Pégourié-Gonnard154b84e2022-11-28 13:12:10 +0100189 ASAN_CFLAGS='-O2 -Werror -fsanitize=address,undefined -fno-sanitize-recover=all'
Gilles Peskine8fd59422019-10-21 17:11:33 +0200190
Andrzej Kurekd95b8ed2023-06-27 10:02:09 -0400191 # Platform tests have an allocation that returns null
192 export ASAN_OPTIONS="allocator_may_return_null=1"
Andrzej Kurek6e4a9be2023-07-05 08:32:43 -0400193 export MSAN_OPTIONS="allocator_may_return_null=1"
Andrzej Kurekd95b8ed2023-06-27 10:02:09 -0400194
Gilles Peskine878cf602019-01-06 20:50:38 +0000195 # Gather the list of available components. These are the functions
196 # defined in this script whose name starts with "component_".
Gowtham Suresh Kumar13850f32023-07-28 16:41:21 +0100197 ALL_COMPONENTS=$(compgen -A function component_ | sed 's/component_//')
Gilles Peskine878cf602019-01-06 20:50:38 +0000198
Dave Rodgman8470d112024-01-16 17:33:34 +0000199 # Delay determining SUPPORTED_COMPONENTS until the command line options have a chance to override
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100200 # the commands set by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100201}
Andres AG38495a32016-07-12 16:54:33 +0100202
Dave Rodgman4cb98a92024-02-26 11:41:19 +0000203setup_quiet_wrappers()
204{
205 # Pick up "quiet" wrappers for make and cmake, which don't output very much
206 # unless there is an error. This reduces logging overhead in the CI.
207 #
208 # Note that the cmake wrapper breaks unless we use an absolute path here.
Dave Rodgmane2317642024-02-26 17:27:18 +0000209 if [[ -e ${PWD}/tests/scripts/quiet ]]; then
210 export PATH=${PWD}/tests/scripts/quiet:$PATH
Dave Rodgman4cb98a92024-02-26 11:41:19 +0000211 fi
212}
213
Gilles Peskinea28db922019-01-10 00:05:18 +0100214# Test whether the component $1 is included in the command line patterns.
215is_component_included()
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100216{
Gilles Peskine6702ce92021-08-06 11:35:17 +0200217 # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS
218 # only does word splitting.
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100219 set -f
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000220 for pattern in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100221 set +f
222 case ${1#component_} in $pattern) return 0;; esac
223 done
224 set +f
225 return 1
226}
Andres AG7770ea82016-10-10 15:46:20 +0100227
Simon Butcher41eeccf2016-09-07 00:07:09 +0100228usage()
Andres AGd9eba4b2016-08-26 14:42:14 +0100229{
Gilles Peskine709346a2017-12-10 23:43:39 +0100230 cat <<EOF
Gilles Peskine92525112018-11-27 18:15:35 +0100231Usage: $0 [OPTION]... [COMPONENT]...
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100232Run mbedtls release validation tests.
Gilles Peskine92525112018-11-27 18:15:35 +0100233By default, run all tests. With one or more COMPONENT, run only those.
Gilles Peskinea28db922019-01-10 00:05:18 +0100234COMPONENT can be the name of a component or a shell wildcard pattern.
235
236Examples:
237 $0 "check_*"
238 Run all sanity checks.
239 $0 --no-armcc --except test_memsan
240 Run everything except builds that require armcc and MemSan.
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100241
242Special options:
243 -h|--help Print this help and exit.
Gilles Peskine878cf602019-01-06 20:50:38 +0000244 --list-all-components List all available test components and exit.
245 --list-components List components supported on this platform and exit.
Gilles Peskine709346a2017-12-10 23:43:39 +0100246
247General options:
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200248 -q|--quiet Only output component names, and errors if any.
Gilles Peskine709346a2017-12-10 23:43:39 +0100249 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100250 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100251 -m|--memory Additional optional memory tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200252 --append-outcome Append to the outcome file (if used).
Gilles Peskine6d061342020-04-30 18:19:32 +0200253 --arm-none-eabi-gcc-prefix=<string>
254 Prefix for a cross-compiler for arm-none-eabi
255 (default: "${ARM_NONE_EABI_GCC_PREFIX}")
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200256 --arm-linux-gnueabi-gcc-prefix=<string>
257 Prefix for a cross-compiler for arm-linux-gnueabi
258 (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}")
Bence Szépkúti61da0dd2024-10-27 22:46:48 +0100259 --arm-linux-gnueabihf-gcc-prefix=<string>
260 Prefix for a cross-compiler for arm-linux-gnueabihf
261 (default: "${ARM_LINUX_GNUEABIHF_GCC_PREFIX}")
262 --aarch64-linux-gnu-gcc-prefix=<string>
263 Prefix for a cross-compiler for aarch64-linux-gnu
264 (default: "${AARCH64_LINUX_GNU_GCC_PREFIX}")
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100265 --armcc Run ARM Compiler builds (on by default).
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200266 --restore First clean up the build tree, restoring backed up
267 files. Do not run any components unless they are
268 explicitly specified.
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100269 --error-test Error test mode: run a failing function in addition
Gilles Peskinea25c5672021-08-05 15:11:33 +0200270 to any specified component. May be repeated.
Gilles Peskinea28db922019-01-10 00:05:18 +0100271 --except Exclude the COMPONENTs listed on the command line,
272 instead of running only those.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200273 --no-append-outcome Write a new outcome file and analyze it (default).
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100274 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100275 --no-force Refuse to overwrite modified files (default).
276 --no-keep-going Stop at the first error (default).
277 --no-memory No additional memory tests (default).
Shaun Case0e7791f2021-12-20 21:14:10 -0800278 --no-quiet Print full output from components.
Gilles Peskine709346a2017-12-10 23:43:39 +0100279 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200280 --outcome-file=<path> File where test outcomes are written (not done if
281 empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
Gilles Peskine38d81652018-03-21 08:40:26 +0100282 --random-seed Use a random seed value for randomized tests (default).
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200283 -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}.
Gilles Peskine709346a2017-12-10 23:43:39 +0100284 -s|--seed Integer seed value to use for this test run.
285
286Tool path options:
Gilles Peskine709346a2017-12-10 23:43:39 +0100287 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100288 --clang-earliest=<Clang_earliest_path> Earliest version of clang available
289 --clang-latest=<Clang_latest_path> Latest version of clang available
290 --gcc-earliest=<GCC_earliest_path> Earliest version of GCC available
291 --gcc-latest=<GCC_latest_path> Latest version of GCC available
Gilles Peskine709346a2017-12-10 23:43:39 +0100292 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
293 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
Gilles Peskine709346a2017-12-10 23:43:39 +0100294 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
295 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100296 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100297EOF
SimonB2e23c822016-04-16 21:54:39 +0100298}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100299
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200300# Cleanup before/after running a component.
301# Remove built files as well as the cmake cache/config.
302# Does not remove generated source files.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100303cleanup()
304{
Gilles Peskine7c652162017-12-11 00:01:40 +0100305 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200306
Gilles Peskine31b07e22018-03-21 12:15:06 +0100307 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000308 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100309 -iname CMakeFiles -exec rm -rf {} \+ -o \
310 \( -iname cmake_install.cmake -o \
311 -iname CTestTestfile.cmake -o \
312 -iname CMakeCache.txt \) -exec rm {} \+
Ronald Crone3bdbd52024-06-12 10:04:22 +0200313 # Remove Makefiles generated by in-tree CMake builds
314 rm -f 3rdparty/Makefile 3rdparty/*/Makefile pkgconfig/Makefile
315 rm -f include/Makefile programs/!(fuzz)/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200316
Jaeden Ameroab83fdf2019-06-20 17:38:22 +0100317 # Remove any artifacts from the component_test_cmake_as_subdirectory test.
318 rm -rf programs/test/cmake_subproject/build
319 rm -f programs/test/cmake_subproject/Makefile
320 rm -f programs/test/cmake_subproject/cmake_subproject
321
Gilles Peskine24bdf022020-03-30 20:11:39 +0200322 # Restore files that may have been clobbered by the job
323 for x in $files_to_back_up; do
Gilles Peskine423dd132022-08-30 21:02:00 +0200324 if [[ -e "$x$backup_suffix" ]]; then
325 cp -p "$x$backup_suffix" "$x"
326 fi
Gilles Peskine24bdf022020-03-30 20:11:39 +0200327 done
328}
John Durkopbd069d32020-10-31 22:14:03 -0700329
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200330# Final cleanup when this script exits (except when exiting on a failure
331# in non-keep-going mode).
Gilles Peskine24bdf022020-03-30 20:11:39 +0200332final_cleanup () {
333 cleanup
334
335 for x in $files_to_back_up; do
336 rm -f "$x$backup_suffix"
337 done
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100338}
339
Gilles Peskine7c652162017-12-11 00:01:40 +0100340# Executed on exit. May be redefined depending on command line options.
341final_report () {
342 :
343}
344
345fatal_signal () {
Gilles Peskine24bdf022020-03-30 20:11:39 +0200346 final_cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100347 final_report $1
348 trap - $1
349 kill -$1 $$
350}
351
352trap 'fatal_signal HUP' HUP
353trap 'fatal_signal INT' INT
354trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200355
Gilles Peskine85229ac2021-09-30 18:24:21 +0200356# Number of processors on this machine. Used as the default setting
357# for parallel make.
358all_sh_nproc ()
359{
360 {
361 nproc || # Linux
362 sysctl -n hw.ncpuonline || # NetBSD, OpenBSD
363 sysctl -n hw.ncpu || # FreeBSD
364 echo 1
365 } 2>/dev/null
366}
367
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100368msg()
369{
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100370 if [ -n "${current_component:-}" ]; then
371 current_section="${current_component#component_}: $1"
372 else
373 current_section="$1"
374 fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200375
376 if [ $QUIET -eq 1 ]; then
377 return
378 fi
379
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100380 echo ""
381 echo "******************************************************************"
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100382 echo "* $current_section "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000383 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100384 echo "******************************************************************"
385}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100386
Gilles Peskine8f073122018-11-27 15:58:47 +0100387armc6_build_test()
388{
389 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100390
Gilles Peskine18487f62020-04-30 23:11:54 +0200391 msg "build: ARM Compiler 6 ($FLAGS)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100392 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
Dave Rodgman6cda3d32023-03-02 13:39:04 +0000393 WARNING_CFLAGS='-Werror -xc -std=c99' make lib
Gilles Peskine18487f62020-04-30 23:11:54 +0200394
395 msg "size: ARM Compiler 6 ($FLAGS)"
396 "$ARMC6_FROMELF" -z library/*.o
397
Gilles Peskine8f073122018-11-27 15:58:47 +0100398 make clean
399}
Andres AGa5cd9732016-10-17 15:23:10 +0100400
Andres AGd9eba4b2016-08-26 14:42:14 +0100401err_msg()
402{
403 echo "$1" >&2
404}
405
406check_tools()
407{
408 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000409 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100410 err_msg "$TOOL not found!"
411 exit 1
412 fi
413 done
414}
415
Gilles Peskine8f073122018-11-27 15:58:47 +0100416pre_parse_command_line () {
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000417 COMMAND_LINE_COMPONENTS=
Gilles Peskinea28db922019-01-10 00:05:18 +0100418 all_except=0
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100419 error_test=0
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100420 list_components=0
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200421 restore_first=0
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000422 no_armcc=
SimonB2e23c822016-04-16 21:54:39 +0100423
Jaeden Amero9b90f2e2018-11-02 18:34:17 +0000424 # Note that legacy options are ignored instead of being omitted from this
425 # list of options, so invocations that worked with previous version of
426 # all.sh will still run and work properly.
Gilles Peskine8f073122018-11-27 15:58:47 +0100427 while [ $# -gt 0 ]; do
Gilles Peskine55f7c942019-01-09 22:28:21 +0100428 case "$1" in
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200429 --append-outcome) append_outcome=1;;
Gilles Peskine6d061342020-04-30 18:19:32 +0200430 --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200431 --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";;
Bence Szépkúti61da0dd2024-10-27 22:46:48 +0100432 --arm-linux-gnueabihf-gcc-prefix) shift; ARM_LINUX_GNUEABIHF_GCC_PREFIX="$1";;
433 --aarch64-linux-gnu-gcc-prefix) shift; AARCH64_LINUX_GNU_GCC_PREFIX="$1";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000434 --armcc) no_armcc=;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100435 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100436 --clang-earliest) shift; CLANG_EARLIEST="$1";;
437 --clang-latest) shift; CLANG_LATEST="$1";;
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100438 --error-test) error_test=$((error_test + 1));;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000439 --except) all_except=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100440 --force|-f) FORCE=1;;
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100441 --gcc-earliest) shift; GCC_EARLIEST="$1";;
442 --gcc-latest) shift; GCC_LATEST="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100443 --gnutls-cli) shift; GNUTLS_CLI="$1";;
Gilles Peskine549a9612023-08-27 21:39:21 +0200444 --gnutls-legacy-cli) shift;; # ignored for backward compatibility
445 --gnutls-legacy-serv) shift;; # ignored for backward compatibility
Gilles Peskine55f7c942019-01-09 22:28:21 +0100446 --gnutls-serv) shift; GNUTLS_SERV="$1";;
447 --help|-h) usage; exit;;
448 --keep-going|-k) KEEP_GOING=1;;
Gilles Peskine878cf602019-01-06 20:50:38 +0000449 --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100450 --list-components) list_components=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100451 --memory|-m) MEMORY=1;;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200452 --no-append-outcome) append_outcome=0;;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000453 --no-armcc) no_armcc=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100454 --no-force) FORCE=0;;
455 --no-keep-going) KEEP_GOING=0;;
456 --no-memory) MEMORY=0;;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200457 --no-quiet) QUIET=0;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100458 --openssl) shift; OPENSSL="$1";;
459 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
460 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200461 --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100462 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200463 --quiet|-q) QUIET=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100464 --random-seed) unset SEED;;
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200465 --release-test|-r) SEED=$RELEASE_SEED;;
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200466 --restore) restore_first=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100467 --seed|-s) shift; SEED="$1";;
468 -*)
469 echo >&2 "Unknown option: $1"
470 echo >&2 "Run $0 --help for usage."
471 exit 120
472 ;;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000473 *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100474 esac
475 shift
Gilles Peskine8f073122018-11-27 15:58:47 +0100476 done
SimonB2e23c822016-04-16 21:54:39 +0100477
Bence Szépkúti2064c9b2023-12-15 19:20:31 +0100478 # Exclude components that are not supported on this platform.
479 SUPPORTED_COMPONENTS=
480 for component in $ALL_COMPONENTS; do
481 case $(type "support_$component" 2>&1) in
482 *' function'*)
483 if ! support_$component; then continue; fi;;
484 esac
485 SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
486 done
487
488 if [ $list_components -eq 1 ]; then
489 printf '%s\n' $SUPPORTED_COMPONENTS
490 exit
491 fi
492
Gilles Peskinea28db922019-01-10 00:05:18 +0100493 # With no list of components, run everything.
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200494 if [ -z "$COMMAND_LINE_COMPONENTS" ] && [ $restore_first -eq 0 ]; then
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000495 all_except=1
Andres AGdc192212016-08-31 17:33:13 +0100496 fi
497
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000498 # --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
499 # Ignore it if components are listed explicitly on the command line.
Gilles Peskinea28db922019-01-10 00:05:18 +0100500 if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000501 COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
SimonB2e23c822016-04-16 21:54:39 +0100502 fi
SimonB2e23c822016-04-16 21:54:39 +0100503
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200504 # Error out if an explicitly requested component doesn't exist.
Gilles Peskinee8056c52020-03-28 21:37:59 +0100505 if [ $all_except -eq 0 ]; then
506 unsupported=0
Gilles Peskine6702ce92021-08-06 11:35:17 +0200507 # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS
508 # only does word splitting.
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200509 set -f
Gilles Peskinee8056c52020-03-28 21:37:59 +0100510 for component in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200511 set +f
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200512 # If the requested name includes a wildcard character, don't
513 # check it. Accept wildcard patterns that don't match anything.
Gilles Peskinee8056c52020-03-28 21:37:59 +0100514 case $component in
515 *[*?\[]*) continue;;
516 esac
517 case " $SUPPORTED_COMPONENTS " in
518 *" $component "*) :;;
519 *)
520 echo >&2 "Component $component was explicitly requested, but is not known or not supported."
521 unsupported=$((unsupported + 1));;
522 esac
523 done
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200524 set +f
Gilles Peskinee8056c52020-03-28 21:37:59 +0100525 if [ $unsupported -ne 0 ]; then
526 exit 2
527 fi
528 fi
529
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000530 # Build the list of components to run.
Gilles Peskinea28db922019-01-10 00:05:18 +0100531 RUN_COMPONENTS=
532 for component in $SUPPORTED_COMPONENTS; do
533 if is_component_included "$component"; [ $? -eq $all_except ]; then
534 RUN_COMPONENTS="$RUN_COMPONENTS $component"
535 fi
536 done
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000537
538 unset all_except
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000539 unset no_armcc
Gilles Peskine8f073122018-11-27 15:58:47 +0100540}
SimonB2e23c822016-04-16 21:54:39 +0100541
Gilles Peskine8f073122018-11-27 15:58:47 +0100542pre_check_git () {
543 if [ $FORCE -eq 1 ]; then
Gilles Peskine53190e62019-01-09 23:17:35 +0100544 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +0100545 git checkout-index -f -q $CONFIG_H
546 cleanup
547 else
SimonB2e23c822016-04-16 21:54:39 +0100548
Gilles Peskine8f073122018-11-27 15:58:47 +0100549 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
550 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
551 echo "You can either delete this directory manually, or force the test by rerunning"
552 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
553 exit 1
554 fi
555
Gilles Peskined1174cf2019-01-09 22:30:01 +0100556 if ! git diff --quiet include/mbedtls/config.h; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100557 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
558 echo "You can either delete or preserve your work, or force the test by rerunning the"
559 echo "script as: $0 --force"
560 exit 1
561 fi
SimonB2e23c822016-04-16 21:54:39 +0100562 fi
Andrzej Kurekeb508712019-02-14 07:18:59 -0500563}
564
Gilles Peskineef64e7f2021-07-12 18:16:01 +0200565pre_restore_files () {
566 # If the makefiles have been generated by a framework such as cmake,
567 # restore them from git. If the makefiles look like modifications from
568 # the ones checked into git, take care not to modify them. Whatever
569 # this function leaves behind is what the script will restore before
570 # each component.
571 case "$(head -n1 Makefile)" in
572 *[Gg]enerated*)
573 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
574 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
575 ;;
576 esac
577}
578
Gilles Peskine24bdf022020-03-30 20:11:39 +0200579pre_back_up () {
580 for x in $files_to_back_up; do
581 cp -p "$x" "$x$backup_suffix"
582 done
583}
584
Gilles Peskine8f073122018-11-27 15:58:47 +0100585pre_setup_keep_going () {
Gilles Peskine7105a332020-03-28 18:50:43 +0100586 failure_count=0 # Number of failed components
587 last_failure_status=0 # Last failure status in this component
588
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100589 # See err_trap
590 previous_failure_status=0
591 previous_failed_command=
592 previous_failure_funcall_depth=0
Gilles Peskine39a3b112020-03-28 21:27:40 +0100593 unset report_failed_command
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100594
Gilles Peskine7c652162017-12-11 00:01:40 +0100595 start_red=
596 end_color=
597 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100598 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100599 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
600 start_red=$(printf '\033[31m')
601 end_color=$(printf '\033[0m')
602 ;;
603 esac
604 fi
Gilles Peskine7105a332020-03-28 18:50:43 +0100605
606 # Keep a summary of failures in a file. We'll print it out at the end.
607 failure_summary_file=$PWD/all-sh-failures-$$.log
608 : >"$failure_summary_file"
609
610 # Whether it makes sense to keep a component going after the specified
611 # command fails (test command) or not (configure or build).
Gilles Peskine6702ce92021-08-06 11:35:17 +0200612 # This function normally receives the failing simple command
613 # ($BASH_COMMAND) as an argument, but if $report_failed_command is set,
614 # this is passed instead.
Gilles Peskine7105a332020-03-28 18:50:43 +0100615 # This doesn't have to be 100% accurate: all failures are recorded anyway.
Gilles Peskine76d40fa2021-08-02 23:29:53 +0200616 # False positives result in running things that can't be expected to
617 # work. False negatives result in things not running after something else
618 # failed even though they might have given useful feedback.
Gilles Peskine7105a332020-03-28 18:50:43 +0100619 can_keep_going_after_failure () {
620 case "$1" in
621 "msg "*) false;;
Gilles Peskine76d40fa2021-08-02 23:29:53 +0200622 "cd "*) false;;
623 *make*[\ /]tests*) false;; # make tests, make CFLAGS=-I../tests, ...
624 *test*) true;; # make test, tests/stuff, env V=v tests/stuff, ...
625 *make*check*) true;;
626 "grep "*) true;;
627 "[ "*) true;;
628 "! "*) true;;
Gilles Peskine7105a332020-03-28 18:50:43 +0100629 *) false;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100630 esac
631 }
Gilles Peskine7105a332020-03-28 18:50:43 +0100632
633 # This function runs if there is any error in a component.
634 # It must either exit with a nonzero status, or set
635 # last_failure_status to a nonzero value.
636 err_trap () {
637 # Save $? (status of the failing command). This must be the very
638 # first thing, before $? is overridden.
639 last_failure_status=$?
Gilles Peskine39a3b112020-03-28 21:27:40 +0100640 failed_command=${report_failed_command-$BASH_COMMAND}
Gilles Peskine7105a332020-03-28 18:50:43 +0100641
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100642 if [[ $last_failure_status -eq $previous_failure_status &&
643 "$failed_command" == "$previous_failed_command" &&
644 ${#FUNCNAME[@]} == $((previous_failure_funcall_depth - 1)) ]]
645 then
646 # The same command failed twice in a row, but this time one level
647 # less deep in the function call stack. This happens when the last
648 # command of a function returns a nonzero status, and the function
649 # returns that same status. Ignore the second failure.
650 previous_failure_funcall_depth=${#FUNCNAME[@]}
651 return
652 fi
653 previous_failure_status=$last_failure_status
654 previous_failed_command=$failed_command
655 previous_failure_funcall_depth=${#FUNCNAME[@]}
656
Gilles Peskine7105a332020-03-28 18:50:43 +0100657 text="$current_section: $failed_command -> $last_failure_status"
658 echo "${start_red}^^^^$text^^^^${end_color}" >&2
659 echo "$text" >>"$failure_summary_file"
660
661 # If the command is fatal (configure or build command), stop this
662 # component. Otherwise (test command) keep the component running
663 # (run more tests from the same build).
664 if ! can_keep_going_after_failure "$failed_command"; then
665 exit $last_failure_status
666 fi
667 }
668
Gilles Peskine7c652162017-12-11 00:01:40 +0100669 final_report () {
670 if [ $failure_count -gt 0 ]; then
671 echo
672 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Gilles Peskine7105a332020-03-28 18:50:43 +0100673 echo "${start_red}FAILED: $failure_count components${end_color}"
674 cat "$failure_summary_file"
Gilles Peskine7c652162017-12-11 00:01:40 +0100675 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
676 elif [ -z "${1-}" ]; then
677 echo "SUCCESS :)"
678 fi
679 if [ -n "${1-}" ]; then
680 echo "Killed by SIG$1."
681 fi
Gilles Peskine7105a332020-03-28 18:50:43 +0100682 rm -f "$failure_summary_file"
683 if [ $failure_count -gt 0 ]; then
684 exit 1
685 fi
Gilles Peskine7c652162017-12-11 00:01:40 +0100686 }
Gilles Peskine8f073122018-11-27 15:58:47 +0100687}
688
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200689# record_status() and if_build_succeeded() are kept temporarily for backward
690# compatibility. Don't use them in new components.
Gilles Peskine7105a332020-03-28 18:50:43 +0100691record_status () {
692 "$@"
Gilles Peskine7c652162017-12-11 00:01:40 +0100693}
Gilles Peskine7c652162017-12-11 00:01:40 +0100694if_build_succeeded () {
Gilles Peskine7105a332020-03-28 18:50:43 +0100695 "$@"
Gilles Peskine7c652162017-12-11 00:01:40 +0100696}
697
Gilles Peskine39a3b112020-03-28 21:27:40 +0100698# '! true' does not trigger the ERR trap. Arrange to trigger it, with
699# a reasonably informative error message (not just "$@").
700not () {
701 if "$@"; then
702 report_failed_command="! $*"
703 false
704 unset report_failed_command
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200705 fi
706}
707
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200708pre_prepare_outcome_file () {
709 case "$MBEDTLS_TEST_OUTCOME_FILE" in
710 [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
711 esac
712 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then
713 rm -f "$MBEDTLS_TEST_OUTCOME_FILE"
714 fi
715}
716
Gilles Peskine8f073122018-11-27 15:58:47 +0100717pre_print_configuration () {
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200718 if [ $QUIET -eq 1 ]; then
719 return
720 fi
721
Gilles Peskine8f073122018-11-27 15:58:47 +0100722 msg "info: $0 configuration"
723 echo "MEMORY: $MEMORY"
724 echo "FORCE: $FORCE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200725 echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}"
Gilles Peskine8f073122018-11-27 15:58:47 +0100726 echo "SEED: ${SEED-"UNSET"}"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100727 echo
Gilles Peskine8f073122018-11-27 15:58:47 +0100728 echo "OPENSSL: $OPENSSL"
729 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
730 echo "OPENSSL_NEXT: $OPENSSL_NEXT"
731 echo "GNUTLS_CLI: $GNUTLS_CLI"
732 echo "GNUTLS_SERV: $GNUTLS_SERV"
Gilles Peskine8f073122018-11-27 15:58:47 +0100733 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
734}
Andres AG7770ea82016-10-10 15:46:20 +0100735
Andres AGd9eba4b2016-08-26 14:42:14 +0100736# Make sure the tools we need are available.
Gilles Peskine8f073122018-11-27 15:58:47 +0100737pre_check_tools () {
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000738 # Build the list of variables to pass to output_env.sh.
739 set env
SimonB2e23c822016-04-16 21:54:39 +0100740
Gilles Peskine87964262019-01-06 22:40:00 +0000741 case " $RUN_COMPONENTS " in
742 # Require OpenSSL and GnuTLS if running any tests (as opposed to
743 # only doing builds). Not all tests run OpenSSL and GnuTLS, but this
744 # is a good enough approximation in practice.
Bence Szépkúticb89fbd2023-12-15 20:58:15 +0100745 *" test_"* | *" release_test_"*)
Gilles Peskine87964262019-01-06 22:40:00 +0000746 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh
747 # and ssl-opt.sh, we just export the variables they require.
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +0100748 export OPENSSL="$OPENSSL"
Gilles Peskine87964262019-01-06 22:40:00 +0000749 export GNUTLS_CLI="$GNUTLS_CLI"
750 export GNUTLS_SERV="$GNUTLS_SERV"
751 # Avoid passing --seed flag in every call to ssl-opt.sh
752 if [ -n "${SEED-}" ]; then
753 export SEED
754 fi
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000755 set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY"
756 set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000757 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
Gilles Peskine549a9612023-08-27 21:39:21 +0200758 "$GNUTLS_CLI" "$GNUTLS_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000759 ;;
760 esac
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200761
Gilles Peskine87964262019-01-06 22:40:00 +0000762 case " $RUN_COMPONENTS " in
763 *_doxygen[_\ ]*) check_tools "doxygen" "dot";;
764 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100765
Gilles Peskine87964262019-01-06 22:40:00 +0000766 case " $RUN_COMPONENTS " in
Gilles Peskine6d061342020-04-30 18:19:32 +0200767 *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";;
Gilles Peskine87964262019-01-06 22:40:00 +0000768 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100769
Gilles Peskine87964262019-01-06 22:40:00 +0000770 case " $RUN_COMPONENTS " in
771 *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";;
772 esac
773
774 case " $RUN_COMPONENTS " in
775 *" test_zeroize "*) check_tools "gdb";;
776 esac
777
778 case " $RUN_COMPONENTS " in
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000779 *_armcc*)
Gilles Peskine87964262019-01-06 22:40:00 +0000780 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
781 ARMC6_AR="$ARMC6_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200782 ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf"
Manuel Pégourié-Gonnarda674e982024-10-29 10:55:23 +0100783 check_tools "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000784 esac
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000785
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200786 # past this point, no call to check_tool, only printing output
787 if [ $QUIET -eq 1 ]; then
788 return
789 fi
790
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000791 msg "info: output_env.sh"
792 case $RUN_COMPONENTS in
793 *_armcc*)
Manuel Pégourié-Gonnarda674e982024-10-29 10:55:23 +0100794 set "$@" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;;
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000795 *) set "$@" RUN_ARMCC=0;;
796 esac
797 "$@" scripts/output_env.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100798}
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100799
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100800gcc_version() {
Bence Szépkúti26822ab2024-07-12 14:00:29 +0100801 gcc="$1"
802 if command -v "$gcc" > /dev/null ; then
803 "$gcc" --version | sed -En '1s/^[^ ]* \([^)]*\) ([0-9]+).*/\1/p'
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100804 else
Bence Szépkúti26822ab2024-07-12 14:00:29 +0100805 echo 0 # report version 0 for "no gcc"
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100806 fi
807}
808
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100809can_run_cc_output() {
810 cc="$1"
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100811 result=false
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100812 if type "$cc" >/dev/null 2>&1; then
813 testbin=$(mktemp)
814 if echo 'int main(void){return 0;}' | "$cc" -o "$testbin" -x c -; then
815 if "$testbin" 2>/dev/null; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100816 result=true
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100817 fi
818 fi
Bence Szépkúti08c14d12024-07-12 20:33:15 +0100819 rm -f "$testbin"
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100820 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100821 $result
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100822}
823
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100824can_run_arm_linux_gnueabi=
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100825can_run_arm_linux_gnueabi () {
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100826 if [ -z "$can_run_arm_linux_gnueabi" ]; then
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100827 if can_run_cc_output "${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc"; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100828 can_run_arm_linux_gnueabi=true
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100829 else
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100830 can_run_arm_linux_gnueabi=false
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100831 fi
832 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100833 $can_run_arm_linux_gnueabi
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100834}
835
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100836can_run_arm_linux_gnueabihf=
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100837can_run_arm_linux_gnueabihf () {
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100838 if [ -z "$can_run_arm_linux_gnueabihf" ]; then
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100839 if can_run_cc_output "${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc"; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100840 can_run_arm_linux_gnueabihf=true
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100841 else
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100842 can_run_arm_linux_gnueabihf=false
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100843 fi
844 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100845 $can_run_arm_linux_gnueabihf
Bence Szépkúti86aa7802024-07-11 09:50:45 +0100846}
847
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100848can_run_aarch64_linux_gnu=
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100849can_run_aarch64_linux_gnu () {
Bence Szépkútia56b61c2024-07-12 20:50:07 +0100850 if [ -z "$can_run_aarch64_linux_gnu" ]; then
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100851 if can_run_cc_output "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc"; then
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100852 can_run_aarch64_linux_gnu=true
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100853 else
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100854 can_run_aarch64_linux_gnu=false
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100855 fi
856 fi
Bence Szépkúti63a10d02024-07-12 20:48:08 +0100857 $can_run_aarch64_linux_gnu
Bence Szépkúti915fa3e2024-07-11 15:52:07 +0100858}
859
Gilles Peskine192c72f2017-12-21 15:59:21 +0100860
861
862################################################################
863#### Basic checks
864################################################################
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100865
866#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200867# Test Suites to be executed
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100868#
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100869# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200870# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100871# 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 +0200872# time, so start with a GCC build).
873# 2. Minimize total running time, by avoiding useless rebuilds
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100874#
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100875# Indicative running times are given for reference.
876
Gilles Peskine8f073122018-11-27 15:58:47 +0100877component_check_recursion () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200878 msg "Check: recursion.pl" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200879 tests/scripts/recursion.pl library/*.c
Gilles Peskine8f073122018-11-27 15:58:47 +0100880}
Janos Follathb72c6782016-07-19 14:54:17 +0100881
Gilles Peskine8f073122018-11-27 15:58:47 +0100882component_check_generated_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200883 msg "Check: freshness of generated source files" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200884 tests/scripts/check-generated-files.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100885}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200886
Gilles Peskine8f073122018-11-27 15:58:47 +0100887component_check_doxy_blocks () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200888 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200889 tests/scripts/check-doxy-blocks.pl
Gilles Peskine8f073122018-11-27 15:58:47 +0100890}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200891
Gilles Peskine8f073122018-11-27 15:58:47 +0100892component_check_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200893 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200894 tests/scripts/check_files.py
Gilles Peskine8f073122018-11-27 15:58:47 +0100895}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200896
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200897component_check_changelog () {
898 msg "Check: changelog entries" # < 1s
899 rm -f ChangeLog.new
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200900 scripts/assemble_changelog.py -o ChangeLog.new
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200901 if [ -e ChangeLog.new ]; then
902 # Show the diff for information. It isn't an error if the diff is
903 # non-empty.
904 diff -u ChangeLog ChangeLog.new || true
905 rm ChangeLog.new
906 fi
907}
908
Gilles Peskine8f073122018-11-27 15:58:47 +0100909component_check_names () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200910 msg "Check: declared and exported names (builds the library)" # < 3s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200911 tests/scripts/check_names.py -v
Gilles Peskine8f073122018-11-27 15:58:47 +0100912}
Darryl Greena07039c2018-03-13 16:48:16 +0000913
Gilles Peskine895868b2019-09-19 21:30:05 +0200914component_check_test_cases () {
915 msg "Check: test case descriptions" # < 1s
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200916 if [ $QUIET -eq 1 ]; then
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200917 opt='--quiet'
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200918 else
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200919 opt=''
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200920 fi
Gilles Peskine58987962022-12-15 14:46:31 +0100921 tests/scripts/check_test_cases.py -q $opt
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200922 unset opt
Gilles Peskine895868b2019-09-19 21:30:05 +0200923}
924
Gilles Peskine8f073122018-11-27 15:58:47 +0100925component_check_doxygen_warnings () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200926 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200927 tests/scripts/doxygen.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100928}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200929
Gilles Peskine192c72f2017-12-21 15:59:21 +0100930
Gilles Peskine636c26a2020-03-04 20:46:15 +0100931
Gilles Peskine192c72f2017-12-21 15:59:21 +0100932################################################################
933#### Build and test many configurations and targets
934################################################################
935
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200936component_test_default_out_of_box () {
937 msg "build: make, default config (out-of-box)" # ~1min
938 make
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200939 # Disable fancy stuff
940 unset MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200941
942 msg "test: main suites make, default config (out-of-box)" # ~10s
943 make test
944
945 msg "selftest: make, default config (out-of-box)" # ~10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200946 programs/test/selftest
Gilles Peskine93aaf2e2019-06-14 18:27:03 +0200947
948 msg "program demos: make, default config (out-of-box)" # ~10s
949 tests/scripts/run_demos.py
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200950}
951
Gilles Peskinea8cd2e62024-05-17 19:00:46 +0200952component_build_without_check_config () {
953 msg "build: full without check_config.h"
954 scripts/config.py full
955 sed -i '/#include.*check_config\.h/ s!^!//!' "$CONFIG_H"
956 make
957}
958
Gilles Peskine8f073122018-11-27 15:58:47 +0100959component_test_default_cmake_gcc_asan () {
960 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Gilles Peskine8f073122018-11-27 15:58:47 +0100961 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
962 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200963
Gilles Peskine8f073122018-11-27 15:58:47 +0100964 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
965 make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200966
Gilles Peskine93aaf2e2019-06-14 18:27:03 +0200967 msg "program demos (ASan build)" # ~10s
968 tests/scripts/run_demos.py
969
Gilles Peskine97bea012020-04-23 23:37:45 +0200970 msg "test: selftest (ASan build)" # ~ 10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200971 programs/test/selftest
Gilles Peskine97bea012020-04-23 23:37:45 +0200972
Gilles Peskineee8af062023-11-02 19:58:03 +0100973 msg "test: metatests (GCC, ASan build)"
David Horstmann1b421b12024-01-17 14:53:08 +0000974 tests/scripts/run-metatests.sh any asan poison
Gilles Peskineee8af062023-11-02 19:58:03 +0100975
Gilles Peskine8f073122018-11-27 15:58:47 +0100976 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200977 tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200978
Gilles Peskine8f073122018-11-27 15:58:47 +0100979 msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200980 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200981
982 msg "test: context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200983 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100984}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200985
Hanno Becker01635512019-02-26 14:27:09 +0000986component_test_full_cmake_gcc_asan () {
987 msg "build: full config, cmake, gcc, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200988 scripts/config.py full
Hanno Becker01635512019-02-26 14:27:09 +0000989 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
990 make
991
992 msg "test: main suites (inc. selftests) (full config, ASan build)"
993 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +0100994
Gilles Peskine97bea012020-04-23 23:37:45 +0200995 msg "test: selftest (ASan build)" # ~ 10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200996 programs/test/selftest
Gilles Peskine97bea012020-04-23 23:37:45 +0200997
Gilles Peskine636c26a2020-03-04 20:46:15 +0100998 msg "test: ssl-opt.sh (full config, ASan build)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200999 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001000
Manuel Pégourié-Gonnardb76606c2024-04-17 12:15:51 +02001001 msg "test: compat.sh all except legacy/next (full config, ASan build)"
1002 tests/compat.sh -e '^DES-CBC-\|-DES-CBC-\|ARIA\|CHACHA' \
1003 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
1004
1005 msg "test: compat.sh single-DES (full config, ASan build)"
1006 env OPENSSL="$OPENSSL_LEGACY" tests/compat.sh -e '^$' -f '^DES-CBC\|-DES-CBC-' \
1007 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
1008
1009 # ARIA and ChachaPoly are both (D)TLS 1.2 only
1010 msg "test: compat.sh ARIA + ChachaPoly (full config, ASan build)"
1011 env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' \
Manuel Pégourié-Gonnardde887ba2024-04-18 10:05:04 +02001012 -m 'tls12 dtls12'
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001013
1014 msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001015 tests/context-info.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001016}
1017
Ronald Cronc3623db2020-10-29 10:51:32 +01001018component_test_psa_crypto_key_id_encodes_owner () {
1019 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
1020 scripts/config.py full
1021 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1022 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1023 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1024 make
1025
1026 msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
1027 make test
1028}
1029
David Horstmann42015332024-03-13 15:42:31 +00001030component_test_psa_assume_exclusive_buffers () {
1031 msg "build: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan"
David Horstmanndda52ae2023-12-20 11:10:16 +00001032 scripts/config.py full
David Horstmann42015332024-03-13 15:42:31 +00001033 scripts/config.py set MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS
David Horstmanndda52ae2023-12-20 11:10:16 +00001034 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1035 make
1036
David Horstmann42015332024-03-13 15:42:31 +00001037 msg "test: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan"
David Horstmanndda52ae2023-12-20 11:10:16 +00001038 make test
1039}
1040
Gilles Peskine99a34622021-06-17 11:37:52 +02001041# check_renamed_symbols HEADER LIB
1042# Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol
1043# name is LIB.
1044check_renamed_symbols () {
1045 ! nm "$2" | sed 's/.* //' |
1046 grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")"
1047}
1048
Gilles Peskine984c19f2021-06-15 18:37:38 +02001049component_build_psa_crypto_spm () {
1050 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc"
1051 scripts/config.py full
1052 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1053 scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
1054 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1055 scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM
1056 # We can only compile, not link, since our test and sample programs
1057 # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM
1058 # is active.
1059 make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib
Gilles Peskine99a34622021-06-17 11:37:52 +02001060
1061 # Check that if a symbol is renamed by crypto_spe.h, the non-renamed
1062 # version is not present.
1063 echo "Checking for renamed symbols in the library"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001064 check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
Gilles Peskine984c19f2021-06-15 18:37:38 +02001065}
1066
Ronald Cron336678b2021-01-28 17:54:24 +01001067component_test_psa_crypto_client () {
1068 msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
1069 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1070 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
1071 scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT
1072 make
1073
1074 msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
1075 make test
1076}
1077
Gilles Peskine636c26a2020-03-04 20:46:15 +01001078component_test_zlib_make() {
1079 msg "build: zlib enabled, make"
1080 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
Gilles Peskine6fa69862021-10-05 09:36:03 +02001081 make ZLIB=1 CFLAGS='-Werror -O2'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001082
1083 msg "test: main suites (zlib, make)"
1084 make test
1085
1086 msg "test: ssl-opt.sh (zlib, make)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001087 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001088}
1089support_test_zlib_make () {
1090 base=support_test_zlib_$$
1091 cat <<'EOF' > ${base}.c
1092#include "zlib.h"
1093int main(void) { return 0; }
1094EOF
1095 gcc -o ${base}.exe ${base}.c -lz 2>/dev/null
1096 ret=$?
1097 rm -f ${base}.*
1098 return $ret
1099}
1100
1101component_test_zlib_cmake() {
Dave Rodgmandff18da2024-03-01 15:53:52 +00001102 # This is needed due to something parsing the output from make
1103 export VERBOSE_LOGS=1
1104
Gilles Peskine636c26a2020-03-04 20:46:15 +01001105 msg "build: zlib enabled, cmake"
1106 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
Gilles Peskine25319702021-10-07 19:34:57 +02001107 cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Release .
Gilles Peskine636c26a2020-03-04 20:46:15 +01001108 make
1109
1110 msg "test: main suites (zlib, cmake)"
1111 make test
1112
1113 msg "test: ssl-opt.sh (zlib, cmake)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001114 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001115}
1116support_test_zlib_cmake () {
1117 support_test_zlib_make "$@"
Manuel Pégourié-Gonnardf2e29022020-01-24 10:17:20 +01001118}
Manuel Pégourié-Gonnard95e04492020-01-02 11:45:12 +01001119
Jaeden Ameroc17f2932021-05-14 08:34:32 +01001120component_test_psa_crypto_rsa_no_genprime() {
1121 msg "build: default config minus MBEDTLS_GENPRIME"
1122 scripts/config.py unset MBEDTLS_GENPRIME
1123 make
1124
1125 msg "test: default config minus MBEDTLS_GENPRIME"
1126 make test
1127}
1128
Gilles Peskine782f4112018-11-27 16:11:09 +01001129component_test_ref_configs () {
1130 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
1131 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001132 tests/scripts/test-ref-configs.pl
Gilles Peskine782f4112018-11-27 16:11:09 +01001133}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02001134
Gilles Peskine8f073122018-11-27 15:58:47 +01001135component_test_sslv3 () {
1136 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001137 scripts/config.py set MBEDTLS_SSL_PROTO_SSL3
Gilles Peskine8f073122018-11-27 15:58:47 +01001138 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1139 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02001140
Gilles Peskine8f073122018-11-27 15:58:47 +01001141 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
1142 make test
Simon Butcher3ea7f522016-03-07 23:22:10 +00001143
Gilles Peskine8f073122018-11-27 15:58:47 +01001144 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskinec67c3b32023-08-27 21:33:41 +02001145 tests/compat.sh -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
Simon Butcher3ea7f522016-03-07 23:22:10 +00001146
Gilles Peskine8f073122018-11-27 15:58:47 +01001147 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001148 tests/ssl-opt.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001149
1150 msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001151 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001152}
Simon Butcher3ea7f522016-03-07 23:22:10 +00001153
Gilles Peskine8f073122018-11-27 15:58:47 +01001154component_test_no_renegotiation () {
1155 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001156 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine8f073122018-11-27 15:58:47 +01001157 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1158 make
Simon Butcher3ea7f522016-03-07 23:22:10 +00001159
Gilles Peskine8f073122018-11-27 15:58:47 +01001160 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
1161 make test
Hanno Becker134c2ab2017-10-12 15:29:50 +01001162
Gilles Peskine8f073122018-11-27 15:58:47 +01001163 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001164 tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001165}
Hanno Becker134c2ab2017-10-12 15:29:50 +01001166
Gilles Peskine56194432023-02-01 18:44:11 +01001167component_test_no_certs () {
1168 msg "build: full minus MBEDTLS_CERTS_C"
1169 scripts/config.py full
1170 scripts/config.py unset MBEDTLS_CERTS_C
1171 # Quick build+test (we're checking for stray uses of the test certs,
1172 # not expecting their absence to lead to subtle problems).
1173 make
1174
1175 msg "test: full minus MBEDTLS_CERTS_C - main suites"
1176 make test
1177}
1178
Gilles Peskine636c26a2020-03-04 20:46:15 +01001179component_test_no_pem_no_fs () {
1180 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
1181 scripts/config.py unset MBEDTLS_PEM_PARSE_C
1182 scripts/config.py unset MBEDTLS_FS_IO
1183 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
1184 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
1185 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1186 make
1187
1188 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
1189 make test
1190
1191 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001192 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001193}
1194
Gilles Peskine8f073122018-11-27 15:58:47 +01001195component_test_rsa_no_crt () {
1196 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001197 scripts/config.py set MBEDTLS_RSA_NO_CRT
Gilles Peskine8f073122018-11-27 15:58:47 +01001198 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1199 make
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +01001200
Gilles Peskine8f073122018-11-27 15:58:47 +01001201 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
1202 make test
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001203
Gilles Peskine8f073122018-11-27 15:58:47 +01001204 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001205 tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001206
Gilles Peskine8f073122018-11-27 15:58:47 +01001207 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001208 tests/compat.sh -t RSA
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001209
1210 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001211 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001212}
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001213
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001214component_test_no_ctr_drbg_classic () {
1215 msg "build: Full minus CTR_DRBG, classic crypto in TLS"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001216 scripts/config.py full
1217 scripts/config.py unset MBEDTLS_CTR_DRBG_C
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001218 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001219
1220 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1221 make
1222
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001223 msg "test: Full minus CTR_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001224 make test
1225
Gilles Peskineba749042021-01-13 20:02:03 +01001226 # In this configuration, the TLS test programs use HMAC_DRBG.
1227 # The SSL tests are slow, so run a small subset, just enough to get
1228 # confidence that the SSL code copes with HMAC_DRBG.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001229 msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001230 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
Gilles Peskineba749042021-01-13 20:02:03 +01001231
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001232 msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001233 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001234}
1235
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001236component_test_no_ctr_drbg_use_psa () {
1237 msg "build: Full minus CTR_DRBG, PSA crypto in TLS"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001238 scripts/config.py full
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001239 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1240 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001241
1242 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1243 make
1244
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001245 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites"
1246 make test
1247
1248 # In this configuration, the TLS test programs use HMAC_DRBG.
1249 # The SSL tests are slow, so run a small subset, just enough to get
1250 # confidence that the SSL code copes with HMAC_DRBG.
1251 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001252 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001253
1254 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001255 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001256}
1257
1258component_test_no_hmac_drbg_classic () {
1259 msg "build: Full minus HMAC_DRBG, classic crypto in TLS"
1260 scripts/config.py full
1261 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1262 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1263 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1264
1265 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1266 make
1267
1268 msg "test: Full minus HMAC_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001269 make test
1270
Gilles Peskinea2224342020-11-19 22:14:34 +01001271 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1272 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1273 # instead.
1274 # Test SSL with non-deterministic ECDSA. Only test features that
1275 # might be affected by how ECDSA signature is performed.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001276 msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001277 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
Gilles Peskinea2224342020-11-19 22:14:34 +01001278
1279 # To save time, only test one protocol version, since this part of
1280 # the protocol is identical in (D)TLS up to 1.2.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001281 msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001282 tests/compat.sh -m tls12 -t 'ECDSA'
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001283}
1284
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001285component_test_no_hmac_drbg_use_psa () {
1286 msg "build: Full minus HMAC_DRBG, PSA crypto in TLS"
1287 scripts/config.py full
1288 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1289 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1290 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1291
1292 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1293 make
1294
1295 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites"
1296 make test
1297
1298 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1299 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1300 # instead.
1301 # Test SSL with non-deterministic ECDSA. Only test features that
1302 # might be affected by how ECDSA signature is performed.
1303 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001304 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001305
1306 # To save time, only test one protocol version, since this part of
1307 # the protocol is identical in (D)TLS up to 1.2.
1308 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001309 tests/compat.sh -m tls12 -t 'ECDSA'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001310}
1311
1312component_test_psa_external_rng_no_drbg_classic () {
1313 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS"
1314 scripts/config.py full
1315 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1316 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001317 scripts/config.py unset MBEDTLS_ENTROPY_C
1318 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1319 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001320 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1321 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1322 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1323 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
Gilles Peskine8eb29432021-02-03 20:07:11 +01001324 # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG,
1325 # the SSL test programs don't have an RNG and can't work. Explicitly
1326 # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG.
1327 make CFLAGS="$ASAN_CFLAGS -O2 -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001328
1329 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites"
1330 make test
1331
Gilles Peskine8eb29432021-02-03 20:07:11 +01001332 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001333 tests/ssl-opt.sh -f 'Default'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001334}
1335
1336component_test_psa_external_rng_no_drbg_use_psa () {
1337 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS"
Gilles Peskinec109b372020-11-23 17:39:04 +01001338 scripts/config.py full
1339 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001340 scripts/config.py unset MBEDTLS_ENTROPY_C
1341 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1342 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskinec109b372020-11-23 17:39:04 +01001343 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1344 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1345 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1346 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1347 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1348
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001349 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites"
Gilles Peskinec109b372020-11-23 17:39:04 +01001350 make test
1351
Gilles Peskine8eb29432021-02-03 20:07:11 +01001352 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001353 tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001354}
1355
1356component_test_psa_external_rng_use_psa_crypto () {
1357 msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1358 scripts/config.py full
1359 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
1360 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1361 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1362 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1363
1364 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1365 make test
1366
Gilles Peskineba749042021-01-13 20:02:03 +01001367 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001368 tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001369}
1370
Gilles Peskine55e89982023-04-28 21:04:28 +02001371component_test_psa_inject_entropy () {
1372 msg "build: full + MBEDTLS_PSA_INJECT_ENTROPY"
1373 scripts/config.py full
1374 scripts/config.py set MBEDTLS_PSA_INJECT_ENTROPY
1375 scripts/config.py set MBEDTLS_ENTROPY_NV_SEED
1376 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
1377 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
1378 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_READ
1379 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_WRITE
1380 make CFLAGS="$ASAN_CFLAGS '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" LDFLAGS="$ASAN_CFLAGS"
1381
1382 msg "test: full + MBEDTLS_PSA_INJECT_ENTROPY"
1383 make test
1384}
1385
Manuel Pégourié-Gonnard1a3f9ed2020-05-19 12:38:31 +02001386component_test_ecp_no_internal_rng () {
1387 msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules"
1388 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1389 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1390 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1391 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1392 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG
1393 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1394
1395 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1396 make
1397
1398 msg "test: ECP_NO_INTERNAL_RNG, no DRBG module"
1399 make test
1400
1401 # no SSL tests as they all depend on having a DRBG
1402}
1403
Manuel Pégourié-Gonnard53fb66d2020-06-04 09:43:14 +02001404component_test_ecp_restartable_no_internal_rng () {
1405 msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG"
1406 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1407 scripts/config.py set MBEDTLS_ECP_RESTARTABLE
1408 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1409 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1410 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1411 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
1412 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1413
1414 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1415 make
1416
1417 msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module"
1418 make test
1419
1420 # no SSL tests as they all depend on having a DRBG
1421}
1422
Przemek Stekiele5352702022-10-05 11:37:54 +02001423component_test_tls1_2_default_stream_cipher_only () {
1424 msg "build: default with only stream cipher"
1425
1426 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C
1427 scripts/config.py unset MBEDTLS_GCM_C
1428 scripts/config.py unset MBEDTLS_CCM_C
1429 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1430 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1431 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1432 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1433 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1434 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1435 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
1436 # Modules that depend on AEAD
1437 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001438 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001439
1440 make
1441
1442 msg "test: default with only stream cipher"
1443 make test
1444
1445 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
1446}
1447
1448component_test_tls1_2_default_stream_cipher_only_use_psa () {
1449 msg "build: default with only stream cipher use psa"
1450
1451 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1452 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1453 scripts/config.py unset MBEDTLS_GCM_C
1454 scripts/config.py unset MBEDTLS_CCM_C
1455 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1456 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1457 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1458 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1459 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1460 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1461 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
1462 # Modules that depend on AEAD
1463 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001464 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001465
1466 make
1467
1468 msg "test: default with only stream cipher use psa"
1469 make test
1470
1471 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
1472}
1473
1474component_test_tls1_2_default_cbc_legacy_cipher_only () {
1475 msg "build: default with only CBC-legacy cipher"
1476
1477 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1478 scripts/config.py unset MBEDTLS_GCM_C
1479 scripts/config.py unset MBEDTLS_CCM_C
1480 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1481 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1482 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1483 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1484 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1485 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1486 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1487 # Modules that depend on AEAD
1488 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001489 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001490
1491 make
1492
1493 msg "test: default with only CBC-legacy cipher"
1494 make test
1495
1496 msg "test: default with only CBC-legacy cipher - ssl-opt.sh (subset)"
1497 tests/ssl-opt.sh -f "TLS 1.2"
1498}
1499
1500component_test_tls1_2_deafult_cbc_legacy_cipher_only_use_psa () {
1501 msg "build: default with only CBC-legacy cipher use psa"
1502
1503 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1504 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1505 scripts/config.py unset MBEDTLS_GCM_C
1506 scripts/config.py unset MBEDTLS_CCM_C
1507 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1508 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1509 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1510 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1511 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1512 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1513 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1514 # Modules that depend on AEAD
1515 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001516 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001517
1518 make
1519
1520 msg "test: default with only CBC-legacy cipher use psa"
1521 make test
1522
1523 msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)"
1524 tests/ssl-opt.sh -f "TLS 1.2"
1525}
1526
1527component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () {
1528 msg "build: default with only CBC-legacy and CBC-EtM ciphers"
1529
1530 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1531 scripts/config.py unset MBEDTLS_GCM_C
1532 scripts/config.py unset MBEDTLS_CCM_C
1533 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1534 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1535 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1536 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1537 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
1538 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1539 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1540 # Modules that depend on AEAD
1541 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001542 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001543
1544 make
1545
1546 msg "test: default with only CBC-legacy and CBC-EtM ciphers"
1547 make test
1548
1549 msg "test: default with only CBC-legacy and CBC-EtM ciphers - ssl-opt.sh (subset)"
1550 tests/ssl-opt.sh -f "TLS 1.2"
1551}
1552
1553component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa () {
1554 msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa"
1555
1556 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1557 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1558 scripts/config.py unset MBEDTLS_GCM_C
1559 scripts/config.py unset MBEDTLS_CCM_C
1560 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1561 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1562 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1563 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1564 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
1565 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1566 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1567 # Modules that depend on AEAD
1568 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001569 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001570
1571 make
1572
1573 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa"
1574 make test
1575
1576 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)"
1577 tests/ssl-opt.sh -f "TLS 1.2"
1578}
1579
Gilles Peskine636c26a2020-03-04 20:46:15 +01001580component_test_new_ecdh_context () {
1581 msg "build: new ECDH context (ASan build)" # ~ 6 min
1582 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1583 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1584 make
1585
1586 msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1587 make test
1588
1589 msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001590 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01001591
1592 msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1593 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001594 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001595}
1596
1597component_test_everest () {
1598 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
1599 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1600 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1601 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
1602 make
1603
1604 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1605 make test
1606
Gilles Peskineee8af062023-11-02 19:58:03 +01001607 msg "test: metatests (clang, ASan)"
David Horstmann1b421b12024-01-17 14:53:08 +00001608 tests/scripts/run-metatests.sh any asan poison
Gilles Peskineee8af062023-11-02 19:58:03 +01001609
Gilles Peskine636c26a2020-03-04 20:46:15 +01001610 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001611 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01001612
1613 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1614 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001615 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001616}
1617
Gilles Peskined3beca92020-07-03 00:15:37 +02001618component_test_everest_curve25519_only () {
1619 msg "build: Everest ECDH context, only Curve25519" # ~ 6 min
1620 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1621 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1622 scripts/config.py unset MBEDTLS_ECDSA_C
1623 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1624 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1625 # Disable all curves
1626 for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do
1627 scripts/config.py unset "$c"
1628 done
1629 scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED
1630
1631 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1632
1633 msg "test: Everest ECDH context, only Curve25519" # ~ 50s
1634 make test
1635}
1636
Gilles Peskine8f073122018-11-27 15:58:47 +01001637component_test_small_ssl_out_content_len () {
1638 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001639 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
1640 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01001641 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1642 make
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001643
Gilles Peskine8f073122018-11-27 15:58:47 +01001644 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001645 tests/ssl-opt.sh -f "Max fragment\|Large packet"
Gilles Peskine8f073122018-11-27 15:58:47 +01001646}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001647
Gilles Peskine8f073122018-11-27 15:58:47 +01001648component_test_small_ssl_in_content_len () {
1649 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001650 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
1651 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
Gilles Peskine8f073122018-11-27 15:58:47 +01001652 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1653 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001654
Gilles Peskine8f073122018-11-27 15:58:47 +01001655 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001656 tests/ssl-opt.sh -f "Max fragment"
Gilles Peskine8f073122018-11-27 15:58:47 +01001657}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001658
Gilles Peskine8f073122018-11-27 15:58:47 +01001659component_test_small_ssl_dtls_max_buffering () {
1660 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001661 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
Gilles Peskine8f073122018-11-27 15:58:47 +01001662 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1663 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001664
Gilles Peskine8f073122018-11-27 15:58:47 +01001665 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001666 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 +01001667}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001668
Gilles Peskine8f073122018-11-27 15:58:47 +01001669component_test_small_mbedtls_ssl_dtls_max_buffering () {
1670 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
Gilles Peskine636c26a2020-03-04 20:46:15 +01001671 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
Gilles Peskine8f073122018-11-27 15:58:47 +01001672 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1673 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001674
Gilles Peskine8f073122018-11-27 15:58:47 +01001675 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001676 tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
Gilles Peskine8f073122018-11-27 15:58:47 +01001677}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001678
Gilles Peskine75cc7712019-09-06 19:47:17 +02001679component_test_psa_collect_statuses () {
1680 msg "build+test: psa_collect_statuses" # ~30s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001681 scripts/config.py full
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001682 tests/scripts/psa_collect_statuses.py
Gilles Peskine75cc7712019-09-06 19:47:17 +02001683 # Check that psa_crypto_init() succeeded at least once
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001684 grep -q '^0:psa_crypto_init:' tests/statuses.log
Gilles Peskine75cc7712019-09-06 19:47:17 +02001685 rm -f tests/statuses.log
1686}
1687
Gilles Peskine8f073122018-11-27 15:58:47 +01001688component_test_full_cmake_clang () {
1689 msg "build: cmake, full config, clang" # ~ 50s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001690 scripts/config.py full
Gilles Peskine83264be2022-10-30 21:02:40 +01001691 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 +01001692 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001693
k-stachowiak0291cb72019-06-26 15:52:12 +02001694 msg "test: main suites (full config, clang)" # ~ 5s
Gilles Peskine8f073122018-11-27 15:58:47 +01001695 make test
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01001696
Gilles Peskine83264be2022-10-30 21:02:40 +01001697 msg "test: cpp_dummy_build (full config, clang)" # ~ 1s
1698 programs/test/cpp_dummy_build
1699
Gilles Peskineee8af062023-11-02 19:58:03 +01001700 msg "test: metatests (clang)"
Gilles Peskinee38eb792023-11-03 18:05:38 +01001701 tests/scripts/run-metatests.sh any pthread
Gilles Peskineee8af062023-11-02 19:58:03 +01001702
Gilles Peskine93aaf2e2019-06-14 18:27:03 +02001703 msg "program demos (full config, clang)" # ~10s
1704 tests/scripts/run_demos.py
1705
k-stachowiak0291cb72019-06-26 15:52:12 +02001706 msg "test: psa_constant_names (full config, clang)" # ~ 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001707 tests/scripts/test_psa_constant_names.py
Gilles Peskine69e8f7f2020-02-26 19:51:43 +01001708
Gilles Peskine8f073122018-11-27 15:58:47 +01001709 msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001710 tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Gilles Peskine8f073122018-11-27 15:58:47 +01001711}
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001712
Gilles Peskine9603a442022-11-29 16:01:41 +01001713skip_suites_without_constant_flow () {
1714 # Skip the test suites that don't have any constant-flow annotations.
1715 # This will need to be adjusted if we ever start declaring things as
1716 # secret from macros or functions inside tests/include or tests/src.
1717 SKIP_TEST_SUITES=$(
1718 git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' |
1719 sed 's/test_suite_//; s/\.function$//' |
1720 tr '\n' ,)
1721 export SKIP_TEST_SUITES
1722}
1723
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001724component_test_memsan_constant_flow () {
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001725 # This tests both (1) accesses to undefined memory, and (2) branches or
1726 # memory access depending on secret values. To distinguish between those:
1727 # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist?
1728 # - or alternatively, change the build type to MemSanDbg, which enables
1729 # origin tracking and nicer stack traces (which are useful for debugging
1730 # anyway), and check if the origin was TEST_CF_SECRET() or something else.
1731 msg "build: cmake MSan (clang), full config with constant flow testing"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001732 scripts/config.py full
1733 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
1734 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
1735 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1736 make
1737
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001738 msg "test: main suites (Msan + constant flow)"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001739 make test
1740}
1741
Bence Szépkútie1c6c4c2023-12-06 16:14:37 +01001742component_release_test_valgrind_constant_flow () {
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001743 # This tests both (1) everything that valgrind's memcheck usually checks
1744 # (heap buffer overflows, use of uninitialized memory, use-after-free,
1745 # etc.) and (2) branches or memory access depending on secret values,
1746 # which will be reported as uninitialized memory. To distinguish between
1747 # secret and actually uninitialized:
1748 # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist?
1749 # - or alternatively, build with debug info and manually run the offending
1750 # test suite with valgrind --track-origins=yes, then check if the origin
1751 # was TEST_CF_SECRET() or something else.
1752 msg "build: cmake release GCC, full config with constant flow testing"
1753 scripts/config.py full
1754 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND
Gilles Peskine9603a442022-11-29 16:01:41 +01001755 skip_suites_without_constant_flow
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001756 cmake -D CMAKE_BUILD_TYPE:String=Release .
1757 make
1758
1759 # this only shows a summary of the results (how many of each type)
1760 # details are left in Testing/<date>/DynamicAnalysis.xml
Gilles Peskine9603a442022-11-29 16:01:41 +01001761 msg "test: some suites (valgrind + constant flow)"
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001762 make memcheck
1763}
1764
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001765component_test_default_no_deprecated () {
Gilles Peskine8386ea22020-04-30 09:07:29 +02001766 # Test that removing the deprecated features from the default
1767 # configuration leaves something consistent.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001768 msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
1769 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
Dave Rodgman374b1882024-01-04 10:30:57 +00001770 make CFLAGS='-O -Werror -Wall -Wextra'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001771
1772 msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
1773 make test
1774}
1775
1776component_test_full_no_deprecated () {
Gilles Peskine30de2e82020-04-20 21:39:22 +02001777 msg "build: make, full_no_deprecated config" # ~ 30s
1778 scripts/config.py full_no_deprecated
Dave Rodgman374b1882024-01-04 10:30:57 +00001779 make CFLAGS='-O -Werror -Wall -Wextra'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001780
Gilles Peskine30de2e82020-04-20 21:39:22 +02001781 msg "test: make, full_no_deprecated config" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001782 make test
Gilles Peskine13094932025-02-17 17:42:35 +01001783
1784 msg "test: ssl-opt.sh authentication, full_no_deprecated config" # ~ 10s
1785 tests/ssl-opt.sh -f 'Default\|Authentication'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001786}
1787
Gilles Peskine8386ea22020-04-30 09:07:29 +02001788component_test_full_no_deprecated_deprecated_warning () {
1789 # Test that there is nothing deprecated in "full_no_deprecated".
1790 # A deprecated feature would trigger a warning (made fatal) from
1791 # MBEDTLS_DEPRECATED_WARNING.
Gilles Peskine30de2e82020-04-20 21:39:22 +02001792 msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
1793 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001794 scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
1795 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Dave Rodgman374b1882024-01-04 10:30:57 +00001796 make CFLAGS='-O -Werror -Wall -Wextra'
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001797
Gilles Peskine30de2e82020-04-20 21:39:22 +02001798 msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001799 make test
1800}
1801
Gilles Peskine8386ea22020-04-30 09:07:29 +02001802component_test_full_deprecated_warning () {
1803 # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
1804 # with only certain whitelisted types of warnings.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001805 msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001806 scripts/config.py full
1807 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001808 # Expect warnings from '#warning' directives in check_config.h.
Dave Rodgman9d2c67f2023-12-19 14:07:15 +00001809 # Note that gcc is required to allow the use of -Wno-error=cpp, which allows us to
1810 # display #warning messages without them being treated as errors.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001811 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +01001812
Gilles Peskine8386ea22020-04-30 09:07:29 +02001813 msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
1814 # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
1815 # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001816 # Expect warnings from '#warning' directives in check_config.h and
1817 # from the use of deprecated functions in test suites.
1818 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 +01001819
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001820 msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
1821 make test
Gilles Peskine93aaf2e2019-06-14 18:27:03 +02001822
1823 msg "program demos: full config + MBEDTLS_TEST_DEPRECATED" # ~10s
1824 tests/scripts/run_demos.py
Gilles Peskine8f073122018-11-27 15:58:47 +01001825}
Jaeden Ameroed93bdc2018-11-02 16:57:24 +00001826
Gilles Peskineec541fe2020-01-31 14:24:14 +01001827# Check that the specified libraries exist and are empty.
1828are_empty_libraries () {
1829 nm "$@" >/dev/null 2>/dev/null
1830 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
1831}
1832
1833component_build_crypto_default () {
1834 msg "build: make, crypto only"
1835 scripts/config.py crypto
Gilles Peskine6bb39152020-02-03 11:59:20 +01001836 make CFLAGS='-O1 -Werror'
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001837 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001838}
1839
1840component_build_crypto_full () {
1841 msg "build: make, crypto only, full config"
1842 scripts/config.py crypto_full
Gilles Peskine6bb39152020-02-03 11:59:20 +01001843 make CFLAGS='-O1 -Werror'
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001844 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001845}
1846
Gilles Peskine8df27482022-10-21 19:34:54 +02001847component_test_crypto_for_psa_service () {
Gilles Peskine21503df2022-10-11 21:05:06 +02001848 msg "build: make, config for PSA crypto service"
1849 scripts/config.py crypto
1850 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1851 # Disable things that are not needed for just cryptography, to
1852 # reach a configuration that would be typical for a PSA cryptography
1853 # service providing all implemented PSA algorithms.
1854 # System stuff
1855 scripts/config.py unset MBEDTLS_ERROR_C
1856 scripts/config.py unset MBEDTLS_TIMING_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001857 scripts/config.py unset MBEDTLS_VERSION_FEATURES
Gilles Peskine21503df2022-10-11 21:05:06 +02001858 # Crypto stuff with no PSA interface
1859 scripts/config.py unset MBEDTLS_BASE64_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001860 scripts/config.py unset MBEDTLS_BLOWFISH_C
1861 # Keep MBEDTLS_CIPHER_C because psa_crypto_cipher, CCM and GCM need it.
1862 # Keep MBEDTLS_MD_C because RSA and ECDSA need it, also HMAC_DRBG which
1863 # is needed for deterministic ECDSA.
1864 scripts/config.py unset MBEDTLS_ECJPAKE_C
1865 scripts/config.py unset MBEDTLS_HKDF_C # PSA's HKDF is independent
Gilles Peskine21503df2022-10-11 21:05:06 +02001866 scripts/config.py unset MBEDTLS_NIST_KW_C
1867 scripts/config.py unset MBEDTLS_PEM_PARSE_C
1868 scripts/config.py unset MBEDTLS_PEM_WRITE_C
1869 scripts/config.py unset MBEDTLS_PKCS12_C
1870 scripts/config.py unset MBEDTLS_PKCS5_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001871 # We keep MBEDTLS_PK_{,PARSE,WRITE}_C because PSA with RSA needs it.
1872 scripts/config.py unset MBEDTLS_XTEA_C
Gilles Peskine21503df2022-10-11 21:05:06 +02001873 make CFLAGS='-O1 -Werror' all test
1874 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1875}
1876
Gilles Peskineec541fe2020-01-31 14:24:14 +01001877component_build_crypto_baremetal () {
1878 msg "build: make, crypto only, baremetal config"
1879 scripts/config.py crypto_baremetal
David Horstmann3cb5e9b2021-11-30 11:40:54 +00001880 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001881 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001882}
Daniel Axtens6f63cc72020-09-02 21:30:13 +10001883support_build_crypto_baremetal () {
Daniel Axtens1a021af2020-08-31 14:22:58 +10001884 support_build_baremetal "$@"
1885}
1886
1887component_build_baremetal () {
1888 msg "build: make, baremetal config"
1889 scripts/config.py baremetal
David Horstmann3cb5e9b2021-11-30 11:40:54 +00001890 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
Daniel Axtens1a021af2020-08-31 14:22:58 +10001891}
1892support_build_baremetal () {
Daniel Axtens6f63cc72020-09-02 21:30:13 +10001893 # Older Glibc versions include time.h from other headers such as stdlib.h,
1894 # which makes the no-time.h-in-baremetal check fail. Ubuntu 16.04 has this
1895 # problem, Ubuntu 18.04 is ok.
1896 ! grep -q -F time.h /usr/include/x86_64-linux-gnu/sys/types.h
1897}
Gilles Peskineec541fe2020-01-31 14:24:14 +01001898
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001899# depends.py family of tests
Andrzej Kurek85d69302022-10-05 09:14:07 -04001900component_test_depends_py_cipher_id () {
1901 msg "test/build: depends.py cipher_id (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001902 tests/scripts/depends.py cipher_id --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001903}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001904
Andrzej Kurek85d69302022-10-05 09:14:07 -04001905component_test_depends_py_cipher_chaining () {
1906 msg "test/build: depends.py cipher_chaining (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001907 tests/scripts/depends.py cipher_chaining --unset-use-psa
John Durkopc14be902020-08-20 06:16:41 -07001908}
1909
Andrzej Kurek85d69302022-10-05 09:14:07 -04001910component_test_depends_py_cipher_padding () {
1911 msg "test/build: depends.py cipher_padding (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001912 tests/scripts/depends.py cipher_padding --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001913}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001914
Andrzej Kurek85d69302022-10-05 09:14:07 -04001915component_test_depends_py_curves () {
1916 msg "test/build: depends.py curves (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001917 tests/scripts/depends.py curves --unset-use-psa
John Durkop2ec2eaa2020-08-24 18:29:15 -07001918}
1919
Andrzej Kurek85d69302022-10-05 09:14:07 -04001920component_test_depends_py_hashes () {
1921 msg "test/build: depends.py hashes (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001922 tests/scripts/depends.py hashes --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001923}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001924
Andrzej Kurek85d69302022-10-05 09:14:07 -04001925component_test_depends_py_kex () {
1926 msg "test/build: depends.py kex (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001927 tests/scripts/depends.py kex --unset-use-psa
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001928}
1929
Andrzej Kurek85d69302022-10-05 09:14:07 -04001930component_test_depends_py_pkalgs () {
1931 msg "test/build: depends.py pkalgs (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001932 tests/scripts/depends.py pkalgs --unset-use-psa
1933}
1934
1935# PSA equivalents of the depends.py tests
1936component_test_depends_py_cipher_id_psa () {
1937 msg "test/build: depends.py cipher_id (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1938 tests/scripts/depends.py cipher_id
1939}
1940
1941component_test_depends_py_cipher_chaining_psa () {
1942 msg "test/build: depends.py cipher_chaining (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1943 tests/scripts/depends.py cipher_chaining
1944}
1945
1946component_test_depends_py_cipher_padding_psa () {
1947 msg "test/build: depends.py cipher_padding (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1948 tests/scripts/depends.py cipher_padding
1949}
1950
1951component_test_depends_py_curves_psa () {
1952 msg "test/build: depends.py curves (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1953 tests/scripts/depends.py curves
1954}
1955
1956component_test_depends_py_hashes_psa () {
1957 msg "test/build: depends.py hashes (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1958 tests/scripts/depends.py hashes
1959}
1960
1961component_test_depends_py_kex_psa () {
1962 msg "test/build: depends.py kex (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1963 tests/scripts/depends.py kex
1964}
1965
1966component_test_depends_py_pkalgs_psa () {
1967 msg "test/build: depends.py pkalgs (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
Andrzej Kurek85d69302022-10-05 09:14:07 -04001968 tests/scripts/depends.py pkalgs
Gilles Peskine8f073122018-11-27 15:58:47 +01001969}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001970
Dave Rodgman5fce4f62023-01-20 13:18:05 +00001971component_build_no_pk_rsa_alt_support () {
1972 msg "build: !MBEDTLS_PK_RSA_ALT_SUPPORT" # ~30s
1973
1974 scripts/config.py full
1975 scripts/config.py unset MBEDTLS_PK_RSA_ALT_SUPPORT
1976 scripts/config.py set MBEDTLS_RSA_C
1977 scripts/config.py set MBEDTLS_X509_CRT_WRITE_C
1978
1979 # Only compile - this is primarily to test for compile issues
Dave Rodgman374b1882024-01-04 10:30:57 +00001980 make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy'
Dave Rodgman5fce4f62023-01-20 13:18:05 +00001981}
1982
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001983component_test_no_use_psa_crypto_full_cmake_asan() {
1984 # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
Gilles Peskinedc3a1792019-09-03 11:42:04 +02001985 msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001986 scripts/config.py full
1987 scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
1988 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1989 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1990 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskinedc6d8382020-04-12 14:21:55 +02001991 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001992 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Manuel Pégourié-Gonnardd8167e82019-02-01 11:12:52 +01001993 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001994 make
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +02001995
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001996 msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001997 make test
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +02001998
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001999 msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002000 tests/ssl-opt.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002001
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002002 msg "test: compat.sh all except legacy/next (full minus MBEDTLS_USE_PSA_CRYPTO)"
2003 tests/compat.sh -e '^DES-CBC-\|-DES-CBC-\|ARIA\|CHACHA' \
Manuel Pégourié-Gonnard2cd43a72024-04-09 23:01:09 +02002004 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
Gilles Peskinec67c3b32023-08-27 21:33:41 +02002005
2006 msg "test: compat.sh single-DES (full minus MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002007 env OPENSSL="$OPENSSL_LEGACY" tests/compat.sh -e '^$' -f '^DES-CBC\|-DES-CBC-' \
Manuel Pégourié-Gonnard2cd43a72024-04-09 23:01:09 +02002008 -m 'ssl3 tls1 tls1_1 tls12 dtls1 dtls12'
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002009
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002010 # ARIA and ChachaPoly are both (D)TLS 1.2 only
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01002011 msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnardaefbb662024-04-17 11:51:13 +02002012 env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' \
Manuel Pégourié-Gonnardde887ba2024-04-18 10:05:04 +02002013 -m 'tls12 dtls12'
Andrzej Kurekde5a0072019-02-01 07:03:03 -05002014}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002015
Ronald Crond2c53e62021-09-13 09:38:05 +02002016component_test_psa_crypto_config_accel_ecdsa () {
2017 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
2018
2019 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2020 # partial support for cipher operations in the driver test library.
2021 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2022 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
Gilles Peskine62de7672022-04-21 11:05:16 +02002023 # Disable obsolete hashes (alternatively we could enable support for them
2024 # in the driver test library).
2025 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2026 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
Ronald Crond2c53e62021-09-13 09:38:05 +02002027
2028 # SHA384 needed for some ECDSA signature tests.
2029 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA512_C
2030
2031 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY"
2032 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2033 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2034
2035 # Restore test driver base configuration
2036 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA512_C
2037
2038 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2039 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2040 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2041 scripts/config.py unset MBEDTLS_ECDSA_C
2042 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
2043 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
2044
2045 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2046 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"
2047
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002048 not grep mbedtls_ecdsa_ library/ecdsa.o
Ronald Crond2c53e62021-09-13 09:38:05 +02002049
2050 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
2051 make test
2052}
2053
2054component_test_psa_crypto_config_accel_rsa_signature () {
2055 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
2056
2057 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2058 # partial support for cipher operations in the driver test library.
2059 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2060 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2061
2062 # It seems it is not possible to remove only the support for RSA signature
2063 # in the library. Thus we have to remove all RSA support (signature and
2064 # encryption/decryption). AS there is no driver support for asymmetric
2065 # encryption/decryption so far remove RSA encryption/decryption from the
2066 # application algorithm list.
2067 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2068 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2069
2070 # Make sure both the library and the test library support the SHA hash
2071 # algorithms and only those ones (SHA256 is included by default). That way:
2072 # - the test library can compute the RSA signatures even in the case of a
2073 # composite RSA signature algorithm based on a SHA hash (no other hash
2074 # used in the unit tests).
2075 # - the dependency of RSA signature tests on PSA_WANT_ALG_SHA_xyz is
2076 # fulfilled as the hash SHA algorithm is supported by the library, and
2077 # thus the tests are run, not skipped.
2078 # - when testing a signature key with an algorithm wildcard built from
2079 # PSA_ALG_ANY_HASH as algorithm to test with the key, the chosen hash
2080 # algorithm based on the hashes supported by the library is also
2081 # supported by the test library.
2082 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2083 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2084 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2085 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160_C
2086
2087 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA1_C
2088 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA512_C
2089 # We need PEM parsing in the test library as well to support the import
2090 # of PEM encoded RSA keys.
2091 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_PEM_PARSE_C
2092 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_BASE64_C
2093
2094 loc_accel_list="ALG_RSA_PKCS1V15_SIGN ALG_RSA_PSS KEY_TYPE_RSA_KEY_PAIR KEY_TYPE_RSA_PUBLIC_KEY"
2095 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2096 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2097
2098 # Restore test driver base configuration
2099 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA1_C
2100 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA512_C
2101 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_PEM_PARSE_C
2102 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_BASE64_C
2103
2104
2105 # Mbed TLS library build
2106 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2107 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2108
2109 # Remove RSA support and its dependencies
2110 scripts/config.py unset MBEDTLS_PKCS1_V15
2111 scripts/config.py unset MBEDTLS_PKCS1_V21
2112 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
2113 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
2114 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
2115 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
2116 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
2117 scripts/config.py unset MBEDTLS_RSA_C
2118 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
2119
2120 scripts/config.py unset MBEDTLS_MD2_C
2121 scripts/config.py unset MBEDTLS_MD4_C
2122 scripts/config.py unset MBEDTLS_MD5_C
2123 scripts/config.py unset MBEDTLS_RIPEMD160_C
2124 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1
2125 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_1
2126 scripts/config.py unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
2127
2128 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2129 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2130
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002131 not grep mbedtls_rsa_rsassa_pkcs1_v15_sign library/rsa.o
2132 not grep mbedtls_rsa_rsassa_pss_sign_ext library/rsa.o
Ronald Crond2c53e62021-09-13 09:38:05 +02002133
2134 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
2135 make test
2136}
2137
Ronald Cronf7e483c2021-05-08 14:32:59 +02002138component_test_psa_crypto_config_accel_hash () {
2139 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2140
2141 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2142 # partial support for cipher operations in the driver test library.
2143 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2144 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2145
2146 loc_accel_list="ALG_MD4 ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512"
2147 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2148 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2149
2150 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2151 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2152 scripts/config.py unset MBEDTLS_MD2_C
2153 scripts/config.py unset MBEDTLS_MD4_C
2154 scripts/config.py unset MBEDTLS_MD5_C
2155 scripts/config.py unset MBEDTLS_RIPEMD160_C
2156 scripts/config.py unset MBEDTLS_SHA1_C
2157 # Don't unset MBEDTLS_SHA256_C as it is needed by PSA crypto core.
2158 scripts/config.py unset MBEDTLS_SHA512_C
2159 # Unset MBEDTLS_SSL_PROTO_SSL3, MBEDTLS_SSL_PROTO_TLS1 and MBEDTLS_SSL_PROTO_TLS1_1 as they depend on MBEDTLS_SHA1_C
2160 scripts/config.py unset MBEDTLS_SSL_PROTO_SSL3
2161 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1
2162 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_1
2163 # Unset MBEDTLS_SSL_CBC_RECORD_SPLITTING as it depends on MBEDTLS_SSL_PROTO_TLS1 in the default configuration.
2164 scripts/config.py unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
2165 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2166 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2167
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002168 not grep mbedtls_sha512_init library/sha512.o
2169 not grep mbedtls_sha1_init library/sha1.o
Ronald Cronf7e483c2021-05-08 14:32:59 +02002170
2171 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2172 make test
2173}
2174
Ronald Cron09623702021-10-18 11:26:01 +02002175component_test_psa_crypto_config_accel_cipher () {
2176 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated cipher"
2177
Gilles Peskine186331872022-04-12 15:58:03 +02002178 # This test case focuses on cipher+AEAD. We don't yet support all
2179 # combinations of configurations, so deactivate block-cipher-based MACs.
2180 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CMAC
2181
Ronald Cron09623702021-10-18 11:26:01 +02002182 loc_accel_list="ALG_CBC_NO_PADDING ALG_CBC_PKCS7 ALG_CTR ALG_CFB ALG_OFB ALG_XTS KEY_TYPE_DES"
2183 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2184 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2185
2186 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2187 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2188
2189 # There is no intended accelerator support for ALG STREAM_CIPHER and
2190 # ALG_ECB_NO_PADDING. Therefore, asking for them in the build implies the
2191 # inclusion of the Mbed TLS cipher operations. As we want to test here with
2192 # cipher operations solely supported by accelerators, disabled those
2193 # PSA configuration options.
2194 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2195 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
Ronald Cron09623702021-10-18 11:26:01 +02002196
2197 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2198 scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7
2199 scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR
2200 scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB
2201 scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB
2202 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2203 scripts/config.py unset MBEDTLS_DES_C
2204
2205 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2206 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2207
Gilles Peskine82143402024-06-19 15:09:27 +02002208 not grep mbedtls_des library/des.o
Ronald Cron09623702021-10-18 11:26:01 +02002209
2210 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2211 make test
2212}
2213
Przemek Stekiel8b56f232022-10-02 20:58:39 +02002214component_test_psa_crypto_config_accel_aead () {
2215 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2216
2217 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2218 # partial support for cipher operations in the driver test library.
2219 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2220 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2221
2222 loc_accel_list="ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 KEY_TYPE_AES KEY_TYPE_CHACHA20 KEY_TYPE_ARIA KEY_TYPE_CAMELLIA"
2223 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2224 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2225
2226 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2227 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2228
2229 scripts/config.py unset MBEDTLS_GCM_C
2230 scripts/config.py unset MBEDTLS_CCM_C
2231 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2232 # Features that depend on AEAD
2233 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
2234 scripts/config.py unset MBEDTLS_SSL_TICKET_C
2235
2236 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2237 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"
2238
2239 # There's a risk of something getting re-enabled via config_psa.h
2240 # make sure it did not happen.
2241 not grep mbedtls_ccm library/ccm.o
2242 not grep mbedtls_gcm library/gcm.o
2243 not grep mbedtls_chachapoly library/chachapoly.o
2244
2245 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2246 make test
2247}
2248
John Durkop4377bf72020-10-23 01:26:57 -07002249component_test_psa_crypto_config_no_driver() {
John Durkop4377bf72020-10-23 01:26:57 -07002250 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
2251 scripts/config.py full
2252 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2253 scripts/config.py unset MBEDTLS_PSA_CRYPTO_DRIVERS
2254 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkope7012c72020-10-26 09:55:01 -07002255 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkop4377bf72020-10-23 01:26:57 -07002256
2257 msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
John Durkopd8959392020-09-20 23:09:17 -07002258 make test
2259}
2260
Gilles Peskined4c85af2023-07-20 22:19:45 +02002261component_test_aead_chachapoly_disabled() {
2262 msg "build: full minus CHACHAPOLY"
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002263 scripts/config.py full
2264 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
Gilles Peskined4c85af2023-07-20 22:19:45 +02002265 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002266 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
2267
Gilles Peskined4c85af2023-07-20 22:19:45 +02002268 msg "test: full minus CHACHAPOLY"
2269 make test
2270}
2271
2272component_test_aead_only_ccm() {
2273 msg "build: full minus CHACHAPOLY and GCM"
2274 scripts/config.py full
2275 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2276 scripts/config.py unset MBEDTLS_GCM_C
2277 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
2278 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_GCM
2279 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
2280
2281 msg "test: full minus CHACHAPOLY and GCM"
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002282 make test
2283}
2284
John Durkopd0321952020-10-29 21:37:36 -07002285# 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 -08002286component_build_psa_accel_alg_ecdh() {
Gilles Peskine168be012023-07-19 19:36:55 +02002287 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C"
John Durkopd0321952020-10-29 21:37:36 -07002288 scripts/config.py full
2289 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2290 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2291 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2292 scripts/config.py unset MBEDTLS_ECDH_C
2293 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
2294 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
2295 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
2296 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
2297 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
2298 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2299 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2300}
2301
John Durkopf4c4cb02020-10-28 20:09:55 -07002302# 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 -08002303component_build_psa_accel_key_type_ecc_key_pair() {
Gilles Peskine168be012023-07-19 19:36:55 +02002304 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR"
John Durkopf4c4cb02020-10-28 20:09:55 -07002305 scripts/config.py full
2306 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2307 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2308 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08002309 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 -08002310 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 -07002311 # 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 -08002312 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 -07002313}
2314
2315# 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 -08002316component_build_psa_accel_key_type_ecc_public_key() {
Gilles Peskine168be012023-07-19 19:36:55 +02002317 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY"
John Durkopf4c4cb02020-10-28 20:09:55 -07002318 scripts/config.py full
2319 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2320 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2321 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08002322 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
2323 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR
John Durkopf4c4cb02020-10-28 20:09:55 -07002324 # 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 -08002325 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 -07002326}
2327
John Durkopd0321952020-10-29 21:37:36 -07002328# 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 -08002329component_build_psa_accel_alg_hmac() {
Gilles Peskine168be012023-07-19 19:36:55 +02002330 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HMAC"
John Durkopd0321952020-10-29 21:37:36 -07002331 scripts/config.py full
2332 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2333 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2334 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2335 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2336 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2337}
2338
2339# 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 -08002340component_build_psa_accel_alg_hkdf() {
Gilles Peskine168be012023-07-19 19:36:55 +02002341 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C"
John Durkopd0321952020-10-29 21:37:36 -07002342 scripts/config.py full
2343 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2344 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2345 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2346 scripts/config.py unset MBEDTLS_HKDF_C
John Durkopbd069d32020-10-31 22:14:03 -07002347 # Make sure to unset TLS1_3_EXPERIMENTAL since it requires HKDF_C and will not build properly without it.
2348 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
John Durkopd0321952020-10-29 21:37:36 -07002349 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2350 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2351}
2352
John Durkop1b7ee052020-11-27 08:51:22 -08002353# This should be renamed to test and updated once the accelerator MD2 code is in place and ready to test.
2354component_build_psa_accel_alg_md2() {
Gilles Peskine168be012023-07-19 19:36:55 +02002355 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD2 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002356 scripts/config.py full
2357 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2358 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2359 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2360 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2361 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2362 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2363 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2364 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2365 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2366 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2367 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2368 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2369 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD2 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2370}
2371
2372# This should be renamed to test and updated once the accelerator MD4 code is in place and ready to test.
2373component_build_psa_accel_alg_md4() {
Gilles Peskine168be012023-07-19 19:36:55 +02002374 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD4 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002375 scripts/config.py full
2376 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2377 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2378 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2379 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2380 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2381 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2382 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2383 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2384 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2385 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2386 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2387 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2388 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD4 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2389}
2390
2391# This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test.
2392component_build_psa_accel_alg_md5() {
Gilles Peskine168be012023-07-19 19:36:55 +02002393 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD5 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002394 scripts/config.py full
2395 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2396 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2397 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2398 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2399 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2400 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2401 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2402 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2403 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2404 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2405 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2406 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2407 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2408}
2409
2410# This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test.
2411component_build_psa_accel_alg_ripemd160() {
Gilles Peskine168be012023-07-19 19:36:55 +02002412 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RIPEMD160 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002413 scripts/config.py full
2414 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2415 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2416 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2417 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2418 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2419 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2420 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2421 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2422 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2423 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2424 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2425 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2426 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2427}
2428
2429# This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test.
2430component_build_psa_accel_alg_sha1() {
Gilles Peskine168be012023-07-19 19:36:55 +02002431 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_1 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002432 scripts/config.py full
2433 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2434 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2435 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2436 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2437 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2438 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2439 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2440 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2441 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2442 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2443 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2444 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2445 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2446}
2447
2448# This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test.
2449component_build_psa_accel_alg_sha224() {
Gilles Peskine168be012023-07-19 19:36:55 +02002450 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_224 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002451 scripts/config.py full
2452 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2453 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2454 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2455 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2456 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2457 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2458 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2459 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2460 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2461 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2462 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2463 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2464}
2465
2466# This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test.
2467component_build_psa_accel_alg_sha256() {
Gilles Peskine168be012023-07-19 19:36:55 +02002468 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_256 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002469 scripts/config.py full
2470 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2471 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2472 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2473 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2474 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2475 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2476 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2477 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2478 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2479 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2480 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2481 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2482 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2483}
2484
2485# This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test.
2486component_build_psa_accel_alg_sha384() {
Gilles Peskine168be012023-07-19 19:36:55 +02002487 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_384 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002488 scripts/config.py full
2489 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2490 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2491 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2492 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2493 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2494 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2495 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2496 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2497 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2498 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2499 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2500 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2501}
2502
2503# This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test.
2504component_build_psa_accel_alg_sha512() {
Gilles Peskine168be012023-07-19 19:36:55 +02002505 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_512 - other hashes"
John Durkop1b7ee052020-11-27 08:51:22 -08002506 scripts/config.py full
2507 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2508 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2509 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2510 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2511 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2512 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2513 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2514 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2515 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2516 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2517 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2518 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2519 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2520}
2521
John Durkopd0321952020-10-29 21:37:36 -07002522# 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 -08002523component_build_psa_accel_alg_rsa_pkcs1v15_crypt() {
Gilles Peskine168be012023-07-19 19:36:55 +02002524 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 -07002525 scripts/config.py full
2526 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2527 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2528 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkopbd069d32020-10-31 22:14:03 -07002529 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002530 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2531 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2532 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopd0321952020-10-29 21:37:36 -07002533 # 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 -07002534 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2535}
2536
2537# 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 -08002538component_build_psa_accel_alg_rsa_pkcs1v15_sign() {
Gilles Peskine168be012023-07-19 19:36:55 +02002539 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 -07002540 scripts/config.py full
2541 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2542 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2543 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2544 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002545 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2546 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2547 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07002548 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2549 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2550}
2551
2552# 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 -08002553component_build_psa_accel_alg_rsa_oaep() {
Gilles Peskine168be012023-07-19 19:36:55 +02002554 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 -07002555 scripts/config.py full
2556 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2557 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2558 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2559 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_OAEP 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002560 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2561 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2562 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07002563 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2564 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2565}
2566
2567# 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 -08002568component_build_psa_accel_alg_rsa_pss() {
Gilles Peskine168be012023-07-19 19:36:55 +02002569 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 -07002570 scripts/config.py full
2571 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2572 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2573 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2574 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002575 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2576 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2577 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
John Durkopbd069d32020-10-31 22:14:03 -07002578 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2579 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2580}
2581
2582# 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 -08002583component_build_psa_accel_key_type_rsa_key_pair() {
Gilles Peskine168be012023-07-19 19:36:55 +02002584 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 -07002585 scripts/config.py full
2586 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2587 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2588 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2589 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
2590 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1
2591 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2592 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"
2593}
2594
2595# 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 -08002596component_build_psa_accel_key_type_rsa_public_key() {
Gilles Peskine168be012023-07-19 19:36:55 +02002597 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 -07002598 scripts/config.py full
2599 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2600 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2601 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2602 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
2603 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
2604 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2605 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 -07002606}
2607
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002608component_test_check_params_functionality () {
2609 msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002610 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002611 # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002612 scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
Ronald Crona1236142020-07-01 16:01:21 +02002613 make CC=gcc CFLAGS='-Werror -O1' all test
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002614}
2615
Gilles Peskineb28636b2019-01-02 19:06:24 +01002616component_test_check_params_without_platform () {
2617 msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002618 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002619 # Keep MBEDTLS_PARAM_FAILED as assert.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002620 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
2621 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
2622 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
2623 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
Gilles Peskine32e889d2020-04-12 23:43:28 +02002624 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002625 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
2626 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Gilles Peskine9c764bf2022-09-18 14:05:23 +02002627 scripts/config.py unset MBEDTLS_PLATFORM_VSNPRINTF_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002628 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
2629 scripts/config.py unset MBEDTLS_PLATFORM_C
Gilles Peskineb28636b2019-01-02 19:06:24 +01002630 make CC=gcc CFLAGS='-Werror -O1' all test
2631}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002632
Gilles Peskineb28636b2019-01-02 19:06:24 +01002633component_test_check_params_silent () {
2634 msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002635 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002636 # Set MBEDTLS_PARAM_FAILED to nothing.
Gilles Peskineb28636b2019-01-02 19:06:24 +01002637 sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
2638 make CC=gcc CFLAGS='-Werror -O1' all test
2639}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002640
Dave Rodgman173227d2023-06-29 09:29:00 +01002641component_build_aes_variations() { # ~45s
2642 msg "build: aes.o for all combinations of relevant config options"
Dave Rodgmanbf998282023-06-29 12:10:45 +01002643
Dave Rodgman173227d2023-06-29 09:29:00 +01002644 for a in set unset; do
2645 for b in set unset; do
2646 for c in set unset; do
2647 for d in set unset; do
2648 for e in set unset; do
2649 for f in set unset; do
2650 for g in set unset; do
Dave Rodgmanbf998282023-06-29 12:10:45 +01002651 echo ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT
2652 echo ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT
2653 echo ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES
2654 echo ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT
2655 echo ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT
2656 echo ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES
2657 echo ./scripts/config.py $g MBEDTLS_PADLOCK_C
Dave Rodgman173227d2023-06-29 09:29:00 +01002658
Dave Rodgmanbf998282023-06-29 12:10:45 +01002659 ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT
2660 ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT
2661 ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES
2662 ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT
2663 ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT
2664 ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES
2665 ./scripts/config.py $g MBEDTLS_PADLOCK_C
Dave Rodgman173227d2023-06-29 09:29:00 +01002666
Dave Rodgmanbf998282023-06-29 12:10:45 +01002667 rm -f library/aes.o
2668 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 +01002669 done
2670 done
2671 done
2672 done
2673 done
2674 done
2675 done
2676}
2677
Gilles Peskine8f073122018-11-27 15:58:47 +01002678component_test_no_platform () {
2679 # Full configuration build, without platform support, file IO and net sockets.
2680 # This should catch missing mbedtls_printf definitions, and by disabling file
2681 # IO, it should catch missing '#include <stdio.h>'
2682 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Paul Elliott68050372023-11-03 19:24:56 +00002683 scripts/config.py full_no_platform
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002684 scripts/config.py unset MBEDTLS_PLATFORM_C
2685 scripts/config.py unset MBEDTLS_NET_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002686 scripts/config.py unset MBEDTLS_FS_IO
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002687 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002688 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
2689 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Paul Elliott68050372023-11-03 19:24:56 +00002690 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine8f073122018-11-27 15:58:47 +01002691 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
2692 # to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002693 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
2694 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
Gilles Peskine8f073122018-11-27 15:58:47 +01002695}
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +00002696
Gilles Peskine8f073122018-11-27 15:58:47 +01002697component_build_no_std_function () {
2698 # catch compile bugs in _uninit functions
2699 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002700 scripts/config.py full
2701 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
2702 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002703 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine31fdda12021-10-08 11:45:47 +02002704 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine25319702021-10-07 19:34:57 +02002705 make
Gilles Peskine8f073122018-11-27 15:58:47 +01002706}
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +01002707
Gilles Peskine8f073122018-11-27 15:58:47 +01002708component_build_no_ssl_srv () {
2709 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002710 scripts/config.py full
2711 scripts/config.py unset MBEDTLS_SSL_SRV_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002712 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01002713}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02002714
Gilles Peskine8f073122018-11-27 15:58:47 +01002715component_build_no_ssl_cli () {
2716 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002717 scripts/config.py full
2718 scripts/config.py unset MBEDTLS_SSL_CLI_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002719 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01002720}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02002721
Gilles Peskine8f073122018-11-27 15:58:47 +01002722component_build_no_sockets () {
2723 # Note, C99 compliance can also be tested with the sockets support disabled,
2724 # as that requires a POSIX platform (which isn't the same as C99).
2725 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002726 scripts/config.py full
2727 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
2728 scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002729 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01002730}
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +02002731
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002732component_test_memory_buffer_allocator_backtrace () {
2733 msg "build: default config with memory buffer allocator and backtrace enabled"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002734 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2735 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2736 scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
2737 scripts/config.py set MBEDTLS_MEMORY_DEBUG
Dave Rodgman374b1882024-01-04 10:30:57 +00002738 cmake -DCMAKE_BUILD_TYPE:String=Release .
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002739 make
2740
2741 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
2742 make test
2743}
2744
2745component_test_memory_buffer_allocator () {
2746 msg "build: default config with memory buffer allocator"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002747 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2748 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
Dave Rodgman374b1882024-01-04 10:30:57 +00002749 cmake -DCMAKE_BUILD_TYPE:String=Release .
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002750 make
2751
2752 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2753 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01002754
2755 msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2756 # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002757 tests/ssl-opt.sh -e '^DTLS proxy'
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002758}
2759
Gilles Peskine8f073122018-11-27 15:58:47 +01002760component_test_no_max_fragment_length () {
2761 # Run max fragment length tests with MFL disabled
2762 msg "build: default config except MFL extension (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002763 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Gilles Peskine8f073122018-11-27 15:58:47 +01002764 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2765 make
Hanno Becker5175ac62017-09-18 15:36:25 +01002766
Gilles Peskine8f073122018-11-27 15:58:47 +01002767 msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002768 tests/ssl-opt.sh -f "Max fragment length"
Gilles Peskine8f073122018-11-27 15:58:47 +01002769}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002770
Hanno Becker545ced42019-02-19 11:10:48 +00002771component_test_asan_remove_peer_certificate () {
2772 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002773 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
Hanno Becker545ced42019-02-19 11:10:48 +00002774 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2775 make
2776
2777 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2778 make test
2779
2780 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002781 tests/ssl-opt.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002782
2783 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002784 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002785
2786 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002787 tests/context-info.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002788}
2789
Gilles Peskine8f073122018-11-27 15:58:47 +01002790component_test_no_max_fragment_length_small_ssl_out_content_len () {
2791 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002792 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2793 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
2794 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01002795 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2796 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10002797
Gilles Peskine8f073122018-11-27 15:58:47 +01002798 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002799 tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002800
2801 msg "test: context-info.sh (disabled MFL extension case)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002802 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01002803}
Angus Grattonc4dd0732018-04-11 16:28:39 +10002804
Darryl Greenaad82f92019-12-02 10:53:11 +00002805component_test_variable_ssl_in_out_buffer_len () {
2806 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
2807 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2808 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2809 make
2810
2811 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
2812 make test
2813
2814 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002815 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002816
2817 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002818 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002819}
2820
2821component_test_variable_ssl_in_out_buffer_len_CID () {
2822 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)"
2823 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2824 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
2825
2826 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2827 make
2828
2829 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID"
2830 make test
2831
2832 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002833 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002834
2835 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002836 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002837}
2838
2839component_test_variable_ssl_in_out_buffer_len_record_splitting () {
2840 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)"
2841 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2842 scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING
2843
2844 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2845 make
2846
2847 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING"
2848 make test
2849
2850 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002851 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002852
2853 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002854 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002855}
2856
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002857component_test_ssl_alloc_buffer_and_mfl () {
2858 msg "build: default config with memory buffer allocator and MFL extension"
2859 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2860 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2861 scripts/config.py set MBEDTLS_MEMORY_DEBUG
2862 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2863 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
Dave Rodgman374b1882024-01-04 10:30:57 +00002864 cmake -DCMAKE_BUILD_TYPE:String=Release .
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002865 make
2866
2867 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
2868 make test
2869
2870 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 +02002871 tests/ssl-opt.sh -f "Handshake memory usage"
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002872}
2873
Gilles Peskine636c26a2020-03-04 20:46:15 +01002874component_test_when_no_ciphersuites_have_mac () {
2875 msg "build: when no ciphersuites have MAC"
2876 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
2877 scripts/config.py unset MBEDTLS_ARC4_C
2878 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2879 make
2880
2881 msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
2882 make test
2883
2884 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002885 tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
Gilles Peskine636c26a2020-03-04 20:46:15 +01002886}
2887
Gilles Peskine8f073122018-11-27 15:58:47 +01002888component_test_null_entropy () {
2889 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002890 scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY
2891 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
2892 scripts/config.py set MBEDTLS_ENTROPY_C
2893 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002894 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002895 scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT
2896 scripts/config.py unset MBEDTLS_HAVEGE_C
Gilles Peskine5fa32a72019-01-06 19:48:30 +00002897 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON .
Gilles Peskine8f073122018-11-27 15:58:47 +01002898 make
Janos Follath06c54002016-06-09 13:57:40 +01002899
Gilles Peskine8f073122018-11-27 15:58:47 +01002900 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
2901 make test
2902}
Janos Follath06c54002016-06-09 13:57:40 +01002903
Raoul Strackxa4e86142020-06-15 17:03:13 +02002904component_test_no_date_time () {
2905 msg "build: default config without MBEDTLS_HAVE_TIME_DATE"
2906 scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
Gilles Peskine31fdda12021-10-08 11:45:47 +02002907 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
Raoul Strackxa4e86142020-06-15 17:03:13 +02002908 make
2909
2910 msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites"
2911 make test
2912}
2913
Andrzej Kurekc890b222023-01-17 04:03:19 -05002914component_test_alt_timing() {
2915 msg "build: alternate timing implementation"
2916 scripts/config.py set MBEDTLS_TIMING_ALT
2917 make lib TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../tests/src/external_timing"
2918
2919 msg "test: MBEDTLS_TIMING_ALT - test suites"
2920 make test TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../tests/src/external_timing"
Andrzej Kurek3a261a42023-01-26 04:33:59 -05002921
2922 msg "selftest - MBEDTLS-TIMING_ALT"
2923 make programs TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../../tests/src/external_timing -I../tests/src/external_timing"
2924 programs/test/selftest
Andrzej Kurekc890b222023-01-17 04:03:19 -05002925}
2926
Gilles Peskine8f073122018-11-27 15:58:47 +01002927component_test_platform_calloc_macro () {
2928 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002929 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2930 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
2931 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
Gilles Peskine8f073122018-11-27 15:58:47 +01002932 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2933 make
Hanno Beckere5fecec2018-10-11 11:02:52 +01002934
Gilles Peskine8f073122018-11-27 15:58:47 +01002935 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
2936 make test
2937}
Hanno Beckere5fecec2018-10-11 11:02:52 +01002938
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002939component_test_malloc_0_null () {
2940 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002941 scripts/config.py full
Gilles Peskine2e70f1c2023-07-20 19:00:15 +02002942 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 +02002943
2944 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
2945 make test
2946
2947 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
2948 # Just the calloc selftest. "make test" ran the others as part of the
2949 # test suites.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002950 programs/test/selftest calloc
Gilles Peskine765d2402020-02-11 18:26:34 +01002951
2952 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
2953 # Run a subset of the tests. The choice is a balance between coverage
2954 # and time (including time indirectly wasted due to flaky tests).
2955 # The current choice is to skip tests whose description includes
2956 # "proxy", which is an approximation of skipping tests that use the
2957 # UDP proxy, which tend to be slower and flakier.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002958 tests/ssl-opt.sh -e 'proxy'
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002959}
2960
Gilles Peskine8f073122018-11-27 15:58:47 +01002961component_test_aes_fewer_tables () {
2962 msg "build: default config with AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002963 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
Dave Rodgmance04f242024-01-04 10:34:31 +00002964 make CFLAGS='-O2 -Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002965
Gilles Peskine8f073122018-11-27 15:58:47 +01002966 msg "test: AES_FEWER_TABLES"
2967 make test
2968}
Hanno Becker83ebf782017-07-07 12:29:15 +01002969
Gilles Peskine8f073122018-11-27 15:58:47 +01002970component_test_aes_rom_tables () {
2971 msg "build: default config with AES_ROM_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002972 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Dave Rodgmance04f242024-01-04 10:34:31 +00002973 make CFLAGS='-O2 -Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002974
Gilles Peskine8f073122018-11-27 15:58:47 +01002975 msg "test: AES_ROM_TABLES"
2976 make test
2977}
Hanno Becker83ebf782017-07-07 12:29:15 +01002978
Gilles Peskine8f073122018-11-27 15:58:47 +01002979component_test_aes_fewer_tables_and_rom_tables () {
2980 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002981 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
2982 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Dave Rodgmance04f242024-01-04 10:34:31 +00002983 make CFLAGS='-O2 -Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002984
Gilles Peskine8f073122018-11-27 15:58:47 +01002985 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
2986 make test
2987}
2988
Gilles Peskine592f5912019-10-07 18:49:32 +02002989component_test_ctr_drbg_aes_256_sha_256 () {
2990 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002991 scripts/config.py full
2992 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2993 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02002994 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2995 make
2996
2997 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
2998 make test
2999}
3000
3001component_test_ctr_drbg_aes_128_sha_512 () {
3002 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01003003 scripts/config.py full
3004 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3005 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
Gilles Peskine592f5912019-10-07 18:49:32 +02003006 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3007 make
3008
3009 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
3010 make test
3011}
3012
3013component_test_ctr_drbg_aes_128_sha_256 () {
3014 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01003015 scripts/config.py full
3016 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3017 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
3018 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02003019 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3020 make
3021
3022 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3023 make test
3024}
3025
Gilles Peskinef96aefe2019-07-24 14:58:38 +02003026component_test_se_default () {
3027 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003028 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine004206c2019-10-21 17:11:33 +02003029 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinef96aefe2019-07-24 14:58:38 +02003030
3031 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
3032 make test
3033}
3034
Steven Cooremand57203d2020-07-16 20:28:59 +02003035component_test_psa_crypto_drivers () {
Gilles Peskine8d77ec22023-07-26 18:45:20 +02003036 msg "build: full + test drivers dispatching to builtins"
Steven Cooreman753f9732021-03-15 11:38:44 +01003037 scripts/config.py full
Steven Cooremand57203d2020-07-16 20:28:59 +02003038 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
Gilles Peskinefe0acc62021-09-20 19:20:04 +02003039 loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL"
3040 loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
Ronald Cron17b3afc2020-12-10 18:17:09 +01003041 loc_cflags="${loc_cflags} -I../tests/include -O2"
3042
3043 make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
Steven Cooremand57203d2020-07-16 20:28:59 +02003044
Gilles Peskine8d77ec22023-07-26 18:45:20 +02003045 msg "test: full + test drivers dispatching to builtins"
Steven Cooremand57203d2020-07-16 20:28:59 +02003046 make test
3047}
3048
Gilles Peskine8f073122018-11-27 15:58:47 +01003049component_test_make_shared () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003050 msg "build/test: make shared" # ~ 40s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04003051 make SHARED=1 all check
Gilles Peskine56c01612019-07-03 20:43:32 +02003052 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskine27482f12021-11-04 12:52:14 +01003053 programs/test/dlopen_demo.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003054}
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +02003055
Gilles Peskinecf740502019-07-03 20:43:05 +02003056component_test_cmake_shared () {
3057 msg "build/test: cmake shared" # ~ 2min
3058 cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
3059 make
Gilles Peskine56c01612019-07-03 20:43:32 +02003060 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskinecf740502019-07-03 20:43:05 +02003061 make test
Gilles Peskine27482f12021-11-04 12:52:14 +01003062 programs/test/dlopen_demo.sh
Gilles Peskinecf740502019-07-03 20:43:05 +02003063}
3064
Gilles Peskineec10bf12019-09-20 19:56:06 +02003065test_build_opt () {
3066 info=$1 cc=$2; shift 2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003067 $cc --version
Gilles Peskineec10bf12019-09-20 19:56:06 +02003068 for opt in "$@"; do
3069 msg "build/test: $cc $opt, $info" # ~ 30s
Gilles Peskinee094a182020-04-14 20:08:41 +02003070 make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Gilles Peskineec10bf12019-09-20 19:56:06 +02003071 # We're confident enough in compilers to not run _all_ the tests,
3072 # but at least run the unit tests. In particular, runs with
3073 # optimizations use inline assembly whereas runs with -O0
3074 # skip inline assembly.
3075 make test # ~30s
3076 make clean
3077 done
3078}
3079
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003080# For FreeBSD we invoke the function by name so this condition is added
3081# to disable the existing test_clang_opt function for linux.
3082if [[ $(uname) != "Linux" ]]; then
3083 component_test_clang_opt () {
3084 scripts/config.py full
3085 test_build_opt 'full config' clang -O0 -Os -O2
3086 }
3087fi
3088
3089component_test_clang_latest_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01003090 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003091 test_build_opt 'full config' "$CLANG_LATEST" -O0 -Os -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003092}
3093support_test_clang_latest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003094 type "$CLANG_LATEST" >/dev/null 2>/dev/null
Gilles Peskineec10bf12019-09-20 19:56:06 +02003095}
3096
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003097component_test_clang_earliest_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01003098 scripts/config.py full
Gilles Peskinebfe4fc62024-06-19 16:30:36 +02003099 test_build_opt 'full config' "$CLANG_EARLIEST" -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003100}
3101support_test_clang_earliest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003102 type "$CLANG_EARLIEST" >/dev/null 2>/dev/null
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003103}
3104
3105component_test_gcc_latest_opt () {
3106 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003107 test_build_opt 'full config' "$GCC_LATEST" -O0 -Os -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003108}
3109support_test_gcc_latest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003110 type "$GCC_LATEST" >/dev/null 2>/dev/null
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003111}
3112
3113component_test_gcc_earliest_opt () {
3114 scripts/config.py full
Gilles Peskinebfe4fc62024-06-19 16:30:36 +02003115 test_build_opt 'full config' "$GCC_EARLIEST" -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003116}
3117support_test_gcc_earliest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003118 type "$GCC_EARLIEST" >/dev/null 2>/dev/null
Gilles Peskineec10bf12019-09-20 19:56:06 +02003119}
3120
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02003121component_build_mbedtls_config_file () {
3122 msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
Gilles Peskine6af9dc92022-04-07 20:55:57 +02003123 scripts/config.py -w full_config.h full
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02003124 echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
3125 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
Gilles Peskine932b30b2022-04-13 23:23:21 +02003126 # Make sure this feature is enabled. We'll disable it in the next phase.
Gilles Peskine036a9bb2022-04-07 21:06:41 +02003127 programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3128 make clean
3129
3130 msg "build: make with MBEDTLS_CONFIG_FILE + MBEDTLS_USER_CONFIG_FILE"
3131 # In the user config, disable one feature (for simplicity, pick a feature
3132 # that nothing else depends on).
3133 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3134 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"' -DMBEDTLS_USER_CONFIG_FILE='\"user_config.h\"'"
3135 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3136
3137 rm -f user_config.h full_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003138}
3139
Gilles Peskine690a2ef2022-04-07 21:59:14 +02003140component_build_psa_config_file () {
3141 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE" # ~40s
3142 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
3143 cp "$CRYPTO_CONFIG_H" psa_test_config.h
3144 echo '#error "MBEDTLS_PSA_CRYPTO_CONFIG_FILE is not working"' >"$CRYPTO_CONFIG_H"
3145 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"'"
Gilles Peskine932b30b2022-04-13 23:23:21 +02003146 # Make sure this feature is enabled. We'll disable it in the next phase.
Gilles Peskine690a2ef2022-04-07 21:59:14 +02003147 programs/test/query_compile_time_config MBEDTLS_CMAC_C
3148 make clean
3149
3150 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE + MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE" # ~40s
3151 # In the user config, disable one feature, which will reflect on the
3152 # mbedtls configuration so we can query it with query_compile_time_config.
3153 echo '#undef PSA_WANT_ALG_CMAC' >psa_user_config.h
3154 scripts/config.py unset MBEDTLS_CMAC_C
3155 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"' -DMBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE='\"psa_user_config.h\"'"
3156 not programs/test/query_compile_time_config MBEDTLS_CMAC_C
3157
3158 rm -f psa_test_config.h psa_user_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003159}
3160
Gilles Peskine8f073122018-11-27 15:58:47 +01003161component_test_m32_o0 () {
Gilles Peskinea0c51fb2021-10-07 19:27:16 +02003162 # Build without optimization, so as to use portable C code (in a 32-bit
3163 # build) and not the i386-specific inline assembly.
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003164 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003165 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02003166 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01003167
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003168 msg "test: i386, make, gcc -O0 (ASan build)"
3169 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01003170}
Gilles Peskine878cf602019-01-06 20:50:38 +00003171support_test_m32_o0 () {
3172 case $(uname -m) in
Pengyu Lva89b3672022-10-21 10:50:26 +00003173 amd64|x86_64) true;;
Gilles Peskine878cf602019-01-06 20:50:38 +00003174 *) false;;
3175 esac
3176}
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003177
Gilles Peskine6fa69862021-10-05 09:36:03 +02003178component_test_m32_o2 () {
3179 # Build with optimization, to use the i386 specific inline assembly
3180 # and go faster for tests.
3181 msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003182 scripts/config.py full
Gilles Peskine6fa69862021-10-05 09:36:03 +02003183 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003184
Gilles Peskine6fa69862021-10-05 09:36:03 +02003185 msg "test: i386, make, gcc -O2 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003186 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01003187
Gilles Peskine6fa69862021-10-05 09:36:03 +02003188 msg "test ssl-opt.sh, i386, make, gcc-O2"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003189 tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003190}
Gilles Peskine3daa83e2021-10-07 19:25:29 +02003191support_test_m32_o2 () {
Gilles Peskine878cf602019-01-06 20:50:38 +00003192 support_test_m32_o0 "$@"
3193}
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003194
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003195component_test_m32_everest () {
3196 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003197 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
3198 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
Gilles Peskine8fd59422019-10-21 17:11:33 +02003199 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003200
3201 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
3202 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01003203
3204 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003205 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01003206
3207 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
3208 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003209 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003210}
3211support_test_m32_everest () {
3212 support_test_m32_o0 "$@"
3213}
3214
Gilles Peskine8f073122018-11-27 15:58:47 +01003215component_test_mx32 () {
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003216 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003217 scripts/config.py full
Dave Rodgmance04f242024-01-04 10:34:31 +00003218 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003219
3220 msg "test: 64-bit ILP32, make, gcc"
3221 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01003222}
Gilles Peskine878cf602019-01-06 20:50:38 +00003223support_test_mx32 () {
3224 case $(uname -m) in
3225 amd64|x86_64) true;;
3226 *) false;;
3227 esac
3228}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003229
Peter Kolbus60c6da22018-12-27 06:59:04 -06003230component_test_min_mpi_window_size () {
3231 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003232 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
Peter Kolbus60c6da22018-12-27 06:59:04 -06003233 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3234 make
3235
3236 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
3237 make test
3238}
3239
Gilles Peskine8f073122018-11-27 15:58:47 +01003240component_test_have_int32 () {
3241 msg "build: gcc, force 32-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003242 scripts/config.py unset MBEDTLS_HAVE_ASM
3243 scripts/config.py unset MBEDTLS_AESNI_C
3244 scripts/config.py unset MBEDTLS_PADLOCK_C
Dave Rodgmance04f242024-01-04 10:34:31 +00003245 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01003246
Gilles Peskine8f073122018-11-27 15:58:47 +01003247 msg "test: gcc, force 32-bit bignum limbs"
3248 make test
3249}
Andres Amaya Garciafe843a32017-07-20 13:21:34 +01003250
Gilles Peskine8f073122018-11-27 15:58:47 +01003251component_test_have_int64 () {
3252 msg "build: gcc, force 64-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003253 scripts/config.py unset MBEDTLS_HAVE_ASM
3254 scripts/config.py unset MBEDTLS_AESNI_C
3255 scripts/config.py unset MBEDTLS_PADLOCK_C
Dave Rodgmance04f242024-01-04 10:34:31 +00003256 make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Gilles Peskine14c3c062018-01-29 21:25:12 +01003257
Gilles Peskine8f073122018-11-27 15:58:47 +01003258 msg "test: gcc, force 64-bit bignum limbs"
3259 make test
3260}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003261
Gilles Peskine8f073122018-11-27 15:58:47 +01003262component_test_no_udbl_division () {
3263 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003264 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003265 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine8f073122018-11-27 15:58:47 +01003266 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003267
Gilles Peskine8f073122018-11-27 15:58:47 +01003268 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
3269 make test
3270}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003271
Gilles Peskine8f073122018-11-27 15:58:47 +01003272component_test_no_64bit_multiplication () {
3273 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003274 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003275 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine8f073122018-11-27 15:58:47 +01003276 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003277
Gilles Peskine8f073122018-11-27 15:58:47 +01003278 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
3279 make test
3280}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003281
Gilles Peskine3809f5f2020-11-09 15:40:05 +01003282component_test_no_strings () {
3283 msg "build: no strings" # ~10s
3284 scripts/config.py full
3285 # Disable options that activate a large amount of string constants.
3286 scripts/config.py unset MBEDTLS_DEBUG_C
3287 scripts/config.py unset MBEDTLS_ERROR_C
3288 scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY
3289 scripts/config.py unset MBEDTLS_VERSION_FEATURES
3290 make CFLAGS='-Werror -Os'
3291
3292 msg "test: no strings" # ~ 10s
3293 make test
3294}
3295
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003296component_test_arm_linux_gnueabi_gcc_arm5vte () {
3297 # Mimic Debian armel port
Bence Szépkútif92112d2024-07-18 15:56:15 +02003298 msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, default config" # ~4m
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003299 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1'
3300
Bence Szépkútif92112d2024-07-18 15:56:15 +02003301 msg "test: main suites make, default config (out-of-box)" # ~7m 40s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003302 make test
3303
Bence Szépkútif92112d2024-07-18 15:56:15 +02003304 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003305 programs/test/selftest
3306
Bence Szépkútif92112d2024-07-18 15:56:15 +02003307 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003308 tests/scripts/run_demos.py
3309}
3310
3311support_test_arm_linux_gnueabi_gcc_arm5vte () {
3312 can_run_arm_linux_gnueabi
3313}
3314
Bence Szépkúti478730e2024-07-18 16:08:22 +02003315# The hard float ABI is not implemented for Thumb 1, so use gnueabi
3316# Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
3317component_test_arm_linux_gnueabi_gcc_thumb_1_opt_0 () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003318 msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -O0, thumb 1, default config" # ~2m 10s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003319 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O0 -mcpu=arm1136j-s -mthumb'
3320
Bence Szépkútif92112d2024-07-18 15:56:15 +02003321 msg "test: main suites make, default config (out-of-box)" # ~36m
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003322 make test
3323
3324 msg "selftest: make, default config (out-of-box)" # ~10s
3325 programs/test/selftest
3326
Bence Szépkútif92112d2024-07-18 15:56:15 +02003327 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003328 tests/scripts/run_demos.py
Bence Szépkúti478730e2024-07-18 16:08:22 +02003329}
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003330
Bence Szépkúti478730e2024-07-18 16:08:22 +02003331support_test_arm_linux_gnueabi_gcc_thumb_1_opt_0 () {
3332 can_run_arm_linux_gnueabi
3333}
3334
3335component_test_arm_linux_gnueabi_gcc_thumb_1_opt_s () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003336 msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -Os, thumb 1, default config" # ~3m 10s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003337 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -Os -mcpu=arm1136j-s -mthumb'
3338
Bence Szépkútif92112d2024-07-18 15:56:15 +02003339 msg "test: main suites make, default config (out-of-box)" # ~21m 10s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003340 make test
3341
Bence Szépkútif92112d2024-07-18 15:56:15 +02003342 msg "selftest: make, default config (out-of-box)" # ~2s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003343 programs/test/selftest
3344
Bence Szépkútif92112d2024-07-18 15:56:15 +02003345 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003346 tests/scripts/run_demos.py
3347}
3348
Bence Szépkúti478730e2024-07-18 16:08:22 +02003349support_test_arm_linux_gnueabi_gcc_thumb_1_opt_s () {
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003350 can_run_arm_linux_gnueabi
3351}
3352
3353component_test_arm_linux_gnueabihf_gcc_armv7 () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003354 msg "test: ${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc -O2, A32, default config" # ~4m 30s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003355 make CC="${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O2 -march=armv7-a -marm'
3356
Bence Szépkútif92112d2024-07-18 15:56:15 +02003357 msg "test: main suites make, default config (out-of-box)" # ~3m 30s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003358 make test
3359
Bence Szépkútif92112d2024-07-18 15:56:15 +02003360 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003361 programs/test/selftest
3362
Bence Szépkútif92112d2024-07-18 15:56:15 +02003363 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003364 tests/scripts/run_demos.py
3365}
3366
3367support_test_arm_linux_gnueabihf_gcc_armv7 () {
3368 can_run_arm_linux_gnueabihf
3369}
3370
3371component_test_arm_linux_gnueabihf_gcc_thumb_2 () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003372 msg "test: ${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc -Os, thumb 2, default config" # ~4m
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003373 make CC="${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -Os -march=armv7-a -mthumb'
3374
Bence Szépkútif92112d2024-07-18 15:56:15 +02003375 msg "test: main suites make, default config (out-of-box)" # ~3m 40s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003376 make test
3377
Bence Szépkútif92112d2024-07-18 15:56:15 +02003378 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003379 programs/test/selftest
3380
Bence Szépkútif92112d2024-07-18 15:56:15 +02003381 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti86aa7802024-07-11 09:50:45 +01003382 tests/scripts/run_demos.py
3383}
3384
3385support_test_arm_linux_gnueabihf_gcc_thumb_2 () {
3386 can_run_arm_linux_gnueabihf
3387}
3388
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003389component_test_aarch64_linux_gnu_gcc () {
Bence Szépkútif92112d2024-07-18 15:56:15 +02003390 msg "test: ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc -O2, default config" # ~3m 50s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003391 make CC="${AARCH64_LINUX_GNU_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O2'
3392
Bence Szépkútif92112d2024-07-18 15:56:15 +02003393 msg "test: main suites make, default config (out-of-box)" # ~1m 50s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003394 make test
3395
Bence Szépkútif92112d2024-07-18 15:56:15 +02003396 msg "selftest: make, default config (out-of-box)" # ~0s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003397 programs/test/selftest
3398
Bence Szépkútif92112d2024-07-18 15:56:15 +02003399 msg "program demos: make, default config (out-of-box)" # ~0s
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003400 tests/scripts/run_demos.py
3401}
3402
3403support_test_aarch64_linux_gnu_gcc () {
Bence Szépkútib14dd762024-10-27 22:31:13 +01003404 # Minimum version of GCC for MBEDTLS_AESCE_C is 6.0
Bence Szépkúti915fa3e2024-07-11 15:52:07 +01003405 [ "$(gcc_version "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc")" -ge 6 ] && can_run_aarch64_linux_gnu
3406}
3407
Gilles Peskine8f073122018-11-27 15:58:47 +01003408component_build_arm_none_eabi_gcc () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003409 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003410 scripts/config.py baremetal
Gilles Peskineaeedd742020-09-02 11:03:04 +02003411 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 +02003412
Gilles Peskine60d99472021-09-01 20:00:33 +02003413 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug"
Gilles Peskine18487f62020-04-30 23:11:54 +02003414 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003415}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003416
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003417component_build_arm_linux_gnueabi_gcc_arm5vte () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003418 msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003419 scripts/config.py baremetal
Gilles Peskine2c897d72019-08-09 16:05:05 +02003420 # Build for a target platform that's close to what Debian uses
3421 # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
Dave Rodgman52af7692022-03-31 14:27:24 +01003422 # See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments.
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003423 # Build everything including programs, see for example
Dave Rodgman52af7692022-03-31 14:27:24 +01003424 # https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003425 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'
3426
Gilles Peskine60d99472021-09-01 20:00:33 +02003427 msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003428 ${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o
3429}
3430support_build_arm_linux_gnueabi_gcc_arm5vte () {
3431 type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
3432}
3433
3434component_build_arm_none_eabi_gcc_arm5vte () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003435 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003436 scripts/config.py baremetal
3437 # This is an imperfect substitute for
3438 # component_build_arm_linux_gnueabi_gcc_arm5vte
Manuel Pégourié-Gonnard9a260a62021-07-06 09:44:59 +02003439 # in case the gcc-arm-linux-gnueabi toolchain is not available
Gilles Peskineaeedd742020-09-02 11:03:04 +02003440 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 +02003441
Gilles Peskine60d99472021-09-01 20:00:33 +02003442 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
Gilles Peskine18487f62020-04-30 23:11:54 +02003443 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine93e4e032019-08-05 11:34:25 +02003444}
3445
Gilles Peskine6e2fb862020-04-30 23:00:53 +02003446component_build_arm_none_eabi_gcc_m0plus () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003447 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s
3448 scripts/config.py baremetal_size
Gilles Peskineaeedd742020-09-02 11:03:04 +02003449 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 +02003450
Gilles Peskine60d99472021-09-01 20:00:33 +02003451 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size"
Gilles Peskine18487f62020-04-30 23:11:54 +02003452 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine6e2fb862020-04-30 23:00:53 +02003453}
3454
Gilles Peskine8f073122018-11-27 15:58:47 +01003455component_build_arm_none_eabi_gcc_no_udbl_division () {
Gilles Peskine6d061342020-04-30 18:19:32 +02003456 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003457 scripts/config.py baremetal
3458 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskineaeedd742020-09-02 11:03:04 +02003459 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 +01003460 echo "Checking that software 64-bit division is not required"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003461 not grep __aeabi_uldiv library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003462}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003463
Gilles Peskine8f073122018-11-27 15:58:47 +01003464component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
Gilles Peskine6d061342020-04-30 18:19:32 +02003465 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003466 scripts/config.py baremetal
3467 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskineaeedd742020-09-02 11:03:04 +02003468 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 +01003469 echo "Checking that software 64-bit multiplication is not required"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003470 not grep __aeabi_lmul library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003471}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003472
Dave Rodgman43ea9ab2023-06-02 10:26:24 -04003473component_build_arm_clang_thumb () {
3474 # ~ 30s
3475
3476 scripts/config.py baremetal
3477
3478 msg "build: clang thumb 2, make"
3479 make clean
3480 make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib
3481
3482 # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
3483 msg "build: clang thumb 1 -O0, make"
3484 make clean
3485 make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
3486
3487 msg "build: clang thumb 1 -Os, make"
3488 make clean
3489 make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
3490}
3491
Gilles Peskine8f073122018-11-27 15:58:47 +01003492component_build_armcc () {
Manuel Pégourié-Gonnarda674e982024-10-29 10:55:23 +01003493 # Common configuration for all the builds below
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003494 scripts/config.py baremetal
Andres AG87bb5772016-09-27 15:05:15 +01003495
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003496 # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0.
3497
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003498 # ARM Compiler 6 - Target ARMv7-A
3499 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02003500
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003501 # ARM Compiler 6 - Target ARMv7-M
3502 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02003503
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003504 # ARM Compiler 6 - Target ARMv8-A - AArch32
3505 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02003506
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003507 # ARM Compiler 6 - Target ARMv8-M
3508 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02003509
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003510 # ARM Compiler 6 - Target ARMv8-A - AArch64
3511 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003512
3513 # ARM Compiler 6 - Target Cortex-M0 - no optimisation
3514 armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0"
3515
3516 # ARM Compiler 6 - Target Cortex-M0
3517 armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0"
Gilles Peskine8f073122018-11-27 15:58:47 +01003518}
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003519
Pengyu Lvd216c042023-03-03 18:23:35 +08003520support_build_armcc () {
Pengyu Lvd216c042023-03-03 18:23:35 +08003521 armc6_cc="$ARMC6_BIN_DIR/armclang"
Manuel Pégourié-Gonnarda674e982024-10-29 10:55:23 +01003522 (check_tools "$armc6_cc" > /dev/null 2>&1)
Pengyu Lvd216c042023-03-03 18:23:35 +08003523}
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01003524
Manuel Pégourié-Gonnarddd8807f2020-02-26 09:56:27 +01003525component_build_ssl_hw_record_accel() {
3526 msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled"
3527 scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL
3528 make CFLAGS='-Werror -O1'
3529}
3530
Hanno Beckera711f6e2020-05-04 12:03:51 +01003531component_test_tls13_experimental () {
3532 msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
3533 scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
3534 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3535 make
3536 msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
3537 make test
3538}
3539
Gilles Peskine8f073122018-11-27 15:58:47 +01003540component_build_mingw () {
3541 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Gilles Peskinec61187f2024-06-19 16:34:29 +02003542 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 +00003543
Gilles Peskine8f073122018-11-27 15:58:47 +01003544 # note Make tests only builds the tests, but doesn't run them
Gilles Peskinec61187f2024-06-19 16:34:29 +02003545 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror' WINDOWS_BUILD=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01003546 make WINDOWS_BUILD=1 clean
Gilles Peskine2a458da2017-05-12 15:26:58 +02003547
Gilles Peskine8f073122018-11-27 15:58:47 +01003548 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskinec61187f2024-06-19 16:34:29 +02003549 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
3550 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 +01003551 make WINDOWS_BUILD=1 clean
Pengyu Lvb2ca0322023-10-19 17:17:19 +08003552
3553 msg "build: Windows cross build - mingw64, make (Library only, AESNI intrinsics)" # ~ 30s
Gilles Peskinec61187f2024-06-19 16:34:29 +02003554 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 +08003555 make WINDOWS_BUILD=1 clean
3556
3557 msg "build: Windows cross build - mingw64, make (Library only, default config without MBEDTLS_AESNI_C)" # ~ 30s
3558 ./scripts/config.py unset MBEDTLS_AESNI_C
Gilles Peskinec61187f2024-06-19 16:34:29 +02003559 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 +08003560 make WINDOWS_BUILD=1 clean
Gilles Peskinec61187f2024-06-19 16:34:29 +02003561}
3562
Jaeden Amero117b8a42019-04-17 15:19:26 +01003563support_build_mingw() {
Pengyu Lva19ce122023-02-24 15:38:52 +08003564 case $(i686-w64-mingw32-gcc -dumpversion 2>/dev/null) in
3565 [0-5]*|"") false;;
Jaeden Amero117b8a42019-04-17 15:19:26 +01003566 *) true;;
3567 esac
3568}
Simon Butcher91aef332016-11-17 09:20:50 +00003569
Gilles Peskine8f073122018-11-27 15:58:47 +01003570component_test_memsan () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003571 msg "build: MSan (clang)" # ~ 1 min 20s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003572 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003573 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
3574 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02003575
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003576 msg "test: main suites (MSan)" # ~ 10s
3577 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003578
Gilles Peskineee8af062023-11-02 19:58:03 +01003579 msg "test: metatests (MSan)"
3580 tests/scripts/run-metatests.sh any msan
3581
Gilles Peskine93aaf2e2019-06-14 18:27:03 +02003582 msg "program demos (MSan)" # ~20s
3583 tests/scripts/run_demos.py
3584
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003585 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003586 tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003587
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003588 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003589
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003590 if [ "$MEMORY" -gt 0 ]; then
3591 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003592 tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003593 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01003594}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003595
Bence Szépkútie1c6c4c2023-12-06 16:14:37 +01003596component_release_test_valgrind () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003597 msg "build: Release (clang)"
Gilles Peskine619b73d2022-11-29 16:45:30 +01003598 # default config, in particular without MBEDTLS_USE_PSA_CRYPTO
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003599 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
3600 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003601
Gilles Peskine619b73d2022-11-29 16:45:30 +01003602 msg "test: main suites, Valgrind (default config)"
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003603 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003604
Gilles Peskine636c26a2020-03-04 20:46:15 +01003605 # Optional parts (slow; currently broken on OS X because programs don't
3606 # seem to receive signals under valgrind on OS X).
Gilles Peskine619b73d2022-11-29 16:45:30 +01003607 # These optional parts don't run on the CI.
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003608 if [ "$MEMORY" -gt 0 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003609 msg "test: ssl-opt.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003610 tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003611 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003612
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003613 if [ "$MEMORY" -gt 1 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003614 msg "test: compat.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003615 tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003616 fi
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02003617
3618 if [ "$MEMORY" -gt 0 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003619 msg "test: context-info.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003620 tests/context-info.sh --memcheck
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02003621 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01003622}
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003623
Bence Szépkútie1c6c4c2023-12-06 16:14:37 +01003624component_release_test_valgrind_psa () {
Gilles Peskine619b73d2022-11-29 16:45:30 +01003625 msg "build: Release, full (clang)"
3626 # full config, in particular with MBEDTLS_USE_PSA_CRYPTO
3627 scripts/config.py full
3628 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
3629 make
3630
3631 msg "test: main suites, Valgrind (full config)"
3632 make memcheck
3633}
3634
Paul Elliott2ab9a7a2021-11-25 17:29:40 +00003635support_test_cmake_out_of_source () {
3636 distrib_id=""
3637 distrib_ver=""
3638 distrib_ver_minor=""
3639 distrib_ver_major=""
3640
3641 # Attempt to parse lsb-release to find out distribution and version. If not
3642 # found this should fail safe (test is supported).
3643 if [[ -f /etc/lsb-release ]]; then
3644
3645 while read -r lsb_line; do
3646 case "$lsb_line" in
3647 "DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};;
3648 "DISTRIB_RELEASE"*) distrib_ver=${lsb_line/#DISTRIB_RELEASE=};;
3649 esac
3650 done < /etc/lsb-release
3651
3652 distrib_ver_major="${distrib_ver%%.*}"
3653 distrib_ver="${distrib_ver#*.}"
3654 distrib_ver_minor="${distrib_ver%%.*}"
3655 fi
3656
3657 # Running the out of source CMake test on Ubuntu 16.04 using more than one
3658 # processor (as the CI does) can create a race condition whereby the build
3659 # fails to see a generated file, despite that file actually having been
3660 # generated. This problem appears to go away with 18.04 or newer, so make
3661 # the out of source tests unsupported on Ubuntu 16.04.
3662 [ "$distrib_id" != "Ubuntu" ] || [ "$distrib_ver_major" -gt 16 ]
3663}
3664
Gilles Peskine8f073122018-11-27 15:58:47 +01003665component_test_cmake_out_of_source () {
3666 msg "build: cmake 'out-of-source' build"
Gilles Peskine8f073122018-11-27 15:58:47 +01003667 MBEDTLS_ROOT_DIR="$PWD"
3668 mkdir "$OUT_OF_SOURCE_DIR"
3669 cd "$OUT_OF_SOURCE_DIR"
Gilles Peskine25319702021-10-07 19:34:57 +02003670 cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +01003671 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003672
Gilles Peskine8f073122018-11-27 15:58:47 +01003673 msg "test: cmake 'out-of-source' build"
3674 make test
3675 # Test an SSL option that requires an auxiliary script in test/scripts/.
3676 # Also ensure that there are no error messages such as
3677 # "No such file or directory", which would indicate that some required
3678 # file is missing (ssl-opt.sh tolerates the absence of some files so
3679 # may exit with status 0 but emit errors).
Gilles Peskinee8133cb2022-04-15 22:43:38 +02003680 ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' >ssl-opt.out 2>ssl-opt.err
3681 grep PASS ssl-opt.out
Gilles Peskine0a7984f2020-03-28 18:56:09 +01003682 cat ssl-opt.err >&2
3683 # If ssl-opt.err is non-empty, record an error and keep going.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003684 [ ! -s ssl-opt.err ]
Gilles Peskinee8133cb2022-04-15 22:43:38 +02003685 rm ssl-opt.out ssl-opt.err
Gilles Peskine8f073122018-11-27 15:58:47 +01003686 cd "$MBEDTLS_ROOT_DIR"
3687 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +01003688}
Andres AGdc192212016-08-31 17:33:13 +01003689
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003690component_test_cmake_as_subdirectory () {
3691 msg "build: cmake 'as-subdirectory' build"
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003692 cd programs/test/cmake_subproject
3693 cmake .
3694 make
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003695 ./cmake_subproject
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003696}
Gilles Peskineca9cfca2022-02-04 00:21:12 +01003697support_test_cmake_as_subdirectory () {
3698 support_test_cmake_out_of_source
3699}
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003700
David Horstmann175afbd2023-01-12 14:17:01 +00003701component_build_cmake_custom_config_file () {
David Horstmann67622312023-01-31 10:34:44 +00003702 # Make a copy of config file to use for the in-tree test
3703 cp "$CONFIG_H" include/mbedtls_config_in_tree_copy.h
David Horstmann175afbd2023-01-12 14:17:01 +00003704
3705 MBEDTLS_ROOT_DIR="$PWD"
3706 mkdir "$OUT_OF_SOURCE_DIR"
3707 cd "$OUT_OF_SOURCE_DIR"
3708
David Horstmann67622312023-01-31 10:34:44 +00003709 # Build once to get the generated files (which need an intact config file)
David Horstmann175afbd2023-01-12 14:17:01 +00003710 cmake "$MBEDTLS_ROOT_DIR"
3711 make
3712
3713 msg "build: cmake with -DMBEDTLS_CONFIG_FILE"
3714 scripts/config.py -w full_config.h full
David Horstmann67622312023-01-31 10:34:44 +00003715 echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003716 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h "$MBEDTLS_ROOT_DIR"
3717 make
3718
3719 msg "build: cmake with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
3720 # In the user config, disable one feature (for simplicity, pick a feature
3721 # that nothing else depends on).
3722 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3723
3724 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h "$MBEDTLS_ROOT_DIR"
3725 make
3726 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3727
3728 rm -f user_config.h full_config.h
3729
3730 cd "$MBEDTLS_ROOT_DIR"
3731 rm -rf "$OUT_OF_SOURCE_DIR"
3732
3733 # Now repeat the test for an in-tree build:
3734
David Horstmann67622312023-01-31 10:34:44 +00003735 # Restore config for the in-tree test
3736 mv include/mbedtls_config_in_tree_copy.h "$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003737
David Horstmann67622312023-01-31 10:34:44 +00003738 # Build once to get the generated files (which need an intact config)
David Horstmann175afbd2023-01-12 14:17:01 +00003739 cmake .
3740 make
3741
3742 msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE"
3743 scripts/config.py -w full_config.h full
David Horstmann67622312023-01-31 10:34:44 +00003744 echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003745 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h .
3746 make
3747
3748 msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
3749 # In the user config, disable one feature (for simplicity, pick a feature
3750 # that nothing else depends on).
3751 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3752
3753 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h .
3754 make
3755 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3756
3757 rm -f user_config.h full_config.h
3758}
3759support_build_cmake_custom_config_file () {
3760 support_test_cmake_out_of_source
3761}
3762
3763
Tom Cosgrove51170622023-09-01 10:40:15 +01003764component_build_zeroize_checks () {
3765 msg "build: check for obviously wrong calls to mbedtls_platform_zeroize()"
3766
3767 scripts/config.py full
3768
3769 # Only compile - we're looking for sizeof-pointer-memaccess warnings
Dave Rodgman374b1882024-01-04 10:30:57 +00003770 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 +01003771}
3772
3773
Gilles Peskine8f073122018-11-27 15:58:47 +01003774component_test_zeroize () {
3775 # Test that the function mbedtls_platform_zeroize() is not optimized away by
3776 # different combinations of compilers and optimization flags by using an
3777 # auxiliary GDB script. Unfortunately, GDB does not return error values to the
3778 # system in all cases that the script fails, so we must manually search the
3779 # output to check whether the pass string is present and no failure strings
3780 # were printed.
Andres AGdc192212016-08-31 17:33:13 +01003781
Gilles Peskine4976e822019-01-06 19:52:22 +00003782 # Don't try to disable ASLR. We don't care about ASLR here. We do care
3783 # about a spurious message if Gdb tries and fails, so suppress that.
3784 gdb_disable_aslr=
3785 if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
3786 gdb_disable_aslr='set disable-randomization off'
3787 fi
3788
Gilles Peskine8f073122018-11-27 15:58:47 +01003789 for optimization_flag in -O2 -O3 -Ofast -Os; do
Gilles Peskine55f7c942019-01-09 22:28:21 +01003790 for compiler in clang gcc; do
3791 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
3792 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003793 gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
3794 grep "The buffer was correctly zeroized" test_zeroize.log
3795 not grep -i "error" test_zeroize.log
Gilles Peskine55f7c942019-01-09 22:28:21 +01003796 rm -f test_zeroize.log
3797 make clean
3798 done
Andres Amaya Garcia29673812017-10-25 10:35:51 +01003799 done
Gilles Peskine8f073122018-11-27 15:58:47 +01003800}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003801
Bence Szépkúti9f849112021-10-19 15:05:36 +02003802component_test_psa_compliance () {
Dave Rodgmanb0660c22023-12-18 19:55:40 +00003803 # The arch tests build with gcc, so require use of gcc here to link properly
Bence Szépkútic1e79fd2021-11-11 20:13:14 +01003804 msg "build: make, default config + CMAC, libmbedcrypto.a only"
3805 scripts/config.py set MBEDTLS_CMAC_C
Dave Rodgmanb0660c22023-12-18 19:55:40 +00003806 CC=gcc make -C library libmbedcrypto.a
Bence Szépkúti9f849112021-10-19 15:05:36 +02003807
3808 msg "unit test: test_psa_compliance.py"
Dave Rodgman5b00fb12023-12-18 22:29:56 +00003809 CC=gcc ./tests/scripts/test_psa_compliance.py
Bence Szépkúti9f849112021-10-19 15:05:36 +02003810}
3811
3812support_test_psa_compliance () {
Bence Szépkútid6cf0892021-11-03 11:36:09 +01003813 # psa-compliance-tests only supports CMake >= 3.10.0
Bence Szépkútiab796e62021-10-25 19:29:07 +02003814 ver="$(cmake --version)"
3815 ver="${ver#cmake version }"
3816 ver_major="${ver%%.*}"
3817
3818 ver="${ver#*.}"
3819 ver_minor="${ver%%.*}"
3820
3821 [ "$ver_major" -eq 3 ] && [ "$ver_minor" -ge 10 ]
Bence Szépkúti9f849112021-10-19 15:05:36 +02003822}
3823
Gilles Peskineb9e56fb2022-12-09 12:23:35 +01003824component_check_code_style () {
3825 msg "Check C code style"
3826 ./scripts/code_style.py
David Horstmanne09c4762022-11-10 18:30:52 +00003827}
3828
Gilles Peskineb9e56fb2022-12-09 12:23:35 +01003829support_check_code_style() {
David Horstmanne09c4762022-11-10 18:30:52 +00003830 case $(uncrustify --version) in
3831 *0.75.1*) true;;
3832 *) false;;
3833 esac
3834}
3835
Gilles Peskine8f073122018-11-27 15:58:47 +01003836component_check_python_files () {
3837 msg "Lint: Python scripts"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003838 tests/scripts/check-python-files.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003839}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003840
Gilles Peskine8f073122018-11-27 15:58:47 +01003841component_check_generate_test_code () {
3842 msg "uint test: generate_test_code.py"
Manuel Pégourié-Gonnarddfb114a2020-06-02 11:40:08 +02003843 # unittest writes out mundane stuff like number or tests run on stderr.
3844 # Our convention is to reserve stderr for actual errors, and write
3845 # harmless info on stdout so it can be suppress with --quiet.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003846 ./tests/scripts/test_generate_test_code.py 2>&1
Gilles Peskine8f073122018-11-27 15:58:47 +01003847}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003848
3849################################################################
3850#### Termination
3851################################################################
3852
Gilles Peskine8f073122018-11-27 15:58:47 +01003853post_report () {
3854 msg "Done, cleaning up"
Gilles Peskine24bdf022020-03-30 20:11:39 +02003855 final_cleanup
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003856
Gilles Peskine8f073122018-11-27 15:58:47 +01003857 final_report
3858}
3859
3860
3861
3862################################################################
3863#### Run all the things
3864################################################################
3865
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003866# Function invoked by --error-test to test error reporting.
3867pseudo_component_error_test () {
Gilles Peskine202e9b42021-08-02 23:28:00 +02003868 msg "Testing error reporting $error_test_i"
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003869 if [ $KEEP_GOING -ne 0 ]; then
3870 echo "Expect three failing commands."
3871 fi
Gilles Peskine202e9b42021-08-02 23:28:00 +02003872 # If the component doesn't run in a subshell, changing error_test_i to an
3873 # invalid integer will cause an error in the loop that runs this function.
3874 error_test_i=this_should_not_be_used_since_the_component_runs_in_a_subshell
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003875 # Expected error: 'grep non_existent /dev/null -> 1'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003876 grep non_existent /dev/null
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003877 # Expected error: '! grep -q . tests/scripts/all.sh -> 1'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003878 not grep -q . "$0"
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003879 # Expected error: 'make unknown_target -> 2'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003880 make unknown_target
3881 false "this should not be executed"
3882}
3883
Gilles Peskinee48351a2018-11-27 16:06:30 +01003884# Run one component and clean up afterwards.
Gilles Peskine8f073122018-11-27 15:58:47 +01003885run_component () {
Gilles Peskineffcdeff2018-12-04 12:49:28 +01003886 current_component="$1"
Gilles Peskine9004a172019-09-16 15:20:36 +02003887 export MBEDTLS_TEST_CONFIGURATION="$current_component"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003888
3889 # Unconditionally create a seedfile that's sufficiently long.
3890 # Do this before each component, because a previous component may
3891 # have messed it up or shortened it.
Gilles Peskinef3133362021-07-08 19:03:50 +02003892 local dd_cmd
3893 dd_cmd=(dd if=/dev/urandom of=./tests/seedfile bs=64 count=1)
3894 case $OSTYPE in
3895 linux*|freebsd*|openbsd*|darwin*) dd_cmd+=(status=none)
3896 esac
3897 "${dd_cmd[@]}"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003898
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003899 # Run the component in a subshell, with error trapping and output
3900 # redirection set up based on the relevant options.
Gilles Peskine7105a332020-03-28 18:50:43 +01003901 if [ $KEEP_GOING -eq 1 ]; then
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003902 # We want to keep running if the subshell fails, so 'set -e' must
3903 # be off when the subshell runs.
Gilles Peskine7105a332020-03-28 18:50:43 +01003904 set +e
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02003905 fi
Gilles Peskine7105a332020-03-28 18:50:43 +01003906 (
3907 if [ $QUIET -eq 1 ]; then
3908 # msg() will be silenced, so just print the component name here.
3909 echo "${current_component#component_}"
3910 exec >/dev/null
3911 fi
3912 if [ $KEEP_GOING -eq 1 ]; then
3913 # Keep "set -e" off, and run an ERR trap instead to record failures.
3914 set -E
3915 trap err_trap ERR
3916 fi
3917 # The next line is what runs the component
3918 "$@"
3919 if [ $KEEP_GOING -eq 1 ]; then
3920 trap - ERR
3921 exit $last_failure_status
3922 fi
3923 )
3924 component_status=$?
3925 if [ $KEEP_GOING -eq 1 ]; then
3926 set -e
3927 if [ $component_status -ne 0 ]; then
3928 failure_count=$((failure_count + 1))
3929 fi
3930 fi
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003931
3932 # Restore the build tree to a clean state.
Gilles Peskinee48351a2018-11-27 16:06:30 +01003933 cleanup
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +02003934 unset current_component
Gilles Peskine8f073122018-11-27 15:58:47 +01003935}
3936
3937# Preliminary setup
3938pre_check_environment
3939pre_initialize_variables
3940pre_parse_command_line "$@"
Gilles Peskine348fb9a2018-11-27 17:04:29 +01003941
Dave Rodgman4cb98a92024-02-26 11:41:19 +00003942setup_quiet_wrappers
Gilles Peskine878cf602019-01-06 20:50:38 +00003943pre_check_git
Gilles Peskineef64e7f2021-07-12 18:16:01 +02003944pre_restore_files
Gilles Peskine24bdf022020-03-30 20:11:39 +02003945pre_back_up
Andrzej Kurekeb508712019-02-14 07:18:59 -05003946
Gilles Peskine878cf602019-01-06 20:50:38 +00003947build_status=0
3948if [ $KEEP_GOING -eq 1 ]; then
3949 pre_setup_keep_going
Gilles Peskine8f073122018-11-27 15:58:47 +01003950fi
Gilles Peskine67ffdaf2019-09-16 15:55:46 +02003951pre_prepare_outcome_file
Gilles Peskine878cf602019-01-06 20:50:38 +00003952pre_print_configuration
3953pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003954cleanup
3955
Gilles Peskinebeb3a812019-01-06 22:11:25 +00003956# Run the requested tests.
Gilles Peskine202e9b42021-08-02 23:28:00 +02003957for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003958 run_component pseudo_component_error_test
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003959done
Gilles Peskine202e9b42021-08-02 23:28:00 +02003960unset error_test_i
Gilles Peskinebeb3a812019-01-06 22:11:25 +00003961for component in $RUN_COMPONENTS; do
3962 run_component "component_$component"
3963done
Gilles Peskine8f073122018-11-27 15:58:47 +01003964
3965# We're done.
Gilles Peskine878cf602019-01-06 20:50:38 +00003966post_report