blob: aeb6d7b706fe0efd7cfb7b377a69eabbbb079f4c [file] [log] [blame]
Andres AG31f9b5b2016-10-04 17:14:38 +01001#! /usr/bin/env sh
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
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02006# SPDX-License-Identifier: Apache-2.0
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
Gilles Peskine192c72f2017-12-21 15:59:21 +010019
20
21
22################################################################
23#### Documentation
24################################################################
25
Simon Butcher3ea7f522016-03-07 23:22:10 +000026# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010027# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000028#
SimonB2e23c822016-04-16 21:54:39 +010029# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010030#
Gilles Peskine192c72f2017-12-21 15:59:21 +010031# Notes for users
32# ---------------
33#
SimonB2e23c822016-04-16 21:54:39 +010034# Warning: the test is destructive. It includes various build modes and
35# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010036# configuration. The following files must be committed into git:
37# * include/mbedtls/config.h
Gilles Peskine636c26a2020-03-04 20:46:15 +010038# * Makefile, library/Makefile, programs/Makefile, tests/Makefile,
39# programs/fuzz/Makefile
Gilles Peskine192c72f2017-12-21 15:59:21 +010040# After running this script, the CMake cache will be lost and CMake
41# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010042#
Gilles Peskine192c72f2017-12-21 15:59:21 +010043# The script assumes the presence of a number of tools:
44# * Basic Unix tools (Windows users note: a Unix-style find must be before
45# the Windows find in the PATH)
46# * Perl
47# * GNU Make
48# * CMake
49# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040050# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010051# * arm-gcc and mingw-gcc
52# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine192c72f2017-12-21 15:59:21 +010053# * OpenSSL and GnuTLS command line tools, recent enough for the
54# interoperability tests. If they don't support SSLv3 then a legacy
55# version of these tools must be present as well (search for LEGACY
56# below).
57# See the invocation of check_tools below for details.
58#
59# This script must be invoked from the toplevel directory of a git
60# working copy of Mbed TLS.
61#
62# Note that the output is not saved. You may want to run
63# script -c tests/scripts/all.sh
64# or
65# tests/scripts/all.sh >all.log 2>&1
66#
67# Notes for maintainers
68# ---------------------
69#
Gilles Peskine8f073122018-11-27 15:58:47 +010070# The bulk of the code is organized into functions that follow one of the
71# following naming conventions:
72# * pre_XXX: things to do before running the tests, in order.
73# * component_XXX: independent components. They can be run in any order.
Gilles Peskinec70637a2019-01-09 22:29:17 +010074# * component_check_XXX: quick tests that aren't worth parallelizing.
75# * component_build_XXX: build things but don't run them.
76# * component_test_XXX: build and test.
Gilles Peskine878cf602019-01-06 20:50:38 +000077# * support_XXX: if support_XXX exists and returns false then
78# component_XXX is not run by default.
Gilles Peskine8f073122018-11-27 15:58:47 +010079# * post_XXX: things to do after running the tests.
80# * other: miscellaneous support functions.
81#
Gilles Peskinec70637a2019-01-09 22:29:17 +010082# Each component must start by invoking `msg` with a short informative message.
83#
84# The framework performs some cleanup tasks after each component. This
85# means that components can assume that the working directory is in a
86# cleaned-up state, and don't need to perform the cleanup themselves.
87# * Run `make clean`.
88# * Restore `include/mbedtks/config.h` from a backup made before running
89# the component.
Gilles Peskine636c26a2020-03-04 20:46:15 +010090# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`,
91# `tests/Makefile` and `programs/fuzz/Makefile` from git.
92# This cleans up after an in-tree use of CMake.
Gilles Peskinec70637a2019-01-09 22:29:17 +010093#
94# Any command that is expected to fail must be protected so that the
95# script keeps running in --keep-going mode despite `set -e`. In keep-going
96# mode, if a protected command fails, this is logged as a failure and the
97# script will exit with a failure status once it has run all components.
98# Commands can be protected in any of the following ways:
99# * `make` is a function which runs the `make` command with protection.
100# Note that you must write `make VAR=value`, not `VAR=value make`,
101# because the `VAR=value make` syntax doesn't work with functions.
102# * Put `report_status` before the command to protect it.
103# * Put `if_build_successful` before a command. This protects it, and
104# additionally skips it if a prior invocation of `make` in the same
105# component failed.
106#
Gilles Peskine192c72f2017-12-21 15:59:21 +0100107# The tests are roughly in order from fastest to slowest. This doesn't
108# have to be exact, but in general you should add slower tests towards
109# the end and fast checks near the beginning.
Gilles Peskine192c72f2017-12-21 15:59:21 +0100110
111
112
113################################################################
114#### Initialization and command line parsing
115################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100116
SimonB2e23c822016-04-16 21:54:39 +0100117# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100118set -eu
119
Gilles Peskine8f073122018-11-27 15:58:47 +0100120pre_check_environment () {
Gilles Peskinea16c2b12019-01-06 19:58:02 +0000121 if [ -d library -a -d include -a -d tests ]; then :; else
Gilles Peskine8f073122018-11-27 15:58:47 +0100122 echo "Must be run from mbed TLS root" >&2
123 exit 1
124 fi
125}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100126
Gilles Peskine8f073122018-11-27 15:58:47 +0100127pre_initialize_variables () {
128 CONFIG_H='include/mbedtls/config.h'
129 CONFIG_BAK="$CONFIG_H.bak"
John Durkopbd069d32020-10-31 22:14:03 -0700130 CRYPTO_CONFIG_H='include/psa/crypto_config.h'
131 CRYPTO_CONFIG_BAK="$CRYPTO_CONFIG_H.bak"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200132
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200133 append_outcome=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100134 MEMORY=0
135 FORCE=0
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200136 QUIET=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100137 KEEP_GOING=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100138
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200139 # Seed value used with the --release-test option.
Manuel Pégourié-Gonnard54304472020-06-22 10:11:47 +0200140 #
141 # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if
142 # both values are kept in sync. If you change the value here because it
143 # breaks some tests, you'll definitely want to change it in
144 # basic-build-test.sh as well.
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200145 RELEASE_SEED=1
146
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200147 : ${MBEDTLS_TEST_OUTCOME_FILE=}
Gilles Peskine9004a172019-09-16 15:20:36 +0200148 : ${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 +0200149 export MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine9004a172019-09-16 15:20:36 +0200150 export MBEDTLS_TEST_PLATFORM
151
Jaeden Ameroc4cc2512019-01-30 15:35:44 +0000152 # Default commands, can be overridden by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100153 : ${OPENSSL:="openssl"}
154 : ${OPENSSL_LEGACY:="$OPENSSL"}
155 : ${OPENSSL_NEXT:="$OPENSSL"}
156 : ${GNUTLS_CLI:="gnutls-cli"}
157 : ${GNUTLS_SERV:="gnutls-serv"}
158 : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
159 : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
160 : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
161 : ${ARMC5_BIN_DIR:=/usr/bin}
162 : ${ARMC6_BIN_DIR:=/usr/bin}
Gilles Peskine6d061342020-04-30 18:19:32 +0200163 : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200164 : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
Andres AGdc192212016-08-31 17:33:13 +0100165
Gilles Peskine8f073122018-11-27 15:58:47 +0100166 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
Gilles Peskinea1fc4b52019-01-06 20:15:26 +0000167 if [ -z "${MAKEFLAGS+set}" ]; then
Gilles Peskine85229ac2021-09-30 18:24:21 +0200168 export MAKEFLAGS="-j$(all_sh_nproc)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100169 fi
Gilles Peskine878cf602019-01-06 20:50:38 +0000170
Gilles Peskinec761d8f2021-09-20 18:57:55 +0200171 # Include more verbose output for failing tests run by CMake or make
Jaeden Amerod48e9c72019-02-07 17:43:39 +0000172 export CTEST_OUTPUT_ON_FAILURE=1
173
Gilles Peskine8fd59422019-10-21 17:11:33 +0200174 # CFLAGS and LDFLAGS for Asan builds that don't use CMake
Gilles Peskine5ca393f2019-10-21 19:06:33 +0200175 ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all'
Gilles Peskine8fd59422019-10-21 17:11:33 +0200176
Gilles Peskine878cf602019-01-06 20:50:38 +0000177 # Gather the list of available components. These are the functions
178 # defined in this script whose name starts with "component_".
179 # Parse the script with sed, because in sh there is no way to list
180 # defined functions.
181 ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
182
183 # Exclude components that are not supported on this platform.
184 SUPPORTED_COMPONENTS=
185 for component in $ALL_COMPONENTS; do
186 case $(type "support_$component" 2>&1) in
187 *' function'*)
188 if ! support_$component; then continue; fi;;
189 esac
190 SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
191 done
Gilles Peskine8f073122018-11-27 15:58:47 +0100192}
Andres AG38495a32016-07-12 16:54:33 +0100193
Gilles Peskinea28db922019-01-10 00:05:18 +0100194# Test whether the component $1 is included in the command line patterns.
195is_component_included()
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100196{
197 set -f
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000198 for pattern in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100199 set +f
200 case ${1#component_} in $pattern) return 0;; esac
201 done
202 set +f
203 return 1
204}
Andres AG7770ea82016-10-10 15:46:20 +0100205
Simon Butcher41eeccf2016-09-07 00:07:09 +0100206usage()
Andres AGd9eba4b2016-08-26 14:42:14 +0100207{
Gilles Peskine709346a2017-12-10 23:43:39 +0100208 cat <<EOF
Gilles Peskine92525112018-11-27 18:15:35 +0100209Usage: $0 [OPTION]... [COMPONENT]...
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100210Run mbedtls release validation tests.
Gilles Peskine92525112018-11-27 18:15:35 +0100211By default, run all tests. With one or more COMPONENT, run only those.
Gilles Peskinea28db922019-01-10 00:05:18 +0100212COMPONENT can be the name of a component or a shell wildcard pattern.
213
214Examples:
215 $0 "check_*"
216 Run all sanity checks.
217 $0 --no-armcc --except test_memsan
218 Run everything except builds that require armcc and MemSan.
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100219
220Special options:
221 -h|--help Print this help and exit.
Gilles Peskine878cf602019-01-06 20:50:38 +0000222 --list-all-components List all available test components and exit.
223 --list-components List components supported on this platform and exit.
Gilles Peskine709346a2017-12-10 23:43:39 +0100224
225General options:
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200226 -q|--quiet Only output component names, and errors if any.
Gilles Peskine709346a2017-12-10 23:43:39 +0100227 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100228 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100229 -m|--memory Additional optional memory tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200230 --append-outcome Append to the outcome file (if used).
Gilles Peskine6d061342020-04-30 18:19:32 +0200231 --arm-none-eabi-gcc-prefix=<string>
232 Prefix for a cross-compiler for arm-none-eabi
233 (default: "${ARM_NONE_EABI_GCC_PREFIX}")
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200234 --arm-linux-gnueabi-gcc-prefix=<string>
235 Prefix for a cross-compiler for arm-linux-gnueabi
236 (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}")
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100237 --armcc Run ARM Compiler builds (on by default).
Gilles Peskinea28db922019-01-10 00:05:18 +0100238 --except Exclude the COMPONENTs listed on the command line,
239 instead of running only those.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200240 --no-append-outcome Write a new outcome file and analyze it (default).
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100241 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100242 --no-force Refuse to overwrite modified files (default).
243 --no-keep-going Stop at the first error (default).
244 --no-memory No additional memory tests (default).
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200245 --no-quiet Print full ouput from components.
Gilles Peskine709346a2017-12-10 23:43:39 +0100246 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200247 --outcome-file=<path> File where test outcomes are written (not done if
248 empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
Gilles Peskine38d81652018-03-21 08:40:26 +0100249 --random-seed Use a random seed value for randomized tests (default).
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200250 -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}.
Gilles Peskine709346a2017-12-10 23:43:39 +0100251 -s|--seed Integer seed value to use for this test run.
252
253Tool path options:
254 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
255 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
256 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
257 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
258 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
259 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
260 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
261 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100262 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100263EOF
SimonB2e23c822016-04-16 21:54:39 +0100264}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100265
266# remove built files as well as the cmake cache/config
267cleanup()
268{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100269 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
270 cd "$MBEDTLS_ROOT_DIR"
271 fi
272
Gilles Peskine7c652162017-12-11 00:01:40 +0100273 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200274
Gilles Peskine31b07e22018-03-21 12:15:06 +0100275 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000276 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100277 -iname CMakeFiles -exec rm -rf {} \+ -o \
278 \( -iname cmake_install.cmake -o \
279 -iname CTestTestfile.cmake -o \
280 -iname CMakeCache.txt \) -exec rm {} \+
281 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000282 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Gilles Peskine636c26a2020-03-04 20:46:15 +0100283 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
284 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200285
Jaeden Ameroab83fdf2019-06-20 17:38:22 +0100286 # Remove any artifacts from the component_test_cmake_as_subdirectory test.
287 rm -rf programs/test/cmake_subproject/build
288 rm -f programs/test/cmake_subproject/Makefile
289 rm -f programs/test/cmake_subproject/cmake_subproject
290
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200291 if [ -f "$CONFIG_BAK" ]; then
292 mv "$CONFIG_BAK" "$CONFIG_H"
293 fi
John Durkopbd069d32020-10-31 22:14:03 -0700294
295 if [ -f "$CRYPTO_CONFIG_BAK" ]; then
296 mv "$CRYPTO_CONFIG_BAK" "$CRYPTO_CONFIG_H"
297 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100298}
299
Gilles Peskine7c652162017-12-11 00:01:40 +0100300# Executed on exit. May be redefined depending on command line options.
301final_report () {
302 :
303}
304
305fatal_signal () {
306 cleanup
307 final_report $1
308 trap - $1
309 kill -$1 $$
310}
311
312trap 'fatal_signal HUP' HUP
313trap 'fatal_signal INT' INT
314trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200315
Gilles Peskine85229ac2021-09-30 18:24:21 +0200316# Number of processors on this machine. Used as the default setting
317# for parallel make.
318all_sh_nproc ()
319{
320 {
321 nproc || # Linux
322 sysctl -n hw.ncpuonline || # NetBSD, OpenBSD
323 sysctl -n hw.ncpu || # FreeBSD
324 echo 1
325 } 2>/dev/null
326}
327
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100328msg()
329{
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100330 if [ -n "${current_component:-}" ]; then
331 current_section="${current_component#component_}: $1"
332 else
333 current_section="$1"
334 fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200335
336 if [ $QUIET -eq 1 ]; then
337 return
338 fi
339
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100340 echo ""
341 echo "******************************************************************"
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100342 echo "* $current_section "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000343 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100344 echo "******************************************************************"
345}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100346
Gilles Peskine8f073122018-11-27 15:58:47 +0100347armc6_build_test()
348{
349 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100350
Gilles Peskine18487f62020-04-30 23:11:54 +0200351 msg "build: ARM Compiler 6 ($FLAGS)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100352 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
353 WARNING_CFLAGS='-xc -std=c99' make lib
Gilles Peskine18487f62020-04-30 23:11:54 +0200354
355 msg "size: ARM Compiler 6 ($FLAGS)"
356 "$ARMC6_FROMELF" -z library/*.o
357
Gilles Peskine8f073122018-11-27 15:58:47 +0100358 make clean
359}
Andres AGa5cd9732016-10-17 15:23:10 +0100360
Andres AGd9eba4b2016-08-26 14:42:14 +0100361err_msg()
362{
363 echo "$1" >&2
364}
365
366check_tools()
367{
368 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000369 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100370 err_msg "$TOOL not found!"
371 exit 1
372 fi
373 done
374}
375
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400376check_headers_in_cpp () {
Peter Kolbus1bc1a4c2019-02-01 17:19:08 -0600377 ls include/mbedtls | grep "\.h$" >headers.txt
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400378 <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
379 sort |
380 diff headers.txt -
381 rm headers.txt
382}
383
Gilles Peskine8f073122018-11-27 15:58:47 +0100384pre_parse_command_line () {
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000385 COMMAND_LINE_COMPONENTS=
Gilles Peskinea28db922019-01-10 00:05:18 +0100386 all_except=0
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000387 no_armcc=
SimonB2e23c822016-04-16 21:54:39 +0100388
Jaeden Amero9b90f2e2018-11-02 18:34:17 +0000389 # Note that legacy options are ignored instead of being omitted from this
390 # list of options, so invocations that worked with previous version of
391 # all.sh will still run and work properly.
Gilles Peskine8f073122018-11-27 15:58:47 +0100392 while [ $# -gt 0 ]; do
Gilles Peskine55f7c942019-01-09 22:28:21 +0100393 case "$1" in
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200394 --append-outcome) append_outcome=1;;
Gilles Peskine6d061342020-04-30 18:19:32 +0200395 --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200396 --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000397 --armcc) no_armcc=;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100398 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
399 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000400 --except) all_except=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100401 --force|-f) FORCE=1;;
402 --gnutls-cli) shift; GNUTLS_CLI="$1";;
403 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
404 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
405 --gnutls-serv) shift; GNUTLS_SERV="$1";;
406 --help|-h) usage; exit;;
407 --keep-going|-k) KEEP_GOING=1;;
Gilles Peskine878cf602019-01-06 20:50:38 +0000408 --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
409 --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100410 --memory|-m) MEMORY=1;;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200411 --no-append-outcome) append_outcome=0;;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000412 --no-armcc) no_armcc=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100413 --no-force) FORCE=0;;
414 --no-keep-going) KEEP_GOING=0;;
415 --no-memory) MEMORY=0;;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200416 --no-quiet) QUIET=0;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100417 --openssl) shift; OPENSSL="$1";;
418 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
419 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200420 --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100421 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200422 --quiet|-q) QUIET=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100423 --random-seed) unset SEED;;
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200424 --release-test|-r) SEED=$RELEASE_SEED;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100425 --seed|-s) shift; SEED="$1";;
426 -*)
427 echo >&2 "Unknown option: $1"
428 echo >&2 "Run $0 --help for usage."
429 exit 120
430 ;;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000431 *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100432 esac
433 shift
Gilles Peskine8f073122018-11-27 15:58:47 +0100434 done
SimonB2e23c822016-04-16 21:54:39 +0100435
Gilles Peskinea28db922019-01-10 00:05:18 +0100436 # With no list of components, run everything.
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000437 if [ -z "$COMMAND_LINE_COMPONENTS" ]; then
438 all_except=1
Andres AGdc192212016-08-31 17:33:13 +0100439 fi
440
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000441 # --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
442 # Ignore it if components are listed explicitly on the command line.
Gilles Peskinea28db922019-01-10 00:05:18 +0100443 if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000444 COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
SimonB2e23c822016-04-16 21:54:39 +0100445 fi
SimonB2e23c822016-04-16 21:54:39 +0100446
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000447 # Build the list of components to run.
Gilles Peskinea28db922019-01-10 00:05:18 +0100448 RUN_COMPONENTS=
449 for component in $SUPPORTED_COMPONENTS; do
450 if is_component_included "$component"; [ $? -eq $all_except ]; then
451 RUN_COMPONENTS="$RUN_COMPONENTS $component"
452 fi
453 done
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000454
455 unset all_except
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000456 unset no_armcc
Gilles Peskine8f073122018-11-27 15:58:47 +0100457}
SimonB2e23c822016-04-16 21:54:39 +0100458
Gilles Peskine8f073122018-11-27 15:58:47 +0100459pre_check_git () {
460 if [ $FORCE -eq 1 ]; then
Gilles Peskine53190e62019-01-09 23:17:35 +0100461 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +0100462 git checkout-index -f -q $CONFIG_H
463 cleanup
464 else
SimonB2e23c822016-04-16 21:54:39 +0100465
Gilles Peskine8f073122018-11-27 15:58:47 +0100466 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
467 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
468 echo "You can either delete this directory manually, or force the test by rerunning"
469 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
470 exit 1
471 fi
472
Gilles Peskined1174cf2019-01-09 22:30:01 +0100473 if ! git diff --quiet include/mbedtls/config.h; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100474 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
475 echo "You can either delete or preserve your work, or force the test by rerunning the"
476 echo "script as: $0 --force"
477 exit 1
478 fi
SimonB2e23c822016-04-16 21:54:39 +0100479 fi
Andrzej Kurekeb508712019-02-14 07:18:59 -0500480}
481
Gilles Peskine8f073122018-11-27 15:58:47 +0100482pre_setup_keep_going () {
Gilles Peskine7c652162017-12-11 00:01:40 +0100483 failure_summary=
484 failure_count=0
485 start_red=
486 end_color=
487 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100488 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100489 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
490 start_red=$(printf '\033[31m')
491 end_color=$(printf '\033[0m')
492 ;;
493 esac
494 fi
495 record_status () {
496 if "$@"; then
497 last_status=0
498 else
499 last_status=$?
500 text="$current_section: $* -> $last_status"
501 failure_summary="$failure_summary
502$text"
503 failure_count=$((failure_count + 1))
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200504 echo "${start_red}^^^^$text^^^^${end_color}" >&2
Gilles Peskine7c652162017-12-11 00:01:40 +0100505 fi
506 }
507 make () {
508 case "$*" in
509 *test|*check)
510 if [ $build_status -eq 0 ]; then
511 record_status command make "$@"
512 else
513 echo "(skipped because the build failed)"
514 fi
515 ;;
516 *)
517 record_status command make "$@"
518 build_status=$last_status
519 ;;
520 esac
521 }
522 final_report () {
523 if [ $failure_count -gt 0 ]; then
524 echo
525 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
526 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
527 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7c1258d2018-07-20 16:42:14 +0100528 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100529 elif [ -z "${1-}" ]; then
530 echo "SUCCESS :)"
531 fi
532 if [ -n "${1-}" ]; then
533 echo "Killed by SIG$1."
534 fi
535 }
Gilles Peskine8f073122018-11-27 15:58:47 +0100536}
537
Gilles Peskine7c652162017-12-11 00:01:40 +0100538if_build_succeeded () {
539 if [ $build_status -eq 0 ]; then
540 record_status "$@"
541 fi
542}
543
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200544# to be used instead of ! for commands run with
545# record_status or if_build_succeeded
546not() {
547 ! "$@"
548}
549
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200550pre_setup_quiet_redirect () {
551 if [ $QUIET -ne 1 ]; then
552 redirect_out () {
553 "$@"
554 }
Manuel Pégourié-Gonnardf1f180a2020-06-08 10:46:35 +0200555 redirect_err () {
556 "$@"
557 }
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200558 else
559 redirect_out () {
560 "$@" >/dev/null
561 }
Manuel Pégourié-Gonnardf1f180a2020-06-08 10:46:35 +0200562 redirect_err () {
563 "$@" 2>/dev/null
564 }
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200565 fi
566}
567
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200568pre_prepare_outcome_file () {
569 case "$MBEDTLS_TEST_OUTCOME_FILE" in
570 [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
571 esac
572 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then
573 rm -f "$MBEDTLS_TEST_OUTCOME_FILE"
574 fi
575}
576
Gilles Peskine8f073122018-11-27 15:58:47 +0100577pre_print_configuration () {
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200578 if [ $QUIET -eq 1 ]; then
579 return
580 fi
581
Gilles Peskine8f073122018-11-27 15:58:47 +0100582 msg "info: $0 configuration"
583 echo "MEMORY: $MEMORY"
584 echo "FORCE: $FORCE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200585 echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}"
Gilles Peskine8f073122018-11-27 15:58:47 +0100586 echo "SEED: ${SEED-"UNSET"}"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100587 echo
Gilles Peskine8f073122018-11-27 15:58:47 +0100588 echo "OPENSSL: $OPENSSL"
589 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
590 echo "OPENSSL_NEXT: $OPENSSL_NEXT"
591 echo "GNUTLS_CLI: $GNUTLS_CLI"
592 echo "GNUTLS_SERV: $GNUTLS_SERV"
593 echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
594 echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
595 echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
596 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
597}
Andres AG7770ea82016-10-10 15:46:20 +0100598
Andres AGd9eba4b2016-08-26 14:42:14 +0100599# Make sure the tools we need are available.
Gilles Peskine8f073122018-11-27 15:58:47 +0100600pre_check_tools () {
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000601 # Build the list of variables to pass to output_env.sh.
602 set env
SimonB2e23c822016-04-16 21:54:39 +0100603
Gilles Peskine87964262019-01-06 22:40:00 +0000604 case " $RUN_COMPONENTS " in
605 # Require OpenSSL and GnuTLS if running any tests (as opposed to
606 # only doing builds). Not all tests run OpenSSL and GnuTLS, but this
607 # is a good enough approximation in practice.
608 *" test_"*)
609 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh
610 # and ssl-opt.sh, we just export the variables they require.
611 export OPENSSL_CMD="$OPENSSL"
612 export GNUTLS_CLI="$GNUTLS_CLI"
613 export GNUTLS_SERV="$GNUTLS_SERV"
614 # Avoid passing --seed flag in every call to ssl-opt.sh
615 if [ -n "${SEED-}" ]; then
616 export SEED
617 fi
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000618 set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY"
619 set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV"
620 set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI"
621 set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000622 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
623 "$GNUTLS_CLI" "$GNUTLS_SERV" \
624 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV"
625 ;;
626 esac
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200627
Gilles Peskine87964262019-01-06 22:40:00 +0000628 case " $RUN_COMPONENTS " in
629 *_doxygen[_\ ]*) check_tools "doxygen" "dot";;
630 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100631
Gilles Peskine87964262019-01-06 22:40:00 +0000632 case " $RUN_COMPONENTS " in
Gilles Peskine6d061342020-04-30 18:19:32 +0200633 *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";;
Gilles Peskine87964262019-01-06 22:40:00 +0000634 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100635
Gilles Peskine87964262019-01-06 22:40:00 +0000636 case " $RUN_COMPONENTS " in
637 *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";;
638 esac
639
640 case " $RUN_COMPONENTS " in
641 *" test_zeroize "*) check_tools "gdb";;
642 esac
643
644 case " $RUN_COMPONENTS " in
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000645 *_armcc*)
Gilles Peskine87964262019-01-06 22:40:00 +0000646 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
647 ARMC5_AR="$ARMC5_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200648 ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf"
Gilles Peskine87964262019-01-06 22:40:00 +0000649 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
650 ARMC6_AR="$ARMC6_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200651 ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf"
652 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \
653 "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000654 esac
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000655
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200656 # past this point, no call to check_tool, only printing output
657 if [ $QUIET -eq 1 ]; then
658 return
659 fi
660
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000661 msg "info: output_env.sh"
662 case $RUN_COMPONENTS in
663 *_armcc*)
664 set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;;
665 *) set "$@" RUN_ARMCC=0;;
666 esac
667 "$@" scripts/output_env.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100668}
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100669
Gilles Peskine192c72f2017-12-21 15:59:21 +0100670
671
672################################################################
673#### Basic checks
674################################################################
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100675
676#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200677# Test Suites to be executed
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100678#
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100679# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200680# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100681# 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 +0200682# time, so start with a GCC build).
683# 2. Minimize total running time, by avoiding useless rebuilds
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100684#
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100685# Indicative running times are given for reference.
686
Gilles Peskine8f073122018-11-27 15:58:47 +0100687component_check_recursion () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200688 msg "Check: recursion.pl" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100689 record_status tests/scripts/recursion.pl library/*.c
690}
Janos Follathb72c6782016-07-19 14:54:17 +0100691
Gilles Peskine8f073122018-11-27 15:58:47 +0100692component_check_generated_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200693 msg "Check: freshness of generated source files" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100694 record_status tests/scripts/check-generated-files.sh
695}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200696
Gilles Peskine8f073122018-11-27 15:58:47 +0100697component_check_doxy_blocks () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200698 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100699 record_status tests/scripts/check-doxy-blocks.pl
700}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200701
Gilles Peskine8f073122018-11-27 15:58:47 +0100702component_check_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200703 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Gilles Peskinefb4f9332020-06-25 14:18:34 +0200704 record_status tests/scripts/check_files.py
Gilles Peskine8f073122018-11-27 15:58:47 +0100705}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200706
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200707component_check_changelog () {
708 msg "Check: changelog entries" # < 1s
709 rm -f ChangeLog.new
710 record_status scripts/assemble_changelog.py -o ChangeLog.new
711 if [ -e ChangeLog.new ]; then
712 # Show the diff for information. It isn't an error if the diff is
713 # non-empty.
714 diff -u ChangeLog ChangeLog.new || true
715 rm ChangeLog.new
716 fi
717}
718
Gilles Peskine8f073122018-11-27 15:58:47 +0100719component_check_names () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200720 msg "Check: declared and exported names (builds the library)" # < 3s
Gilles Peskine31da67b2021-09-27 20:13:00 +0200721 record_status tests/scripts/check_names.py -v
Gilles Peskine8f073122018-11-27 15:58:47 +0100722}
Darryl Greena07039c2018-03-13 16:48:16 +0000723
Gilles Peskine895868b2019-09-19 21:30:05 +0200724component_check_test_cases () {
725 msg "Check: test case descriptions" # < 1s
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200726 if [ $QUIET -eq 1 ]; then
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200727 opt='--quiet'
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200728 else
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200729 opt=''
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200730 fi
Gilles Peskinefb4f9332020-06-25 14:18:34 +0200731 record_status tests/scripts/check_test_cases.py $opt
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200732 unset opt
Gilles Peskine895868b2019-09-19 21:30:05 +0200733}
734
Gilles Peskine8f073122018-11-27 15:58:47 +0100735component_check_doxygen_warnings () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200736 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Gilles Peskine8f073122018-11-27 15:58:47 +0100737 record_status tests/scripts/doxygen.sh
738}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200739
Gilles Peskine192c72f2017-12-21 15:59:21 +0100740
Gilles Peskine636c26a2020-03-04 20:46:15 +0100741
Gilles Peskine192c72f2017-12-21 15:59:21 +0100742################################################################
743#### Build and test many configurations and targets
744################################################################
745
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200746component_test_default_out_of_box () {
747 msg "build: make, default config (out-of-box)" # ~1min
748 make
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200749 # Disable fancy stuff
Gilles Peskine717cd762019-09-27 20:21:11 +0200750 SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200751 unset MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200752
753 msg "test: main suites make, default config (out-of-box)" # ~10s
754 make test
755
756 msg "selftest: make, default config (out-of-box)" # ~10s
Gilles Peskine97bea012020-04-23 23:37:45 +0200757 if_build_succeeded programs/test/selftest
Gilles Peskine717cd762019-09-27 20:21:11 +0200758
759 export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE"
760 unset SAVE_MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200761}
762
Gilles Peskine8f073122018-11-27 15:58:47 +0100763component_test_default_cmake_gcc_asan () {
764 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Gilles Peskine8f073122018-11-27 15:58:47 +0100765 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
766 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200767
Gilles Peskine8f073122018-11-27 15:58:47 +0100768 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
769 make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200770
Gilles Peskine97bea012020-04-23 23:37:45 +0200771 msg "test: selftest (ASan build)" # ~ 10s
772 if_build_succeeded programs/test/selftest
773
Gilles Peskine8f073122018-11-27 15:58:47 +0100774 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
775 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200776
Gilles Peskine8f073122018-11-27 15:58:47 +0100777 msg "test: compat.sh (ASan build)" # ~ 6 min
778 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200779
780 msg "test: context-info.sh (ASan build)" # ~ 15 sec
781 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100782}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200783
Hanno Becker01635512019-02-26 14:27:09 +0000784component_test_full_cmake_gcc_asan () {
785 msg "build: full config, cmake, gcc, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200786 scripts/config.py full
Hanno Becker01635512019-02-26 14:27:09 +0000787 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
788 make
789
790 msg "test: main suites (inc. selftests) (full config, ASan build)"
791 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +0100792
Gilles Peskine97bea012020-04-23 23:37:45 +0200793 msg "test: selftest (ASan build)" # ~ 10s
794 if_build_succeeded programs/test/selftest
795
Gilles Peskine636c26a2020-03-04 20:46:15 +0100796 msg "test: ssl-opt.sh (full config, ASan build)"
797 if_build_succeeded tests/ssl-opt.sh
798
799 msg "test: compat.sh (full config, ASan build)"
800 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200801
802 msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
803 if_build_succeeded tests/context-info.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +0100804}
805
Ronald Cronc3623db2020-10-29 10:51:32 +0100806component_test_psa_crypto_key_id_encodes_owner () {
807 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
808 scripts/config.py full
809 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
810 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
811 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
812 make
813
814 msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
815 make test
816}
817
Gilles Peskine99a34622021-06-17 11:37:52 +0200818# check_renamed_symbols HEADER LIB
819# Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol
820# name is LIB.
821check_renamed_symbols () {
822 ! nm "$2" | sed 's/.* //' |
823 grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")"
824}
825
Gilles Peskine984c19f2021-06-15 18:37:38 +0200826component_build_psa_crypto_spm () {
827 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc"
828 scripts/config.py full
829 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
830 scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
831 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
832 scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM
833 # We can only compile, not link, since our test and sample programs
834 # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM
835 # is active.
836 make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib
Gilles Peskine99a34622021-06-17 11:37:52 +0200837
838 # Check that if a symbol is renamed by crypto_spe.h, the non-renamed
839 # version is not present.
840 echo "Checking for renamed symbols in the library"
841 if_build_succeeded check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
Gilles Peskine984c19f2021-06-15 18:37:38 +0200842}
843
Ronald Cron336678b2021-01-28 17:54:24 +0100844component_test_psa_crypto_client () {
845 msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
846 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
847 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
848 scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT
849 make
850
851 msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
852 make test
853}
854
Gilles Peskine636c26a2020-03-04 20:46:15 +0100855component_test_zlib_make() {
856 msg "build: zlib enabled, make"
857 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
858 make ZLIB=1 CFLAGS='-Werror -O1'
859
860 msg "test: main suites (zlib, make)"
861 make test
862
863 msg "test: ssl-opt.sh (zlib, make)"
864 if_build_succeeded tests/ssl-opt.sh
865}
866support_test_zlib_make () {
867 base=support_test_zlib_$$
868 cat <<'EOF' > ${base}.c
869#include "zlib.h"
870int main(void) { return 0; }
871EOF
872 gcc -o ${base}.exe ${base}.c -lz 2>/dev/null
873 ret=$?
874 rm -f ${base}.*
875 return $ret
876}
877
878component_test_zlib_cmake() {
879 msg "build: zlib enabled, cmake"
880 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
881 cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check .
882 make
883
884 msg "test: main suites (zlib, cmake)"
885 make test
886
887 msg "test: ssl-opt.sh (zlib, cmake)"
888 if_build_succeeded tests/ssl-opt.sh
889}
890support_test_zlib_cmake () {
891 support_test_zlib_make "$@"
Manuel Pégourié-Gonnardf2e29022020-01-24 10:17:20 +0100892}
Manuel Pégourié-Gonnard95e04492020-01-02 11:45:12 +0100893
Jaeden Ameroc17f2932021-05-14 08:34:32 +0100894component_test_psa_crypto_rsa_no_genprime() {
895 msg "build: default config minus MBEDTLS_GENPRIME"
896 scripts/config.py unset MBEDTLS_GENPRIME
897 make
898
899 msg "test: default config minus MBEDTLS_GENPRIME"
900 make test
901}
902
Gilles Peskine782f4112018-11-27 16:11:09 +0100903component_test_ref_configs () {
904 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
905 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
906 record_status tests/scripts/test-ref-configs.pl
907}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200908
Gilles Peskine8f073122018-11-27 15:58:47 +0100909component_test_sslv3 () {
910 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200911 scripts/config.py set MBEDTLS_SSL_PROTO_SSL3
Gilles Peskine8f073122018-11-27 15:58:47 +0100912 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
913 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200914
Gilles Peskine8f073122018-11-27 15:58:47 +0100915 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
916 make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000917
Gilles Peskine8f073122018-11-27 15:58:47 +0100918 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
919 if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
920 if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000921
Gilles Peskine8f073122018-11-27 15:58:47 +0100922 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
923 if_build_succeeded tests/ssl-opt.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200924
925 msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec
926 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100927}
Simon Butcher3ea7f522016-03-07 23:22:10 +0000928
Gilles Peskine8f073122018-11-27 15:58:47 +0100929component_test_no_renegotiation () {
930 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200931 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine8f073122018-11-27 15:58:47 +0100932 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
933 make
Simon Butcher3ea7f522016-03-07 23:22:10 +0000934
Gilles Peskine8f073122018-11-27 15:58:47 +0100935 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
936 make test
Hanno Becker134c2ab2017-10-12 15:29:50 +0100937
Gilles Peskine8f073122018-11-27 15:58:47 +0100938 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
939 if_build_succeeded tests/ssl-opt.sh
940}
Hanno Becker134c2ab2017-10-12 15:29:50 +0100941
Gilles Peskine636c26a2020-03-04 20:46:15 +0100942component_test_no_pem_no_fs () {
943 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
944 scripts/config.py unset MBEDTLS_PEM_PARSE_C
945 scripts/config.py unset MBEDTLS_FS_IO
946 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
947 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
948 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
949 make
950
951 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
952 make test
953
954 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
955 if_build_succeeded tests/ssl-opt.sh
956}
957
Gilles Peskine8f073122018-11-27 15:58:47 +0100958component_test_rsa_no_crt () {
959 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200960 scripts/config.py set MBEDTLS_RSA_NO_CRT
Gilles Peskine8f073122018-11-27 15:58:47 +0100961 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
962 make
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100963
Gilles Peskine8f073122018-11-27 15:58:47 +0100964 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
965 make test
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100966
Gilles Peskine8f073122018-11-27 15:58:47 +0100967 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
968 if_build_succeeded tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100969
Gilles Peskine8f073122018-11-27 15:58:47 +0100970 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
971 if_build_succeeded tests/compat.sh -t RSA
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200972
973 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
974 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100975}
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100976
Gilles Peskine2747d7d2021-02-03 14:56:51 +0100977component_test_no_ctr_drbg_classic () {
978 msg "build: Full minus CTR_DRBG, classic crypto in TLS"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +0200979 scripts/config.py full
980 scripts/config.py unset MBEDTLS_CTR_DRBG_C
Gilles Peskine2747d7d2021-02-03 14:56:51 +0100981 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +0200982
983 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
984 make
985
Gilles Peskine2747d7d2021-02-03 14:56:51 +0100986 msg "test: Full minus CTR_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +0200987 make test
988
Gilles Peskineba749042021-01-13 20:02:03 +0100989 # In this configuration, the TLS test programs use HMAC_DRBG.
990 # The SSL tests are slow, so run a small subset, just enough to get
991 # confidence that the SSL code copes with HMAC_DRBG.
Gilles Peskine2747d7d2021-02-03 14:56:51 +0100992 msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskineba749042021-01-13 20:02:03 +0100993 if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
994
Gilles Peskine2747d7d2021-02-03 14:56:51 +0100995 msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)"
Gilles Peskineba749042021-01-13 20:02:03 +0100996 if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +0200997}
998
Gilles Peskine2747d7d2021-02-03 14:56:51 +0100999component_test_no_ctr_drbg_use_psa () {
1000 msg "build: Full minus CTR_DRBG, PSA crypto in TLS"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001001 scripts/config.py full
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001002 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1003 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001004
1005 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1006 make
1007
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001008 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites"
1009 make test
1010
1011 # In this configuration, the TLS test programs use HMAC_DRBG.
1012 # The SSL tests are slow, so run a small subset, just enough to get
1013 # confidence that the SSL code copes with HMAC_DRBG.
1014 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
1015 if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
1016
1017 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)"
1018 if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL
1019}
1020
1021component_test_no_hmac_drbg_classic () {
1022 msg "build: Full minus HMAC_DRBG, classic crypto in TLS"
1023 scripts/config.py full
1024 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1025 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1026 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1027
1028 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1029 make
1030
1031 msg "test: Full minus HMAC_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001032 make test
1033
Gilles Peskinea2224342020-11-19 22:14:34 +01001034 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1035 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1036 # instead.
1037 # Test SSL with non-deterministic ECDSA. Only test features that
1038 # might be affected by how ECDSA signature is performed.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001039 msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinea2224342020-11-19 22:14:34 +01001040 if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
1041
1042 # To save time, only test one protocol version, since this part of
1043 # the protocol is identical in (D)TLS up to 1.2.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001044 msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)"
Gilles Peskinea2224342020-11-19 22:14:34 +01001045 if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA'
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001046}
1047
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001048component_test_no_hmac_drbg_use_psa () {
1049 msg "build: Full minus HMAC_DRBG, PSA crypto in TLS"
1050 scripts/config.py full
1051 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1052 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1053 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1054
1055 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1056 make
1057
1058 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites"
1059 make test
1060
1061 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1062 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1063 # instead.
1064 # Test SSL with non-deterministic ECDSA. Only test features that
1065 # might be affected by how ECDSA signature is performed.
1066 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
1067 if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
1068
1069 # To save time, only test one protocol version, since this part of
1070 # the protocol is identical in (D)TLS up to 1.2.
1071 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)"
1072 if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA'
1073}
1074
1075component_test_psa_external_rng_no_drbg_classic () {
1076 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS"
1077 scripts/config.py full
1078 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1079 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001080 scripts/config.py unset MBEDTLS_ENTROPY_C
1081 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1082 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001083 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1084 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1085 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1086 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
Gilles Peskine8eb29432021-02-03 20:07:11 +01001087 # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG,
1088 # the SSL test programs don't have an RNG and can't work. Explicitly
1089 # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG.
1090 make CFLAGS="$ASAN_CFLAGS -O2 -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001091
1092 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites"
1093 make test
1094
Gilles Peskine8eb29432021-02-03 20:07:11 +01001095 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)"
1096 if_build_succeeded tests/ssl-opt.sh -f 'Default'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001097}
1098
1099component_test_psa_external_rng_no_drbg_use_psa () {
1100 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS"
Gilles Peskinec109b372020-11-23 17:39:04 +01001101 scripts/config.py full
1102 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001103 scripts/config.py unset MBEDTLS_ENTROPY_C
1104 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1105 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskinec109b372020-11-23 17:39:04 +01001106 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1107 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1108 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1109 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1110 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1111
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001112 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites"
Gilles Peskinec109b372020-11-23 17:39:04 +01001113 make test
1114
Gilles Peskine8eb29432021-02-03 20:07:11 +01001115 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)"
1116 if_build_succeeded tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001117}
1118
1119component_test_psa_external_rng_use_psa_crypto () {
1120 msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1121 scripts/config.py full
1122 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
1123 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1124 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1125 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1126
1127 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1128 make test
1129
Gilles Peskineba749042021-01-13 20:02:03 +01001130 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1131 if_build_succeeded tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001132}
1133
Manuel Pégourié-Gonnard1a3f9ed2020-05-19 12:38:31 +02001134component_test_ecp_no_internal_rng () {
1135 msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules"
1136 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1137 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1138 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1139 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1140 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG
1141 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1142
1143 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1144 make
1145
1146 msg "test: ECP_NO_INTERNAL_RNG, no DRBG module"
1147 make test
1148
1149 # no SSL tests as they all depend on having a DRBG
1150}
1151
Manuel Pégourié-Gonnard53fb66d2020-06-04 09:43:14 +02001152component_test_ecp_restartable_no_internal_rng () {
1153 msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG"
1154 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1155 scripts/config.py set MBEDTLS_ECP_RESTARTABLE
1156 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1157 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1158 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1159 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
1160 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1161
1162 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1163 make
1164
1165 msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module"
1166 make test
1167
1168 # no SSL tests as they all depend on having a DRBG
1169}
1170
Gilles Peskine636c26a2020-03-04 20:46:15 +01001171component_test_new_ecdh_context () {
1172 msg "build: new ECDH context (ASan build)" # ~ 6 min
1173 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1174 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1175 make
1176
1177 msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1178 make test
1179
1180 msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
1181 if_build_succeeded tests/ssl-opt.sh -f ECDH
1182
1183 msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1184 # Exclude some symmetric ciphers that are redundant here to gain time.
1185 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
1186}
1187
1188component_test_everest () {
1189 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
1190 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1191 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1192 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
1193 make
1194
1195 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1196 make test
1197
1198 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
1199 if_build_succeeded tests/ssl-opt.sh -f ECDH
1200
1201 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1202 # Exclude some symmetric ciphers that are redundant here to gain time.
1203 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
1204}
1205
Gilles Peskined3beca92020-07-03 00:15:37 +02001206component_test_everest_curve25519_only () {
1207 msg "build: Everest ECDH context, only Curve25519" # ~ 6 min
1208 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1209 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1210 scripts/config.py unset MBEDTLS_ECDSA_C
1211 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1212 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1213 # Disable all curves
1214 for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do
1215 scripts/config.py unset "$c"
1216 done
1217 scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED
1218
1219 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1220
1221 msg "test: Everest ECDH context, only Curve25519" # ~ 50s
1222 make test
1223}
1224
Gilles Peskine8f073122018-11-27 15:58:47 +01001225component_test_small_ssl_out_content_len () {
1226 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001227 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
1228 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01001229 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1230 make
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001231
Gilles Peskine8f073122018-11-27 15:58:47 +01001232 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
1233 if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet"
1234}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001235
Gilles Peskine8f073122018-11-27 15:58:47 +01001236component_test_small_ssl_in_content_len () {
1237 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001238 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
1239 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
Gilles Peskine8f073122018-11-27 15:58:47 +01001240 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1241 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001242
Gilles Peskine8f073122018-11-27 15:58:47 +01001243 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
1244 if_build_succeeded tests/ssl-opt.sh -f "Max fragment"
1245}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001246
Gilles Peskine8f073122018-11-27 15:58:47 +01001247component_test_small_ssl_dtls_max_buffering () {
1248 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001249 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
Gilles Peskine8f073122018-11-27 15:58:47 +01001250 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1251 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001252
Gilles Peskine8f073122018-11-27 15:58:47 +01001253 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
1254 if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
1255}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001256
Gilles Peskine8f073122018-11-27 15:58:47 +01001257component_test_small_mbedtls_ssl_dtls_max_buffering () {
1258 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
Gilles Peskine636c26a2020-03-04 20:46:15 +01001259 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
Gilles Peskine8f073122018-11-27 15:58:47 +01001260 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1261 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001262
Gilles Peskine8f073122018-11-27 15:58:47 +01001263 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
1264 if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
1265}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001266
Gilles Peskine75cc7712019-09-06 19:47:17 +02001267component_test_psa_collect_statuses () {
1268 msg "build+test: psa_collect_statuses" # ~30s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001269 scripts/config.py full
Gilles Peskine75cc7712019-09-06 19:47:17 +02001270 record_status tests/scripts/psa_collect_statuses.py
1271 # Check that psa_crypto_init() succeeded at least once
1272 record_status grep -q '^0:psa_crypto_init:' tests/statuses.log
1273 rm -f tests/statuses.log
1274}
1275
Gilles Peskine8f073122018-11-27 15:58:47 +01001276component_test_full_cmake_clang () {
1277 msg "build: cmake, full config, clang" # ~ 50s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001278 scripts/config.py full
Gilles Peskine8f073122018-11-27 15:58:47 +01001279 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
1280 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001281
k-stachowiak0291cb72019-06-26 15:52:12 +02001282 msg "test: main suites (full config, clang)" # ~ 5s
Gilles Peskine8f073122018-11-27 15:58:47 +01001283 make test
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01001284
k-stachowiak0291cb72019-06-26 15:52:12 +02001285 msg "test: psa_constant_names (full config, clang)" # ~ 1s
Darryl Green45010a32019-02-06 13:43:58 +00001286 record_status tests/scripts/test_psa_constant_names.py
Gilles Peskine69e8f7f2020-02-26 19:51:43 +01001287
Gilles Peskine8f073122018-11-27 15:58:47 +01001288 msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
1289 if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001290
Andres Amaya Garcia2dadab72019-01-08 21:42:27 +00001291 msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min
Andres Amaya Garcia419bd002019-02-19 20:20:57 +00001292 if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001293
Gilles Peskine8f073122018-11-27 15:58:47 +01001294 msg "test: compat.sh ARIA + ChachaPoly"
1295 if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
1296}
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001297
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001298component_test_memsan_constant_flow () {
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001299 # This tests both (1) accesses to undefined memory, and (2) branches or
1300 # memory access depending on secret values. To distinguish between those:
1301 # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist?
1302 # - or alternatively, change the build type to MemSanDbg, which enables
1303 # origin tracking and nicer stack traces (which are useful for debugging
1304 # anyway), and check if the origin was TEST_CF_SECRET() or something else.
1305 msg "build: cmake MSan (clang), full config with constant flow testing"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001306 scripts/config.py full
1307 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
1308 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
1309 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1310 make
1311
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001312 msg "test: main suites (Msan + constant flow)"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001313 make test
1314}
1315
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001316component_test_valgrind_constant_flow () {
1317 # This tests both (1) everything that valgrind's memcheck usually checks
1318 # (heap buffer overflows, use of uninitialized memory, use-after-free,
1319 # etc.) and (2) branches or memory access depending on secret values,
1320 # which will be reported as uninitialized memory. To distinguish between
1321 # secret and actually uninitialized:
1322 # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist?
1323 # - or alternatively, build with debug info and manually run the offending
1324 # test suite with valgrind --track-origins=yes, then check if the origin
1325 # was TEST_CF_SECRET() or something else.
1326 msg "build: cmake release GCC, full config with constant flow testing"
1327 scripts/config.py full
1328 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND
1329 cmake -D CMAKE_BUILD_TYPE:String=Release .
1330 make
1331
1332 # this only shows a summary of the results (how many of each type)
1333 # details are left in Testing/<date>/DynamicAnalysis.xml
1334 msg "test: main suites (valgrind + constant flow)"
1335 make memcheck
1336}
1337
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001338component_test_default_no_deprecated () {
Gilles Peskine8386ea22020-04-30 09:07:29 +02001339 # Test that removing the deprecated features from the default
1340 # configuration leaves something consistent.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001341 msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
1342 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
1343 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1344
1345 msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
1346 make test
1347}
1348
1349component_test_full_no_deprecated () {
Gilles Peskine30de2e82020-04-20 21:39:22 +02001350 msg "build: make, full_no_deprecated config" # ~ 30s
1351 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001352 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1353
Gilles Peskine30de2e82020-04-20 21:39:22 +02001354 msg "test: make, full_no_deprecated config" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001355 make test
1356}
1357
Gilles Peskine8386ea22020-04-30 09:07:29 +02001358component_test_full_no_deprecated_deprecated_warning () {
1359 # Test that there is nothing deprecated in "full_no_deprecated".
1360 # A deprecated feature would trigger a warning (made fatal) from
1361 # MBEDTLS_DEPRECATED_WARNING.
Gilles Peskine30de2e82020-04-20 21:39:22 +02001362 msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
1363 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001364 scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
1365 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
1366 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1367
Gilles Peskine30de2e82020-04-20 21:39:22 +02001368 msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001369 make test
1370}
1371
Gilles Peskine8386ea22020-04-30 09:07:29 +02001372component_test_full_deprecated_warning () {
1373 # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
1374 # with only certain whitelisted types of warnings.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001375 msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001376 scripts/config.py full
1377 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001378 # Expect warnings from '#warning' directives in check_config.h.
1379 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +01001380
Gilles Peskine8386ea22020-04-30 09:07:29 +02001381 msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
1382 # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
1383 # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001384 # Expect warnings from '#warning' directives in check_config.h and
1385 # from the use of deprecated functions in test suites.
1386 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 +01001387
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001388 msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
1389 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001390}
Jaeden Ameroed93bdc2018-11-02 16:57:24 +00001391
Gilles Peskineec541fe2020-01-31 14:24:14 +01001392# Check that the specified libraries exist and are empty.
1393are_empty_libraries () {
1394 nm "$@" >/dev/null 2>/dev/null
1395 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
1396}
1397
1398component_build_crypto_default () {
1399 msg "build: make, crypto only"
1400 scripts/config.py crypto
Gilles Peskine6bb39152020-02-03 11:59:20 +01001401 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001402 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1403}
1404
1405component_build_crypto_full () {
1406 msg "build: make, crypto only, full config"
1407 scripts/config.py crypto_full
Gilles Peskine6bb39152020-02-03 11:59:20 +01001408 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001409 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1410}
1411
1412component_build_crypto_baremetal () {
1413 msg "build: make, crypto only, baremetal config"
1414 scripts/config.py crypto_baremetal
Gilles Peskine6bb39152020-02-03 11:59:20 +01001415 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001416 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1417}
1418
Gilles Peskine8f073122018-11-27 15:58:47 +01001419component_test_depends_curves () {
1420 msg "test/build: curves.pl (gcc)" # ~ 4 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001421 record_status tests/scripts/curves.pl
1422}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001423
John Durkopc14be902020-08-20 06:16:41 -07001424component_test_depends_curves_psa () {
1425 msg "test/build: curves.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)"
1426 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1427 record_status tests/scripts/curves.pl
1428}
1429
Gilles Peskine8f073122018-11-27 15:58:47 +01001430component_test_depends_hashes () {
1431 msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001432 record_status tests/scripts/depends-hashes.pl
1433}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001434
John Durkop2ec2eaa2020-08-24 18:29:15 -07001435component_test_depends_hashes_psa () {
1436 msg "test/build: depends-hashes.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)"
1437 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1438 record_status tests/scripts/depends-hashes.pl
1439}
1440
Gilles Peskine8f073122018-11-27 15:58:47 +01001441component_test_depends_pkalgs () {
1442 msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001443 record_status tests/scripts/depends-pkalgs.pl
1444}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001445
John Durkop619e09e2020-09-08 22:19:56 -07001446component_test_depends_pkalgs_psa () {
1447 msg "test/build: depends-pkalgs.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)"
1448 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001449 record_status tests/scripts/depends-pkalgs.pl
1450}
1451
Gilles Peskine8f073122018-11-27 15:58:47 +01001452component_build_key_exchanges () {
1453 msg "test/build: key-exchanges (gcc)" # ~ 1 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001454 record_status tests/scripts/key-exchanges.pl
1455}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001456
Gilles Peskine8f073122018-11-27 15:58:47 +01001457component_build_default_make_gcc_and_cxx () {
1458 msg "build: Unix make, -Os (gcc)" # ~ 30s
Gilles Peskine8f073122018-11-27 15:58:47 +01001459 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001460
Gilles Peskine8f073122018-11-27 15:58:47 +01001461 msg "test: verify header list in cpp_dummy_build.cpp"
1462 record_status check_headers_in_cpp
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001463
Gilles Peskine8f073122018-11-27 15:58:47 +01001464 msg "build: Unix make, incremental g++"
1465 make TEST_CPP=1
1466}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001467
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001468component_test_no_use_psa_crypto_full_cmake_asan() {
1469 # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
Gilles Peskinedc3a1792019-09-03 11:42:04 +02001470 msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001471 scripts/config.py full
1472 scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
1473 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1474 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1475 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskinedc6d8382020-04-12 14:21:55 +02001476 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001477 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Manuel Pégourié-Gonnardd8167e82019-02-01 11:12:52 +01001478 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001479 make
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +02001480
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001481 msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001482 make test
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +02001483
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001484 msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001485 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001486
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001487 msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001488 if_build_succeeded tests/compat.sh
Andrzej Kurek991f9fe2018-07-02 09:08:21 -04001489
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001490 msg "test: compat.sh RC4, DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001491 if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001492
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001493 msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001494 if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
1495}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001496
John Durkopd8959392020-09-20 23:09:17 -07001497component_test_psa_crypto_config_basic() {
Ronald Cron067de3b2021-03-11 11:49:03 +01001498 # Test the library excluding all Mbed TLS cryptographic support for which
1499 # we have an accelerator support. Acceleration is faked with the
1500 # transparent test driver.
1501 msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG + as much acceleration as supported"
John Durkopd8959392020-09-20 23:09:17 -07001502 scripts/config.py full
1503 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1504 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1505 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
Ronald Cron067de3b2021-03-11 11:49:03 +01001506
1507 # There is no intended accelerator support for ALG STREAM_CIPHER and
1508 # ALG_ECB_NO_PADDING. Therefore, asking for them in the build implies the
1509 # inclusion of the Mbed TLS cipher operations. As we want to test here with
1510 # cipher operations solely supported by accelerators, disabled those
1511 # PSA configuration options.
1512 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
1513 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
1514
1515 # Don't test DES encryption as:
1516 # 1) It is not an issue if we don't test all cipher types here.
1517 # 2) That way we don't have to modify in psa_crypto.c the compilation
1518 # guards MBEDTLS_PSA_BUILTIN_KEY_TYPE_DES for the code they guard to be
1519 # available to the test driver. Modifications that we would need to
1520 # revert when we move to compile the test driver separately.
1521 # We also disable MBEDTLS_DES_C as the dependencies on DES in PSA test
1522 # suites are still based on MBEDTLS_DES_C and not PSA_WANT_KEY_TYPE_DES.
1523 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_DES
1524 scripts/config.py unset MBEDTLS_DES_C
1525
Gilles Peskinefe0acc62021-09-20 19:20:04 +02001526 loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL"
1527 loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
Ronald Cron17b3afc2020-12-10 18:17:09 +01001528 loc_cflags="${loc_cflags} -I../tests/include -O2"
1529
1530 make CC=gcc CFLAGS="$loc_cflags" LDFLAGS="$ASAN_CFLAGS"
1531 unset loc_cflags
John Durkopd8959392020-09-20 23:09:17 -07001532
John Durkop4377bf72020-10-23 01:26:57 -07001533 msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG"
1534 make test
1535}
1536
1537component_test_psa_crypto_config_no_driver() {
1538 # full plus MBEDTLS_PSA_CRYPTO_CONFIG
1539 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
1540 scripts/config.py full
1541 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1542 scripts/config.py unset MBEDTLS_PSA_CRYPTO_DRIVERS
1543 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkope7012c72020-10-26 09:55:01 -07001544 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkop4377bf72020-10-23 01:26:57 -07001545
1546 msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
John Durkopd8959392020-09-20 23:09:17 -07001547 make test
1548}
1549
John Durkop8ac0b802020-10-23 01:32:15 -07001550# This should be renamed to test and updated once the accelerator ECDSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08001551component_build_psa_accel_alg_ecdsa() {
John Durkopdd544e12020-10-12 21:47:19 -07001552 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_ECDSA
1553 # without MBEDTLS_ECDSA_C
John Durkop28baa1f2020-10-23 00:51:52 -07001554 # PSA_WANT_ALG_ECDSA and PSA_WANT_ALG_DETERMINISTIC_ECDSA are already
1555 # set in include/psa/crypto_config.h
John Durkopdd544e12020-10-12 21:47:19 -07001556 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_ECDSA without MBEDTLS_ECDSA_C"
John Durkopd8959392020-09-20 23:09:17 -07001557 scripts/config.py full
1558 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1559 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1560 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1561 scripts/config.py unset MBEDTLS_ECDSA_C
John Durkop28baa1f2020-10-23 00:51:52 -07001562 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1563 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
John Durkopd8959392020-09-20 23:09:17 -07001564 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkop28baa1f2020-10-23 00:51:52 -07001565 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDSA -DMBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopd8959392020-09-20 23:09:17 -07001566}
1567
John Durkopd0321952020-10-29 21:37:36 -07001568# 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 -08001569component_build_psa_accel_alg_ecdh() {
John Durkopd0321952020-10-29 21:37:36 -07001570 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_ECDH
1571 # without MBEDTLS_ECDH_C
1572 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C"
1573 scripts/config.py full
1574 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1575 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1576 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1577 scripts/config.py unset MBEDTLS_ECDH_C
1578 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
1579 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1580 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1581 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
1582 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
1583 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1584 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1585}
1586
John Durkopf4c4cb02020-10-28 20:09:55 -07001587# 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 -08001588component_build_psa_accel_key_type_ecc_key_pair() {
John Durkop9814fa22020-11-04 12:28:15 -08001589 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_ECC_KEY_PAIR
1590 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR"
John Durkopf4c4cb02020-10-28 20:09:55 -07001591 scripts/config.py full
1592 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1593 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1594 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08001595 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 -08001596 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 -07001597 # 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 -08001598 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 -07001599}
1600
1601# 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 -08001602component_build_psa_accel_key_type_ecc_public_key() {
John Durkop9814fa22020-11-04 12:28:15 -08001603 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY
1604 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY"
John Durkopf4c4cb02020-10-28 20:09:55 -07001605 scripts/config.py full
1606 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1607 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1608 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08001609 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
1610 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR
John Durkopf4c4cb02020-10-28 20:09:55 -07001611 # 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 -08001612 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 -07001613}
1614
John Durkopd0321952020-10-29 21:37:36 -07001615# 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 -08001616component_build_psa_accel_alg_hmac() {
John Durkopd0321952020-10-29 21:37:36 -07001617 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_HMAC
1618 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HMAC"
1619 scripts/config.py full
1620 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1621 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1622 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1623 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1624 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1625}
1626
1627# 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 -08001628component_build_psa_accel_alg_hkdf() {
John Durkopd0321952020-10-29 21:37:36 -07001629 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_HKDF
1630 # without MBEDTLS_HKDF_C
1631 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C"
1632 scripts/config.py full
1633 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1634 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1635 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1636 scripts/config.py unset MBEDTLS_HKDF_C
John Durkopbd069d32020-10-31 22:14:03 -07001637 # Make sure to unset TLS1_3_EXPERIMENTAL since it requires HKDF_C and will not build properly without it.
1638 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
John Durkopd0321952020-10-29 21:37:36 -07001639 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1640 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1641}
1642
John Durkop1b7ee052020-11-27 08:51:22 -08001643# This should be renamed to test and updated once the accelerator MD2 code is in place and ready to test.
1644component_build_psa_accel_alg_md2() {
1645 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_MD2 without other hashes
1646 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD2 - other hashes"
1647 scripts/config.py full
1648 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1649 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1650 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1651 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1652 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1653 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1654 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1655 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1656 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1657 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1658 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1659 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1660 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD2 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1661}
1662
1663# This should be renamed to test and updated once the accelerator MD4 code is in place and ready to test.
1664component_build_psa_accel_alg_md4() {
1665 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_MD4 without other hashes
1666 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD4 - other hashes"
1667 scripts/config.py full
1668 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1669 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1670 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1671 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1672 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1673 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1674 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1675 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1676 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1677 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1678 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1679 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1680 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD4 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1681}
1682
1683# This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test.
1684component_build_psa_accel_alg_md5() {
1685 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_MD5 without other hashes
1686 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD5 - other hashes"
1687 scripts/config.py full
1688 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1689 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1690 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1691 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1692 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1693 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1694 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1695 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1696 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1697 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1698 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1699 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1700 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1701}
1702
1703# This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test.
1704component_build_psa_accel_alg_ripemd160() {
1705 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RIPEMD160 without other hashes
1706 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RIPEMD160 - other hashes"
1707 scripts/config.py full
1708 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1709 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1710 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1711 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1712 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1713 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1714 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1715 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1716 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1717 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1718 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1719 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1720 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1721}
1722
1723# This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test.
1724component_build_psa_accel_alg_sha1() {
1725 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_1 without other hashes
1726 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_1 - other hashes"
1727 scripts/config.py full
1728 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1729 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1730 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1731 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1732 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1733 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1734 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1735 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1736 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1737 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1738 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1739 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1740 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1741}
1742
1743# This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test.
1744component_build_psa_accel_alg_sha224() {
1745 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_224 without other hashes
1746 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_224 - other hashes"
1747 scripts/config.py full
1748 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1749 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1750 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1751 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1752 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1753 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1754 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1755 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1756 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1757 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1758 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1759 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1760}
1761
1762# This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test.
1763component_build_psa_accel_alg_sha256() {
1764 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_256 without other hashes
1765 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_256 - other hashes"
1766 scripts/config.py full
1767 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1768 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1769 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1770 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1771 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1772 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1773 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1774 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1775 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1776 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1777 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
1778 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1779 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1780}
1781
1782# This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test.
1783component_build_psa_accel_alg_sha384() {
1784 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_384 without other hashes
1785 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_384 - other hashes"
1786 scripts/config.py full
1787 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1788 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1789 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1790 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1791 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1792 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1793 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1794 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1795 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1796 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1797 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1798 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1799}
1800
1801# This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test.
1802component_build_psa_accel_alg_sha512() {
1803 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_512 without other hashes
1804 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_512 - other hashes"
1805 scripts/config.py full
1806 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1807 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1808 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1809 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1810 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1811 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1812 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
1813 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
1814 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
1815 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
1816 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
1817 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1818 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1819}
1820
John Durkopd0321952020-10-29 21:37:36 -07001821# 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 -08001822component_build_psa_accel_alg_rsa_pkcs1v15_crypt() {
John Durkopbd069d32020-10-31 22:14:03 -07001823 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
1824 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
John Durkopd0321952020-10-29 21:37:36 -07001825 scripts/config.py full
1826 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1827 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1828 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkopbd069d32020-10-31 22:14:03 -07001829 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
John Durkop7fc75ea2020-11-03 19:05:36 -08001830 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
1831 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
1832 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopd0321952020-10-29 21:37:36 -07001833 # 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 -07001834 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1835}
1836
1837# 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 -08001838component_build_psa_accel_alg_rsa_pkcs1v15_sign() {
John Durkopbd069d32020-10-31 22:14:03 -07001839 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PKCS1V15_SIGN and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY
1840 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
1841 scripts/config.py full
1842 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1843 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1844 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1845 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
John Durkop7fc75ea2020-11-03 19:05:36 -08001846 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
1847 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
1848 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07001849 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1850 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1851}
1852
1853# 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 -08001854component_build_psa_accel_alg_rsa_oaep() {
John Durkopbd069d32020-10-31 22:14:03 -07001855 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_OAEP and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY
1856 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
1857 scripts/config.py full
1858 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1859 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1860 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1861 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_OAEP 1
John Durkop7fc75ea2020-11-03 19:05:36 -08001862 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
1863 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
1864 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07001865 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1866 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1867}
1868
1869# 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 -08001870component_build_psa_accel_alg_rsa_pss() {
John Durkopbd069d32020-10-31 22:14:03 -07001871 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PSS and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY
1872 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
1873 scripts/config.py full
1874 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1875 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1876 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1877 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
John Durkop7fc75ea2020-11-03 19:05:36 -08001878 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
1879 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
1880 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
John Durkopbd069d32020-10-31 22:14:03 -07001881 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1882 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
1883}
1884
1885# 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 -08001886component_build_psa_accel_key_type_rsa_key_pair() {
John Durkopbd069d32020-10-31 22:14:03 -07001887 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_RSA_KEY_PAIR and PSA_WANT_ALG_RSA_PSS
1888 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + PSA_WANT_ALG_RSA_PSS"
1889 scripts/config.py full
1890 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1891 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1892 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1893 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
1894 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1
1895 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1896 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"
1897}
1898
1899# 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 -08001900component_build_psa_accel_key_type_rsa_public_key() {
John Durkopbd069d32020-10-31 22:14:03 -07001901 # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY and PSA_WANT_ALG_RSA_PSS
1902 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS"
1903 scripts/config.py full
1904 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1905 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1906 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1907 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
1908 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
1909 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1910 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 -07001911}
1912
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001913component_test_check_params_functionality () {
1914 msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001915 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001916 # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001917 scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
Ronald Crona1236142020-07-01 16:01:21 +02001918 make CC=gcc CFLAGS='-Werror -O1' all test
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001919}
1920
Gilles Peskineb28636b2019-01-02 19:06:24 +01001921component_test_check_params_without_platform () {
1922 msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001923 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001924 # Keep MBEDTLS_PARAM_FAILED as assert.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001925 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
1926 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
1927 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
1928 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
Gilles Peskine32e889d2020-04-12 23:43:28 +02001929 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001930 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
1931 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
1932 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1933 scripts/config.py unset MBEDTLS_PLATFORM_C
Gilles Peskineb28636b2019-01-02 19:06:24 +01001934 make CC=gcc CFLAGS='-Werror -O1' all test
1935}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001936
Gilles Peskineb28636b2019-01-02 19:06:24 +01001937component_test_check_params_silent () {
1938 msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001939 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001940 # Set MBEDTLS_PARAM_FAILED to nothing.
Gilles Peskineb28636b2019-01-02 19:06:24 +01001941 sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
1942 make CC=gcc CFLAGS='-Werror -O1' all test
1943}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001944
Gilles Peskine8f073122018-11-27 15:58:47 +01001945component_test_no_platform () {
1946 # Full configuration build, without platform support, file IO and net sockets.
1947 # This should catch missing mbedtls_printf definitions, and by disabling file
1948 # IO, it should catch missing '#include <stdio.h>'
1949 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001950 scripts/config.py full
1951 scripts/config.py unset MBEDTLS_PLATFORM_C
1952 scripts/config.py unset MBEDTLS_NET_C
1953 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
1954 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
1955 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
1956 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
1957 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
1958 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
Gilles Peskine32e889d2020-04-12 23:43:28 +02001959 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001960 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1961 scripts/config.py unset MBEDTLS_FS_IO
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001962 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001963 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
1964 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001965 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
1966 # to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001967 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
1968 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
Gilles Peskine8f073122018-11-27 15:58:47 +01001969}
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +00001970
Gilles Peskine8f073122018-11-27 15:58:47 +01001971component_build_no_std_function () {
1972 # catch compile bugs in _uninit functions
1973 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001974 scripts/config.py full
1975 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
1976 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02001977 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001978 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Gilles Peskine8f073122018-11-27 15:58:47 +01001979}
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +01001980
Gilles Peskine8f073122018-11-27 15:58:47 +01001981component_build_no_ssl_srv () {
1982 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001983 scripts/config.py full
1984 scripts/config.py unset MBEDTLS_SSL_SRV_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001985 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01001986}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02001987
Gilles Peskine8f073122018-11-27 15:58:47 +01001988component_build_no_ssl_cli () {
1989 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001990 scripts/config.py full
1991 scripts/config.py unset MBEDTLS_SSL_CLI_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001992 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01001993}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02001994
Gilles Peskine8f073122018-11-27 15:58:47 +01001995component_build_no_sockets () {
1996 # Note, C99 compliance can also be tested with the sockets support disabled,
1997 # as that requires a POSIX platform (which isn't the same as C99).
1998 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001999 scripts/config.py full
2000 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
2001 scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002002 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01002003}
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +02002004
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002005component_test_memory_buffer_allocator_backtrace () {
2006 msg "build: default config with memory buffer allocator and backtrace enabled"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002007 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2008 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2009 scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
2010 scripts/config.py set MBEDTLS_MEMORY_DEBUG
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002011 CC=gcc cmake .
2012 make
2013
2014 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
2015 make test
2016}
2017
2018component_test_memory_buffer_allocator () {
2019 msg "build: default config with memory buffer allocator"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002020 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2021 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002022 CC=gcc cmake .
2023 make
2024
2025 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2026 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01002027
2028 msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2029 # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
2030 if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy'
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002031}
2032
Gilles Peskine8f073122018-11-27 15:58:47 +01002033component_test_no_max_fragment_length () {
2034 # Run max fragment length tests with MFL disabled
2035 msg "build: default config except MFL extension (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002036 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Gilles Peskine8f073122018-11-27 15:58:47 +01002037 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2038 make
Hanno Becker5175ac62017-09-18 15:36:25 +01002039
Gilles Peskine8f073122018-11-27 15:58:47 +01002040 msg "test: ssl-opt.sh, MFL-related tests"
2041 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
2042}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002043
Hanno Becker545ced42019-02-19 11:10:48 +00002044component_test_asan_remove_peer_certificate () {
2045 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002046 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
Hanno Becker545ced42019-02-19 11:10:48 +00002047 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2048 make
2049
2050 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2051 make test
2052
2053 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2054 if_build_succeeded tests/ssl-opt.sh
2055
2056 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2057 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002058
2059 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2060 if_build_succeeded tests/context-info.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002061}
2062
Gilles Peskine8f073122018-11-27 15:58:47 +01002063component_test_no_max_fragment_length_small_ssl_out_content_len () {
2064 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002065 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2066 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
2067 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01002068 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2069 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10002070
Gilles Peskine8f073122018-11-27 15:58:47 +01002071 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
2072 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002073
2074 msg "test: context-info.sh (disabled MFL extension case)"
2075 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01002076}
Angus Grattonc4dd0732018-04-11 16:28:39 +10002077
Darryl Greenaad82f92019-12-02 10:53:11 +00002078component_test_variable_ssl_in_out_buffer_len () {
2079 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
2080 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2081 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2082 make
2083
2084 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
2085 make test
2086
2087 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
2088 if_build_succeeded tests/ssl-opt.sh
2089
2090 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
2091 if_build_succeeded tests/compat.sh
2092}
2093
2094component_test_variable_ssl_in_out_buffer_len_CID () {
2095 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)"
2096 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2097 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
2098
2099 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2100 make
2101
2102 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID"
2103 make test
2104
2105 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
2106 if_build_succeeded tests/ssl-opt.sh
2107
2108 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
2109 if_build_succeeded tests/compat.sh
2110}
2111
2112component_test_variable_ssl_in_out_buffer_len_record_splitting () {
2113 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)"
2114 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2115 scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING
2116
2117 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2118 make
2119
2120 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING"
2121 make test
2122
2123 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
2124 if_build_succeeded tests/ssl-opt.sh
2125
2126 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
2127 if_build_succeeded tests/compat.sh
2128}
2129
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002130component_test_ssl_alloc_buffer_and_mfl () {
2131 msg "build: default config with memory buffer allocator and MFL extension"
2132 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2133 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2134 scripts/config.py set MBEDTLS_MEMORY_DEBUG
2135 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2136 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2137 CC=gcc cmake .
2138 make
2139
2140 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
2141 make test
2142
2143 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
2144 if_build_succeeded tests/ssl-opt.sh -f "Handshake memory usage"
2145}
2146
Gilles Peskine636c26a2020-03-04 20:46:15 +01002147component_test_when_no_ciphersuites_have_mac () {
2148 msg "build: when no ciphersuites have MAC"
2149 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
2150 scripts/config.py unset MBEDTLS_ARC4_C
2151 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2152 make
2153
2154 msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
2155 make test
2156
2157 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
2158 if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
2159}
2160
Gilles Peskine8f073122018-11-27 15:58:47 +01002161component_test_null_entropy () {
2162 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002163 scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY
2164 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
2165 scripts/config.py set MBEDTLS_ENTROPY_C
2166 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002167 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002168 scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT
2169 scripts/config.py unset MBEDTLS_HAVEGE_C
Gilles Peskine5fa32a72019-01-06 19:48:30 +00002170 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON .
Gilles Peskine8f073122018-11-27 15:58:47 +01002171 make
Janos Follath06c54002016-06-09 13:57:40 +01002172
Gilles Peskine8f073122018-11-27 15:58:47 +01002173 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
2174 make test
2175}
Janos Follath06c54002016-06-09 13:57:40 +01002176
Raoul Strackxa4e86142020-06-15 17:03:13 +02002177component_test_no_date_time () {
2178 msg "build: default config without MBEDTLS_HAVE_TIME_DATE"
2179 scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
2180 CC=gcc cmake
2181 make
2182
2183 msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites"
2184 make test
2185}
2186
Gilles Peskine8f073122018-11-27 15:58:47 +01002187component_test_platform_calloc_macro () {
2188 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002189 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2190 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
2191 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
Gilles Peskine8f073122018-11-27 15:58:47 +01002192 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2193 make
Hanno Beckere5fecec2018-10-11 11:02:52 +01002194
Gilles Peskine8f073122018-11-27 15:58:47 +01002195 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
2196 make test
2197}
Hanno Beckere5fecec2018-10-11 11:02:52 +01002198
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002199component_test_malloc_0_null () {
2200 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002201 scripts/config.py full
Gilles Peskine004206c2019-10-21 17:11:33 +02002202 make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002203
2204 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
2205 make test
2206
2207 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
2208 # Just the calloc selftest. "make test" ran the others as part of the
2209 # test suites.
2210 if_build_succeeded programs/test/selftest calloc
Gilles Peskine765d2402020-02-11 18:26:34 +01002211
2212 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
2213 # Run a subset of the tests. The choice is a balance between coverage
2214 # and time (including time indirectly wasted due to flaky tests).
2215 # The current choice is to skip tests whose description includes
2216 # "proxy", which is an approximation of skipping tests that use the
2217 # UDP proxy, which tend to be slower and flakier.
2218 if_build_succeeded tests/ssl-opt.sh -e 'proxy'
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002219}
2220
Gilles Peskine8f073122018-11-27 15:58:47 +01002221component_test_aes_fewer_tables () {
2222 msg "build: default config with AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002223 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01002224 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002225
Gilles Peskine8f073122018-11-27 15:58:47 +01002226 msg "test: AES_FEWER_TABLES"
2227 make test
2228}
Hanno Becker83ebf782017-07-07 12:29:15 +01002229
Gilles Peskine8f073122018-11-27 15:58:47 +01002230component_test_aes_rom_tables () {
2231 msg "build: default config with AES_ROM_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002232 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01002233 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002234
Gilles Peskine8f073122018-11-27 15:58:47 +01002235 msg "test: AES_ROM_TABLES"
2236 make test
2237}
Hanno Becker83ebf782017-07-07 12:29:15 +01002238
Gilles Peskine8f073122018-11-27 15:58:47 +01002239component_test_aes_fewer_tables_and_rom_tables () {
2240 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002241 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
2242 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01002243 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002244
Gilles Peskine8f073122018-11-27 15:58:47 +01002245 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
2246 make test
2247}
2248
Gilles Peskine592f5912019-10-07 18:49:32 +02002249component_test_ctr_drbg_aes_256_sha_256 () {
2250 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002251 scripts/config.py full
2252 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2253 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02002254 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2255 make
2256
2257 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
2258 make test
2259}
2260
2261component_test_ctr_drbg_aes_128_sha_512 () {
2262 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002263 scripts/config.py full
2264 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2265 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
Gilles Peskine592f5912019-10-07 18:49:32 +02002266 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2267 make
2268
2269 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
2270 make test
2271}
2272
2273component_test_ctr_drbg_aes_128_sha_256 () {
2274 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002275 scripts/config.py full
2276 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2277 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
2278 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02002279 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2280 make
2281
2282 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
2283 make test
2284}
2285
Gilles Peskinef96aefe2019-07-24 14:58:38 +02002286component_test_se_default () {
2287 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002288 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine004206c2019-10-21 17:11:33 +02002289 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinef96aefe2019-07-24 14:58:38 +02002290
2291 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
2292 make test
2293}
2294
Steven Cooremand57203d2020-07-16 20:28:59 +02002295component_test_psa_crypto_drivers () {
Steven Cooreman55ae2172020-07-17 19:46:15 +02002296 msg "build: MBEDTLS_PSA_CRYPTO_DRIVERS w/ driver hooks"
Steven Cooreman753f9732021-03-15 11:38:44 +01002297 scripts/config.py full
Steven Cooremand57203d2020-07-16 20:28:59 +02002298 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
Steven Cooreman6801f082021-02-19 17:21:22 +01002299 scripts/config.py set MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
Gilles Peskinefe0acc62021-09-20 19:20:04 +02002300 loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL"
2301 loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
Ronald Cron17b3afc2020-12-10 18:17:09 +01002302 loc_cflags="${loc_cflags} -I../tests/include -O2"
2303
2304 make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
2305 unset loc_cflags
Steven Cooremand57203d2020-07-16 20:28:59 +02002306
Steven Cooreman753f9732021-03-15 11:38:44 +01002307 msg "test: full + MBEDTLS_PSA_CRYPTO_DRIVERS"
Steven Cooremand57203d2020-07-16 20:28:59 +02002308 make test
2309}
2310
Gilles Peskine8f073122018-11-27 15:58:47 +01002311component_test_make_shared () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002312 msg "build/test: make shared" # ~ 40s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04002313 make SHARED=1 all check
Gilles Peskine56c01612019-07-03 20:43:32 +02002314 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskine8f073122018-11-27 15:58:47 +01002315}
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +02002316
Gilles Peskinecf740502019-07-03 20:43:05 +02002317component_test_cmake_shared () {
2318 msg "build/test: cmake shared" # ~ 2min
2319 cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
2320 make
Gilles Peskine56c01612019-07-03 20:43:32 +02002321 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskinecf740502019-07-03 20:43:05 +02002322 make test
2323}
2324
Gilles Peskineec10bf12019-09-20 19:56:06 +02002325test_build_opt () {
2326 info=$1 cc=$2; shift 2
2327 for opt in "$@"; do
2328 msg "build/test: $cc $opt, $info" # ~ 30s
Gilles Peskinee094a182020-04-14 20:08:41 +02002329 make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Gilles Peskineec10bf12019-09-20 19:56:06 +02002330 # We're confident enough in compilers to not run _all_ the tests,
2331 # but at least run the unit tests. In particular, runs with
2332 # optimizations use inline assembly whereas runs with -O0
2333 # skip inline assembly.
2334 make test # ~30s
2335 make clean
2336 done
2337}
2338
2339component_test_clang_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002340 scripts/config.py full
Gilles Peskineec10bf12019-09-20 19:56:06 +02002341 test_build_opt 'full config' clang -O0 -Os -O2
2342}
2343
2344component_test_gcc_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002345 scripts/config.py full
Gilles Peskineec10bf12019-09-20 19:56:06 +02002346 test_build_opt 'full config' gcc -O0 -Os -O2
2347}
2348
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02002349component_build_mbedtls_config_file () {
2350 msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
2351 # Use the full config so as to catch a maximum of places where
2352 # the check of MBEDTLS_CONFIG_FILE might be missing.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002353 scripts/config.py full
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02002354 sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h
2355 echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
2356 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
2357 rm -f full_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002358}
2359
Gilles Peskine8f073122018-11-27 15:58:47 +01002360component_test_m32_o0 () {
Simon Butcher8e6a22a2018-07-20 21:27:33 +01002361 # Build once with -O0, to compile out the i386 specific inline assembly
2362 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002363 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02002364 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01002365
Simon Butcher8e6a22a2018-07-20 21:27:33 +01002366 msg "test: i386, make, gcc -O0 (ASan build)"
2367 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01002368}
Gilles Peskine878cf602019-01-06 20:50:38 +00002369support_test_m32_o0 () {
2370 case $(uname -m) in
2371 *64*) true;;
2372 *) false;;
2373 esac
2374}
Simon Butcher8e6a22a2018-07-20 21:27:33 +01002375
Gilles Peskine8f073122018-11-27 15:58:47 +01002376component_test_m32_o1 () {
Simon Butcher8e6a22a2018-07-20 21:27:33 +01002377 # Build again with -O1, to compile in the i386 specific inline assembly
2378 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002379 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02002380 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS"
Simon Butcher8e6a22a2018-07-20 21:27:33 +01002381
2382 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01002383 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01002384
2385 msg "test ssl-opt.sh, i386, make, gcc-O1"
2386 if_build_succeeded tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01002387}
Gilles Peskine878cf602019-01-06 20:50:38 +00002388support_test_m32_o1 () {
2389 support_test_m32_o0 "$@"
2390}
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01002391
Gilles Peskine0c6b7992019-04-12 20:29:48 +02002392component_test_m32_everest () {
2393 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002394 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
2395 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
Gilles Peskine8fd59422019-10-21 17:11:33 +02002396 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Gilles Peskine0c6b7992019-04-12 20:29:48 +02002397
2398 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
2399 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01002400
2401 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
2402 if_build_succeeded tests/ssl-opt.sh -f ECDH
2403
2404 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
2405 # Exclude some symmetric ciphers that are redundant here to gain time.
2406 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine0c6b7992019-04-12 20:29:48 +02002407}
2408support_test_m32_everest () {
2409 support_test_m32_o0 "$@"
2410}
2411
Gilles Peskine8f073122018-11-27 15:58:47 +01002412component_test_mx32 () {
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01002413 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002414 scripts/config.py full
Gilles Peskine5d26e7c2019-06-07 14:50:09 +02002415 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01002416
2417 msg "test: 64-bit ILP32, make, gcc"
2418 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01002419}
Gilles Peskine878cf602019-01-06 20:50:38 +00002420support_test_mx32 () {
2421 case $(uname -m) in
2422 amd64|x86_64) true;;
2423 *) false;;
2424 esac
2425}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002426
Peter Kolbus60c6da22018-12-27 06:59:04 -06002427component_test_min_mpi_window_size () {
2428 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002429 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
Peter Kolbus60c6da22018-12-27 06:59:04 -06002430 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2431 make
2432
2433 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
2434 make test
2435}
2436
Gilles Peskine8f073122018-11-27 15:58:47 +01002437component_test_have_int32 () {
2438 msg "build: gcc, force 32-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002439 scripts/config.py unset MBEDTLS_HAVE_ASM
2440 scripts/config.py unset MBEDTLS_AESNI_C
2441 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01002442 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01002443
Gilles Peskine8f073122018-11-27 15:58:47 +01002444 msg "test: gcc, force 32-bit bignum limbs"
2445 make test
2446}
Andres Amaya Garciafe843a32017-07-20 13:21:34 +01002447
Gilles Peskine8f073122018-11-27 15:58:47 +01002448component_test_have_int64 () {
2449 msg "build: gcc, force 64-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002450 scripts/config.py unset MBEDTLS_HAVE_ASM
2451 scripts/config.py unset MBEDTLS_AESNI_C
2452 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01002453 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Gilles Peskine14c3c062018-01-29 21:25:12 +01002454
Gilles Peskine8f073122018-11-27 15:58:47 +01002455 msg "test: gcc, force 64-bit bignum limbs"
2456 make test
2457}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002458
Gilles Peskine8f073122018-11-27 15:58:47 +01002459component_test_no_udbl_division () {
2460 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002461 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002462 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine8f073122018-11-27 15:58:47 +01002463 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002464
Gilles Peskine8f073122018-11-27 15:58:47 +01002465 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
2466 make test
2467}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002468
Gilles Peskine8f073122018-11-27 15:58:47 +01002469component_test_no_64bit_multiplication () {
2470 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002471 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002472 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine8f073122018-11-27 15:58:47 +01002473 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002474
Gilles Peskine8f073122018-11-27 15:58:47 +01002475 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
2476 make test
2477}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002478
Gilles Peskine3809f5f2020-11-09 15:40:05 +01002479component_test_no_strings () {
2480 msg "build: no strings" # ~10s
2481 scripts/config.py full
2482 # Disable options that activate a large amount of string constants.
2483 scripts/config.py unset MBEDTLS_DEBUG_C
2484 scripts/config.py unset MBEDTLS_ERROR_C
2485 scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY
2486 scripts/config.py unset MBEDTLS_VERSION_FEATURES
2487 make CFLAGS='-Werror -Os'
2488
2489 msg "test: no strings" # ~ 10s
2490 make test
2491}
2492
Gilles Peskine8f073122018-11-27 15:58:47 +01002493component_build_arm_none_eabi_gcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02002494 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002495 scripts/config.py baremetal
Gilles Peskineaeedd742020-09-02 11:03:04 +02002496 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 +02002497
2498 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1"
2499 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01002500}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002501
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02002502component_build_arm_linux_gnueabi_gcc_arm5vte () {
2503 msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002504 scripts/config.py baremetal
Gilles Peskine2c897d72019-08-09 16:05:05 +02002505 # Build for a target platform that's close to what Debian uses
2506 # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
2507 # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments.
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02002508 # Build everything including programs, see for example
2509 # https://github.com/ARMmbed/mbedtls/pull/3449#issuecomment-675313720
2510 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'
2511
2512 msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1"
2513 ${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o
2514}
2515support_build_arm_linux_gnueabi_gcc_arm5vte () {
2516 type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
2517}
2518
2519component_build_arm_none_eabi_gcc_arm5vte () {
2520 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
2521 scripts/config.py baremetal
2522 # This is an imperfect substitute for
2523 # component_build_arm_linux_gnueabi_gcc_arm5vte
Manuel Pégourié-Gonnard9a260a62021-07-06 09:44:59 +02002524 # in case the gcc-arm-linux-gnueabi toolchain is not available
Gilles Peskineaeedd742020-09-02 11:03:04 +02002525 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 +02002526
2527 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1"
2528 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine93e4e032019-08-05 11:34:25 +02002529}
2530
Gilles Peskine6e2fb862020-04-30 23:00:53 +02002531component_build_arm_none_eabi_gcc_m0plus () {
2532 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s
2533 scripts/config.py baremetal
Gilles Peskineaeedd742020-09-02 11:03:04 +02002534 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 +02002535
2536 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os"
2537 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine6e2fb862020-04-30 23:00:53 +02002538}
2539
Gilles Peskine8f073122018-11-27 15:58:47 +01002540component_build_arm_none_eabi_gcc_no_udbl_division () {
Gilles Peskine6d061342020-04-30 18:19:32 +02002541 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002542 scripts/config.py baremetal
2543 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskineaeedd742020-09-02 11:03:04 +02002544 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 +01002545 echo "Checking that software 64-bit division is not required"
2546 if_build_succeeded not grep __aeabi_uldiv library/*.o
2547}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002548
Gilles Peskine8f073122018-11-27 15:58:47 +01002549component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
Gilles Peskine6d061342020-04-30 18:19:32 +02002550 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002551 scripts/config.py baremetal
2552 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskineaeedd742020-09-02 11:03:04 +02002553 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 +01002554 echo "Checking that software 64-bit multiplication is not required"
2555 if_build_succeeded not grep __aeabi_lmul library/*.o
2556}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02002557
Gilles Peskine8f073122018-11-27 15:58:47 +01002558component_build_armcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02002559 msg "build: ARM Compiler 5"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002560 scripts/config.py baremetal
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002561 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02002562
2563 msg "size: ARM Compiler 5"
2564 "$ARMC5_FROMELF" -z library/*.o
2565
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002566 make clean
Andres AG87bb5772016-09-27 15:05:15 +01002567
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002568 # ARM Compiler 6 - Target ARMv7-A
2569 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02002570
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002571 # ARM Compiler 6 - Target ARMv7-M
2572 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02002573
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002574 # ARM Compiler 6 - Target ARMv8-A - AArch32
2575 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02002576
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002577 # ARM Compiler 6 - Target ARMv8-M
2578 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02002579
Gilles Peskinebca6ab92017-12-19 18:24:31 +01002580 # ARM Compiler 6 - Target ARMv8-A - AArch64
2581 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Gilles Peskine8f073122018-11-27 15:58:47 +01002582}
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01002583
Manuel Pégourié-Gonnarddd8807f2020-02-26 09:56:27 +01002584component_build_ssl_hw_record_accel() {
2585 msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled"
2586 scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL
2587 make CFLAGS='-Werror -O1'
2588}
2589
Hanno Beckera711f6e2020-05-04 12:03:51 +01002590component_test_tls13_experimental () {
2591 msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
2592 scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
2593 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2594 make
2595 msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
2596 make test
2597}
2598
Gilles Peskine8f073122018-11-27 15:58:47 +01002599component_build_mingw () {
2600 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04002601 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Hanno Beckere963efa2018-01-03 10:03:43 +00002602
Gilles Peskine8f073122018-11-27 15:58:47 +01002603 # note Make tests only builds the tests, but doesn't run them
Andrzej Kurek232e8f92019-10-03 03:18:01 -04002604 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01002605 make WINDOWS_BUILD=1 clean
Gilles Peskine2a458da2017-05-12 15:26:58 +02002606
Gilles Peskine8f073122018-11-27 15:58:47 +01002607 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04002608 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
2609 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01002610 make WINDOWS_BUILD=1 clean
2611}
Jaeden Amero117b8a42019-04-17 15:19:26 +01002612support_build_mingw() {
2613 case $(i686-w64-mingw32-gcc -dumpversion) in
2614 [0-5]*) false;;
2615 *) true;;
2616 esac
2617}
Simon Butcher91aef332016-11-17 09:20:50 +00002618
Gilles Peskine8f073122018-11-27 15:58:47 +01002619component_test_memsan () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002620 msg "build: MSan (clang)" # ~ 1 min 20s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002621 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002622 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
2623 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02002624
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002625 msg "test: main suites (MSan)" # ~ 10s
2626 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01002627
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002628 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +01002629 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01002630
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002631 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01002632
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002633 if [ "$MEMORY" -gt 0 ]; then
2634 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +01002635 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002636 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01002637}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002638
Gilles Peskine69f190e2019-01-10 00:11:42 +01002639component_test_valgrind () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002640 msg "build: Release (clang)"
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002641 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
2642 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00002643
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002644 msg "test: main suites valgrind (Release)"
2645 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00002646
Gilles Peskine636c26a2020-03-04 20:46:15 +01002647 # Optional parts (slow; currently broken on OS X because programs don't
2648 # seem to receive signals under valgrind on OS X).
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002649 if [ "$MEMORY" -gt 0 ]; then
2650 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01002651 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002652 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00002653
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002654 if [ "$MEMORY" -gt 1 ]; then
2655 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01002656 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002657 fi
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002658
2659 if [ "$MEMORY" -gt 0 ]; then
2660 msg "test: context-info.sh --memcheck (Release)"
2661 if_build_succeeded tests/context-info.sh --memcheck
2662 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01002663}
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00002664
Gilles Peskine8f073122018-11-27 15:58:47 +01002665component_test_cmake_out_of_source () {
2666 msg "build: cmake 'out-of-source' build"
Gilles Peskine8f073122018-11-27 15:58:47 +01002667 MBEDTLS_ROOT_DIR="$PWD"
2668 mkdir "$OUT_OF_SOURCE_DIR"
2669 cd "$OUT_OF_SOURCE_DIR"
2670 cmake "$MBEDTLS_ROOT_DIR"
2671 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00002672
Gilles Peskine8f073122018-11-27 15:58:47 +01002673 msg "test: cmake 'out-of-source' build"
2674 make test
2675 # Test an SSL option that requires an auxiliary script in test/scripts/.
2676 # Also ensure that there are no error messages such as
2677 # "No such file or directory", which would indicate that some required
2678 # file is missing (ssl-opt.sh tolerates the absence of some files so
2679 # may exit with status 0 but emit errors).
2680 if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
2681 if [ -s ssl-opt.err ]; then
2682 cat ssl-opt.err >&2
2683 record_status [ ! -s ssl-opt.err ]
2684 rm ssl-opt.err
2685 fi
2686 cd "$MBEDTLS_ROOT_DIR"
2687 rm -rf "$OUT_OF_SOURCE_DIR"
2688 unset MBEDTLS_ROOT_DIR
2689}
Andres AGdc192212016-08-31 17:33:13 +01002690
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01002691component_test_cmake_as_subdirectory () {
2692 msg "build: cmake 'as-subdirectory' build"
2693 MBEDTLS_ROOT_DIR="$PWD"
2694
2695 cd programs/test/cmake_subproject
2696 cmake .
2697 make
2698 if_build_succeeded ./cmake_subproject
2699
2700 cd "$MBEDTLS_ROOT_DIR"
2701 unset MBEDTLS_ROOT_DIR
2702}
2703
Gilles Peskine8f073122018-11-27 15:58:47 +01002704component_test_zeroize () {
2705 # Test that the function mbedtls_platform_zeroize() is not optimized away by
2706 # different combinations of compilers and optimization flags by using an
2707 # auxiliary GDB script. Unfortunately, GDB does not return error values to the
2708 # system in all cases that the script fails, so we must manually search the
2709 # output to check whether the pass string is present and no failure strings
2710 # were printed.
Andres AGdc192212016-08-31 17:33:13 +01002711
Gilles Peskine4976e822019-01-06 19:52:22 +00002712 # Don't try to disable ASLR. We don't care about ASLR here. We do care
2713 # about a spurious message if Gdb tries and fails, so suppress that.
2714 gdb_disable_aslr=
2715 if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
2716 gdb_disable_aslr='set disable-randomization off'
2717 fi
2718
Gilles Peskine8f073122018-11-27 15:58:47 +01002719 for optimization_flag in -O2 -O3 -Ofast -Os; do
Gilles Peskine55f7c942019-01-09 22:28:21 +01002720 for compiler in clang gcc; do
2721 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
2722 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Gilles Peskine4976e822019-01-06 19:52:22 +00002723 if_build_succeeded gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
Gilles Peskine55f7c942019-01-09 22:28:21 +01002724 if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log
2725 if_build_succeeded not grep -i "error" test_zeroize.log
2726 rm -f test_zeroize.log
2727 make clean
2728 done
Andres Amaya Garcia29673812017-10-25 10:35:51 +01002729 done
Andres Amaya Garciad0d7bf62017-10-25 09:01:31 +01002730
Gilles Peskine4976e822019-01-06 19:52:22 +00002731 unset gdb_disable_aslr
Gilles Peskine8f073122018-11-27 15:58:47 +01002732}
Gilles Peskine192c72f2017-12-21 15:59:21 +01002733
Gilles Peskine8f073122018-11-27 15:58:47 +01002734component_check_python_files () {
2735 msg "Lint: Python scripts"
2736 record_status tests/scripts/check-python-files.sh
2737}
Gilles Peskine192c72f2017-12-21 15:59:21 +01002738
Gilles Peskine8f073122018-11-27 15:58:47 +01002739component_check_generate_test_code () {
2740 msg "uint test: generate_test_code.py"
Manuel Pégourié-Gonnarddfb114a2020-06-02 11:40:08 +02002741 # unittest writes out mundane stuff like number or tests run on stderr.
2742 # Our convention is to reserve stderr for actual errors, and write
2743 # harmless info on stdout so it can be suppress with --quiet.
2744 record_status ./tests/scripts/test_generate_test_code.py 2>&1
Gilles Peskine8f073122018-11-27 15:58:47 +01002745}
Gilles Peskine192c72f2017-12-21 15:59:21 +01002746
2747################################################################
2748#### Termination
2749################################################################
2750
Gilles Peskine8f073122018-11-27 15:58:47 +01002751post_report () {
2752 msg "Done, cleaning up"
2753 cleanup
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002754
Gilles Peskine8f073122018-11-27 15:58:47 +01002755 final_report
2756}
2757
2758
2759
2760################################################################
2761#### Run all the things
2762################################################################
2763
Gilles Peskinee48351a2018-11-27 16:06:30 +01002764# Run one component and clean up afterwards.
Gilles Peskine8f073122018-11-27 15:58:47 +01002765run_component () {
Gilles Peskine608953e2019-01-02 18:57:02 +01002766 # Back up the configuration in case the component modifies it.
2767 # The cleanup function will restore it.
2768 cp -p "$CONFIG_H" "$CONFIG_BAK"
John Durkopbd069d32020-10-31 22:14:03 -07002769 cp -p "$CRYPTO_CONFIG_H" "$CRYPTO_CONFIG_BAK"
Gilles Peskineffcdeff2018-12-04 12:49:28 +01002770 current_component="$1"
Gilles Peskine9004a172019-09-16 15:20:36 +02002771 export MBEDTLS_TEST_CONFIGURATION="$current_component"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02002772
2773 # Unconditionally create a seedfile that's sufficiently long.
2774 # Do this before each component, because a previous component may
2775 # have messed it up or shortened it.
Manuel Pégourié-Gonnardf1f180a2020-06-08 10:46:35 +02002776 redirect_err dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
Gilles Peskine2ef377d2019-10-07 18:44:21 +02002777
2778 # Run the component code.
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02002779 if [ $QUIET -eq 1 ]; then
2780 # msg() is silenced, so just print the component name here
2781 echo "${current_component#component_}"
2782 fi
2783 redirect_out "$@"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02002784
2785 # Restore the build tree to a clean state.
Gilles Peskinee48351a2018-11-27 16:06:30 +01002786 cleanup
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +02002787 unset current_component
Gilles Peskine8f073122018-11-27 15:58:47 +01002788}
2789
2790# Preliminary setup
2791pre_check_environment
2792pre_initialize_variables
2793pre_parse_command_line "$@"
Gilles Peskine348fb9a2018-11-27 17:04:29 +01002794
Gilles Peskine878cf602019-01-06 20:50:38 +00002795pre_check_git
Andrzej Kurekeb508712019-02-14 07:18:59 -05002796
Gilles Peskine878cf602019-01-06 20:50:38 +00002797build_status=0
2798if [ $KEEP_GOING -eq 1 ]; then
2799 pre_setup_keep_going
Gilles Peskine92525112018-11-27 18:15:35 +01002800else
Gilles Peskine878cf602019-01-06 20:50:38 +00002801 record_status () {
2802 "$@"
2803 }
Gilles Peskine8f073122018-11-27 15:58:47 +01002804fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02002805pre_setup_quiet_redirect
Gilles Peskine67ffdaf2019-09-16 15:55:46 +02002806pre_prepare_outcome_file
Gilles Peskine878cf602019-01-06 20:50:38 +00002807pre_print_configuration
2808pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002809cleanup
2810
Gilles Peskinebeb3a812019-01-06 22:11:25 +00002811# Run the requested tests.
2812for component in $RUN_COMPONENTS; do
2813 run_component "component_$component"
2814done
Gilles Peskine8f073122018-11-27 15:58:47 +01002815
2816# We're done.
Gilles Peskine878cf602019-01-06 20:50:38 +00002817post_report