blob: 865c73d42aad7be6719c3b34908d3a1acd66355b [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#
Gilles Peskine192c72f2017-12-21 15:59:21 +01005# Copyright (c) 2014-2017, ARM Limited, All Rights Reserved
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.
19#
20# This file is part of Mbed TLS (https://tls.mbed.org)
Gilles Peskine192c72f2017-12-21 15:59:21 +010021
22
23
24################################################################
25#### Documentation
26################################################################
27
Simon Butcher3ea7f522016-03-07 23:22:10 +000028# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010029# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000030#
SimonB2e23c822016-04-16 21:54:39 +010031# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010032#
Gilles Peskine192c72f2017-12-21 15:59:21 +010033# Notes for users
34# ---------------
35#
SimonB2e23c822016-04-16 21:54:39 +010036# Warning: the test is destructive. It includes various build modes and
37# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010038# configuration. The following files must be committed into git:
39# * include/mbedtls/config.h
Gilles Peskine636c26a2020-03-04 20:46:15 +010040# * Makefile, library/Makefile, programs/Makefile, tests/Makefile,
41# programs/fuzz/Makefile
Gilles Peskine192c72f2017-12-21 15:59:21 +010042# After running this script, the CMake cache will be lost and CMake
43# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010044#
Gilles Peskine192c72f2017-12-21 15:59:21 +010045# The script assumes the presence of a number of tools:
46# * Basic Unix tools (Windows users note: a Unix-style find must be before
47# the Windows find in the PATH)
48# * Perl
49# * GNU Make
50# * CMake
51# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040052# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010053# * arm-gcc and mingw-gcc
54# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine192c72f2017-12-21 15:59:21 +010055# * OpenSSL and GnuTLS command line tools, recent enough for the
56# interoperability tests. If they don't support SSLv3 then a legacy
57# version of these tools must be present as well (search for LEGACY
58# below).
59# See the invocation of check_tools below for details.
60#
61# This script must be invoked from the toplevel directory of a git
62# working copy of Mbed TLS.
63#
64# Note that the output is not saved. You may want to run
65# script -c tests/scripts/all.sh
66# or
67# tests/scripts/all.sh >all.log 2>&1
68#
69# Notes for maintainers
70# ---------------------
71#
Gilles Peskine8f073122018-11-27 15:58:47 +010072# The bulk of the code is organized into functions that follow one of the
73# following naming conventions:
74# * pre_XXX: things to do before running the tests, in order.
75# * component_XXX: independent components. They can be run in any order.
Gilles Peskinec70637a2019-01-09 22:29:17 +010076# * component_check_XXX: quick tests that aren't worth parallelizing.
77# * component_build_XXX: build things but don't run them.
78# * component_test_XXX: build and test.
Gilles Peskine878cf602019-01-06 20:50:38 +000079# * support_XXX: if support_XXX exists and returns false then
80# component_XXX is not run by default.
Gilles Peskine8f073122018-11-27 15:58:47 +010081# * post_XXX: things to do after running the tests.
82# * other: miscellaneous support functions.
83#
Gilles Peskinec70637a2019-01-09 22:29:17 +010084# Each component must start by invoking `msg` with a short informative message.
85#
86# The framework performs some cleanup tasks after each component. This
87# means that components can assume that the working directory is in a
88# cleaned-up state, and don't need to perform the cleanup themselves.
89# * Run `make clean`.
90# * Restore `include/mbedtks/config.h` from a backup made before running
91# the component.
Gilles Peskine636c26a2020-03-04 20:46:15 +010092# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`,
93# `tests/Makefile` and `programs/fuzz/Makefile` from git.
94# This cleans up after an in-tree use of CMake.
Gilles Peskinec70637a2019-01-09 22:29:17 +010095#
96# Any command that is expected to fail must be protected so that the
97# script keeps running in --keep-going mode despite `set -e`. In keep-going
98# mode, if a protected command fails, this is logged as a failure and the
99# script will exit with a failure status once it has run all components.
100# Commands can be protected in any of the following ways:
101# * `make` is a function which runs the `make` command with protection.
102# Note that you must write `make VAR=value`, not `VAR=value make`,
103# because the `VAR=value make` syntax doesn't work with functions.
104# * Put `report_status` before the command to protect it.
105# * Put `if_build_successful` before a command. This protects it, and
106# additionally skips it if a prior invocation of `make` in the same
107# component failed.
108#
Gilles Peskine192c72f2017-12-21 15:59:21 +0100109# The tests are roughly in order from fastest to slowest. This doesn't
110# have to be exact, but in general you should add slower tests towards
111# the end and fast checks near the beginning.
Gilles Peskine192c72f2017-12-21 15:59:21 +0100112
113
114
115################################################################
116#### Initialization and command line parsing
117################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100118
SimonB2e23c822016-04-16 21:54:39 +0100119# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100120set -eu
121
Gilles Peskine8f073122018-11-27 15:58:47 +0100122pre_check_environment () {
Gilles Peskinea16c2b12019-01-06 19:58:02 +0000123 if [ -d library -a -d include -a -d tests ]; then :; else
Gilles Peskine8f073122018-11-27 15:58:47 +0100124 echo "Must be run from mbed TLS root" >&2
125 exit 1
126 fi
127}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100128
Gilles Peskine8f073122018-11-27 15:58:47 +0100129pre_initialize_variables () {
130 CONFIG_H='include/mbedtls/config.h'
131 CONFIG_BAK="$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
136 KEEP_GOING=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100137
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200138 : ${MBEDTLS_TEST_OUTCOME_FILE=}
Gilles Peskine9004a172019-09-16 15:20:36 +0200139 : ${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 +0200140 export MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine9004a172019-09-16 15:20:36 +0200141 export MBEDTLS_TEST_PLATFORM
142
Jaeden Ameroc4cc2512019-01-30 15:35:44 +0000143 # Default commands, can be overridden by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100144 : ${OPENSSL:="openssl"}
145 : ${OPENSSL_LEGACY:="$OPENSSL"}
146 : ${OPENSSL_NEXT:="$OPENSSL"}
147 : ${GNUTLS_CLI:="gnutls-cli"}
148 : ${GNUTLS_SERV:="gnutls-serv"}
149 : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
150 : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
151 : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
152 : ${ARMC5_BIN_DIR:=/usr/bin}
153 : ${ARMC6_BIN_DIR:=/usr/bin}
Gilles Peskine6d061342020-04-30 18:19:32 +0200154 : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
Andres AGdc192212016-08-31 17:33:13 +0100155
Gilles Peskine8f073122018-11-27 15:58:47 +0100156 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
Gilles Peskinea1fc4b52019-01-06 20:15:26 +0000157 if [ -z "${MAKEFLAGS+set}" ]; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100158 export MAKEFLAGS="-j"
159 fi
Gilles Peskine878cf602019-01-06 20:50:38 +0000160
Jaeden Amerod48e9c72019-02-07 17:43:39 +0000161 # Include more verbose output for failing tests run by CMake
162 export CTEST_OUTPUT_ON_FAILURE=1
163
Gilles Peskine8fd59422019-10-21 17:11:33 +0200164 # CFLAGS and LDFLAGS for Asan builds that don't use CMake
Gilles Peskine5ca393f2019-10-21 19:06:33 +0200165 ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all'
Gilles Peskine8fd59422019-10-21 17:11:33 +0200166
Gilles Peskine878cf602019-01-06 20:50:38 +0000167 # Gather the list of available components. These are the functions
168 # defined in this script whose name starts with "component_".
169 # Parse the script with sed, because in sh there is no way to list
170 # defined functions.
171 ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
172
173 # Exclude components that are not supported on this platform.
174 SUPPORTED_COMPONENTS=
175 for component in $ALL_COMPONENTS; do
176 case $(type "support_$component" 2>&1) in
177 *' function'*)
178 if ! support_$component; then continue; fi;;
179 esac
180 SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
181 done
Gilles Peskine8f073122018-11-27 15:58:47 +0100182}
Andres AG38495a32016-07-12 16:54:33 +0100183
Gilles Peskinea28db922019-01-10 00:05:18 +0100184# Test whether the component $1 is included in the command line patterns.
185is_component_included()
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100186{
187 set -f
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000188 for pattern in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100189 set +f
190 case ${1#component_} in $pattern) return 0;; esac
191 done
192 set +f
193 return 1
194}
Andres AG7770ea82016-10-10 15:46:20 +0100195
Simon Butcher41eeccf2016-09-07 00:07:09 +0100196usage()
Andres AGd9eba4b2016-08-26 14:42:14 +0100197{
Gilles Peskine709346a2017-12-10 23:43:39 +0100198 cat <<EOF
Gilles Peskine92525112018-11-27 18:15:35 +0100199Usage: $0 [OPTION]... [COMPONENT]...
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100200Run mbedtls release validation tests.
Gilles Peskine92525112018-11-27 18:15:35 +0100201By default, run all tests. With one or more COMPONENT, run only those.
Gilles Peskinea28db922019-01-10 00:05:18 +0100202COMPONENT can be the name of a component or a shell wildcard pattern.
203
204Examples:
205 $0 "check_*"
206 Run all sanity checks.
207 $0 --no-armcc --except test_memsan
208 Run everything except builds that require armcc and MemSan.
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100209
210Special options:
211 -h|--help Print this help and exit.
Gilles Peskine878cf602019-01-06 20:50:38 +0000212 --list-all-components List all available test components and exit.
213 --list-components List components supported on this platform and exit.
Gilles Peskine709346a2017-12-10 23:43:39 +0100214
215General options:
216 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100217 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100218 -m|--memory Additional optional memory tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200219 --append-outcome Append to the outcome file (if used).
Gilles Peskine6d061342020-04-30 18:19:32 +0200220 --arm-none-eabi-gcc-prefix=<string>
221 Prefix for a cross-compiler for arm-none-eabi
222 (default: "${ARM_NONE_EABI_GCC_PREFIX}")
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100223 --armcc Run ARM Compiler builds (on by default).
Gilles Peskinea28db922019-01-10 00:05:18 +0100224 --except Exclude the COMPONENTs listed on the command line,
225 instead of running only those.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200226 --no-append-outcome Write a new outcome file and analyze it (default).
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100227 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100228 --no-force Refuse to overwrite modified files (default).
229 --no-keep-going Stop at the first error (default).
230 --no-memory No additional memory tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100231 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200232 --outcome-file=<path> File where test outcomes are written (not done if
233 empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
Gilles Peskine38d81652018-03-21 08:40:26 +0100234 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100235 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
236 -s|--seed Integer seed value to use for this test run.
237
238Tool path options:
239 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
240 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
241 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
242 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
243 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
244 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
245 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
246 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100247 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100248EOF
SimonB2e23c822016-04-16 21:54:39 +0100249}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100250
251# remove built files as well as the cmake cache/config
252cleanup()
253{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100254 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
255 cd "$MBEDTLS_ROOT_DIR"
256 fi
257
Gilles Peskine7c652162017-12-11 00:01:40 +0100258 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200259
Gilles Peskine31b07e22018-03-21 12:15:06 +0100260 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000261 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100262 -iname CMakeFiles -exec rm -rf {} \+ -o \
263 \( -iname cmake_install.cmake -o \
264 -iname CTestTestfile.cmake -o \
265 -iname CMakeCache.txt \) -exec rm {} \+
266 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000267 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Gilles Peskine636c26a2020-03-04 20:46:15 +0100268 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
269 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200270
Jaeden Ameroab83fdf2019-06-20 17:38:22 +0100271 # Remove any artifacts from the component_test_cmake_as_subdirectory test.
272 rm -rf programs/test/cmake_subproject/build
273 rm -f programs/test/cmake_subproject/Makefile
274 rm -f programs/test/cmake_subproject/cmake_subproject
275
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200276 if [ -f "$CONFIG_BAK" ]; then
277 mv "$CONFIG_BAK" "$CONFIG_H"
278 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100279}
280
Gilles Peskine7c652162017-12-11 00:01:40 +0100281# Executed on exit. May be redefined depending on command line options.
282final_report () {
283 :
284}
285
286fatal_signal () {
287 cleanup
288 final_report $1
289 trap - $1
290 kill -$1 $$
291}
292
293trap 'fatal_signal HUP' HUP
294trap 'fatal_signal INT' INT
295trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200296
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100297msg()
298{
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100299 if [ -n "${current_component:-}" ]; then
300 current_section="${current_component#component_}: $1"
301 else
302 current_section="$1"
303 fi
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100304 echo ""
305 echo "******************************************************************"
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100306 echo "* $current_section "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000307 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100308 echo "******************************************************************"
309}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100310
Gilles Peskine8f073122018-11-27 15:58:47 +0100311armc6_build_test()
312{
313 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100314
Gilles Peskine18487f62020-04-30 23:11:54 +0200315 msg "build: ARM Compiler 6 ($FLAGS)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100316 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
317 WARNING_CFLAGS='-xc -std=c99' make lib
Gilles Peskine18487f62020-04-30 23:11:54 +0200318
319 msg "size: ARM Compiler 6 ($FLAGS)"
320 "$ARMC6_FROMELF" -z library/*.o
321
Gilles Peskine8f073122018-11-27 15:58:47 +0100322 make clean
323}
Andres AGa5cd9732016-10-17 15:23:10 +0100324
Andres AGd9eba4b2016-08-26 14:42:14 +0100325err_msg()
326{
327 echo "$1" >&2
328}
329
330check_tools()
331{
332 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000333 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100334 err_msg "$TOOL not found!"
335 exit 1
336 fi
337 done
338}
339
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400340check_headers_in_cpp () {
Peter Kolbus1bc1a4c2019-02-01 17:19:08 -0600341 ls include/mbedtls | grep "\.h$" >headers.txt
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400342 <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
343 sort |
344 diff headers.txt -
345 rm headers.txt
346}
347
Gilles Peskine8f073122018-11-27 15:58:47 +0100348pre_parse_command_line () {
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000349 COMMAND_LINE_COMPONENTS=
Gilles Peskinea28db922019-01-10 00:05:18 +0100350 all_except=0
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000351 no_armcc=
SimonB2e23c822016-04-16 21:54:39 +0100352
Jaeden Amero9b90f2e2018-11-02 18:34:17 +0000353 # Note that legacy options are ignored instead of being omitted from this
354 # list of options, so invocations that worked with previous version of
355 # all.sh will still run and work properly.
Gilles Peskine8f073122018-11-27 15:58:47 +0100356 while [ $# -gt 0 ]; do
Gilles Peskine55f7c942019-01-09 22:28:21 +0100357 case "$1" in
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200358 --append-outcome) append_outcome=1;;
Gilles Peskine6d061342020-04-30 18:19:32 +0200359 --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000360 --armcc) no_armcc=;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100361 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
362 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000363 --except) all_except=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100364 --force|-f) FORCE=1;;
365 --gnutls-cli) shift; GNUTLS_CLI="$1";;
366 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
367 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
368 --gnutls-serv) shift; GNUTLS_SERV="$1";;
369 --help|-h) usage; exit;;
370 --keep-going|-k) KEEP_GOING=1;;
Gilles Peskine878cf602019-01-06 20:50:38 +0000371 --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
372 --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100373 --memory|-m) MEMORY=1;;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200374 --no-append-outcome) append_outcome=0;;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000375 --no-armcc) no_armcc=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100376 --no-force) FORCE=0;;
377 --no-keep-going) KEEP_GOING=0;;
378 --no-memory) MEMORY=0;;
379 --openssl) shift; OPENSSL="$1";;
380 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
381 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200382 --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100383 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
384 --random-seed) unset SEED;;
385 --release-test|-r) SEED=1;;
386 --seed|-s) shift; SEED="$1";;
387 -*)
388 echo >&2 "Unknown option: $1"
389 echo >&2 "Run $0 --help for usage."
390 exit 120
391 ;;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000392 *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100393 esac
394 shift
Gilles Peskine8f073122018-11-27 15:58:47 +0100395 done
SimonB2e23c822016-04-16 21:54:39 +0100396
Gilles Peskinea28db922019-01-10 00:05:18 +0100397 # With no list of components, run everything.
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000398 if [ -z "$COMMAND_LINE_COMPONENTS" ]; then
399 all_except=1
Andres AGdc192212016-08-31 17:33:13 +0100400 fi
401
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000402 # --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
403 # Ignore it if components are listed explicitly on the command line.
Gilles Peskinea28db922019-01-10 00:05:18 +0100404 if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000405 COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
SimonB2e23c822016-04-16 21:54:39 +0100406 fi
SimonB2e23c822016-04-16 21:54:39 +0100407
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000408 # Build the list of components to run.
Gilles Peskinea28db922019-01-10 00:05:18 +0100409 RUN_COMPONENTS=
410 for component in $SUPPORTED_COMPONENTS; do
411 if is_component_included "$component"; [ $? -eq $all_except ]; then
412 RUN_COMPONENTS="$RUN_COMPONENTS $component"
413 fi
414 done
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000415
416 unset all_except
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000417 unset no_armcc
Gilles Peskine8f073122018-11-27 15:58:47 +0100418}
SimonB2e23c822016-04-16 21:54:39 +0100419
Gilles Peskine8f073122018-11-27 15:58:47 +0100420pre_check_git () {
421 if [ $FORCE -eq 1 ]; then
Gilles Peskine53190e62019-01-09 23:17:35 +0100422 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +0100423 git checkout-index -f -q $CONFIG_H
424 cleanup
425 else
SimonB2e23c822016-04-16 21:54:39 +0100426
Gilles Peskine8f073122018-11-27 15:58:47 +0100427 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
428 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
429 echo "You can either delete this directory manually, or force the test by rerunning"
430 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
431 exit 1
432 fi
433
Gilles Peskined1174cf2019-01-09 22:30:01 +0100434 if ! git diff --quiet include/mbedtls/config.h; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100435 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
436 echo "You can either delete or preserve your work, or force the test by rerunning the"
437 echo "script as: $0 --force"
438 exit 1
439 fi
SimonB2e23c822016-04-16 21:54:39 +0100440 fi
Andrzej Kurekeb508712019-02-14 07:18:59 -0500441}
442
Gilles Peskine8f073122018-11-27 15:58:47 +0100443pre_setup_keep_going () {
Gilles Peskine7c652162017-12-11 00:01:40 +0100444 failure_summary=
445 failure_count=0
446 start_red=
447 end_color=
448 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100449 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100450 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
451 start_red=$(printf '\033[31m')
452 end_color=$(printf '\033[0m')
453 ;;
454 esac
455 fi
456 record_status () {
457 if "$@"; then
458 last_status=0
459 else
460 last_status=$?
461 text="$current_section: $* -> $last_status"
462 failure_summary="$failure_summary
463$text"
464 failure_count=$((failure_count + 1))
465 echo "${start_red}^^^^$text^^^^${end_color}"
466 fi
467 }
468 make () {
469 case "$*" in
470 *test|*check)
471 if [ $build_status -eq 0 ]; then
472 record_status command make "$@"
473 else
474 echo "(skipped because the build failed)"
475 fi
476 ;;
477 *)
478 record_status command make "$@"
479 build_status=$last_status
480 ;;
481 esac
482 }
483 final_report () {
484 if [ $failure_count -gt 0 ]; then
485 echo
486 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
487 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
488 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7c1258d2018-07-20 16:42:14 +0100489 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100490 elif [ -z "${1-}" ]; then
491 echo "SUCCESS :)"
492 fi
493 if [ -n "${1-}" ]; then
494 echo "Killed by SIG$1."
495 fi
496 }
Gilles Peskine8f073122018-11-27 15:58:47 +0100497}
498
Gilles Peskine7c652162017-12-11 00:01:40 +0100499if_build_succeeded () {
500 if [ $build_status -eq 0 ]; then
501 record_status "$@"
502 fi
503}
504
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200505# to be used instead of ! for commands run with
506# record_status or if_build_succeeded
507not() {
508 ! "$@"
509}
510
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200511pre_prepare_outcome_file () {
512 case "$MBEDTLS_TEST_OUTCOME_FILE" in
513 [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
514 esac
515 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then
516 rm -f "$MBEDTLS_TEST_OUTCOME_FILE"
517 fi
518}
519
Gilles Peskine8f073122018-11-27 15:58:47 +0100520pre_print_configuration () {
521 msg "info: $0 configuration"
522 echo "MEMORY: $MEMORY"
523 echo "FORCE: $FORCE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200524 echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}"
Gilles Peskine8f073122018-11-27 15:58:47 +0100525 echo "SEED: ${SEED-"UNSET"}"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100526 echo
Gilles Peskine8f073122018-11-27 15:58:47 +0100527 echo "OPENSSL: $OPENSSL"
528 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
529 echo "OPENSSL_NEXT: $OPENSSL_NEXT"
530 echo "GNUTLS_CLI: $GNUTLS_CLI"
531 echo "GNUTLS_SERV: $GNUTLS_SERV"
532 echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
533 echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
534 echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
535 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
536}
Andres AG7770ea82016-10-10 15:46:20 +0100537
Andres AGd9eba4b2016-08-26 14:42:14 +0100538# Make sure the tools we need are available.
Gilles Peskine8f073122018-11-27 15:58:47 +0100539pre_check_tools () {
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000540 # Build the list of variables to pass to output_env.sh.
541 set env
SimonB2e23c822016-04-16 21:54:39 +0100542
Gilles Peskine87964262019-01-06 22:40:00 +0000543 case " $RUN_COMPONENTS " in
544 # Require OpenSSL and GnuTLS if running any tests (as opposed to
545 # only doing builds). Not all tests run OpenSSL and GnuTLS, but this
546 # is a good enough approximation in practice.
547 *" test_"*)
548 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh
549 # and ssl-opt.sh, we just export the variables they require.
550 export OPENSSL_CMD="$OPENSSL"
551 export GNUTLS_CLI="$GNUTLS_CLI"
552 export GNUTLS_SERV="$GNUTLS_SERV"
553 # Avoid passing --seed flag in every call to ssl-opt.sh
554 if [ -n "${SEED-}" ]; then
555 export SEED
556 fi
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000557 set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY"
558 set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV"
559 set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI"
560 set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000561 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
562 "$GNUTLS_CLI" "$GNUTLS_SERV" \
563 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV"
564 ;;
565 esac
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200566
Gilles Peskine87964262019-01-06 22:40:00 +0000567 case " $RUN_COMPONENTS " in
568 *_doxygen[_\ ]*) check_tools "doxygen" "dot";;
569 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100570
Gilles Peskine87964262019-01-06 22:40:00 +0000571 case " $RUN_COMPONENTS " in
Gilles Peskine6d061342020-04-30 18:19:32 +0200572 *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";;
Gilles Peskine87964262019-01-06 22:40:00 +0000573 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100574
Gilles Peskine87964262019-01-06 22:40:00 +0000575 case " $RUN_COMPONENTS " in
576 *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";;
577 esac
578
579 case " $RUN_COMPONENTS " in
580 *" test_zeroize "*) check_tools "gdb";;
581 esac
582
583 case " $RUN_COMPONENTS " in
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000584 *_armcc*)
Gilles Peskine87964262019-01-06 22:40:00 +0000585 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
586 ARMC5_AR="$ARMC5_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200587 ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf"
Gilles Peskine87964262019-01-06 22:40:00 +0000588 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
589 ARMC6_AR="$ARMC6_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200590 ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf"
591 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \
592 "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000593 esac
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000594
595 msg "info: output_env.sh"
596 case $RUN_COMPONENTS in
597 *_armcc*)
598 set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;;
599 *) set "$@" RUN_ARMCC=0;;
600 esac
601 "$@" scripts/output_env.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100602}
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100603
Gilles Peskine192c72f2017-12-21 15:59:21 +0100604
605
606################################################################
607#### Basic checks
608################################################################
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100609
610#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200611# Test Suites to be executed
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100612#
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100613# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200614# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100615# 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 +0200616# time, so start with a GCC build).
617# 2. Minimize total running time, by avoiding useless rebuilds
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100618#
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100619# Indicative running times are given for reference.
620
Gilles Peskine8f073122018-11-27 15:58:47 +0100621component_check_recursion () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200622 msg "Check: recursion.pl" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100623 record_status tests/scripts/recursion.pl library/*.c
624}
Janos Follathb72c6782016-07-19 14:54:17 +0100625
Gilles Peskine8f073122018-11-27 15:58:47 +0100626component_check_generated_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200627 msg "Check: freshness of generated source files" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100628 record_status tests/scripts/check-generated-files.sh
629}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200630
Gilles Peskine8f073122018-11-27 15:58:47 +0100631component_check_doxy_blocks () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200632 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100633 record_status tests/scripts/check-doxy-blocks.pl
634}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200635
Gilles Peskine8f073122018-11-27 15:58:47 +0100636component_check_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200637 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100638 record_status tests/scripts/check-files.py
639}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200640
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200641component_check_changelog () {
642 msg "Check: changelog entries" # < 1s
643 rm -f ChangeLog.new
644 record_status scripts/assemble_changelog.py -o ChangeLog.new
645 if [ -e ChangeLog.new ]; then
646 # Show the diff for information. It isn't an error if the diff is
647 # non-empty.
648 diff -u ChangeLog ChangeLog.new || true
649 rm ChangeLog.new
650 fi
651}
652
Gilles Peskine8f073122018-11-27 15:58:47 +0100653component_check_names () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200654 msg "Check: declared and exported names (builds the library)" # < 3s
Gilles Peskine13f97dc2019-05-15 17:52:22 +0200655 record_status tests/scripts/check-names.sh -v
Gilles Peskine8f073122018-11-27 15:58:47 +0100656}
Darryl Greena07039c2018-03-13 16:48:16 +0000657
Gilles Peskine895868b2019-09-19 21:30:05 +0200658component_check_test_cases () {
659 msg "Check: test case descriptions" # < 1s
660 record_status tests/scripts/check-test-cases.py
661}
662
Gilles Peskine8f073122018-11-27 15:58:47 +0100663component_check_doxygen_warnings () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200664 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Gilles Peskine8f073122018-11-27 15:58:47 +0100665 record_status tests/scripts/doxygen.sh
666}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200667
Gilles Peskine192c72f2017-12-21 15:59:21 +0100668
Gilles Peskine636c26a2020-03-04 20:46:15 +0100669
Gilles Peskine192c72f2017-12-21 15:59:21 +0100670################################################################
671#### Build and test many configurations and targets
672################################################################
673
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200674component_test_default_out_of_box () {
675 msg "build: make, default config (out-of-box)" # ~1min
676 make
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200677 # Disable fancy stuff
Gilles Peskine717cd762019-09-27 20:21:11 +0200678 SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200679 unset MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200680
681 msg "test: main suites make, default config (out-of-box)" # ~10s
682 make test
683
684 msg "selftest: make, default config (out-of-box)" # ~10s
Gilles Peskine97bea012020-04-23 23:37:45 +0200685 if_build_succeeded programs/test/selftest
Gilles Peskine717cd762019-09-27 20:21:11 +0200686
687 export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE"
688 unset SAVE_MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200689}
690
Gilles Peskine8f073122018-11-27 15:58:47 +0100691component_test_default_cmake_gcc_asan () {
692 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Gilles Peskine8f073122018-11-27 15:58:47 +0100693 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
694 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200695
Gilles Peskine8f073122018-11-27 15:58:47 +0100696 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
697 make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200698
Gilles Peskine97bea012020-04-23 23:37:45 +0200699 msg "test: selftest (ASan build)" # ~ 10s
700 if_build_succeeded programs/test/selftest
701
Gilles Peskine8f073122018-11-27 15:58:47 +0100702 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
703 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200704
Gilles Peskine8f073122018-11-27 15:58:47 +0100705 msg "test: compat.sh (ASan build)" # ~ 6 min
706 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200707
708 msg "test: context-info.sh (ASan build)" # ~ 15 sec
709 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100710}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200711
Hanno Becker01635512019-02-26 14:27:09 +0000712component_test_full_cmake_gcc_asan () {
713 msg "build: full config, cmake, gcc, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200714 scripts/config.py full
Hanno Becker01635512019-02-26 14:27:09 +0000715 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
716 make
717
718 msg "test: main suites (inc. selftests) (full config, ASan build)"
719 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +0100720
Gilles Peskine97bea012020-04-23 23:37:45 +0200721 msg "test: selftest (ASan build)" # ~ 10s
722 if_build_succeeded programs/test/selftest
723
Gilles Peskine636c26a2020-03-04 20:46:15 +0100724 msg "test: ssl-opt.sh (full config, ASan build)"
725 if_build_succeeded tests/ssl-opt.sh
726
727 msg "test: compat.sh (full config, ASan build)"
728 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200729
730 msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
731 if_build_succeeded tests/context-info.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +0100732}
733
734component_test_zlib_make() {
735 msg "build: zlib enabled, make"
736 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
737 make ZLIB=1 CFLAGS='-Werror -O1'
738
739 msg "test: main suites (zlib, make)"
740 make test
741
742 msg "test: ssl-opt.sh (zlib, make)"
743 if_build_succeeded tests/ssl-opt.sh
744}
745support_test_zlib_make () {
746 base=support_test_zlib_$$
747 cat <<'EOF' > ${base}.c
748#include "zlib.h"
749int main(void) { return 0; }
750EOF
751 gcc -o ${base}.exe ${base}.c -lz 2>/dev/null
752 ret=$?
753 rm -f ${base}.*
754 return $ret
755}
756
757component_test_zlib_cmake() {
758 msg "build: zlib enabled, cmake"
759 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
760 cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check .
761 make
762
763 msg "test: main suites (zlib, cmake)"
764 make test
765
766 msg "test: ssl-opt.sh (zlib, cmake)"
767 if_build_succeeded tests/ssl-opt.sh
768}
769support_test_zlib_cmake () {
770 support_test_zlib_make "$@"
Manuel Pégourié-Gonnardf2e29022020-01-24 10:17:20 +0100771}
Manuel Pégourié-Gonnard95e04492020-01-02 11:45:12 +0100772
Gilles Peskine782f4112018-11-27 16:11:09 +0100773component_test_ref_configs () {
774 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
775 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
776 record_status tests/scripts/test-ref-configs.pl
777}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200778
Gilles Peskine8f073122018-11-27 15:58:47 +0100779component_test_sslv3 () {
780 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200781 scripts/config.py set MBEDTLS_SSL_PROTO_SSL3
Gilles Peskine8f073122018-11-27 15:58:47 +0100782 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
783 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200784
Gilles Peskine8f073122018-11-27 15:58:47 +0100785 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
786 make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000787
Gilles Peskine8f073122018-11-27 15:58:47 +0100788 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
789 if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
790 if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000791
Gilles Peskine8f073122018-11-27 15:58:47 +0100792 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
793 if_build_succeeded tests/ssl-opt.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200794
795 msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec
796 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100797}
Simon Butcher3ea7f522016-03-07 23:22:10 +0000798
Gilles Peskine8f073122018-11-27 15:58:47 +0100799component_test_no_renegotiation () {
800 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200801 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine8f073122018-11-27 15:58:47 +0100802 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
803 make
Simon Butcher3ea7f522016-03-07 23:22:10 +0000804
Gilles Peskine8f073122018-11-27 15:58:47 +0100805 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
806 make test
Hanno Becker134c2ab2017-10-12 15:29:50 +0100807
Gilles Peskine8f073122018-11-27 15:58:47 +0100808 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
809 if_build_succeeded tests/ssl-opt.sh
810}
Hanno Becker134c2ab2017-10-12 15:29:50 +0100811
Gilles Peskine636c26a2020-03-04 20:46:15 +0100812component_test_no_pem_no_fs () {
813 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
814 scripts/config.py unset MBEDTLS_PEM_PARSE_C
815 scripts/config.py unset MBEDTLS_FS_IO
816 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
817 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
818 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
819 make
820
821 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
822 make test
823
824 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
825 if_build_succeeded tests/ssl-opt.sh
826}
827
Gilles Peskine8f073122018-11-27 15:58:47 +0100828component_test_rsa_no_crt () {
829 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200830 scripts/config.py set MBEDTLS_RSA_NO_CRT
Gilles Peskine8f073122018-11-27 15:58:47 +0100831 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
832 make
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100833
Gilles Peskine8f073122018-11-27 15:58:47 +0100834 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
835 make test
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100836
Gilles Peskine8f073122018-11-27 15:58:47 +0100837 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
838 if_build_succeeded tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100839
Gilles Peskine8f073122018-11-27 15:58:47 +0100840 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
841 if_build_succeeded tests/compat.sh -t RSA
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200842
843 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
844 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100845}
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100846
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +0200847component_test_no_ctr_drbg () {
848 msg "build: Full minus CTR_DRBG"
849 scripts/config.py full
850 scripts/config.py unset MBEDTLS_CTR_DRBG_C
851 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
852 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
853 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C # requires PSA Crypto
854 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO # requires PSA Crypto
855
856 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
857 make
858
859 msg "test: no CTR_DRBG"
860 make test
861
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +0200862 # no ssl-opt.sh/compat.sh as they all depend on CTR_DRBG so far
863}
864
865component_test_no_hmac_drbg () {
866 msg "build: Full minus HMAC_DRBG"
867 scripts/config.py full
868 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
869 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
870
871 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
872 make
873
874 msg "test: no HMAC_DRBG"
875 make test
876
877 # No ssl-opt.sh/compat.sh as they never use HMAC_DRBG so far,
878 # so there's little value in running those lengthy tests here.
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +0200879}
880
Gilles Peskine636c26a2020-03-04 20:46:15 +0100881component_test_new_ecdh_context () {
882 msg "build: new ECDH context (ASan build)" # ~ 6 min
883 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
884 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
885 make
886
887 msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
888 make test
889
890 msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
891 if_build_succeeded tests/ssl-opt.sh -f ECDH
892
893 msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
894 # Exclude some symmetric ciphers that are redundant here to gain time.
895 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
896}
897
898component_test_everest () {
899 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
900 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
901 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
902 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
903 make
904
905 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
906 make test
907
908 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
909 if_build_succeeded tests/ssl-opt.sh -f ECDH
910
911 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
912 # Exclude some symmetric ciphers that are redundant here to gain time.
913 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
914}
915
Gilles Peskine8f073122018-11-27 15:58:47 +0100916component_test_small_ssl_out_content_len () {
917 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200918 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
919 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +0100920 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
921 make
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100922
Gilles Peskine8f073122018-11-27 15:58:47 +0100923 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
924 if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet"
925}
Angus Grattonc4dd0732018-04-11 16:28:39 +1000926
Gilles Peskine8f073122018-11-27 15:58:47 +0100927component_test_small_ssl_in_content_len () {
928 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200929 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
930 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
Gilles Peskine8f073122018-11-27 15:58:47 +0100931 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
932 make
Angus Grattonc4dd0732018-04-11 16:28:39 +1000933
Gilles Peskine8f073122018-11-27 15:58:47 +0100934 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
935 if_build_succeeded tests/ssl-opt.sh -f "Max fragment"
936}
Angus Grattonc4dd0732018-04-11 16:28:39 +1000937
Gilles Peskine8f073122018-11-27 15:58:47 +0100938component_test_small_ssl_dtls_max_buffering () {
939 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200940 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
Gilles Peskine8f073122018-11-27 15:58:47 +0100941 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
942 make
Angus Grattonc4dd0732018-04-11 16:28:39 +1000943
Gilles Peskine8f073122018-11-27 15:58:47 +0100944 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
945 if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
946}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100947
Gilles Peskine8f073122018-11-27 15:58:47 +0100948component_test_small_mbedtls_ssl_dtls_max_buffering () {
949 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100950 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
Gilles Peskine8f073122018-11-27 15:58:47 +0100951 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
952 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100953
Gilles Peskine8f073122018-11-27 15:58:47 +0100954 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
955 if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
956}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100957
Gilles Peskine75cc7712019-09-06 19:47:17 +0200958component_test_psa_collect_statuses () {
959 msg "build+test: psa_collect_statuses" # ~30s
Gilles Peskine3bdd4122019-07-27 23:52:53 +0200960 scripts/config.py full
Gilles Peskine75cc7712019-09-06 19:47:17 +0200961 record_status tests/scripts/psa_collect_statuses.py
962 # Check that psa_crypto_init() succeeded at least once
963 record_status grep -q '^0:psa_crypto_init:' tests/statuses.log
964 rm -f tests/statuses.log
965}
966
Gilles Peskine8f073122018-11-27 15:58:47 +0100967component_test_full_cmake_clang () {
968 msg "build: cmake, full config, clang" # ~ 50s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200969 scripts/config.py full
Gilles Peskine8f073122018-11-27 15:58:47 +0100970 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
971 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100972
k-stachowiak0291cb72019-06-26 15:52:12 +0200973 msg "test: main suites (full config, clang)" # ~ 5s
Gilles Peskine8f073122018-11-27 15:58:47 +0100974 make test
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100975
k-stachowiak0291cb72019-06-26 15:52:12 +0200976 msg "test: psa_constant_names (full config, clang)" # ~ 1s
Darryl Green45010a32019-02-06 13:43:58 +0000977 record_status tests/scripts/test_psa_constant_names.py
Gilles Peskine69e8f7f2020-02-26 19:51:43 +0100978
Gilles Peskine8f073122018-11-27 15:58:47 +0100979 msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
980 if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200981
Andres Amaya Garcia2dadab72019-01-08 21:42:27 +0000982 msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min
Andres Amaya Garcia419bd002019-02-19 20:20:57 +0000983 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 +0200984
Gilles Peskine8f073122018-11-27 15:58:47 +0100985 msg "test: compat.sh ARIA + ChachaPoly"
986 if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
987}
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200988
Gilles Peskine1093d9f2020-04-13 01:03:21 +0200989component_test_default_no_deprecated () {
Gilles Peskine8386ea22020-04-30 09:07:29 +0200990 # Test that removing the deprecated features from the default
991 # configuration leaves something consistent.
Gilles Peskine1093d9f2020-04-13 01:03:21 +0200992 msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
993 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
994 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
995
996 msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
997 make test
998}
999
1000component_test_full_no_deprecated () {
Gilles Peskine30de2e82020-04-20 21:39:22 +02001001 msg "build: make, full_no_deprecated config" # ~ 30s
1002 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001003 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1004
Gilles Peskine30de2e82020-04-20 21:39:22 +02001005 msg "test: make, full_no_deprecated config" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001006 make test
1007}
1008
Gilles Peskine8386ea22020-04-30 09:07:29 +02001009component_test_full_no_deprecated_deprecated_warning () {
1010 # Test that there is nothing deprecated in "full_no_deprecated".
1011 # A deprecated feature would trigger a warning (made fatal) from
1012 # MBEDTLS_DEPRECATED_WARNING.
Gilles Peskine30de2e82020-04-20 21:39:22 +02001013 msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
1014 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001015 scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
1016 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
1017 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1018
Gilles Peskine30de2e82020-04-20 21:39:22 +02001019 msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001020 make test
1021}
1022
Gilles Peskine8386ea22020-04-30 09:07:29 +02001023component_test_full_deprecated_warning () {
1024 # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
1025 # with only certain whitelisted types of warnings.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001026 msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001027 scripts/config.py full
1028 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001029 # Expect warnings from '#warning' directives in check_config.h.
1030 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +01001031
Gilles Peskine8386ea22020-04-30 09:07:29 +02001032 msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
1033 # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
1034 # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001035 # Expect warnings from '#warning' directives in check_config.h and
1036 # from the use of deprecated functions in test suites.
1037 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 +01001038
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001039 msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
1040 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001041}
Jaeden Ameroed93bdc2018-11-02 16:57:24 +00001042
Gilles Peskineec541fe2020-01-31 14:24:14 +01001043# Check that the specified libraries exist and are empty.
1044are_empty_libraries () {
1045 nm "$@" >/dev/null 2>/dev/null
1046 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
1047}
1048
1049component_build_crypto_default () {
1050 msg "build: make, crypto only"
1051 scripts/config.py crypto
Gilles Peskine6bb39152020-02-03 11:59:20 +01001052 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001053 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1054}
1055
1056component_build_crypto_full () {
1057 msg "build: make, crypto only, full config"
1058 scripts/config.py crypto_full
Gilles Peskine6bb39152020-02-03 11:59:20 +01001059 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001060 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1061}
1062
1063component_build_crypto_baremetal () {
1064 msg "build: make, crypto only, baremetal config"
1065 scripts/config.py crypto_baremetal
Gilles Peskine6bb39152020-02-03 11:59:20 +01001066 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001067 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1068}
1069
Gilles Peskine8f073122018-11-27 15:58:47 +01001070component_test_depends_curves () {
1071 msg "test/build: curves.pl (gcc)" # ~ 4 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001072 record_status tests/scripts/curves.pl
1073}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001074
Gilles Peskine8f073122018-11-27 15:58:47 +01001075component_test_depends_hashes () {
1076 msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001077 record_status tests/scripts/depends-hashes.pl
1078}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001079
Gilles Peskine8f073122018-11-27 15:58:47 +01001080component_test_depends_pkalgs () {
1081 msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001082 record_status tests/scripts/depends-pkalgs.pl
1083}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001084
Gilles Peskine8f073122018-11-27 15:58:47 +01001085component_build_key_exchanges () {
1086 msg "test/build: key-exchanges (gcc)" # ~ 1 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001087 record_status tests/scripts/key-exchanges.pl
1088}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001089
Gilles Peskine8f073122018-11-27 15:58:47 +01001090component_build_default_make_gcc_and_cxx () {
1091 msg "build: Unix make, -Os (gcc)" # ~ 30s
Gilles Peskine8f073122018-11-27 15:58:47 +01001092 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001093
Gilles Peskine8f073122018-11-27 15:58:47 +01001094 msg "test: verify header list in cpp_dummy_build.cpp"
1095 record_status check_headers_in_cpp
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001096
Gilles Peskine8f073122018-11-27 15:58:47 +01001097 msg "build: Unix make, incremental g++"
1098 make TEST_CPP=1
1099}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001100
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001101component_test_no_use_psa_crypto_full_cmake_asan() {
1102 # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
Gilles Peskinedc3a1792019-09-03 11:42:04 +02001103 msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001104 scripts/config.py full
1105 scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
1106 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1107 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1108 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskinedc6d8382020-04-12 14:21:55 +02001109 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001110 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Manuel Pégourié-Gonnardd8167e82019-02-01 11:12:52 +01001111 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001112 make
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +02001113
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001114 msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001115 make test
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +02001116
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001117 msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001118 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001119
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001120 msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001121 if_build_succeeded tests/compat.sh
Andrzej Kurek991f9fe2018-07-02 09:08:21 -04001122
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001123 msg "test: compat.sh RC4, DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001124 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 -05001125
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001126 msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001127 if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
1128}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001129
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001130component_test_check_params_functionality () {
1131 msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001132 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001133 # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001134 scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001135 # Only build and run tests. Do not build sample programs, because
1136 # they don't have a mbedtls_param_failed() function.
1137 make CC=gcc CFLAGS='-Werror -O1' lib test
1138}
1139
Gilles Peskineb28636b2019-01-02 19:06:24 +01001140component_test_check_params_without_platform () {
1141 msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001142 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001143 # Keep MBEDTLS_PARAM_FAILED as assert.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001144 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
1145 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
1146 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
1147 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
Gilles Peskine32e889d2020-04-12 23:43:28 +02001148 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001149 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
1150 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
1151 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1152 scripts/config.py unset MBEDTLS_PLATFORM_C
Gilles Peskineb28636b2019-01-02 19:06:24 +01001153 make CC=gcc CFLAGS='-Werror -O1' all test
1154}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001155
Gilles Peskineb28636b2019-01-02 19:06:24 +01001156component_test_check_params_silent () {
1157 msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001158 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001159 # Set MBEDTLS_PARAM_FAILED to nothing.
Gilles Peskineb28636b2019-01-02 19:06:24 +01001160 sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
1161 make CC=gcc CFLAGS='-Werror -O1' all test
1162}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001163
Gilles Peskine8f073122018-11-27 15:58:47 +01001164component_test_no_platform () {
1165 # Full configuration build, without platform support, file IO and net sockets.
1166 # This should catch missing mbedtls_printf definitions, and by disabling file
1167 # IO, it should catch missing '#include <stdio.h>'
1168 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001169 scripts/config.py full
1170 scripts/config.py unset MBEDTLS_PLATFORM_C
1171 scripts/config.py unset MBEDTLS_NET_C
1172 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
1173 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
1174 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
1175 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
1176 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
1177 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
Gilles Peskine32e889d2020-04-12 23:43:28 +02001178 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001179 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1180 scripts/config.py unset MBEDTLS_FS_IO
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001181 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001182 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
1183 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001184 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
1185 # to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001186 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
1187 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
Gilles Peskine8f073122018-11-27 15:58:47 +01001188}
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +00001189
Gilles Peskine8f073122018-11-27 15:58:47 +01001190component_build_no_std_function () {
1191 # catch compile bugs in _uninit functions
1192 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001193 scripts/config.py full
1194 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
1195 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02001196 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001197 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Gilles Peskine8f073122018-11-27 15:58:47 +01001198}
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +01001199
Gilles Peskine8f073122018-11-27 15:58:47 +01001200component_build_no_ssl_srv () {
1201 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001202 scripts/config.py full
1203 scripts/config.py unset MBEDTLS_SSL_SRV_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001204 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01001205}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02001206
Gilles Peskine8f073122018-11-27 15:58:47 +01001207component_build_no_ssl_cli () {
1208 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001209 scripts/config.py full
1210 scripts/config.py unset MBEDTLS_SSL_CLI_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001211 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01001212}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02001213
Gilles Peskine8f073122018-11-27 15:58:47 +01001214component_build_no_sockets () {
1215 # Note, C99 compliance can also be tested with the sockets support disabled,
1216 # as that requires a POSIX platform (which isn't the same as C99).
1217 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001218 scripts/config.py full
1219 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
1220 scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001221 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01001222}
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +02001223
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04001224component_test_memory_buffer_allocator_backtrace () {
1225 msg "build: default config with memory buffer allocator and backtrace enabled"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001226 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
1227 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
1228 scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
1229 scripts/config.py set MBEDTLS_MEMORY_DEBUG
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04001230 CC=gcc cmake .
1231 make
1232
1233 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
1234 make test
1235}
1236
1237component_test_memory_buffer_allocator () {
1238 msg "build: default config with memory buffer allocator"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001239 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
1240 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
Hanno Becker0fb9ba22019-02-26 14:34:13 +00001241 CC=gcc cmake .
1242 make
1243
1244 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
1245 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001246
1247 msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
1248 # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
1249 if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy'
Hanno Becker0fb9ba22019-02-26 14:34:13 +00001250}
1251
Gilles Peskine8f073122018-11-27 15:58:47 +01001252component_test_no_max_fragment_length () {
1253 # Run max fragment length tests with MFL disabled
1254 msg "build: default config except MFL extension (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001255 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Gilles Peskine8f073122018-11-27 15:58:47 +01001256 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1257 make
Hanno Becker5175ac62017-09-18 15:36:25 +01001258
Gilles Peskine8f073122018-11-27 15:58:47 +01001259 msg "test: ssl-opt.sh, MFL-related tests"
1260 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
1261}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001262
Hanno Becker545ced42019-02-19 11:10:48 +00001263component_test_asan_remove_peer_certificate () {
1264 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001265 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
Hanno Becker545ced42019-02-19 11:10:48 +00001266 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1267 make
1268
1269 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1270 make test
1271
1272 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1273 if_build_succeeded tests/ssl-opt.sh
1274
1275 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1276 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001277
1278 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1279 if_build_succeeded tests/context-info.sh
Hanno Becker545ced42019-02-19 11:10:48 +00001280}
1281
Gilles Peskine8f073122018-11-27 15:58:47 +01001282component_test_no_max_fragment_length_small_ssl_out_content_len () {
1283 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001284 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1285 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
1286 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01001287 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1288 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001289
Gilles Peskine8f073122018-11-27 15:58:47 +01001290 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
1291 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001292
1293 msg "test: context-info.sh (disabled MFL extension case)"
1294 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001295}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001296
Darryl Greenaad82f92019-12-02 10:53:11 +00001297component_test_variable_ssl_in_out_buffer_len () {
1298 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
1299 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1300 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1301 make
1302
1303 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
1304 make test
1305
1306 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
1307 if_build_succeeded tests/ssl-opt.sh
1308
1309 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
1310 if_build_succeeded tests/compat.sh
1311}
1312
1313component_test_variable_ssl_in_out_buffer_len_CID () {
1314 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)"
1315 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1316 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
1317
1318 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1319 make
1320
1321 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID"
1322 make test
1323
1324 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
1325 if_build_succeeded tests/ssl-opt.sh
1326
1327 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
1328 if_build_succeeded tests/compat.sh
1329}
1330
1331component_test_variable_ssl_in_out_buffer_len_record_splitting () {
1332 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)"
1333 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1334 scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING
1335
1336 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1337 make
1338
1339 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING"
1340 make test
1341
1342 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
1343 if_build_succeeded tests/ssl-opt.sh
1344
1345 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
1346 if_build_succeeded tests/compat.sh
1347}
1348
Piotr Nowicki0937ed22019-11-26 16:32:40 +01001349component_test_ssl_alloc_buffer_and_mfl () {
1350 msg "build: default config with memory buffer allocator and MFL extension"
1351 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
1352 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
1353 scripts/config.py set MBEDTLS_MEMORY_DEBUG
1354 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1355 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1356 CC=gcc cmake .
1357 make
1358
1359 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
1360 make test
1361
1362 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
1363 if_build_succeeded tests/ssl-opt.sh -f "Handshake memory usage"
1364}
1365
Gilles Peskine636c26a2020-03-04 20:46:15 +01001366component_test_when_no_ciphersuites_have_mac () {
1367 msg "build: when no ciphersuites have MAC"
1368 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1369 scripts/config.py unset MBEDTLS_ARC4_C
1370 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1371 make
1372
1373 msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
1374 make test
1375
1376 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
1377 if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
1378}
1379
Gilles Peskine8f073122018-11-27 15:58:47 +01001380component_test_null_entropy () {
1381 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001382 scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY
1383 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
1384 scripts/config.py set MBEDTLS_ENTROPY_C
1385 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02001386 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001387 scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT
1388 scripts/config.py unset MBEDTLS_HAVEGE_C
Gilles Peskine5fa32a72019-01-06 19:48:30 +00001389 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON .
Gilles Peskine8f073122018-11-27 15:58:47 +01001390 make
Janos Follath06c54002016-06-09 13:57:40 +01001391
Gilles Peskine8f073122018-11-27 15:58:47 +01001392 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
1393 make test
1394}
Janos Follath06c54002016-06-09 13:57:40 +01001395
Gilles Peskine8f073122018-11-27 15:58:47 +01001396component_test_platform_calloc_macro () {
1397 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001398 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
1399 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
1400 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
Gilles Peskine8f073122018-11-27 15:58:47 +01001401 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1402 make
Hanno Beckere5fecec2018-10-11 11:02:52 +01001403
Gilles Peskine8f073122018-11-27 15:58:47 +01001404 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
1405 make test
1406}
Hanno Beckere5fecec2018-10-11 11:02:52 +01001407
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02001408component_test_malloc_0_null () {
1409 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01001410 scripts/config.py full
Gilles Peskine004206c2019-10-21 17:11:33 +02001411 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 +02001412
1413 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
1414 make test
1415
1416 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
1417 # Just the calloc selftest. "make test" ran the others as part of the
1418 # test suites.
1419 if_build_succeeded programs/test/selftest calloc
Gilles Peskine765d2402020-02-11 18:26:34 +01001420
1421 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
1422 # Run a subset of the tests. The choice is a balance between coverage
1423 # and time (including time indirectly wasted due to flaky tests).
1424 # The current choice is to skip tests whose description includes
1425 # "proxy", which is an approximation of skipping tests that use the
1426 # UDP proxy, which tend to be slower and flakier.
1427 if_build_succeeded tests/ssl-opt.sh -e 'proxy'
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02001428}
1429
Gilles Peskine8f073122018-11-27 15:58:47 +01001430component_test_aes_fewer_tables () {
1431 msg "build: default config with AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001432 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01001433 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01001434
Gilles Peskine8f073122018-11-27 15:58:47 +01001435 msg "test: AES_FEWER_TABLES"
1436 make test
1437}
Hanno Becker83ebf782017-07-07 12:29:15 +01001438
Gilles Peskine8f073122018-11-27 15:58:47 +01001439component_test_aes_rom_tables () {
1440 msg "build: default config with AES_ROM_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001441 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01001442 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01001443
Gilles Peskine8f073122018-11-27 15:58:47 +01001444 msg "test: AES_ROM_TABLES"
1445 make test
1446}
Hanno Becker83ebf782017-07-07 12:29:15 +01001447
Gilles Peskine8f073122018-11-27 15:58:47 +01001448component_test_aes_fewer_tables_and_rom_tables () {
1449 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001450 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
1451 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01001452 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01001453
Gilles Peskine8f073122018-11-27 15:58:47 +01001454 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
1455 make test
1456}
1457
Gilles Peskine592f5912019-10-07 18:49:32 +02001458component_test_ctr_drbg_aes_256_sha_256 () {
1459 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01001460 scripts/config.py full
1461 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
1462 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02001463 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1464 make
1465
1466 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
1467 make test
1468}
1469
1470component_test_ctr_drbg_aes_128_sha_512 () {
1471 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01001472 scripts/config.py full
1473 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
1474 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
Gilles Peskine592f5912019-10-07 18:49:32 +02001475 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1476 make
1477
1478 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
1479 make test
1480}
1481
1482component_test_ctr_drbg_aes_128_sha_256 () {
1483 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01001484 scripts/config.py full
1485 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
1486 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
1487 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02001488 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1489 make
1490
1491 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
1492 make test
1493}
1494
Gilles Peskinef96aefe2019-07-24 14:58:38 +02001495component_test_se_default () {
1496 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001497 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine004206c2019-10-21 17:11:33 +02001498 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinef96aefe2019-07-24 14:58:38 +02001499
1500 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
1501 make test
1502}
1503
Gilles Peskine8f073122018-11-27 15:58:47 +01001504component_test_make_shared () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001505 msg "build/test: make shared" # ~ 40s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001506 make SHARED=1 all check
Gilles Peskine56c01612019-07-03 20:43:32 +02001507 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskine8f073122018-11-27 15:58:47 +01001508}
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +02001509
Gilles Peskinecf740502019-07-03 20:43:05 +02001510component_test_cmake_shared () {
1511 msg "build/test: cmake shared" # ~ 2min
1512 cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
1513 make
Gilles Peskine56c01612019-07-03 20:43:32 +02001514 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskinecf740502019-07-03 20:43:05 +02001515 make test
1516}
1517
Gilles Peskineec10bf12019-09-20 19:56:06 +02001518test_build_opt () {
1519 info=$1 cc=$2; shift 2
1520 for opt in "$@"; do
1521 msg "build/test: $cc $opt, $info" # ~ 30s
Gilles Peskinee094a182020-04-14 20:08:41 +02001522 make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Gilles Peskineec10bf12019-09-20 19:56:06 +02001523 # We're confident enough in compilers to not run _all_ the tests,
1524 # but at least run the unit tests. In particular, runs with
1525 # optimizations use inline assembly whereas runs with -O0
1526 # skip inline assembly.
1527 make test # ~30s
1528 make clean
1529 done
1530}
1531
1532component_test_clang_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01001533 scripts/config.py full
Gilles Peskineec10bf12019-09-20 19:56:06 +02001534 test_build_opt 'full config' clang -O0 -Os -O2
1535}
1536
1537component_test_gcc_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01001538 scripts/config.py full
Gilles Peskineec10bf12019-09-20 19:56:06 +02001539 test_build_opt 'full config' gcc -O0 -Os -O2
1540}
1541
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02001542component_build_mbedtls_config_file () {
1543 msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
1544 # Use the full config so as to catch a maximum of places where
1545 # the check of MBEDTLS_CONFIG_FILE might be missing.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001546 scripts/config.py full
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02001547 sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h
1548 echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
1549 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
1550 rm -f full_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001551}
1552
Gilles Peskine8f073122018-11-27 15:58:47 +01001553component_test_m32_o0 () {
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001554 # Build once with -O0, to compile out the i386 specific inline assembly
1555 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001556 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02001557 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01001558
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001559 msg "test: i386, make, gcc -O0 (ASan build)"
1560 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001561}
Gilles Peskine878cf602019-01-06 20:50:38 +00001562support_test_m32_o0 () {
1563 case $(uname -m) in
1564 *64*) true;;
1565 *) false;;
1566 esac
1567}
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001568
Gilles Peskine8f073122018-11-27 15:58:47 +01001569component_test_m32_o1 () {
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001570 # Build again with -O1, to compile in the i386 specific inline assembly
1571 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001572 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02001573 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS"
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001574
1575 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001576 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001577
1578 msg "test ssl-opt.sh, i386, make, gcc-O1"
1579 if_build_succeeded tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001580}
Gilles Peskine878cf602019-01-06 20:50:38 +00001581support_test_m32_o1 () {
1582 support_test_m32_o0 "$@"
1583}
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001584
Gilles Peskine0c6b7992019-04-12 20:29:48 +02001585component_test_m32_everest () {
1586 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001587 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1588 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
Gilles Peskine8fd59422019-10-21 17:11:33 +02001589 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Gilles Peskine0c6b7992019-04-12 20:29:48 +02001590
1591 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1592 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001593
1594 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
1595 if_build_succeeded tests/ssl-opt.sh -f ECDH
1596
1597 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1598 # Exclude some symmetric ciphers that are redundant here to gain time.
1599 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine0c6b7992019-04-12 20:29:48 +02001600}
1601support_test_m32_everest () {
1602 support_test_m32_o0 "$@"
1603}
1604
Gilles Peskine8f073122018-11-27 15:58:47 +01001605component_test_mx32 () {
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001606 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001607 scripts/config.py full
Gilles Peskine5d26e7c2019-06-07 14:50:09 +02001608 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001609
1610 msg "test: 64-bit ILP32, make, gcc"
1611 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001612}
Gilles Peskine878cf602019-01-06 20:50:38 +00001613support_test_mx32 () {
1614 case $(uname -m) in
1615 amd64|x86_64) true;;
1616 *) false;;
1617 esac
1618}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001619
Peter Kolbus60c6da22018-12-27 06:59:04 -06001620component_test_min_mpi_window_size () {
1621 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001622 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
Peter Kolbus60c6da22018-12-27 06:59:04 -06001623 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1624 make
1625
1626 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
1627 make test
1628}
1629
Gilles Peskine8f073122018-11-27 15:58:47 +01001630component_test_have_int32 () {
1631 msg "build: gcc, force 32-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001632 scripts/config.py unset MBEDTLS_HAVE_ASM
1633 scripts/config.py unset MBEDTLS_AESNI_C
1634 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001635 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01001636
Gilles Peskine8f073122018-11-27 15:58:47 +01001637 msg "test: gcc, force 32-bit bignum limbs"
1638 make test
1639}
Andres Amaya Garciafe843a32017-07-20 13:21:34 +01001640
Gilles Peskine8f073122018-11-27 15:58:47 +01001641component_test_have_int64 () {
1642 msg "build: gcc, force 64-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001643 scripts/config.py unset MBEDTLS_HAVE_ASM
1644 scripts/config.py unset MBEDTLS_AESNI_C
1645 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001646 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Gilles Peskine14c3c062018-01-29 21:25:12 +01001647
Gilles Peskine8f073122018-11-27 15:58:47 +01001648 msg "test: gcc, force 64-bit bignum limbs"
1649 make test
1650}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001651
Gilles Peskine8f073122018-11-27 15:58:47 +01001652component_test_no_udbl_division () {
1653 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001654 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001655 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine8f073122018-11-27 15:58:47 +01001656 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001657
Gilles Peskine8f073122018-11-27 15:58:47 +01001658 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
1659 make test
1660}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001661
Gilles Peskine8f073122018-11-27 15:58:47 +01001662component_test_no_64bit_multiplication () {
1663 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001664 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001665 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine8f073122018-11-27 15:58:47 +01001666 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001667
Gilles Peskine8f073122018-11-27 15:58:47 +01001668 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
1669 make test
1670}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001671
Gilles Peskine8f073122018-11-27 15:58:47 +01001672component_build_arm_none_eabi_gcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02001673 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001674 scripts/config.py baremetal
Gilles Peskine65375882020-04-30 22:54:00 +02001675 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra -O1' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02001676
1677 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1"
1678 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01001679}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001680
Gilles Peskine2c897d72019-08-09 16:05:05 +02001681component_build_arm_none_eabi_gcc_arm5vte () {
Gilles Peskine18487f62020-04-30 23:11:54 +02001682 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001683 scripts/config.py baremetal
Gilles Peskine2c897d72019-08-09 16:05:05 +02001684 # Build for a target platform that's close to what Debian uses
1685 # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
1686 # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments.
1687 # It would be better to build with arm-linux-gnueabi-gcc but
1688 # we don't have that on our CI at this time.
Gilles Peskine6d061342020-04-30 18:19:32 +02001689 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02001690
1691 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1"
1692 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine93e4e032019-08-05 11:34:25 +02001693}
1694
Gilles Peskine6e2fb862020-04-30 23:00:53 +02001695component_build_arm_none_eabi_gcc_m0plus () {
1696 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s
1697 scripts/config.py baremetal
1698 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02001699
1700 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os"
1701 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine6e2fb862020-04-30 23:00:53 +02001702}
1703
Gilles Peskine8f073122018-11-27 15:58:47 +01001704component_build_arm_none_eabi_gcc_no_udbl_division () {
Gilles Peskine6d061342020-04-30 18:19:32 +02001705 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001706 scripts/config.py baremetal
1707 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine6d061342020-04-30 18:19:32 +02001708 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01001709 echo "Checking that software 64-bit division is not required"
1710 if_build_succeeded not grep __aeabi_uldiv library/*.o
1711}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001712
Gilles Peskine8f073122018-11-27 15:58:47 +01001713component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
Gilles Peskine6d061342020-04-30 18:19:32 +02001714 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001715 scripts/config.py baremetal
1716 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine6d061342020-04-30 18:19:32 +02001717 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01001718 echo "Checking that software 64-bit multiplication is not required"
1719 if_build_succeeded not grep __aeabi_lmul library/*.o
1720}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001721
Gilles Peskine8f073122018-11-27 15:58:47 +01001722component_build_armcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02001723 msg "build: ARM Compiler 5"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001724 scripts/config.py baremetal
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001725 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02001726
1727 msg "size: ARM Compiler 5"
1728 "$ARMC5_FROMELF" -z library/*.o
1729
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001730 make clean
Andres AG87bb5772016-09-27 15:05:15 +01001731
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001732 # ARM Compiler 6 - Target ARMv7-A
1733 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02001734
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001735 # ARM Compiler 6 - Target ARMv7-M
1736 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02001737
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001738 # ARM Compiler 6 - Target ARMv8-A - AArch32
1739 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02001740
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001741 # ARM Compiler 6 - Target ARMv8-M
1742 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02001743
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001744 # ARM Compiler 6 - Target ARMv8-A - AArch64
1745 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Gilles Peskine8f073122018-11-27 15:58:47 +01001746}
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01001747
Manuel Pégourié-Gonnarddd8807f2020-02-26 09:56:27 +01001748component_build_ssl_hw_record_accel() {
1749 msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled"
1750 scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL
1751 make CFLAGS='-Werror -O1'
1752}
1753
Gilles Peskine8f073122018-11-27 15:58:47 +01001754component_test_allow_sha1 () {
1755 msg "build: allow SHA1 in certificates by default"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001756 scripts/config.py set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine8f073122018-11-27 15:58:47 +01001757 make CFLAGS='-Werror -Wall -Wextra'
1758 msg "test: allow SHA1 in certificates by default"
1759 make test
1760 if_build_succeeded tests/ssl-opt.sh -f SHA-1
1761}
Gilles Peskine2a458da2017-05-12 15:26:58 +02001762
Hanno Beckera711f6e2020-05-04 12:03:51 +01001763component_test_tls13_experimental () {
1764 msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
1765 scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
1766 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1767 make
1768 msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
1769 make test
1770}
1771
Gilles Peskine8f073122018-11-27 15:58:47 +01001772component_build_mingw () {
1773 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001774 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 +00001775
Gilles Peskine8f073122018-11-27 15:58:47 +01001776 # note Make tests only builds the tests, but doesn't run them
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001777 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 +01001778 make WINDOWS_BUILD=1 clean
Simon Butcher002bc622016-11-17 09:27:45 +00001779
Gilles Peskine8f073122018-11-27 15:58:47 +01001780 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001781 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
1782 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 +01001783 make WINDOWS_BUILD=1 clean
1784}
Jaeden Amero117b8a42019-04-17 15:19:26 +01001785support_build_mingw() {
1786 case $(i686-w64-mingw32-gcc -dumpversion) in
1787 [0-5]*) false;;
1788 *) true;;
1789 esac
1790}
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +01001791
Gilles Peskine8f073122018-11-27 15:58:47 +01001792component_test_memsan () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001793 msg "build: MSan (clang)" # ~ 1 min 20s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001794 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001795 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1796 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02001797
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001798 msg "test: main suites (MSan)" # ~ 10s
1799 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001800
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001801 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +01001802 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001803
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001804 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001805
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001806 if [ "$MEMORY" -gt 0 ]; then
1807 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +01001808 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001809 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01001810}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001811
Gilles Peskine69f190e2019-01-10 00:11:42 +01001812component_test_valgrind () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001813 msg "build: Release (clang)"
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001814 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
1815 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001816
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001817 msg "test: main suites valgrind (Release)"
1818 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001819
Gilles Peskine636c26a2020-03-04 20:46:15 +01001820 # Optional parts (slow; currently broken on OS X because programs don't
1821 # seem to receive signals under valgrind on OS X).
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001822 if [ "$MEMORY" -gt 0 ]; then
1823 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001824 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001825 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001826
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001827 if [ "$MEMORY" -gt 1 ]; then
1828 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001829 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001830 fi
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001831
1832 if [ "$MEMORY" -gt 0 ]; then
1833 msg "test: context-info.sh --memcheck (Release)"
1834 if_build_succeeded tests/context-info.sh --memcheck
1835 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01001836}
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001837
Gilles Peskine8f073122018-11-27 15:58:47 +01001838component_test_cmake_out_of_source () {
1839 msg "build: cmake 'out-of-source' build"
Gilles Peskine8f073122018-11-27 15:58:47 +01001840 MBEDTLS_ROOT_DIR="$PWD"
1841 mkdir "$OUT_OF_SOURCE_DIR"
1842 cd "$OUT_OF_SOURCE_DIR"
1843 cmake "$MBEDTLS_ROOT_DIR"
1844 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001845
Gilles Peskine8f073122018-11-27 15:58:47 +01001846 msg "test: cmake 'out-of-source' build"
1847 make test
1848 # Test an SSL option that requires an auxiliary script in test/scripts/.
1849 # Also ensure that there are no error messages such as
1850 # "No such file or directory", which would indicate that some required
1851 # file is missing (ssl-opt.sh tolerates the absence of some files so
1852 # may exit with status 0 but emit errors).
1853 if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
1854 if [ -s ssl-opt.err ]; then
1855 cat ssl-opt.err >&2
1856 record_status [ ! -s ssl-opt.err ]
1857 rm ssl-opt.err
1858 fi
1859 cd "$MBEDTLS_ROOT_DIR"
1860 rm -rf "$OUT_OF_SOURCE_DIR"
1861 unset MBEDTLS_ROOT_DIR
1862}
Andres AGdc192212016-08-31 17:33:13 +01001863
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01001864component_test_cmake_as_subdirectory () {
1865 msg "build: cmake 'as-subdirectory' build"
1866 MBEDTLS_ROOT_DIR="$PWD"
1867
1868 cd programs/test/cmake_subproject
1869 cmake .
1870 make
1871 if_build_succeeded ./cmake_subproject
1872
1873 cd "$MBEDTLS_ROOT_DIR"
1874 unset MBEDTLS_ROOT_DIR
1875}
1876
Gilles Peskine8f073122018-11-27 15:58:47 +01001877component_test_zeroize () {
1878 # Test that the function mbedtls_platform_zeroize() is not optimized away by
1879 # different combinations of compilers and optimization flags by using an
1880 # auxiliary GDB script. Unfortunately, GDB does not return error values to the
1881 # system in all cases that the script fails, so we must manually search the
1882 # output to check whether the pass string is present and no failure strings
1883 # were printed.
Andres AGdc192212016-08-31 17:33:13 +01001884
Gilles Peskine4976e822019-01-06 19:52:22 +00001885 # Don't try to disable ASLR. We don't care about ASLR here. We do care
1886 # about a spurious message if Gdb tries and fails, so suppress that.
1887 gdb_disable_aslr=
1888 if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
1889 gdb_disable_aslr='set disable-randomization off'
1890 fi
1891
Gilles Peskine8f073122018-11-27 15:58:47 +01001892 for optimization_flag in -O2 -O3 -Ofast -Os; do
Gilles Peskine55f7c942019-01-09 22:28:21 +01001893 for compiler in clang gcc; do
1894 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
1895 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Gilles Peskine4976e822019-01-06 19:52:22 +00001896 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 +01001897 if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log
1898 if_build_succeeded not grep -i "error" test_zeroize.log
1899 rm -f test_zeroize.log
1900 make clean
1901 done
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001902 done
Andres Amaya Garciad0d7bf62017-10-25 09:01:31 +01001903
Gilles Peskine4976e822019-01-06 19:52:22 +00001904 unset gdb_disable_aslr
Gilles Peskine8f073122018-11-27 15:58:47 +01001905}
Gilles Peskine192c72f2017-12-21 15:59:21 +01001906
Gilles Peskine8f073122018-11-27 15:58:47 +01001907component_check_python_files () {
1908 msg "Lint: Python scripts"
1909 record_status tests/scripts/check-python-files.sh
1910}
Gilles Peskine192c72f2017-12-21 15:59:21 +01001911
Gilles Peskine8f073122018-11-27 15:58:47 +01001912component_check_generate_test_code () {
1913 msg "uint test: generate_test_code.py"
1914 record_status ./tests/scripts/test_generate_test_code.py
1915}
Gilles Peskine192c72f2017-12-21 15:59:21 +01001916
1917################################################################
1918#### Termination
1919################################################################
1920
Gilles Peskine8f073122018-11-27 15:58:47 +01001921post_report () {
1922 msg "Done, cleaning up"
1923 cleanup
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001924
Gilles Peskine8f073122018-11-27 15:58:47 +01001925 final_report
1926}
1927
1928
1929
1930################################################################
1931#### Run all the things
1932################################################################
1933
Gilles Peskinee48351a2018-11-27 16:06:30 +01001934# Run one component and clean up afterwards.
Gilles Peskine8f073122018-11-27 15:58:47 +01001935run_component () {
Gilles Peskine608953e2019-01-02 18:57:02 +01001936 # Back up the configuration in case the component modifies it.
1937 # The cleanup function will restore it.
1938 cp -p "$CONFIG_H" "$CONFIG_BAK"
Gilles Peskineffcdeff2018-12-04 12:49:28 +01001939 current_component="$1"
Gilles Peskine9004a172019-09-16 15:20:36 +02001940 export MBEDTLS_TEST_CONFIGURATION="$current_component"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02001941
1942 # Unconditionally create a seedfile that's sufficiently long.
1943 # Do this before each component, because a previous component may
1944 # have messed it up or shortened it.
1945 dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
1946
1947 # Run the component code.
Gilles Peskine8f073122018-11-27 15:58:47 +01001948 "$@"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02001949
1950 # Restore the build tree to a clean state.
Gilles Peskinee48351a2018-11-27 16:06:30 +01001951 cleanup
Gilles Peskine8f073122018-11-27 15:58:47 +01001952}
1953
1954# Preliminary setup
1955pre_check_environment
1956pre_initialize_variables
1957pre_parse_command_line "$@"
Gilles Peskine348fb9a2018-11-27 17:04:29 +01001958
Gilles Peskine878cf602019-01-06 20:50:38 +00001959pre_check_git
Andrzej Kurekeb508712019-02-14 07:18:59 -05001960
Gilles Peskine878cf602019-01-06 20:50:38 +00001961build_status=0
1962if [ $KEEP_GOING -eq 1 ]; then
1963 pre_setup_keep_going
Gilles Peskine92525112018-11-27 18:15:35 +01001964else
Gilles Peskine878cf602019-01-06 20:50:38 +00001965 record_status () {
1966 "$@"
1967 }
Gilles Peskine8f073122018-11-27 15:58:47 +01001968fi
Gilles Peskine67ffdaf2019-09-16 15:55:46 +02001969pre_prepare_outcome_file
Gilles Peskine878cf602019-01-06 20:50:38 +00001970pre_print_configuration
1971pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001972cleanup
1973
Gilles Peskinebeb3a812019-01-06 22:11:25 +00001974# Run the requested tests.
1975for component in $RUN_COMPONENTS; do
1976 run_component "component_$component"
1977done
Gilles Peskine8f073122018-11-27 15:58:47 +01001978
1979# We're done.
Gilles Peskine878cf602019-01-06 20:50:38 +00001980post_report