blob: 69cc790b4e2fa2a5fa097135c2fff3ca157fdf84 [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
27# * Makefile, library/Makefile, programs/Makefile, tests/Makefile
28# After running this script, the CMake cache will be lost and CMake
29# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010030#
Gilles Peskine192c72f2017-12-21 15:59:21 +010031# The script assumes the presence of a number of tools:
32# * Basic Unix tools (Windows users note: a Unix-style find must be before
33# the Windows find in the PATH)
34# * Perl
35# * GNU Make
36# * CMake
37# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
38# * arm-gcc and mingw-gcc
39# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
40# * Yotta build dependencies, unless invoked with --no-yotta
41# * OpenSSL and GnuTLS command line tools, recent enough for the
42# interoperability tests. If they don't support SSLv3 then a legacy
43# version of these tools must be present as well (search for LEGACY
44# below).
45# See the invocation of check_tools below for details.
46#
47# This script must be invoked from the toplevel directory of a git
48# working copy of Mbed TLS.
49#
50# Note that the output is not saved. You may want to run
51# script -c tests/scripts/all.sh
52# or
53# tests/scripts/all.sh >all.log 2>&1
54#
55# Notes for maintainers
56# ---------------------
57#
58# The tests are roughly in order from fastest to slowest. This doesn't
59# have to be exact, but in general you should add slower tests towards
60# the end and fast checks near the beginning.
61#
62# Sanity checks have the following form:
63# 1. msg "short description of what is about to be done"
64# 2. run sanity check (failure stops the script)
65#
66# Build or build-and-test steps have the following form:
67# 1. msg "short description of what is about to be done"
68# 2. cleanup
69# 3. preparation (config.pl, cmake, ...) (failure stops the script)
70# 4. make
71# 5. Run tests if relevant. All tests must be prefixed with
72# if_build_successful for the sake of --keep-going.
73
74
75
76################################################################
77#### Initialization and command line parsing
78################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010079
SimonB2e23c822016-04-16 21:54:39 +010080# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010081set -eu
82
Andres AG38495a32016-07-12 16:54:33 +010083if [ "$( uname )" != "Linux" ]; then
84 echo "This script only works in Linux" >&2
85 exit 1
86elif [ -d library -a -d include -a -d tests ]; then :; else
87 echo "Must be run from mbed TLS root" >&2
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088 exit 1
89fi
90
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000091CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020092CONFIG_BAK="$CONFIG_H.bak"
93
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010094MEMORY=0
SimonB2e23c822016-04-16 21:54:39 +010095FORCE=0
Gilles Peskine7c652162017-12-11 00:01:40 +010096KEEP_GOING=0
Gilles Peskinebca6ab92017-12-19 18:24:31 +010097RUN_ARMCC=1
Gilles Peskineda519252017-11-30 13:22:04 +010098YOTTA=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010099
Andres AGd9eba4b2016-08-26 14:42:14 +0100100# Default commands, can be overriden by the environment
101: ${OPENSSL:="openssl"}
102: ${OPENSSL_LEGACY:="$OPENSSL"}
103: ${GNUTLS_CLI:="gnutls-cli"}
104: ${GNUTLS_SERV:="gnutls-serv"}
105: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
106: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +0100107: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +0100108: ${ARMC5_BIN_DIR:=/usr/bin}
109: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +0100110
Andres AG38495a32016-07-12 16:54:33 +0100111# if MAKEFLAGS is not set add the -j option to speed up invocations of make
112if [ -n "${MAKEFLAGS+set}" ]; then
113 export MAKEFLAGS="-j"
114fi
115
Simon Butcher41eeccf2016-09-07 00:07:09 +0100116usage()
SimonB2e23c822016-04-16 21:54:39 +0100117{
Gilles Peskine709346a2017-12-10 23:43:39 +0100118 cat <<EOF
119Usage: $0 [OPTION]...
120 -h|--help Print this help.
121
122General options:
123 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100124 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100125 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100126 --armcc Run ARM Compiler builds (on by default).
127 --no-armcc Skip ARM Compiler builds.
Gilles Peskine19ceb712018-03-21 08:40:26 +0100128 --no-force Refuse to overwrite modified files (default).
129 --no-keep-going Stop at the first error (default).
130 --no-memory No additional memory tests (default).
Gilles Peskine2a22a802017-12-21 15:19:00 +0100131 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +0100132 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine19ceb712018-03-21 08:40:26 +0100133 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100134 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
135 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100136 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100137
138Tool path options:
139 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
140 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
141 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
142 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
143 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
144 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
145 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
146 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
147EOF
SimonB2e23c822016-04-16 21:54:39 +0100148}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100149
150# remove built files as well as the cmake cache/config
151cleanup()
152{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100153 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
154 cd "$MBEDTLS_ROOT_DIR"
155 fi
156
Gilles Peskine7c652162017-12-11 00:01:40 +0100157 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200158
Gilles Peskine31b07e22018-03-21 12:15:06 +0100159 # Remove CMake artefacts
160 find . -name .git -prune -o -name yotta -prune -o \
161 -iname CMakeFiles -exec rm -rf {} \+ -o \
162 \( -iname cmake_install.cmake -o \
163 -iname CTestTestfile.cmake -o \
164 -iname CMakeCache.txt \) -exec rm {} \+
165 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000166 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200167 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
168 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200169
170 if [ -f "$CONFIG_BAK" ]; then
171 mv "$CONFIG_BAK" "$CONFIG_H"
172 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100173}
174
Gilles Peskine7c652162017-12-11 00:01:40 +0100175# Executed on exit. May be redefined depending on command line options.
176final_report () {
177 :
178}
179
180fatal_signal () {
181 cleanup
182 final_report $1
183 trap - $1
184 kill -$1 $$
185}
186
187trap 'fatal_signal HUP' HUP
188trap 'fatal_signal INT' INT
189trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200190
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100191msg()
192{
193 echo ""
194 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100195 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000196 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100197 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100198 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100199}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100200
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100201if [ $RUN_ARMCC -ne 0 ]; then
202 armc6_build_test()
203 {
204 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100205
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100206 msg "build: ARM Compiler 6 ($FLAGS), make"
207 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
208 WARNING_CFLAGS='-xc -std=c99' make lib
209 make clean
210 }
211fi
Andres AGa5cd9732016-10-17 15:23:10 +0100212
Andres AGd9eba4b2016-08-26 14:42:14 +0100213err_msg()
214{
215 echo "$1" >&2
216}
217
218check_tools()
219{
220 for TOOL in "$@"; do
221 if ! `hash "$TOOL" >/dev/null 2>&1`; then
222 err_msg "$TOOL not found!"
223 exit 1
224 fi
225 done
226}
227
SimonB2e23c822016-04-16 21:54:39 +0100228while [ $# -gt 0 ]; do
229 case "$1" in
Gilles Peskine54933e92018-03-21 08:39:32 +0100230 --armcc) RUN_ARMCC=1;;
231 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
232 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
233 --force|-f) FORCE=1;;
234 --gnutls-cli) shift; GNUTLS_CLI="$1";;
235 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
236 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
237 --gnutls-serv) shift; GNUTLS_SERV="$1";;
238 --help|-h) usage; exit;;
239 --keep-going|-k) KEEP_GOING=1;;
240 --memory|-m) MEMORY=1;;
241 --no-armcc) RUN_ARMCC=0;;
Gilles Peskine19ceb712018-03-21 08:40:26 +0100242 --no-force) FORCE=0;;
243 --no-keep-going) KEEP_GOING=0;;
244 --no-memory) MEMORY=0;;
Gilles Peskine54933e92018-03-21 08:39:32 +0100245 --no-yotta) YOTTA=0;;
246 --openssl) shift; OPENSSL="$1";;
247 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
248 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Gilles Peskine19ceb712018-03-21 08:40:26 +0100249 --random-seed) unset SEED;;
250 --release-test|-r) SEED=1;;
Gilles Peskine54933e92018-03-21 08:39:32 +0100251 --seed|-s) shift; SEED="$1";;
252 --yotta) YOTTA=1;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100253 *)
254 echo >&2 "Unknown option: $1"
255 echo >&2 "Run $0 --help for usage."
256 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100257 ;;
258 esac
259 shift
260done
261
262if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100263 if [ $YOTTA -eq 1 ]; then
264 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
265 fi
SimonB2e23c822016-04-16 21:54:39 +0100266 git checkout-index -f -q $CONFIG_H
267 cleanup
268else
269
Gilles Peskine2a22a802017-12-21 15:19:00 +0100270 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100271 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100272 echo "You can either delete your work and retry, or force the test to overwrite the"
273 echo "test by rerunning the script as: $0 --force"
274 exit 1
275 fi
276
Andres AGdc192212016-08-31 17:33:13 +0100277 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
278 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
279 echo "You can either delete this directory manually, or force the test by rerunning"
280 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
281 exit 1
282 fi
283
SimonB2e23c822016-04-16 21:54:39 +0100284 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100285 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100286 echo "You can either delete or preserve your work, or force the test by rerunning the"
287 echo "script as: $0 --force"
288 exit 1
289 fi
290fi
291
Gilles Peskine7c652162017-12-11 00:01:40 +0100292build_status=0
293if [ $KEEP_GOING -eq 1 ]; then
294 failure_summary=
295 failure_count=0
296 start_red=
297 end_color=
298 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100299 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100300 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
301 start_red=$(printf '\033[31m')
302 end_color=$(printf '\033[0m')
303 ;;
304 esac
305 fi
306 record_status () {
307 if "$@"; then
308 last_status=0
309 else
310 last_status=$?
311 text="$current_section: $* -> $last_status"
312 failure_summary="$failure_summary
313$text"
314 failure_count=$((failure_count + 1))
315 echo "${start_red}^^^^$text^^^^${end_color}"
316 fi
317 }
318 make () {
319 case "$*" in
320 *test|*check)
321 if [ $build_status -eq 0 ]; then
322 record_status command make "$@"
323 else
324 echo "(skipped because the build failed)"
325 fi
326 ;;
327 *)
328 record_status command make "$@"
329 build_status=$last_status
330 ;;
331 esac
332 }
333 final_report () {
334 if [ $failure_count -gt 0 ]; then
335 echo
336 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
337 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
338 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero5113bde2018-07-20 16:42:14 +0100339 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100340 elif [ -z "${1-}" ]; then
341 echo "SUCCESS :)"
342 fi
343 if [ -n "${1-}" ]; then
344 echo "Killed by SIG$1."
345 fi
346 }
347else
348 record_status () {
349 "$@"
350 }
351fi
352if_build_succeeded () {
353 if [ $build_status -eq 0 ]; then
354 record_status "$@"
355 fi
356}
357
Andres AGd9eba4b2016-08-26 14:42:14 +0100358msg "info: $0 configuration"
359echo "MEMORY: $MEMORY"
360echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100361echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100362echo "OPENSSL: $OPENSSL"
363echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
364echo "GNUTLS_CLI: $GNUTLS_CLI"
365echo "GNUTLS_SERV: $GNUTLS_SERV"
366echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
367echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100368echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
369echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
370
371ARMC5_CC="$ARMC5_BIN_DIR/armcc"
372ARMC5_AR="$ARMC5_BIN_DIR/armar"
373ARMC6_CC="$ARMC6_BIN_DIR/armclang"
374ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100375
Andres AGb2fdd042016-09-22 14:17:46 +0100376# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
377# we just export the variables they require
378export OPENSSL_CMD="$OPENSSL"
379export GNUTLS_CLI="$GNUTLS_CLI"
380export GNUTLS_SERV="$GNUTLS_SERV"
381
Andres AG7770ea82016-10-10 15:46:20 +0100382# Avoid passing --seed flag in every call to ssl-opt.sh
Gilles Peskine19ceb712018-03-21 08:40:26 +0100383if [ -n "${SEED-}" ]; then
384 export SEED
385fi
Andres AG7770ea82016-10-10 15:46:20 +0100386
Andres AGd9eba4b2016-08-26 14:42:14 +0100387# Make sure the tools we need are available.
388check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100389 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100390 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
391if [ $RUN_ARMCC -ne 0 ]; then
392 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
393fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100394
Gilles Peskine192c72f2017-12-21 15:59:21 +0100395
396
397################################################################
398#### Basic checks
399################################################################
SimonB2e23c822016-04-16 21:54:39 +0100400
401#
402# Test Suites to be executed
403#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200404# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100405# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200406# and/or are more likely to fail than others (eg I use Clang most of the
407# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200408# 2. Minimize total running time, by avoiding useless rebuilds
409#
410# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100411
Janos Follathb72c6782016-07-19 14:54:17 +0100412msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100413OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
414 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100415 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
Gilles Peskine53038eb2018-03-21 08:35:07 +0100416 ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100417
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100418msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200419tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100420
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000421msg "test: freshness of generated source files" # < 1s
422tests/scripts/check-generated-files.sh
423
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200424msg "test: doxygen markup outside doxygen blocks" # < 1s
425tests/scripts/check-doxy-blocks.pl
426
Darryl Greenbd38c3b2018-03-13 16:48:16 +0000427msg "test: check-files.py" # < 1s
428cleanup
429tests/scripts/check-files.py
430
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200431msg "test/build: declared and exported names" # < 3s
432cleanup
433tests/scripts/check-names.sh
434
Andres AGd9eba4b2016-08-26 14:42:14 +0100435msg "test: doxygen warnings" # ~ 3s
436cleanup
437tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100438
Gilles Peskine192c72f2017-12-21 15:59:21 +0100439
440
441################################################################
442#### Build and test many configurations and targets
443################################################################
444
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100445if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
446 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
447 # path, and uses whatever version of armcc it finds there.
Gilles Peskineda519252017-11-30 13:22:04 +0100448 msg "build: create and build yotta module" # ~ 30s
449 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100450 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100451fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200452
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100453msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100454cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100455CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100456make
457
Simon Butcher8e3afc72016-09-15 17:13:08 +0100458msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100459make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200460
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100461msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100462if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200463
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100464msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine763da6e2018-03-22 22:26:03 +0100465record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200466
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200467msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
468make
469
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100470msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100471if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200472
Simon Butcher3ea7f522016-03-07 23:22:10 +0000473msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
474cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000475cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000476scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
477CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
478make
479
Simon Butcher8e3afc72016-09-15 17:13:08 +0100480msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000481make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000482
483msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100484if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
485if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000486
487msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100488if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000489
Hanno Becker134c2ab2017-10-12 15:29:50 +0100490msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
491cleanup
492cp "$CONFIG_H" "$CONFIG_BAK"
493scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
494CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
495make
496
497msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
498make test
499
500msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100501if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100502
Hanno Becker69d45cc2018-03-09 10:46:23 +0000503msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
504cleanup
505cp "$CONFIG_H" "$CONFIG_BAK"
506scripts/config.pl set MBEDTLS_RSA_NO_CRT
507CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
508make
509
510msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
511make test
512
513msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
514tests/ssl-opt.sh -f RSA
515
516msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
517tests/compat.sh -t RSA
518
Manuel Pégourié-Gonnard4d9e7cb2017-06-20 10:49:24 +0200519msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100520cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100521cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200522scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200523scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000524CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard4d9e7cb2017-06-20 10:49:24 +0200525make
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100526
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100527msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnard4d9e7cb2017-06-20 10:49:24 +0200528make test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200529
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100530msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100531if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200532
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100533msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100534if_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'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200535
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100536msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
537cleanup
538cp "$CONFIG_H" "$CONFIG_BAK"
539scripts/config.pl full
Gilles Peskine0afe6242018-02-21 19:28:12 +0100540scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100541# Build with -O -Wextra to catch a maximum of issues.
542make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs
543make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
544
545msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s
546# No cleanup, just tweak the configuration and rebuild
547make clean
548scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
Gilles Peskine0afe6242018-02-21 19:28:12 +0100549scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100550# Build with -O -Wextra to catch a maximum of issues.
551make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs
552make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
Gilles Peskine0afe6242018-02-21 19:28:12 +0100553
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200554msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100555cleanup
Gilles Peskine763da6e2018-03-22 22:26:03 +0100556record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100557
Manuel Pégourié-Gonnard483a7762017-06-06 11:36:16 +0200558msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
559cleanup
Gilles Peskine763da6e2018-03-22 22:26:03 +0100560record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard483a7762017-06-06 11:36:16 +0200561
Manuel Pégourié-Gonnard1ddd6822017-06-20 09:53:42 +0200562msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
563cleanup
Gilles Peskine763da6e2018-03-22 22:26:03 +0100564record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnard1ddd6822017-06-20 09:53:42 +0200565
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200566msg "test/build: key-exchanges (gcc)" # ~ 1 min
567cleanup
Gilles Peskine763da6e2018-03-22 22:26:03 +0100568record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200569
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000570msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100571cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100572make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100573
Simon Butcherf95c1762016-11-10 17:25:58 +0000574# Full configuration build, without platform support, file IO and net sockets.
575# This should catch missing mbedtls_printf definitions, and by disabling file
576# IO, it should catch missing '#include <stdio.h>'
577msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000578cleanup
579cp "$CONFIG_H" "$CONFIG_BAK"
580scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200581scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000582scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200583scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100584scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
585scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
586scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100587scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100588scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100589scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200590scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
591scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000592# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
593# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100594make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
595make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000596
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100597# catch compile bugs in _uninit functions
598msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
599cleanup
600cp "$CONFIG_H" "$CONFIG_BAK"
601scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100602scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100603scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100604make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100605
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200606msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
607cleanup
608cp "$CONFIG_H" "$CONFIG_BAK"
609scripts/config.pl full
610scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100611make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200612
613msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
614cleanup
615cp "$CONFIG_H" "$CONFIG_BAK"
616scripts/config.pl full
617scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000618make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200619
Simon Butcherf95c1762016-11-10 17:25:58 +0000620# Note, C99 compliance can also be tested with the sockets support disabled,
621# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100622msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200623cleanup
624cp "$CONFIG_H" "$CONFIG_BAK"
625scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200626scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
627scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100628make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200629
Hanno Becker5175ac62017-09-18 15:36:25 +0100630msg "build: default config except MFL extension (ASan build)" # ~ 30s
631cleanup
632cp "$CONFIG_H" "$CONFIG_BAK"
633scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
634CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
635make
636
637msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100638if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100639
Simon Butcherab5df402016-06-11 02:31:21 +0100640msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100641cleanup
642cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100643scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100644scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
645scripts/config.pl set MBEDTLS_ENTROPY_C
646scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
647scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
648scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100649CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100650make
651
Simon Butcher8e3afc72016-09-15 17:13:08 +0100652msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100653make test
Janos Follath06c54002016-06-09 13:57:40 +0100654
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200655if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100656 msg "build/test: make shared" # ~ 40s
657 cleanup
658 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200659fi
660
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000661if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100662 msg "build: i386, make, gcc" # ~ 30s
663 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100664 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garciadd29c2f2017-05-04 11:35:51 +0100665
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100666 msg "test: i386, make, gcc"
667 make test
668
669 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
670 cleanup
671 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
672
673 msg "test: 64-bit ILP32, make, gcc"
674 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000675fi # x86_64
676
Gilles Peskine14c3c062018-01-29 21:25:12 +0100677msg "build: gcc, force 32-bit bignum limbs"
678cleanup
679cp "$CONFIG_H" "$CONFIG_BAK"
680scripts/config.pl unset MBEDTLS_HAVE_ASM
681scripts/config.pl unset MBEDTLS_AESNI_C
682scripts/config.pl unset MBEDTLS_PADLOCK_C
683make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
684
685msg "test: gcc, force 32-bit bignum limbs"
686make test
687
688msg "build: gcc, force 64-bit bignum limbs"
689cleanup
690cp "$CONFIG_H" "$CONFIG_BAK"
691scripts/config.pl unset MBEDTLS_HAVE_ASM
692scripts/config.pl unset MBEDTLS_AESNI_C
693scripts/config.pl unset MBEDTLS_PADLOCK_C
694make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
695
696msg "test: gcc, force 64-bit bignum limbs"
697make test
698
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000699msg "build: arm-none-eabi-gcc, make" # ~ 10s
700cleanup
701cp "$CONFIG_H" "$CONFIG_BAK"
702scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200703scripts/config.pl unset MBEDTLS_NET_C
704scripts/config.pl unset MBEDTLS_TIMING_C
705scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100706scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000707scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000708# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200709scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
710scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
711scripts/config.pl unset MBEDTLS_THREADING_C
712scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
713scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100714make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000715
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200716msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
717cleanup
Simon Butcher51aaa992017-07-23 13:42:36 +0200718cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia6fb65862017-07-20 13:27:35 +0100719scripts/config.pl full
720scripts/config.pl unset MBEDTLS_NET_C
721scripts/config.pl unset MBEDTLS_TIMING_C
722scripts/config.pl unset MBEDTLS_FS_IO
723scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
724scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
725# following things are not in the default config
726scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
727scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
728scripts/config.pl unset MBEDTLS_THREADING_C
729scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
730scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200731scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100732make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200733echo "Checking that software 64-bit division is not required"
734! grep __aeabi_uldiv library/*.o
735
Andres AG87bb5772016-09-27 15:05:15 +0100736msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100737cleanup
738cp "$CONFIG_H" "$CONFIG_BAK"
739scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200740scripts/config.pl unset MBEDTLS_NET_C
741scripts/config.pl unset MBEDTLS_TIMING_C
742scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100743scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200744scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200745scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000746scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100747# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200748scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
749scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
750scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
751scripts/config.pl unset MBEDTLS_THREADING_C
752scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
753scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300754scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100755
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100756if [ $RUN_ARMCC -ne 0 ]; then
757 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
758 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100759
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100760 # ARM Compiler 6 - Target ARMv7-A
761 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200762
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100763 # ARM Compiler 6 - Target ARMv7-M
764 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher51aaa992017-07-23 13:42:36 +0200765
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100766 # ARM Compiler 6 - Target ARMv8-A - AArch32
767 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200768
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100769 # ARM Compiler 6 - Target ARMv8-M
770 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher51aaa992017-07-23 13:42:36 +0200771
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100772 # ARM Compiler 6 - Target ARMv8-A - AArch64
773 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
774fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100775
Gilles Peskine2a458da2017-05-12 15:26:58 +0200776msg "build: allow SHA1 in certificates by default"
777cleanup
778cp "$CONFIG_H" "$CONFIG_BAK"
779scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100780make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200781msg "test: allow SHA1 in certificates by default"
782make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100783if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200784
Hanno Beckerd485c312018-01-05 13:03:53 +0000785msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000786cleanup
787cp "$CONFIG_H" "$CONFIG_BAK"
788scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000789CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
790make
Hanno Beckere963efa2018-01-03 10:03:43 +0000791
792msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
793make test
794
Simon Butcher002bc622016-11-17 09:27:45 +0000795msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100796cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100797make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Simon Butcher91aef332016-11-17 09:20:50 +0000798
Simon Butcher002bc622016-11-17 09:27:45 +0000799# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100800make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
801make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000802
Simon Butcher002bc622016-11-17 09:27:45 +0000803msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100804make 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
805make 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
806make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100807
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000808# MemSan currently only available on Linux 64 bits
809if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000810
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100811 msg "build: MSan (clang)" # ~ 1 min 20s
812 cleanup
813 cp "$CONFIG_H" "$CONFIG_BAK"
814 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
815 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
816 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200817
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100818 msg "test: main suites (MSan)" # ~ 10s
819 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100820
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100821 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100822 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100823
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100824 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100825
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100826 if [ "$MEMORY" -gt 0 ]; then
827 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100828 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100829 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100830
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000831else # no MemSan
832
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100833 msg "build: Release (clang)"
834 cleanup
835 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
836 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000837
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100838 msg "test: main suites valgrind (Release)"
839 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000840
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100841 # Optional part(s)
842 # Currently broken, programs don't seem to receive signals
843 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000844
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100845 if [ "$MEMORY" -gt 0 ]; then
846 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100847 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100848 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000849
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100850 if [ "$MEMORY" -gt 1 ]; then
851 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100852 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100853 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000854
855fi # MemSan
856
Andres AGdc192212016-08-31 17:33:13 +0100857msg "build: cmake 'out-of-source' build"
858cleanup
859MBEDTLS_ROOT_DIR="$PWD"
860mkdir "$OUT_OF_SOURCE_DIR"
861cd "$OUT_OF_SOURCE_DIR"
862cmake "$MBEDTLS_ROOT_DIR"
863make
864
865msg "test: cmake 'out-of-source' build"
866make test
Gilles Peskine0114ffc2018-03-21 12:17:20 +0100867# Test an SSL option that requires an auxiliary script in test/scripts/.
868# Also ensure that there are no error messages such as
869# "No such file or directory", which would indicate that some required
870# file is missing (ssl-opt.sh tolerates the absence of some files so
871# may exit with status 0 but emit errors).
872if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
873if [ -s ssl-opt.err ]; then
874 cat ssl-opt.err >&2
875 record_status [ ! -s ssl-opt.err ]
876 rm ssl-opt.err
877fi
Andres AGdc192212016-08-31 17:33:13 +0100878cd "$MBEDTLS_ROOT_DIR"
879rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100880unset MBEDTLS_ROOT_DIR
Andres AGdc192212016-08-31 17:33:13 +0100881
Gilles Peskine192c72f2017-12-21 15:59:21 +0100882
883
884################################################################
885#### Termination
886################################################################
887
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100888msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100889cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100890
891final_report