blob: 32efc1d1f078a63382de42b9fdf05da44caa0503 [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#
SimonB2e23c822016-04-16 21:54:39 +01005# This file is part of mbed TLS (https://tls.mbed.org)
6#
Gilles Peskine192c72f2017-12-21 15:59:21 +01007# Copyright (c) 2014-2017, ARM Limited, All Rights Reserved
8
9
10
11################################################################
12#### Documentation
13################################################################
14
Simon Butcher3ea7f522016-03-07 23:22:10 +000015# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010016# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000017#
SimonB2e23c822016-04-16 21:54:39 +010018# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010019#
Gilles Peskine192c72f2017-12-21 15:59:21 +010020# Notes for users
21# ---------------
22#
SimonB2e23c822016-04-16 21:54:39 +010023# Warning: the test is destructive. It includes various build modes and
24# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010025# configuration. The following files must be committed into git:
26# * include/mbedtls/config.h
Gilles Peskine636c26a2020-03-04 20:46:15 +010027# * Makefile, library/Makefile, programs/Makefile, tests/Makefile,
28# programs/fuzz/Makefile
Gilles Peskine192c72f2017-12-21 15:59:21 +010029# After running this script, the CMake cache will be lost and CMake
30# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010031#
Gilles Peskine192c72f2017-12-21 15:59:21 +010032# The script assumes the presence of a number of tools:
33# * Basic Unix tools (Windows users note: a Unix-style find must be before
34# the Windows find in the PATH)
35# * Perl
36# * GNU Make
37# * CMake
38# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040039# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010040# * arm-gcc and mingw-gcc
41# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine192c72f2017-12-21 15:59:21 +010042# * OpenSSL and GnuTLS command line tools, recent enough for the
43# interoperability tests. If they don't support SSLv3 then a legacy
44# version of these tools must be present as well (search for LEGACY
45# below).
46# See the invocation of check_tools below for details.
47#
48# This script must be invoked from the toplevel directory of a git
49# working copy of Mbed TLS.
50#
51# Note that the output is not saved. You may want to run
52# script -c tests/scripts/all.sh
53# or
54# tests/scripts/all.sh >all.log 2>&1
55#
56# Notes for maintainers
57# ---------------------
58#
Gilles Peskine8f073122018-11-27 15:58:47 +010059# The bulk of the code is organized into functions that follow one of the
60# following naming conventions:
61# * pre_XXX: things to do before running the tests, in order.
62# * component_XXX: independent components. They can be run in any order.
Gilles Peskinec70637a2019-01-09 22:29:17 +010063# * component_check_XXX: quick tests that aren't worth parallelizing.
64# * component_build_XXX: build things but don't run them.
65# * component_test_XXX: build and test.
Gilles Peskine878cf602019-01-06 20:50:38 +000066# * support_XXX: if support_XXX exists and returns false then
67# component_XXX is not run by default.
Gilles Peskine8f073122018-11-27 15:58:47 +010068# * post_XXX: things to do after running the tests.
69# * other: miscellaneous support functions.
70#
Gilles Peskinec70637a2019-01-09 22:29:17 +010071# Each component must start by invoking `msg` with a short informative message.
72#
73# The framework performs some cleanup tasks after each component. This
74# means that components can assume that the working directory is in a
75# cleaned-up state, and don't need to perform the cleanup themselves.
76# * Run `make clean`.
77# * Restore `include/mbedtks/config.h` from a backup made before running
78# the component.
Gilles Peskine636c26a2020-03-04 20:46:15 +010079# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`,
80# `tests/Makefile` and `programs/fuzz/Makefile` from git.
81# This cleans up after an in-tree use of CMake.
Gilles Peskinec70637a2019-01-09 22:29:17 +010082#
83# Any command that is expected to fail must be protected so that the
84# script keeps running in --keep-going mode despite `set -e`. In keep-going
85# mode, if a protected command fails, this is logged as a failure and the
86# script will exit with a failure status once it has run all components.
87# Commands can be protected in any of the following ways:
88# * `make` is a function which runs the `make` command with protection.
89# Note that you must write `make VAR=value`, not `VAR=value make`,
90# because the `VAR=value make` syntax doesn't work with functions.
91# * Put `report_status` before the command to protect it.
92# * Put `if_build_successful` before a command. This protects it, and
93# additionally skips it if a prior invocation of `make` in the same
94# component failed.
95#
Gilles Peskine192c72f2017-12-21 15:59:21 +010096# The tests are roughly in order from fastest to slowest. This doesn't
97# have to be exact, but in general you should add slower tests towards
98# the end and fast checks near the beginning.
Gilles Peskine192c72f2017-12-21 15:59:21 +010099
100
101
102################################################################
103#### Initialization and command line parsing
104################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100105
SimonB2e23c822016-04-16 21:54:39 +0100106# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100107set -eu
108
Gilles Peskine8f073122018-11-27 15:58:47 +0100109pre_check_environment () {
Gilles Peskinea16c2b12019-01-06 19:58:02 +0000110 if [ -d library -a -d include -a -d tests ]; then :; else
Gilles Peskine8f073122018-11-27 15:58:47 +0100111 echo "Must be run from mbed TLS root" >&2
112 exit 1
113 fi
114}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100115
Gilles Peskine8f073122018-11-27 15:58:47 +0100116pre_initialize_variables () {
117 CONFIG_H='include/mbedtls/config.h'
118 CONFIG_BAK="$CONFIG_H.bak"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200119
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200120 append_outcome=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100121 MEMORY=0
122 FORCE=0
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200123 QUIET=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100124 KEEP_GOING=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100125
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200126 : ${MBEDTLS_TEST_OUTCOME_FILE=}
Gilles Peskine9004a172019-09-16 15:20:36 +0200127 : ${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 +0200128 export MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine9004a172019-09-16 15:20:36 +0200129 export MBEDTLS_TEST_PLATFORM
130
Jaeden Ameroc4cc2512019-01-30 15:35:44 +0000131 # Default commands, can be overridden by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100132 : ${OPENSSL:="openssl"}
133 : ${OPENSSL_LEGACY:="$OPENSSL"}
134 : ${OPENSSL_NEXT:="$OPENSSL"}
135 : ${GNUTLS_CLI:="gnutls-cli"}
136 : ${GNUTLS_SERV:="gnutls-serv"}
137 : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
138 : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
139 : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
140 : ${ARMC5_BIN_DIR:=/usr/bin}
141 : ${ARMC6_BIN_DIR:=/usr/bin}
Gilles Peskine6d061342020-04-30 18:19:32 +0200142 : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
Andres AGdc192212016-08-31 17:33:13 +0100143
Gilles Peskine8f073122018-11-27 15:58:47 +0100144 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
Gilles Peskinea1fc4b52019-01-06 20:15:26 +0000145 if [ -z "${MAKEFLAGS+set}" ]; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100146 export MAKEFLAGS="-j"
147 fi
Gilles Peskine878cf602019-01-06 20:50:38 +0000148
Jaeden Amerod48e9c72019-02-07 17:43:39 +0000149 # Include more verbose output for failing tests run by CMake
150 export CTEST_OUTPUT_ON_FAILURE=1
151
Gilles Peskine8fd59422019-10-21 17:11:33 +0200152 # CFLAGS and LDFLAGS for Asan builds that don't use CMake
Gilles Peskine5ca393f2019-10-21 19:06:33 +0200153 ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all'
Gilles Peskine8fd59422019-10-21 17:11:33 +0200154
Gilles Peskine878cf602019-01-06 20:50:38 +0000155 # Gather the list of available components. These are the functions
156 # defined in this script whose name starts with "component_".
157 # Parse the script with sed, because in sh there is no way to list
158 # defined functions.
159 ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
160
161 # Exclude components that are not supported on this platform.
162 SUPPORTED_COMPONENTS=
163 for component in $ALL_COMPONENTS; do
164 case $(type "support_$component" 2>&1) in
165 *' function'*)
166 if ! support_$component; then continue; fi;;
167 esac
168 SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
169 done
Gilles Peskine8f073122018-11-27 15:58:47 +0100170}
Andres AG38495a32016-07-12 16:54:33 +0100171
Gilles Peskinea28db922019-01-10 00:05:18 +0100172# Test whether the component $1 is included in the command line patterns.
173is_component_included()
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100174{
175 set -f
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000176 for pattern in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100177 set +f
178 case ${1#component_} in $pattern) return 0;; esac
179 done
180 set +f
181 return 1
182}
Andres AG7770ea82016-10-10 15:46:20 +0100183
Simon Butcher41eeccf2016-09-07 00:07:09 +0100184usage()
Andres AGd9eba4b2016-08-26 14:42:14 +0100185{
Gilles Peskine709346a2017-12-10 23:43:39 +0100186 cat <<EOF
Gilles Peskine92525112018-11-27 18:15:35 +0100187Usage: $0 [OPTION]... [COMPONENT]...
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100188Run mbedtls release validation tests.
Gilles Peskine92525112018-11-27 18:15:35 +0100189By default, run all tests. With one or more COMPONENT, run only those.
Gilles Peskinea28db922019-01-10 00:05:18 +0100190COMPONENT can be the name of a component or a shell wildcard pattern.
191
192Examples:
193 $0 "check_*"
194 Run all sanity checks.
195 $0 --no-armcc --except test_memsan
196 Run everything except builds that require armcc and MemSan.
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100197
198Special options:
199 -h|--help Print this help and exit.
Gilles Peskine878cf602019-01-06 20:50:38 +0000200 --list-all-components List all available test components and exit.
201 --list-components List components supported on this platform and exit.
Gilles Peskine709346a2017-12-10 23:43:39 +0100202
203General options:
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200204 -q|--quiet Only output component names, and errors if any.
Gilles Peskine709346a2017-12-10 23:43:39 +0100205 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100206 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100207 -m|--memory Additional optional memory tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200208 --append-outcome Append to the outcome file (if used).
Gilles Peskine6d061342020-04-30 18:19:32 +0200209 --arm-none-eabi-gcc-prefix=<string>
210 Prefix for a cross-compiler for arm-none-eabi
211 (default: "${ARM_NONE_EABI_GCC_PREFIX}")
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100212 --armcc Run ARM Compiler builds (on by default).
Gilles Peskinea28db922019-01-10 00:05:18 +0100213 --except Exclude the COMPONENTs listed on the command line,
214 instead of running only those.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200215 --no-append-outcome Write a new outcome file and analyze it (default).
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100216 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100217 --no-force Refuse to overwrite modified files (default).
218 --no-keep-going Stop at the first error (default).
219 --no-memory No additional memory tests (default).
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200220 --no-quiet Print full ouput from components.
Gilles Peskine709346a2017-12-10 23:43:39 +0100221 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200222 --outcome-file=<path> File where test outcomes are written (not done if
223 empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
Gilles Peskine38d81652018-03-21 08:40:26 +0100224 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100225 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
226 -s|--seed Integer seed value to use for this test run.
227
228Tool path options:
229 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
230 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
231 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
232 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
233 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
234 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
235 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
236 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100237 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100238EOF
SimonB2e23c822016-04-16 21:54:39 +0100239}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100240
241# remove built files as well as the cmake cache/config
242cleanup()
243{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100244 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
245 cd "$MBEDTLS_ROOT_DIR"
246 fi
247
Gilles Peskine7c652162017-12-11 00:01:40 +0100248 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200249
Gilles Peskine31b07e22018-03-21 12:15:06 +0100250 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000251 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100252 -iname CMakeFiles -exec rm -rf {} \+ -o \
253 \( -iname cmake_install.cmake -o \
254 -iname CTestTestfile.cmake -o \
255 -iname CMakeCache.txt \) -exec rm {} \+
256 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000257 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Gilles Peskine636c26a2020-03-04 20:46:15 +0100258 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
259 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200260
Jaeden Ameroab83fdf2019-06-20 17:38:22 +0100261 # Remove any artifacts from the component_test_cmake_as_subdirectory test.
262 rm -rf programs/test/cmake_subproject/build
263 rm -f programs/test/cmake_subproject/Makefile
264 rm -f programs/test/cmake_subproject/cmake_subproject
265
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200266 if [ -f "$CONFIG_BAK" ]; then
267 mv "$CONFIG_BAK" "$CONFIG_H"
268 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100269}
270
Gilles Peskine7c652162017-12-11 00:01:40 +0100271# Executed on exit. May be redefined depending on command line options.
272final_report () {
273 :
274}
275
276fatal_signal () {
277 cleanup
278 final_report $1
279 trap - $1
280 kill -$1 $$
281}
282
283trap 'fatal_signal HUP' HUP
284trap 'fatal_signal INT' INT
285trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200286
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100287msg()
288{
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100289 if [ -n "${current_component:-}" ]; then
290 current_section="${current_component#component_}: $1"
291 else
292 current_section="$1"
293 fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200294
295 if [ $QUIET -eq 1 ]; then
296 return
297 fi
298
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100299 echo ""
300 echo "******************************************************************"
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100301 echo "* $current_section "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000302 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100303 echo "******************************************************************"
304}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100305
Gilles Peskine8f073122018-11-27 15:58:47 +0100306armc6_build_test()
307{
308 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100309
Gilles Peskine18487f62020-04-30 23:11:54 +0200310 msg "build: ARM Compiler 6 ($FLAGS)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100311 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
312 WARNING_CFLAGS='-xc -std=c99' make lib
Gilles Peskine18487f62020-04-30 23:11:54 +0200313
314 msg "size: ARM Compiler 6 ($FLAGS)"
315 "$ARMC6_FROMELF" -z library/*.o
316
Gilles Peskine8f073122018-11-27 15:58:47 +0100317 make clean
318}
Andres AGa5cd9732016-10-17 15:23:10 +0100319
Andres AGd9eba4b2016-08-26 14:42:14 +0100320err_msg()
321{
322 echo "$1" >&2
323}
324
325check_tools()
326{
327 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000328 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100329 err_msg "$TOOL not found!"
330 exit 1
331 fi
332 done
333}
334
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400335check_headers_in_cpp () {
Peter Kolbus1bc1a4c2019-02-01 17:19:08 -0600336 ls include/mbedtls | grep "\.h$" >headers.txt
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400337 <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
338 sort |
339 diff headers.txt -
340 rm headers.txt
341}
342
Gilles Peskine8f073122018-11-27 15:58:47 +0100343pre_parse_command_line () {
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000344 COMMAND_LINE_COMPONENTS=
Gilles Peskinea28db922019-01-10 00:05:18 +0100345 all_except=0
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000346 no_armcc=
SimonB2e23c822016-04-16 21:54:39 +0100347
Jaeden Amero9b90f2e2018-11-02 18:34:17 +0000348 # Note that legacy options are ignored instead of being omitted from this
349 # list of options, so invocations that worked with previous version of
350 # all.sh will still run and work properly.
Gilles Peskine8f073122018-11-27 15:58:47 +0100351 while [ $# -gt 0 ]; do
Gilles Peskine55f7c942019-01-09 22:28:21 +0100352 case "$1" in
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200353 --append-outcome) append_outcome=1;;
Gilles Peskine6d061342020-04-30 18:19:32 +0200354 --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000355 --armcc) no_armcc=;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100356 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
357 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000358 --except) all_except=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100359 --force|-f) FORCE=1;;
360 --gnutls-cli) shift; GNUTLS_CLI="$1";;
361 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
362 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
363 --gnutls-serv) shift; GNUTLS_SERV="$1";;
364 --help|-h) usage; exit;;
365 --keep-going|-k) KEEP_GOING=1;;
Gilles Peskine878cf602019-01-06 20:50:38 +0000366 --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
367 --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100368 --memory|-m) MEMORY=1;;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200369 --no-append-outcome) append_outcome=0;;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000370 --no-armcc) no_armcc=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100371 --no-force) FORCE=0;;
372 --no-keep-going) KEEP_GOING=0;;
373 --no-memory) MEMORY=0;;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200374 --no-quiet) QUIET=0;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100375 --openssl) shift; OPENSSL="$1";;
376 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
377 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200378 --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100379 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200380 --quiet|-q) QUIET=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100381 --random-seed) unset SEED;;
382 --release-test|-r) SEED=1;;
383 --seed|-s) shift; SEED="$1";;
384 -*)
385 echo >&2 "Unknown option: $1"
386 echo >&2 "Run $0 --help for usage."
387 exit 120
388 ;;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000389 *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100390 esac
391 shift
Gilles Peskine8f073122018-11-27 15:58:47 +0100392 done
SimonB2e23c822016-04-16 21:54:39 +0100393
Gilles Peskinea28db922019-01-10 00:05:18 +0100394 # With no list of components, run everything.
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000395 if [ -z "$COMMAND_LINE_COMPONENTS" ]; then
396 all_except=1
Andres AGdc192212016-08-31 17:33:13 +0100397 fi
398
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000399 # --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
400 # Ignore it if components are listed explicitly on the command line.
Gilles Peskinea28db922019-01-10 00:05:18 +0100401 if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000402 COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
SimonB2e23c822016-04-16 21:54:39 +0100403 fi
SimonB2e23c822016-04-16 21:54:39 +0100404
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000405 # Build the list of components to run.
Gilles Peskinea28db922019-01-10 00:05:18 +0100406 RUN_COMPONENTS=
407 for component in $SUPPORTED_COMPONENTS; do
408 if is_component_included "$component"; [ $? -eq $all_except ]; then
409 RUN_COMPONENTS="$RUN_COMPONENTS $component"
410 fi
411 done
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000412
413 unset all_except
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000414 unset no_armcc
Gilles Peskine8f073122018-11-27 15:58:47 +0100415}
SimonB2e23c822016-04-16 21:54:39 +0100416
Gilles Peskine8f073122018-11-27 15:58:47 +0100417pre_check_git () {
418 if [ $FORCE -eq 1 ]; then
Gilles Peskine53190e62019-01-09 23:17:35 +0100419 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +0100420 git checkout-index -f -q $CONFIG_H
421 cleanup
422 else
SimonB2e23c822016-04-16 21:54:39 +0100423
Gilles Peskine8f073122018-11-27 15:58:47 +0100424 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
425 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
426 echo "You can either delete this directory manually, or force the test by rerunning"
427 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
428 exit 1
429 fi
430
Gilles Peskined1174cf2019-01-09 22:30:01 +0100431 if ! git diff --quiet include/mbedtls/config.h; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100432 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
433 echo "You can either delete or preserve your work, or force the test by rerunning the"
434 echo "script as: $0 --force"
435 exit 1
436 fi
SimonB2e23c822016-04-16 21:54:39 +0100437 fi
Andrzej Kurekeb508712019-02-14 07:18:59 -0500438}
439
Gilles Peskine8f073122018-11-27 15:58:47 +0100440pre_setup_keep_going () {
Gilles Peskine7c652162017-12-11 00:01:40 +0100441 failure_summary=
442 failure_count=0
443 start_red=
444 end_color=
445 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100446 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100447 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
448 start_red=$(printf '\033[31m')
449 end_color=$(printf '\033[0m')
450 ;;
451 esac
452 fi
453 record_status () {
454 if "$@"; then
455 last_status=0
456 else
457 last_status=$?
458 text="$current_section: $* -> $last_status"
459 failure_summary="$failure_summary
460$text"
461 failure_count=$((failure_count + 1))
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200462 echo "${start_red}^^^^$text^^^^${end_color}" >&2
Gilles Peskine7c652162017-12-11 00:01:40 +0100463 fi
464 }
465 make () {
466 case "$*" in
467 *test|*check)
468 if [ $build_status -eq 0 ]; then
469 record_status command make "$@"
470 else
471 echo "(skipped because the build failed)"
472 fi
473 ;;
474 *)
475 record_status command make "$@"
476 build_status=$last_status
477 ;;
478 esac
479 }
480 final_report () {
481 if [ $failure_count -gt 0 ]; then
482 echo
483 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
484 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
485 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7c1258d2018-07-20 16:42:14 +0100486 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100487 elif [ -z "${1-}" ]; then
488 echo "SUCCESS :)"
489 fi
490 if [ -n "${1-}" ]; then
491 echo "Killed by SIG$1."
492 fi
493 }
Gilles Peskine8f073122018-11-27 15:58:47 +0100494}
495
Gilles Peskine7c652162017-12-11 00:01:40 +0100496if_build_succeeded () {
497 if [ $build_status -eq 0 ]; then
498 record_status "$@"
499 fi
500}
501
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200502# to be used instead of ! for commands run with
503# record_status or if_build_succeeded
504not() {
505 ! "$@"
506}
507
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200508pre_setup_quiet_redirect () {
509 if [ $QUIET -ne 1 ]; then
510 redirect_out () {
511 "$@"
512 }
Manuel Pégourié-Gonnardf1f180a2020-06-08 10:46:35 +0200513 redirect_err () {
514 "$@"
515 }
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200516 else
517 redirect_out () {
518 "$@" >/dev/null
519 }
Manuel Pégourié-Gonnardf1f180a2020-06-08 10:46:35 +0200520 redirect_err () {
521 "$@" 2>/dev/null
522 }
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200523 fi
524}
525
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200526pre_prepare_outcome_file () {
527 case "$MBEDTLS_TEST_OUTCOME_FILE" in
528 [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
529 esac
530 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then
531 rm -f "$MBEDTLS_TEST_OUTCOME_FILE"
532 fi
533}
534
Gilles Peskine8f073122018-11-27 15:58:47 +0100535pre_print_configuration () {
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200536 if [ $QUIET -eq 1 ]; then
537 return
538 fi
539
Gilles Peskine8f073122018-11-27 15:58:47 +0100540 msg "info: $0 configuration"
541 echo "MEMORY: $MEMORY"
542 echo "FORCE: $FORCE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200543 echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}"
Gilles Peskine8f073122018-11-27 15:58:47 +0100544 echo "SEED: ${SEED-"UNSET"}"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100545 echo
Gilles Peskine8f073122018-11-27 15:58:47 +0100546 echo "OPENSSL: $OPENSSL"
547 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
548 echo "OPENSSL_NEXT: $OPENSSL_NEXT"
549 echo "GNUTLS_CLI: $GNUTLS_CLI"
550 echo "GNUTLS_SERV: $GNUTLS_SERV"
551 echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
552 echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
553 echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
554 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
555}
Andres AG7770ea82016-10-10 15:46:20 +0100556
Andres AGd9eba4b2016-08-26 14:42:14 +0100557# Make sure the tools we need are available.
Gilles Peskine8f073122018-11-27 15:58:47 +0100558pre_check_tools () {
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000559 # Build the list of variables to pass to output_env.sh.
560 set env
SimonB2e23c822016-04-16 21:54:39 +0100561
Gilles Peskine87964262019-01-06 22:40:00 +0000562 case " $RUN_COMPONENTS " in
563 # Require OpenSSL and GnuTLS if running any tests (as opposed to
564 # only doing builds). Not all tests run OpenSSL and GnuTLS, but this
565 # is a good enough approximation in practice.
566 *" test_"*)
567 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh
568 # and ssl-opt.sh, we just export the variables they require.
569 export OPENSSL_CMD="$OPENSSL"
570 export GNUTLS_CLI="$GNUTLS_CLI"
571 export GNUTLS_SERV="$GNUTLS_SERV"
572 # Avoid passing --seed flag in every call to ssl-opt.sh
573 if [ -n "${SEED-}" ]; then
574 export SEED
575 fi
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000576 set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY"
577 set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV"
578 set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI"
579 set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000580 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
581 "$GNUTLS_CLI" "$GNUTLS_SERV" \
582 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV"
583 ;;
584 esac
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200585
Gilles Peskine87964262019-01-06 22:40:00 +0000586 case " $RUN_COMPONENTS " in
587 *_doxygen[_\ ]*) check_tools "doxygen" "dot";;
588 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100589
Gilles Peskine87964262019-01-06 22:40:00 +0000590 case " $RUN_COMPONENTS " in
Gilles Peskine6d061342020-04-30 18:19:32 +0200591 *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";;
Gilles Peskine87964262019-01-06 22:40:00 +0000592 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100593
Gilles Peskine87964262019-01-06 22:40:00 +0000594 case " $RUN_COMPONENTS " in
595 *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";;
596 esac
597
598 case " $RUN_COMPONENTS " in
599 *" test_zeroize "*) check_tools "gdb";;
600 esac
601
602 case " $RUN_COMPONENTS " in
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000603 *_armcc*)
Gilles Peskine87964262019-01-06 22:40:00 +0000604 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
605 ARMC5_AR="$ARMC5_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200606 ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf"
Gilles Peskine87964262019-01-06 22:40:00 +0000607 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
608 ARMC6_AR="$ARMC6_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200609 ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf"
610 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \
611 "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000612 esac
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000613
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200614 # past this point, no call to check_tool, only printing output
615 if [ $QUIET -eq 1 ]; then
616 return
617 fi
618
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000619 msg "info: output_env.sh"
620 case $RUN_COMPONENTS in
621 *_armcc*)
622 set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;;
623 *) set "$@" RUN_ARMCC=0;;
624 esac
625 "$@" scripts/output_env.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100626}
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100627
Gilles Peskine192c72f2017-12-21 15:59:21 +0100628
629
630################################################################
631#### Basic checks
632################################################################
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100633
634#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200635# Test Suites to be executed
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100636#
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100637# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200638# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100639# 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 +0200640# time, so start with a GCC build).
641# 2. Minimize total running time, by avoiding useless rebuilds
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100642#
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100643# Indicative running times are given for reference.
644
Gilles Peskine8f073122018-11-27 15:58:47 +0100645component_check_recursion () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200646 msg "Check: recursion.pl" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100647 record_status tests/scripts/recursion.pl library/*.c
648}
Janos Follathb72c6782016-07-19 14:54:17 +0100649
Gilles Peskine8f073122018-11-27 15:58:47 +0100650component_check_generated_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200651 msg "Check: freshness of generated source files" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100652 record_status tests/scripts/check-generated-files.sh
653}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200654
Gilles Peskine8f073122018-11-27 15:58:47 +0100655component_check_doxy_blocks () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200656 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100657 record_status tests/scripts/check-doxy-blocks.pl
658}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200659
Gilles Peskine8f073122018-11-27 15:58:47 +0100660component_check_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200661 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Gilles Peskine8f073122018-11-27 15:58:47 +0100662 record_status tests/scripts/check-files.py
663}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200664
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200665component_check_changelog () {
666 msg "Check: changelog entries" # < 1s
667 rm -f ChangeLog.new
668 record_status scripts/assemble_changelog.py -o ChangeLog.new
669 if [ -e ChangeLog.new ]; then
670 # Show the diff for information. It isn't an error if the diff is
671 # non-empty.
672 diff -u ChangeLog ChangeLog.new || true
673 rm ChangeLog.new
674 fi
675}
676
Gilles Peskine8f073122018-11-27 15:58:47 +0100677component_check_names () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200678 msg "Check: declared and exported names (builds the library)" # < 3s
Gilles Peskine13f97dc2019-05-15 17:52:22 +0200679 record_status tests/scripts/check-names.sh -v
Gilles Peskine8f073122018-11-27 15:58:47 +0100680}
Darryl Greena07039c2018-03-13 16:48:16 +0000681
Gilles Peskine895868b2019-09-19 21:30:05 +0200682component_check_test_cases () {
683 msg "Check: test case descriptions" # < 1s
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200684 if [ $QUIET -eq 1 ]; then
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200685 opt='--quiet'
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200686 else
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200687 opt=''
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200688 fi
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200689 record_status tests/scripts/check-test-cases.py $opt
690 unset opt
Gilles Peskine895868b2019-09-19 21:30:05 +0200691}
692
Gilles Peskine8f073122018-11-27 15:58:47 +0100693component_check_doxygen_warnings () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200694 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Gilles Peskine8f073122018-11-27 15:58:47 +0100695 record_status tests/scripts/doxygen.sh
696}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200697
Gilles Peskine192c72f2017-12-21 15:59:21 +0100698
Gilles Peskine636c26a2020-03-04 20:46:15 +0100699
Gilles Peskine192c72f2017-12-21 15:59:21 +0100700################################################################
701#### Build and test many configurations and targets
702################################################################
703
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200704component_test_default_out_of_box () {
705 msg "build: make, default config (out-of-box)" # ~1min
706 make
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200707 # Disable fancy stuff
Gilles Peskine717cd762019-09-27 20:21:11 +0200708 SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200709 unset MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200710
711 msg "test: main suites make, default config (out-of-box)" # ~10s
712 make test
713
714 msg "selftest: make, default config (out-of-box)" # ~10s
Gilles Peskine97bea012020-04-23 23:37:45 +0200715 if_build_succeeded programs/test/selftest
Gilles Peskine717cd762019-09-27 20:21:11 +0200716
717 export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE"
718 unset SAVE_MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200719}
720
Gilles Peskine8f073122018-11-27 15:58:47 +0100721component_test_default_cmake_gcc_asan () {
722 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Gilles Peskine8f073122018-11-27 15:58:47 +0100723 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
724 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200725
Gilles Peskine8f073122018-11-27 15:58:47 +0100726 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
727 make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200728
Gilles Peskine97bea012020-04-23 23:37:45 +0200729 msg "test: selftest (ASan build)" # ~ 10s
730 if_build_succeeded programs/test/selftest
731
Gilles Peskine8f073122018-11-27 15:58:47 +0100732 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
733 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200734
Gilles Peskine8f073122018-11-27 15:58:47 +0100735 msg "test: compat.sh (ASan build)" # ~ 6 min
736 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200737
738 msg "test: context-info.sh (ASan build)" # ~ 15 sec
739 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100740}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200741
Hanno Becker01635512019-02-26 14:27:09 +0000742component_test_full_cmake_gcc_asan () {
743 msg "build: full config, cmake, gcc, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200744 scripts/config.py full
Hanno Becker01635512019-02-26 14:27:09 +0000745 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
746 make
747
748 msg "test: main suites (inc. selftests) (full config, ASan build)"
749 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +0100750
Gilles Peskine97bea012020-04-23 23:37:45 +0200751 msg "test: selftest (ASan build)" # ~ 10s
752 if_build_succeeded programs/test/selftest
753
Gilles Peskine636c26a2020-03-04 20:46:15 +0100754 msg "test: ssl-opt.sh (full config, ASan build)"
755 if_build_succeeded tests/ssl-opt.sh
756
757 msg "test: compat.sh (full config, ASan build)"
758 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200759
760 msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
761 if_build_succeeded tests/context-info.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +0100762}
763
764component_test_zlib_make() {
765 msg "build: zlib enabled, make"
766 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
767 make ZLIB=1 CFLAGS='-Werror -O1'
768
769 msg "test: main suites (zlib, make)"
770 make test
771
772 msg "test: ssl-opt.sh (zlib, make)"
773 if_build_succeeded tests/ssl-opt.sh
774}
775support_test_zlib_make () {
776 base=support_test_zlib_$$
777 cat <<'EOF' > ${base}.c
778#include "zlib.h"
779int main(void) { return 0; }
780EOF
781 gcc -o ${base}.exe ${base}.c -lz 2>/dev/null
782 ret=$?
783 rm -f ${base}.*
784 return $ret
785}
786
787component_test_zlib_cmake() {
788 msg "build: zlib enabled, cmake"
789 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
790 cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check .
791 make
792
793 msg "test: main suites (zlib, cmake)"
794 make test
795
796 msg "test: ssl-opt.sh (zlib, cmake)"
797 if_build_succeeded tests/ssl-opt.sh
798}
799support_test_zlib_cmake () {
800 support_test_zlib_make "$@"
Manuel Pégourié-Gonnardf2e29022020-01-24 10:17:20 +0100801}
Manuel Pégourié-Gonnard95e04492020-01-02 11:45:12 +0100802
Gilles Peskine782f4112018-11-27 16:11:09 +0100803component_test_ref_configs () {
804 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
805 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
806 record_status tests/scripts/test-ref-configs.pl
807}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200808
Gilles Peskine8f073122018-11-27 15:58:47 +0100809component_test_sslv3 () {
810 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200811 scripts/config.py set MBEDTLS_SSL_PROTO_SSL3
Gilles Peskine8f073122018-11-27 15:58:47 +0100812 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
813 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200814
Gilles Peskine8f073122018-11-27 15:58:47 +0100815 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
816 make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000817
Gilles Peskine8f073122018-11-27 15:58:47 +0100818 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
819 if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
820 if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000821
Gilles Peskine8f073122018-11-27 15:58:47 +0100822 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
823 if_build_succeeded tests/ssl-opt.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200824
825 msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec
826 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100827}
Simon Butcher3ea7f522016-03-07 23:22:10 +0000828
Gilles Peskine8f073122018-11-27 15:58:47 +0100829component_test_no_renegotiation () {
830 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200831 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine8f073122018-11-27 15:58:47 +0100832 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
833 make
Simon Butcher3ea7f522016-03-07 23:22:10 +0000834
Gilles Peskine8f073122018-11-27 15:58:47 +0100835 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
836 make test
Hanno Becker134c2ab2017-10-12 15:29:50 +0100837
Gilles Peskine8f073122018-11-27 15:58:47 +0100838 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
839 if_build_succeeded tests/ssl-opt.sh
840}
Hanno Becker134c2ab2017-10-12 15:29:50 +0100841
Gilles Peskine636c26a2020-03-04 20:46:15 +0100842component_test_no_pem_no_fs () {
843 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
844 scripts/config.py unset MBEDTLS_PEM_PARSE_C
845 scripts/config.py unset MBEDTLS_FS_IO
846 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
847 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
848 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
849 make
850
851 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
852 make test
853
854 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
855 if_build_succeeded tests/ssl-opt.sh
856}
857
Gilles Peskine8f073122018-11-27 15:58:47 +0100858component_test_rsa_no_crt () {
859 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200860 scripts/config.py set MBEDTLS_RSA_NO_CRT
Gilles Peskine8f073122018-11-27 15:58:47 +0100861 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
862 make
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100863
Gilles Peskine8f073122018-11-27 15:58:47 +0100864 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
865 make test
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100866
Gilles Peskine8f073122018-11-27 15:58:47 +0100867 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
868 if_build_succeeded tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100869
Gilles Peskine8f073122018-11-27 15:58:47 +0100870 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
871 if_build_succeeded tests/compat.sh -t RSA
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200872
873 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
874 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100875}
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100876
Gilles Peskine636c26a2020-03-04 20:46:15 +0100877component_test_new_ecdh_context () {
878 msg "build: new ECDH context (ASan build)" # ~ 6 min
879 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
880 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
881 make
882
883 msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
884 make test
885
886 msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
887 if_build_succeeded tests/ssl-opt.sh -f ECDH
888
889 msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
890 # Exclude some symmetric ciphers that are redundant here to gain time.
891 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
892}
893
894component_test_everest () {
895 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
896 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
897 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
898 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
899 make
900
901 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
902 make test
903
904 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
905 if_build_succeeded tests/ssl-opt.sh -f ECDH
906
907 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
908 # Exclude some symmetric ciphers that are redundant here to gain time.
909 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
910}
911
Gilles Peskine8f073122018-11-27 15:58:47 +0100912component_test_small_ssl_out_content_len () {
913 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200914 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
915 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +0100916 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
917 make
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100918
Gilles Peskine8f073122018-11-27 15:58:47 +0100919 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
920 if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet"
921}
Angus Grattonc4dd0732018-04-11 16:28:39 +1000922
Gilles Peskine8f073122018-11-27 15:58:47 +0100923component_test_small_ssl_in_content_len () {
924 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200925 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
926 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
Gilles Peskine8f073122018-11-27 15:58:47 +0100927 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
928 make
Angus Grattonc4dd0732018-04-11 16:28:39 +1000929
Gilles Peskine8f073122018-11-27 15:58:47 +0100930 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
931 if_build_succeeded tests/ssl-opt.sh -f "Max fragment"
932}
Angus Grattonc4dd0732018-04-11 16:28:39 +1000933
Gilles Peskine8f073122018-11-27 15:58:47 +0100934component_test_small_ssl_dtls_max_buffering () {
935 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200936 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
Gilles Peskine8f073122018-11-27 15:58:47 +0100937 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
938 make
Angus Grattonc4dd0732018-04-11 16:28:39 +1000939
Gilles Peskine8f073122018-11-27 15:58:47 +0100940 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
941 if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
942}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100943
Gilles Peskine8f073122018-11-27 15:58:47 +0100944component_test_small_mbedtls_ssl_dtls_max_buffering () {
945 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100946 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
Gilles Peskine8f073122018-11-27 15:58:47 +0100947 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
948 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100949
Gilles Peskine8f073122018-11-27 15:58:47 +0100950 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
951 if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
952}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100953
Gilles Peskine75cc7712019-09-06 19:47:17 +0200954component_test_psa_collect_statuses () {
955 msg "build+test: psa_collect_statuses" # ~30s
Gilles Peskine3bdd4122019-07-27 23:52:53 +0200956 scripts/config.py full
Gilles Peskine75cc7712019-09-06 19:47:17 +0200957 record_status tests/scripts/psa_collect_statuses.py
958 # Check that psa_crypto_init() succeeded at least once
959 record_status grep -q '^0:psa_crypto_init:' tests/statuses.log
960 rm -f tests/statuses.log
961}
962
Gilles Peskine8f073122018-11-27 15:58:47 +0100963component_test_full_cmake_clang () {
964 msg "build: cmake, full config, clang" # ~ 50s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200965 scripts/config.py full
Gilles Peskine8f073122018-11-27 15:58:47 +0100966 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
967 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100968
k-stachowiak0291cb72019-06-26 15:52:12 +0200969 msg "test: main suites (full config, clang)" # ~ 5s
Gilles Peskine8f073122018-11-27 15:58:47 +0100970 make test
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100971
k-stachowiak0291cb72019-06-26 15:52:12 +0200972 msg "test: psa_constant_names (full config, clang)" # ~ 1s
Darryl Green45010a32019-02-06 13:43:58 +0000973 record_status tests/scripts/test_psa_constant_names.py
Gilles Peskine69e8f7f2020-02-26 19:51:43 +0100974
Gilles Peskine8f073122018-11-27 15:58:47 +0100975 msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
976 if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200977
Andres Amaya Garcia2dadab72019-01-08 21:42:27 +0000978 msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min
Andres Amaya Garcia419bd002019-02-19 20:20:57 +0000979 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 +0200980
Gilles Peskine8f073122018-11-27 15:58:47 +0100981 msg "test: compat.sh ARIA + ChachaPoly"
982 if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
983}
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200984
Gilles Peskine1093d9f2020-04-13 01:03:21 +0200985component_test_default_no_deprecated () {
Gilles Peskine8386ea22020-04-30 09:07:29 +0200986 # Test that removing the deprecated features from the default
987 # configuration leaves something consistent.
Gilles Peskine1093d9f2020-04-13 01:03:21 +0200988 msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
989 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
990 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
991
992 msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
993 make test
994}
995
996component_test_full_no_deprecated () {
Gilles Peskine30de2e82020-04-20 21:39:22 +0200997 msg "build: make, full_no_deprecated config" # ~ 30s
998 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +0200999 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1000
Gilles Peskine30de2e82020-04-20 21:39:22 +02001001 msg "test: make, full_no_deprecated config" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001002 make test
1003}
1004
Gilles Peskine8386ea22020-04-30 09:07:29 +02001005component_test_full_no_deprecated_deprecated_warning () {
1006 # Test that there is nothing deprecated in "full_no_deprecated".
1007 # A deprecated feature would trigger a warning (made fatal) from
1008 # MBEDTLS_DEPRECATED_WARNING.
Gilles Peskine30de2e82020-04-20 21:39:22 +02001009 msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
1010 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001011 scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
1012 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
1013 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1014
Gilles Peskine30de2e82020-04-20 21:39:22 +02001015 msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001016 make test
1017}
1018
Gilles Peskine8386ea22020-04-30 09:07:29 +02001019component_test_full_deprecated_warning () {
1020 # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
1021 # with only certain whitelisted types of warnings.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001022 msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001023 scripts/config.py full
1024 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001025 # Expect warnings from '#warning' directives in check_config.h.
1026 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +01001027
Gilles Peskine8386ea22020-04-30 09:07:29 +02001028 msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
1029 # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
1030 # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001031 # Expect warnings from '#warning' directives in check_config.h and
1032 # from the use of deprecated functions in test suites.
1033 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 +01001034
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001035 msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
1036 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001037}
Jaeden Ameroed93bdc2018-11-02 16:57:24 +00001038
Gilles Peskineec541fe2020-01-31 14:24:14 +01001039# Check that the specified libraries exist and are empty.
1040are_empty_libraries () {
1041 nm "$@" >/dev/null 2>/dev/null
1042 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
1043}
1044
1045component_build_crypto_default () {
1046 msg "build: make, crypto only"
1047 scripts/config.py crypto
Gilles Peskine6bb39152020-02-03 11:59:20 +01001048 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001049 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1050}
1051
1052component_build_crypto_full () {
1053 msg "build: make, crypto only, full config"
1054 scripts/config.py crypto_full
Gilles Peskine6bb39152020-02-03 11:59:20 +01001055 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001056 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1057}
1058
1059component_build_crypto_baremetal () {
1060 msg "build: make, crypto only, baremetal config"
1061 scripts/config.py crypto_baremetal
Gilles Peskine6bb39152020-02-03 11:59:20 +01001062 make CFLAGS='-O1 -Werror'
Gilles Peskineec541fe2020-01-31 14:24:14 +01001063 if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1064}
1065
Gilles Peskine8f073122018-11-27 15:58:47 +01001066component_test_depends_curves () {
1067 msg "test/build: curves.pl (gcc)" # ~ 4 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001068 record_status tests/scripts/curves.pl
1069}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001070
Gilles Peskine8f073122018-11-27 15:58:47 +01001071component_test_depends_hashes () {
1072 msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001073 record_status tests/scripts/depends-hashes.pl
1074}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001075
Gilles Peskine8f073122018-11-27 15:58:47 +01001076component_test_depends_pkalgs () {
1077 msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001078 record_status tests/scripts/depends-pkalgs.pl
1079}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001080
Gilles Peskine8f073122018-11-27 15:58:47 +01001081component_build_key_exchanges () {
1082 msg "test/build: key-exchanges (gcc)" # ~ 1 min
Gilles Peskine8f073122018-11-27 15:58:47 +01001083 record_status tests/scripts/key-exchanges.pl
1084}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001085
Gilles Peskine8f073122018-11-27 15:58:47 +01001086component_build_default_make_gcc_and_cxx () {
1087 msg "build: Unix make, -Os (gcc)" # ~ 30s
Gilles Peskine8f073122018-11-27 15:58:47 +01001088 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001089
Gilles Peskine8f073122018-11-27 15:58:47 +01001090 msg "test: verify header list in cpp_dummy_build.cpp"
1091 record_status check_headers_in_cpp
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001092
Gilles Peskine8f073122018-11-27 15:58:47 +01001093 msg "build: Unix make, incremental g++"
1094 make TEST_CPP=1
1095}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001096
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001097component_test_no_use_psa_crypto_full_cmake_asan() {
1098 # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
Gilles Peskinedc3a1792019-09-03 11:42:04 +02001099 msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001100 scripts/config.py full
1101 scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
1102 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1103 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1104 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskinedc6d8382020-04-12 14:21:55 +02001105 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001106 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Manuel Pégourié-Gonnardd8167e82019-02-01 11:12:52 +01001107 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001108 make
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +02001109
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001110 msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001111 make test
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +02001112
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001113 msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001114 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001115
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001116 msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001117 if_build_succeeded tests/compat.sh
Andrzej Kurek991f9fe2018-07-02 09:08:21 -04001118
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001119 msg "test: compat.sh RC4, DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001120 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 -05001121
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001122 msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001123 if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
1124}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001125
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001126component_test_check_params_functionality () {
1127 msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001128 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001129 # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001130 scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001131 # Only build and run tests. Do not build sample programs, because
1132 # they don't have a mbedtls_param_failed() function.
1133 make CC=gcc CFLAGS='-Werror -O1' lib test
1134}
1135
Gilles Peskineb28636b2019-01-02 19:06:24 +01001136component_test_check_params_without_platform () {
1137 msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001138 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001139 # Keep MBEDTLS_PARAM_FAILED as assert.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001140 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
1141 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
1142 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
1143 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
Gilles Peskine32e889d2020-04-12 23:43:28 +02001144 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001145 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
1146 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
1147 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1148 scripts/config.py unset MBEDTLS_PLATFORM_C
Gilles Peskineb28636b2019-01-02 19:06:24 +01001149 make CC=gcc CFLAGS='-Werror -O1' all test
1150}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001151
Gilles Peskineb28636b2019-01-02 19:06:24 +01001152component_test_check_params_silent () {
1153 msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001154 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02001155 # Set MBEDTLS_PARAM_FAILED to nothing.
Gilles Peskineb28636b2019-01-02 19:06:24 +01001156 sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
1157 make CC=gcc CFLAGS='-Werror -O1' all test
1158}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001159
Gilles Peskine8f073122018-11-27 15:58:47 +01001160component_test_no_platform () {
1161 # Full configuration build, without platform support, file IO and net sockets.
1162 # This should catch missing mbedtls_printf definitions, and by disabling file
1163 # IO, it should catch missing '#include <stdio.h>'
1164 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001165 scripts/config.py full
1166 scripts/config.py unset MBEDTLS_PLATFORM_C
1167 scripts/config.py unset MBEDTLS_NET_C
1168 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
1169 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
1170 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
1171 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
1172 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
1173 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
Gilles Peskine32e889d2020-04-12 23:43:28 +02001174 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001175 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1176 scripts/config.py unset MBEDTLS_FS_IO
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001177 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001178 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
1179 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001180 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
1181 # to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001182 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
1183 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
Gilles Peskine8f073122018-11-27 15:58:47 +01001184}
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +00001185
Gilles Peskine8f073122018-11-27 15:58:47 +01001186component_build_no_std_function () {
1187 # catch compile bugs in _uninit functions
1188 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001189 scripts/config.py full
1190 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
1191 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02001192 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001193 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Gilles Peskine8f073122018-11-27 15:58:47 +01001194}
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +01001195
Gilles Peskine8f073122018-11-27 15:58:47 +01001196component_build_no_ssl_srv () {
1197 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001198 scripts/config.py full
1199 scripts/config.py unset MBEDTLS_SSL_SRV_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001200 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01001201}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02001202
Gilles Peskine8f073122018-11-27 15:58:47 +01001203component_build_no_ssl_cli () {
1204 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001205 scripts/config.py full
1206 scripts/config.py unset MBEDTLS_SSL_CLI_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001207 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01001208}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02001209
Gilles Peskine8f073122018-11-27 15:58:47 +01001210component_build_no_sockets () {
1211 # Note, C99 compliance can also be tested with the sockets support disabled,
1212 # as that requires a POSIX platform (which isn't the same as C99).
1213 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001214 scripts/config.py full
1215 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
1216 scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02001217 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01001218}
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +02001219
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04001220component_test_memory_buffer_allocator_backtrace () {
1221 msg "build: default config with memory buffer allocator and backtrace enabled"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001222 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
1223 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
1224 scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
1225 scripts/config.py set MBEDTLS_MEMORY_DEBUG
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04001226 CC=gcc cmake .
1227 make
1228
1229 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
1230 make test
1231}
1232
1233component_test_memory_buffer_allocator () {
1234 msg "build: default config with memory buffer allocator"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001235 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
1236 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
Hanno Becker0fb9ba22019-02-26 14:34:13 +00001237 CC=gcc cmake .
1238 make
1239
1240 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
1241 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001242
1243 msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
1244 # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
1245 if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy'
Hanno Becker0fb9ba22019-02-26 14:34:13 +00001246}
1247
Gilles Peskine8f073122018-11-27 15:58:47 +01001248component_test_no_max_fragment_length () {
1249 # Run max fragment length tests with MFL disabled
1250 msg "build: default config except MFL extension (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001251 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Gilles Peskine8f073122018-11-27 15:58:47 +01001252 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1253 make
Hanno Becker5175ac62017-09-18 15:36:25 +01001254
Gilles Peskine8f073122018-11-27 15:58:47 +01001255 msg "test: ssl-opt.sh, MFL-related tests"
1256 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
1257}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001258
Hanno Becker545ced42019-02-19 11:10:48 +00001259component_test_asan_remove_peer_certificate () {
1260 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001261 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
Hanno Becker545ced42019-02-19 11:10:48 +00001262 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1263 make
1264
1265 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1266 make test
1267
1268 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1269 if_build_succeeded tests/ssl-opt.sh
1270
1271 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1272 if_build_succeeded tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001273
1274 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
1275 if_build_succeeded tests/context-info.sh
Hanno Becker545ced42019-02-19 11:10:48 +00001276}
1277
Gilles Peskine8f073122018-11-27 15:58:47 +01001278component_test_no_max_fragment_length_small_ssl_out_content_len () {
1279 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001280 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1281 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
1282 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01001283 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1284 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001285
Gilles Peskine8f073122018-11-27 15:58:47 +01001286 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
1287 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001288
1289 msg "test: context-info.sh (disabled MFL extension case)"
1290 if_build_succeeded tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001291}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001292
Darryl Greenaad82f92019-12-02 10:53:11 +00001293component_test_variable_ssl_in_out_buffer_len () {
1294 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
1295 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1296 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1297 make
1298
1299 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
1300 make test
1301
1302 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
1303 if_build_succeeded tests/ssl-opt.sh
1304
1305 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
1306 if_build_succeeded tests/compat.sh
1307}
1308
1309component_test_variable_ssl_in_out_buffer_len_CID () {
1310 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)"
1311 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1312 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
1313
1314 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1315 make
1316
1317 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID"
1318 make test
1319
1320 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
1321 if_build_succeeded tests/ssl-opt.sh
1322
1323 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
1324 if_build_succeeded tests/compat.sh
1325}
1326
1327component_test_variable_ssl_in_out_buffer_len_record_splitting () {
1328 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)"
1329 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1330 scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING
1331
1332 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1333 make
1334
1335 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING"
1336 make test
1337
1338 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
1339 if_build_succeeded tests/ssl-opt.sh
1340
1341 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
1342 if_build_succeeded tests/compat.sh
1343}
1344
Piotr Nowicki0937ed22019-11-26 16:32:40 +01001345component_test_ssl_alloc_buffer_and_mfl () {
1346 msg "build: default config with memory buffer allocator and MFL extension"
1347 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
1348 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
1349 scripts/config.py set MBEDTLS_MEMORY_DEBUG
1350 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1351 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
1352 CC=gcc cmake .
1353 make
1354
1355 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
1356 make test
1357
1358 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
1359 if_build_succeeded tests/ssl-opt.sh -f "Handshake memory usage"
1360}
1361
Gilles Peskine636c26a2020-03-04 20:46:15 +01001362component_test_when_no_ciphersuites_have_mac () {
1363 msg "build: when no ciphersuites have MAC"
1364 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1365 scripts/config.py unset MBEDTLS_ARC4_C
1366 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1367 make
1368
1369 msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
1370 make test
1371
1372 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
1373 if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
1374}
1375
Gilles Peskine8f073122018-11-27 15:58:47 +01001376component_test_null_entropy () {
1377 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001378 scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY
1379 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
1380 scripts/config.py set MBEDTLS_ENTROPY_C
1381 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02001382 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001383 scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT
1384 scripts/config.py unset MBEDTLS_HAVEGE_C
Gilles Peskine5fa32a72019-01-06 19:48:30 +00001385 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON .
Gilles Peskine8f073122018-11-27 15:58:47 +01001386 make
Janos Follath06c54002016-06-09 13:57:40 +01001387
Gilles Peskine8f073122018-11-27 15:58:47 +01001388 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
1389 make test
1390}
Janos Follath06c54002016-06-09 13:57:40 +01001391
Gilles Peskine8f073122018-11-27 15:58:47 +01001392component_test_platform_calloc_macro () {
1393 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001394 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
1395 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
1396 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
Gilles Peskine8f073122018-11-27 15:58:47 +01001397 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1398 make
Hanno Beckere5fecec2018-10-11 11:02:52 +01001399
Gilles Peskine8f073122018-11-27 15:58:47 +01001400 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
1401 make test
1402}
Hanno Beckere5fecec2018-10-11 11:02:52 +01001403
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02001404component_test_malloc_0_null () {
1405 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01001406 scripts/config.py full
Gilles Peskine004206c2019-10-21 17:11:33 +02001407 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 +02001408
1409 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
1410 make test
1411
1412 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
1413 # Just the calloc selftest. "make test" ran the others as part of the
1414 # test suites.
1415 if_build_succeeded programs/test/selftest calloc
Gilles Peskine765d2402020-02-11 18:26:34 +01001416
1417 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
1418 # Run a subset of the tests. The choice is a balance between coverage
1419 # and time (including time indirectly wasted due to flaky tests).
1420 # The current choice is to skip tests whose description includes
1421 # "proxy", which is an approximation of skipping tests that use the
1422 # UDP proxy, which tend to be slower and flakier.
1423 if_build_succeeded tests/ssl-opt.sh -e 'proxy'
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02001424}
1425
Gilles Peskine8f073122018-11-27 15:58:47 +01001426component_test_aes_fewer_tables () {
1427 msg "build: default config with AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001428 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01001429 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01001430
Gilles Peskine8f073122018-11-27 15:58:47 +01001431 msg "test: AES_FEWER_TABLES"
1432 make test
1433}
Hanno Becker83ebf782017-07-07 12:29:15 +01001434
Gilles Peskine8f073122018-11-27 15:58:47 +01001435component_test_aes_rom_tables () {
1436 msg "build: default config with AES_ROM_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001437 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01001438 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01001439
Gilles Peskine8f073122018-11-27 15:58:47 +01001440 msg "test: AES_ROM_TABLES"
1441 make test
1442}
Hanno Becker83ebf782017-07-07 12:29:15 +01001443
Gilles Peskine8f073122018-11-27 15:58:47 +01001444component_test_aes_fewer_tables_and_rom_tables () {
1445 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001446 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
1447 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01001448 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01001449
Gilles Peskine8f073122018-11-27 15:58:47 +01001450 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
1451 make test
1452}
1453
Gilles Peskine592f5912019-10-07 18:49:32 +02001454component_test_ctr_drbg_aes_256_sha_256 () {
1455 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01001456 scripts/config.py full
1457 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
1458 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02001459 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1460 make
1461
1462 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
1463 make test
1464}
1465
1466component_test_ctr_drbg_aes_128_sha_512 () {
1467 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01001468 scripts/config.py full
1469 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
1470 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
Gilles Peskine592f5912019-10-07 18:49:32 +02001471 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1472 make
1473
1474 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
1475 make test
1476}
1477
1478component_test_ctr_drbg_aes_128_sha_256 () {
1479 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01001480 scripts/config.py full
1481 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
1482 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
1483 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02001484 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1485 make
1486
1487 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
1488 make test
1489}
1490
Gilles Peskinef96aefe2019-07-24 14:58:38 +02001491component_test_se_default () {
1492 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001493 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine004206c2019-10-21 17:11:33 +02001494 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinef96aefe2019-07-24 14:58:38 +02001495
1496 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
1497 make test
1498}
1499
Gilles Peskine8f073122018-11-27 15:58:47 +01001500component_test_make_shared () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001501 msg "build/test: make shared" # ~ 40s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001502 make SHARED=1 all check
Gilles Peskine56c01612019-07-03 20:43:32 +02001503 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskine8f073122018-11-27 15:58:47 +01001504}
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +02001505
Gilles Peskinecf740502019-07-03 20:43:05 +02001506component_test_cmake_shared () {
1507 msg "build/test: cmake shared" # ~ 2min
1508 cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
1509 make
Gilles Peskine56c01612019-07-03 20:43:32 +02001510 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskinecf740502019-07-03 20:43:05 +02001511 make test
1512}
1513
Gilles Peskineec10bf12019-09-20 19:56:06 +02001514test_build_opt () {
1515 info=$1 cc=$2; shift 2
1516 for opt in "$@"; do
1517 msg "build/test: $cc $opt, $info" # ~ 30s
Gilles Peskinee094a182020-04-14 20:08:41 +02001518 make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Gilles Peskineec10bf12019-09-20 19:56:06 +02001519 # We're confident enough in compilers to not run _all_ the tests,
1520 # but at least run the unit tests. In particular, runs with
1521 # optimizations use inline assembly whereas runs with -O0
1522 # skip inline assembly.
1523 make test # ~30s
1524 make clean
1525 done
1526}
1527
1528component_test_clang_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01001529 scripts/config.py full
Gilles Peskineec10bf12019-09-20 19:56:06 +02001530 test_build_opt 'full config' clang -O0 -Os -O2
1531}
1532
1533component_test_gcc_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01001534 scripts/config.py full
Gilles Peskineec10bf12019-09-20 19:56:06 +02001535 test_build_opt 'full config' gcc -O0 -Os -O2
1536}
1537
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02001538component_build_mbedtls_config_file () {
1539 msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
1540 # Use the full config so as to catch a maximum of places where
1541 # the check of MBEDTLS_CONFIG_FILE might be missing.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001542 scripts/config.py full
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02001543 sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h
1544 echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
1545 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
1546 rm -f full_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001547}
1548
Gilles Peskine8f073122018-11-27 15:58:47 +01001549component_test_m32_o0 () {
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001550 # Build once with -O0, to compile out the i386 specific inline assembly
1551 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001552 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02001553 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01001554
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001555 msg "test: i386, make, gcc -O0 (ASan build)"
1556 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001557}
Gilles Peskine878cf602019-01-06 20:50:38 +00001558support_test_m32_o0 () {
1559 case $(uname -m) in
1560 *64*) true;;
1561 *) false;;
1562 esac
1563}
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001564
Gilles Peskine8f073122018-11-27 15:58:47 +01001565component_test_m32_o1 () {
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001566 # Build again with -O1, to compile in the i386 specific inline assembly
1567 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001568 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02001569 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS"
Simon Butcher8e6a22a2018-07-20 21:27:33 +01001570
1571 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001572 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001573
1574 msg "test ssl-opt.sh, i386, make, gcc-O1"
1575 if_build_succeeded tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001576}
Gilles Peskine878cf602019-01-06 20:50:38 +00001577support_test_m32_o1 () {
1578 support_test_m32_o0 "$@"
1579}
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001580
Gilles Peskine0c6b7992019-04-12 20:29:48 +02001581component_test_m32_everest () {
1582 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001583 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1584 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
Gilles Peskine8fd59422019-10-21 17:11:33 +02001585 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Gilles Peskine0c6b7992019-04-12 20:29:48 +02001586
1587 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1588 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01001589
1590 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
1591 if_build_succeeded tests/ssl-opt.sh -f ECDH
1592
1593 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1594 # Exclude some symmetric ciphers that are redundant here to gain time.
1595 if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine0c6b7992019-04-12 20:29:48 +02001596}
1597support_test_m32_everest () {
1598 support_test_m32_o0 "$@"
1599}
1600
Gilles Peskine8f073122018-11-27 15:58:47 +01001601component_test_mx32 () {
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001602 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001603 scripts/config.py full
Gilles Peskine5d26e7c2019-06-07 14:50:09 +02001604 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01001605
1606 msg "test: 64-bit ILP32, make, gcc"
1607 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001608}
Gilles Peskine878cf602019-01-06 20:50:38 +00001609support_test_mx32 () {
1610 case $(uname -m) in
1611 amd64|x86_64) true;;
1612 *) false;;
1613 esac
1614}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001615
Peter Kolbus60c6da22018-12-27 06:59:04 -06001616component_test_min_mpi_window_size () {
1617 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001618 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
Peter Kolbus60c6da22018-12-27 06:59:04 -06001619 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1620 make
1621
1622 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
1623 make test
1624}
1625
Gilles Peskine8f073122018-11-27 15:58:47 +01001626component_test_have_int32 () {
1627 msg "build: gcc, force 32-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001628 scripts/config.py unset MBEDTLS_HAVE_ASM
1629 scripts/config.py unset MBEDTLS_AESNI_C
1630 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001631 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01001632
Gilles Peskine8f073122018-11-27 15:58:47 +01001633 msg "test: gcc, force 32-bit bignum limbs"
1634 make test
1635}
Andres Amaya Garciafe843a32017-07-20 13:21:34 +01001636
Gilles Peskine8f073122018-11-27 15:58:47 +01001637component_test_have_int64 () {
1638 msg "build: gcc, force 64-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001639 scripts/config.py unset MBEDTLS_HAVE_ASM
1640 scripts/config.py unset MBEDTLS_AESNI_C
1641 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01001642 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Gilles Peskine14c3c062018-01-29 21:25:12 +01001643
Gilles Peskine8f073122018-11-27 15:58:47 +01001644 msg "test: gcc, force 64-bit bignum limbs"
1645 make test
1646}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001647
Gilles Peskine8f073122018-11-27 15:58:47 +01001648component_test_no_udbl_division () {
1649 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001650 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001651 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine8f073122018-11-27 15:58:47 +01001652 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001653
Gilles Peskine8f073122018-11-27 15:58:47 +01001654 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
1655 make test
1656}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001657
Gilles Peskine8f073122018-11-27 15:58:47 +01001658component_test_no_64bit_multiplication () {
1659 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001660 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001661 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine8f073122018-11-27 15:58:47 +01001662 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001663
Gilles Peskine8f073122018-11-27 15:58:47 +01001664 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
1665 make test
1666}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001667
Gilles Peskine8f073122018-11-27 15:58:47 +01001668component_build_arm_none_eabi_gcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02001669 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001670 scripts/config.py baremetal
Gilles Peskine65375882020-04-30 22:54:00 +02001671 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 +02001672
1673 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1"
1674 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01001675}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001676
Gilles Peskine2c897d72019-08-09 16:05:05 +02001677component_build_arm_none_eabi_gcc_arm5vte () {
Gilles Peskine18487f62020-04-30 23:11:54 +02001678 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001679 scripts/config.py baremetal
Gilles Peskine2c897d72019-08-09 16:05:05 +02001680 # Build for a target platform that's close to what Debian uses
1681 # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
1682 # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments.
1683 # It would be better to build with arm-linux-gnueabi-gcc but
1684 # we don't have that on our CI at this time.
Gilles Peskine6d061342020-04-30 18:19:32 +02001685 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 +02001686
1687 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1"
1688 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine93e4e032019-08-05 11:34:25 +02001689}
1690
Gilles Peskine6e2fb862020-04-30 23:00:53 +02001691component_build_arm_none_eabi_gcc_m0plus () {
1692 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s
1693 scripts/config.py baremetal
1694 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 +02001695
1696 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os"
1697 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine6e2fb862020-04-30 23:00:53 +02001698}
1699
Gilles Peskine8f073122018-11-27 15:58:47 +01001700component_build_arm_none_eabi_gcc_no_udbl_division () {
Gilles Peskine6d061342020-04-30 18:19:32 +02001701 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001702 scripts/config.py baremetal
1703 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine6d061342020-04-30 18:19:32 +02001704 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 +01001705 echo "Checking that software 64-bit division is not required"
1706 if_build_succeeded not grep __aeabi_uldiv library/*.o
1707}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001708
Gilles Peskine8f073122018-11-27 15:58:47 +01001709component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
Gilles Peskine6d061342020-04-30 18:19:32 +02001710 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001711 scripts/config.py baremetal
1712 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine6d061342020-04-30 18:19:32 +02001713 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 +01001714 echo "Checking that software 64-bit multiplication is not required"
1715 if_build_succeeded not grep __aeabi_lmul library/*.o
1716}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02001717
Gilles Peskine8f073122018-11-27 15:58:47 +01001718component_build_armcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02001719 msg "build: ARM Compiler 5"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001720 scripts/config.py baremetal
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001721 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02001722
1723 msg "size: ARM Compiler 5"
1724 "$ARMC5_FROMELF" -z library/*.o
1725
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001726 make clean
Andres AG87bb5772016-09-27 15:05:15 +01001727
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001728 # ARM Compiler 6 - Target ARMv7-A
1729 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02001730
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001731 # ARM Compiler 6 - Target ARMv7-M
1732 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02001733
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001734 # ARM Compiler 6 - Target ARMv8-A - AArch32
1735 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02001736
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001737 # ARM Compiler 6 - Target ARMv8-M
1738 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02001739
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001740 # ARM Compiler 6 - Target ARMv8-A - AArch64
1741 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Gilles Peskine8f073122018-11-27 15:58:47 +01001742}
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01001743
Manuel Pégourié-Gonnarddd8807f2020-02-26 09:56:27 +01001744component_build_ssl_hw_record_accel() {
1745 msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled"
1746 scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL
1747 make CFLAGS='-Werror -O1'
1748}
1749
Gilles Peskine8f073122018-11-27 15:58:47 +01001750component_test_allow_sha1 () {
1751 msg "build: allow SHA1 in certificates by default"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001752 scripts/config.py set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine8f073122018-11-27 15:58:47 +01001753 make CFLAGS='-Werror -Wall -Wextra'
1754 msg "test: allow SHA1 in certificates by default"
1755 make test
1756 if_build_succeeded tests/ssl-opt.sh -f SHA-1
1757}
Gilles Peskine2a458da2017-05-12 15:26:58 +02001758
Gilles Peskine8f073122018-11-27 15:58:47 +01001759component_build_mingw () {
1760 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001761 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 +00001762
Gilles Peskine8f073122018-11-27 15:58:47 +01001763 # note Make tests only builds the tests, but doesn't run them
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001764 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 +01001765 make WINDOWS_BUILD=1 clean
Simon Butcher002bc622016-11-17 09:27:45 +00001766
Gilles Peskine8f073122018-11-27 15:58:47 +01001767 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04001768 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
1769 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 +01001770 make WINDOWS_BUILD=1 clean
1771}
Jaeden Amero117b8a42019-04-17 15:19:26 +01001772support_build_mingw() {
1773 case $(i686-w64-mingw32-gcc -dumpversion) in
1774 [0-5]*) false;;
1775 *) true;;
1776 esac
1777}
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +01001778
Gilles Peskine8f073122018-11-27 15:58:47 +01001779component_test_memsan () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001780 msg "build: MSan (clang)" # ~ 1 min 20s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001781 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001782 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1783 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02001784
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001785 msg "test: main suites (MSan)" # ~ 10s
1786 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001787
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001788 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +01001789 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001790
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001791 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001792
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001793 if [ "$MEMORY" -gt 0 ]; then
1794 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +01001795 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001796 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01001797}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001798
Gilles Peskine69f190e2019-01-10 00:11:42 +01001799component_test_valgrind () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001800 msg "build: Release (clang)"
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001801 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
1802 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001803
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001804 msg "test: main suites valgrind (Release)"
1805 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001806
Gilles Peskine636c26a2020-03-04 20:46:15 +01001807 # Optional parts (slow; currently broken on OS X because programs don't
1808 # seem to receive signals under valgrind on OS X).
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001809 if [ "$MEMORY" -gt 0 ]; then
1810 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001811 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001812 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001813
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001814 if [ "$MEMORY" -gt 1 ]; then
1815 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001816 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001817 fi
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001818
1819 if [ "$MEMORY" -gt 0 ]; then
1820 msg "test: context-info.sh --memcheck (Release)"
1821 if_build_succeeded tests/context-info.sh --memcheck
1822 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01001823}
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001824
Gilles Peskine8f073122018-11-27 15:58:47 +01001825component_test_cmake_out_of_source () {
1826 msg "build: cmake 'out-of-source' build"
Gilles Peskine8f073122018-11-27 15:58:47 +01001827 MBEDTLS_ROOT_DIR="$PWD"
1828 mkdir "$OUT_OF_SOURCE_DIR"
1829 cd "$OUT_OF_SOURCE_DIR"
1830 cmake "$MBEDTLS_ROOT_DIR"
1831 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001832
Gilles Peskine8f073122018-11-27 15:58:47 +01001833 msg "test: cmake 'out-of-source' build"
1834 make test
1835 # Test an SSL option that requires an auxiliary script in test/scripts/.
1836 # Also ensure that there are no error messages such as
1837 # "No such file or directory", which would indicate that some required
1838 # file is missing (ssl-opt.sh tolerates the absence of some files so
1839 # may exit with status 0 but emit errors).
1840 if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
1841 if [ -s ssl-opt.err ]; then
1842 cat ssl-opt.err >&2
1843 record_status [ ! -s ssl-opt.err ]
1844 rm ssl-opt.err
1845 fi
1846 cd "$MBEDTLS_ROOT_DIR"
1847 rm -rf "$OUT_OF_SOURCE_DIR"
1848 unset MBEDTLS_ROOT_DIR
1849}
Andres AGdc192212016-08-31 17:33:13 +01001850
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01001851component_test_cmake_as_subdirectory () {
1852 msg "build: cmake 'as-subdirectory' build"
1853 MBEDTLS_ROOT_DIR="$PWD"
1854
1855 cd programs/test/cmake_subproject
1856 cmake .
1857 make
1858 if_build_succeeded ./cmake_subproject
1859
1860 cd "$MBEDTLS_ROOT_DIR"
1861 unset MBEDTLS_ROOT_DIR
1862}
1863
Gilles Peskine8f073122018-11-27 15:58:47 +01001864component_test_zeroize () {
1865 # Test that the function mbedtls_platform_zeroize() is not optimized away by
1866 # different combinations of compilers and optimization flags by using an
1867 # auxiliary GDB script. Unfortunately, GDB does not return error values to the
1868 # system in all cases that the script fails, so we must manually search the
1869 # output to check whether the pass string is present and no failure strings
1870 # were printed.
Andres AGdc192212016-08-31 17:33:13 +01001871
Gilles Peskine4976e822019-01-06 19:52:22 +00001872 # Don't try to disable ASLR. We don't care about ASLR here. We do care
1873 # about a spurious message if Gdb tries and fails, so suppress that.
1874 gdb_disable_aslr=
1875 if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
1876 gdb_disable_aslr='set disable-randomization off'
1877 fi
1878
Gilles Peskine8f073122018-11-27 15:58:47 +01001879 for optimization_flag in -O2 -O3 -Ofast -Os; do
Gilles Peskine55f7c942019-01-09 22:28:21 +01001880 for compiler in clang gcc; do
1881 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
1882 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Gilles Peskine4976e822019-01-06 19:52:22 +00001883 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 +01001884 if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log
1885 if_build_succeeded not grep -i "error" test_zeroize.log
1886 rm -f test_zeroize.log
1887 make clean
1888 done
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001889 done
Andres Amaya Garciad0d7bf62017-10-25 09:01:31 +01001890
Gilles Peskine4976e822019-01-06 19:52:22 +00001891 unset gdb_disable_aslr
Gilles Peskine8f073122018-11-27 15:58:47 +01001892}
Gilles Peskine192c72f2017-12-21 15:59:21 +01001893
Gilles Peskine8f073122018-11-27 15:58:47 +01001894component_check_python_files () {
1895 msg "Lint: Python scripts"
1896 record_status tests/scripts/check-python-files.sh
1897}
Gilles Peskine192c72f2017-12-21 15:59:21 +01001898
Gilles Peskine8f073122018-11-27 15:58:47 +01001899component_check_generate_test_code () {
1900 msg "uint test: generate_test_code.py"
Manuel Pégourié-Gonnarddfb114a2020-06-02 11:40:08 +02001901 # unittest writes out mundane stuff like number or tests run on stderr.
1902 # Our convention is to reserve stderr for actual errors, and write
1903 # harmless info on stdout so it can be suppress with --quiet.
1904 record_status ./tests/scripts/test_generate_test_code.py 2>&1
Gilles Peskine8f073122018-11-27 15:58:47 +01001905}
Gilles Peskine192c72f2017-12-21 15:59:21 +01001906
1907################################################################
1908#### Termination
1909################################################################
1910
Gilles Peskine8f073122018-11-27 15:58:47 +01001911post_report () {
1912 msg "Done, cleaning up"
1913 cleanup
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001914
Gilles Peskine8f073122018-11-27 15:58:47 +01001915 final_report
1916}
1917
1918
1919
1920################################################################
1921#### Run all the things
1922################################################################
1923
Gilles Peskinee48351a2018-11-27 16:06:30 +01001924# Run one component and clean up afterwards.
Gilles Peskine8f073122018-11-27 15:58:47 +01001925run_component () {
Gilles Peskine608953e2019-01-02 18:57:02 +01001926 # Back up the configuration in case the component modifies it.
1927 # The cleanup function will restore it.
1928 cp -p "$CONFIG_H" "$CONFIG_BAK"
Gilles Peskineffcdeff2018-12-04 12:49:28 +01001929 current_component="$1"
Gilles Peskine9004a172019-09-16 15:20:36 +02001930 export MBEDTLS_TEST_CONFIGURATION="$current_component"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02001931
1932 # Unconditionally create a seedfile that's sufficiently long.
1933 # Do this before each component, because a previous component may
1934 # have messed it up or shortened it.
Manuel Pégourié-Gonnardf1f180a2020-06-08 10:46:35 +02001935 redirect_err dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
Gilles Peskine2ef377d2019-10-07 18:44:21 +02001936
1937 # Run the component code.
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02001938 if [ $QUIET -eq 1 ]; then
1939 # msg() is silenced, so just print the component name here
1940 echo "${current_component#component_}"
1941 fi
1942 redirect_out "$@"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02001943
1944 # Restore the build tree to a clean state.
Gilles Peskinee48351a2018-11-27 16:06:30 +01001945 cleanup
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +02001946 unset current_component
Gilles Peskine8f073122018-11-27 15:58:47 +01001947}
1948
1949# Preliminary setup
1950pre_check_environment
1951pre_initialize_variables
1952pre_parse_command_line "$@"
Gilles Peskine348fb9a2018-11-27 17:04:29 +01001953
Gilles Peskine878cf602019-01-06 20:50:38 +00001954pre_check_git
Andrzej Kurekeb508712019-02-14 07:18:59 -05001955
Gilles Peskine878cf602019-01-06 20:50:38 +00001956build_status=0
1957if [ $KEEP_GOING -eq 1 ]; then
1958 pre_setup_keep_going
Gilles Peskine92525112018-11-27 18:15:35 +01001959else
Gilles Peskine878cf602019-01-06 20:50:38 +00001960 record_status () {
1961 "$@"
1962 }
Gilles Peskine8f073122018-11-27 15:58:47 +01001963fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02001964pre_setup_quiet_redirect
Gilles Peskine67ffdaf2019-09-16 15:55:46 +02001965pre_prepare_outcome_file
Gilles Peskine878cf602019-01-06 20:50:38 +00001966pre_print_configuration
1967pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001968cleanup
1969
Gilles Peskinebeb3a812019-01-06 22:11:25 +00001970# Run the requested tests.
1971for component in $RUN_COMPONENTS; do
1972 run_component "component_$component"
1973done
Gilles Peskine8f073122018-11-27 15:58:47 +01001974
1975# We're done.
Gilles Peskine878cf602019-01-06 20:50:38 +00001976post_report