blob: 6af13e6608f3937166b68509eda2e541ca541cf1 [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)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040038# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010039# * arm-gcc and mingw-gcc
40# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine192c72f2017-12-21 15:59:21 +010041# * 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
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010098
Andres AGd9eba4b2016-08-26 14:42:14 +010099# Default commands, can be overriden by the environment
100: ${OPENSSL:="openssl"}
101: ${OPENSSL_LEGACY:="$OPENSSL"}
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100102: ${OPENSSL_NEXT:="$OPENSSL"}
Andres AGd9eba4b2016-08-26 14:42:14 +0100103: ${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 Peskine38d81652018-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 Peskine709346a2017-12-10 23:43:39 +0100131 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine38d81652018-03-21 08:40:26 +0100132 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100133 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
134 -s|--seed Integer seed value to use for this test run.
135
136Tool path options:
137 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
138 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
139 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
140 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
141 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
142 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
143 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
144 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100145 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100146EOF
SimonB2e23c822016-04-16 21:54:39 +0100147}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100148
149# remove built files as well as the cmake cache/config
150cleanup()
151{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100152 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
153 cd "$MBEDTLS_ROOT_DIR"
154 fi
155
Gilles Peskine7c652162017-12-11 00:01:40 +0100156 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200157
Gilles Peskine31b07e22018-03-21 12:15:06 +0100158 # Remove CMake artefacts
Simon Butcher3ad2efd2018-05-02 14:49:38 +0100159 find . -name .git -prune \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100160 -iname CMakeFiles -exec rm -rf {} \+ -o \
161 \( -iname cmake_install.cmake -o \
162 -iname CTestTestfile.cmake -o \
163 -iname CMakeCache.txt \) -exec rm {} \+
164 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000165 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200166 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
167 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200168
169 if [ -f "$CONFIG_BAK" ]; then
170 mv "$CONFIG_BAK" "$CONFIG_H"
171 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100172}
173
Gilles Peskine7c652162017-12-11 00:01:40 +0100174# Executed on exit. May be redefined depending on command line options.
175final_report () {
176 :
177}
178
179fatal_signal () {
180 cleanup
181 final_report $1
182 trap - $1
183 kill -$1 $$
184}
185
186trap 'fatal_signal HUP' HUP
187trap 'fatal_signal INT' INT
188trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200189
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100190msg()
191{
192 echo ""
193 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100194 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000195 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100196 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100197 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100198}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100199
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100200if [ $RUN_ARMCC -ne 0 ]; then
201 armc6_build_test()
202 {
203 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100204
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100205 msg "build: ARM Compiler 6 ($FLAGS), make"
206 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
207 WARNING_CFLAGS='-xc -std=c99' make lib
208 make clean
209 }
210fi
Andres AGa5cd9732016-10-17 15:23:10 +0100211
Andres AGd9eba4b2016-08-26 14:42:14 +0100212err_msg()
213{
214 echo "$1" >&2
215}
216
217check_tools()
218{
219 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000220 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100221 err_msg "$TOOL not found!"
222 exit 1
223 fi
224 done
225}
226
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400227check_headers_in_cpp () {
228 ls include/mbedtls >headers.txt
229 <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
230 sort |
231 diff headers.txt -
232 rm headers.txt
233}
234
SimonB2e23c822016-04-16 21:54:39 +0100235while [ $# -gt 0 ]; do
236 case "$1" in
Gilles Peskine8a244c92018-03-21 08:39:32 +0100237 --armcc) RUN_ARMCC=1;;
238 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
239 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
240 --force|-f) FORCE=1;;
241 --gnutls-cli) shift; GNUTLS_CLI="$1";;
242 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
243 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
244 --gnutls-serv) shift; GNUTLS_SERV="$1";;
245 --help|-h) usage; exit;;
246 --keep-going|-k) KEEP_GOING=1;;
247 --memory|-m) MEMORY=1;;
248 --no-armcc) RUN_ARMCC=0;;
Gilles Peskine38d81652018-03-21 08:40:26 +0100249 --no-force) FORCE=0;;
250 --no-keep-going) KEEP_GOING=0;;
251 --no-memory) MEMORY=0;;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100252 --openssl) shift; OPENSSL="$1";;
253 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
Manuel Pégourié-Gonnarda3712be2018-05-22 15:58:50 +0200254 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100255 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Gilles Peskine38d81652018-03-21 08:40:26 +0100256 --random-seed) unset SEED;;
257 --release-test|-r) SEED=1;;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100258 --seed|-s) shift; SEED="$1";;
Gilles Peskine709346a2017-12-10 23:43:39 +0100259 *)
260 echo >&2 "Unknown option: $1"
261 echo >&2 "Run $0 --help for usage."
262 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100263 ;;
264 esac
265 shift
266done
267
268if [ $FORCE -eq 1 ]; then
SimonB2e23c822016-04-16 21:54:39 +0100269 git checkout-index -f -q $CONFIG_H
270 cleanup
271else
272
Andres AGdc192212016-08-31 17:33:13 +0100273 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
274 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
275 echo "You can either delete this directory manually, or force the test by rerunning"
276 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
277 exit 1
278 fi
279
SimonB2e23c822016-04-16 21:54:39 +0100280 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100281 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100282 echo "You can either delete or preserve your work, or force the test by rerunning the"
283 echo "script as: $0 --force"
284 exit 1
285 fi
286fi
287
Gilles Peskine7c652162017-12-11 00:01:40 +0100288build_status=0
289if [ $KEEP_GOING -eq 1 ]; then
290 failure_summary=
291 failure_count=0
292 start_red=
293 end_color=
294 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100295 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100296 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
297 start_red=$(printf '\033[31m')
298 end_color=$(printf '\033[0m')
299 ;;
300 esac
301 fi
302 record_status () {
303 if "$@"; then
304 last_status=0
305 else
306 last_status=$?
307 text="$current_section: $* -> $last_status"
308 failure_summary="$failure_summary
309$text"
310 failure_count=$((failure_count + 1))
311 echo "${start_red}^^^^$text^^^^${end_color}"
312 fi
313 }
314 make () {
315 case "$*" in
316 *test|*check)
317 if [ $build_status -eq 0 ]; then
318 record_status command make "$@"
319 else
320 echo "(skipped because the build failed)"
321 fi
322 ;;
323 *)
324 record_status command make "$@"
325 build_status=$last_status
326 ;;
327 esac
328 }
329 final_report () {
330 if [ $failure_count -gt 0 ]; then
331 echo
332 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
333 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
334 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7c1258d2018-07-20 16:42:14 +0100335 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100336 elif [ -z "${1-}" ]; then
337 echo "SUCCESS :)"
338 fi
339 if [ -n "${1-}" ]; then
340 echo "Killed by SIG$1."
341 fi
342 }
343else
344 record_status () {
345 "$@"
346 }
347fi
348if_build_succeeded () {
349 if [ $build_status -eq 0 ]; then
350 record_status "$@"
351 fi
352}
353
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200354# to be used instead of ! for commands run with
355# record_status or if_build_succeeded
356not() {
357 ! "$@"
358}
359
Andres AGd9eba4b2016-08-26 14:42:14 +0100360msg "info: $0 configuration"
361echo "MEMORY: $MEMORY"
362echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100363echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100364echo "OPENSSL: $OPENSSL"
365echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100366echo "OPENSSL_NEXT: $OPENSSL_NEXT"
Andres AGd9eba4b2016-08-26 14:42:14 +0100367echo "GNUTLS_CLI: $GNUTLS_CLI"
368echo "GNUTLS_SERV: $GNUTLS_SERV"
369echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
370echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100371echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
372echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
373
374ARMC5_CC="$ARMC5_BIN_DIR/armcc"
375ARMC5_AR="$ARMC5_BIN_DIR/armar"
376ARMC6_CC="$ARMC6_BIN_DIR/armclang"
377ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100378
Andres AGb2fdd042016-09-22 14:17:46 +0100379# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
380# we just export the variables they require
381export OPENSSL_CMD="$OPENSSL"
382export GNUTLS_CLI="$GNUTLS_CLI"
383export GNUTLS_SERV="$GNUTLS_SERV"
384
Andres AG7770ea82016-10-10 15:46:20 +0100385# Avoid passing --seed flag in every call to ssl-opt.sh
Gilles Peskine38d81652018-03-21 08:40:26 +0100386if [ -n "${SEED-}" ]; then
387 export SEED
388fi
Andres AG7770ea82016-10-10 15:46:20 +0100389
Andres AGd9eba4b2016-08-26 14:42:14 +0100390# Make sure the tools we need are available.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100391check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
392 "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100393 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Andres Amaya Garciaddebc492017-10-24 22:16:34 +0100394 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc" "gdb"
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100395if [ $RUN_ARMCC -ne 0 ]; then
396 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
397fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100398
Gilles Peskine192c72f2017-12-21 15:59:21 +0100399
400
401################################################################
402#### Basic checks
403################################################################
SimonB2e23c822016-04-16 21:54:39 +0100404
405#
406# Test Suites to be executed
407#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200408# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100409# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200410# and/or are more likely to fail than others (eg I use Clang most of the
411# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200412# 2. Minimize total running time, by avoiding useless rebuilds
413#
414# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100415
Janos Follathb72c6782016-07-19 14:54:17 +0100416msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100417OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
418 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100419 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
Gilles Peskine26232962018-03-21 08:35:07 +0100420 ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100421
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100422msg "test: recursion.pl" # < 1s
Gilles Peskine899c6522018-09-26 15:54:40 +0200423record_status tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100424
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000425msg "test: freshness of generated source files" # < 1s
Gilles Peskine899c6522018-09-26 15:54:40 +0200426record_status tests/scripts/check-generated-files.sh
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000427
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200428msg "test: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskine899c6522018-09-26 15:54:40 +0200429record_status tests/scripts/check-doxy-blocks.pl
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200430
Darryl Greena07039c2018-03-13 16:48:16 +0000431msg "test: check-files.py" # < 1s
432cleanup
Gilles Peskine899c6522018-09-26 15:54:40 +0200433record_status tests/scripts/check-files.py
Darryl Greena07039c2018-03-13 16:48:16 +0000434
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200435msg "test/build: declared and exported names" # < 3s
436cleanup
Gilles Peskine899c6522018-09-26 15:54:40 +0200437record_status tests/scripts/check-names.sh
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200438
Andres AGd9eba4b2016-08-26 14:42:14 +0100439msg "test: doxygen warnings" # ~ 3s
440cleanup
Gilles Peskine899c6522018-09-26 15:54:40 +0200441record_status tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100442
Gilles Peskine192c72f2017-12-21 15:59:21 +0100443
444################################################################
445#### Build and test many configurations and targets
446################################################################
447
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100448msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100449cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100450CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100451make
452
Simon Butcher8e3afc72016-09-15 17:13:08 +0100453msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100454make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200455
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100456msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100457if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200458
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100459msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine396fac12018-03-22 22:26:03 +0100460record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200461
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200462msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
463make
464
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100465msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100466if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200467
Simon Butcher3ea7f522016-03-07 23:22:10 +0000468msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
469cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000470cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000471scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
472CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
473make
474
Simon Butcher8e3afc72016-09-15 17:13:08 +0100475msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000476make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000477
478msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100479if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
480if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000481
482msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100483if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000484
Hanno Becker134c2ab2017-10-12 15:29:50 +0100485msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
486cleanup
487cp "$CONFIG_H" "$CONFIG_BAK"
488scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
489CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
490make
491
492msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
493make test
494
495msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100496if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100497
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100498msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
499cleanup
500cp "$CONFIG_H" "$CONFIG_BAK"
501scripts/config.pl set MBEDTLS_RSA_NO_CRT
502CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
503make
504
505msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
506make test
507
508msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskine3e954cf2018-09-27 10:12:17 +0200509if_build_succeeded tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100510
511msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
Gilles Peskine3e954cf2018-09-27 10:12:17 +0200512if_build_succeeded tests/compat.sh -t RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100513
Angus Grattonc4dd0732018-04-11 16:28:39 +1000514msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
515cleanup
516cp "$CONFIG_H" "$CONFIG_BAK"
517scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
518scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
519CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
520make
521
522msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
523if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet"
524
525msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
526cleanup
527cp "$CONFIG_H" "$CONFIG_BAK"
528scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096
529scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
530CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
531make
532
533msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
534if_build_succeeded tests/ssl-opt.sh -f "Max fragment"
535
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100536msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
537cleanup
538cp "$CONFIG_H" "$CONFIG_BAK"
539scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
540CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
541make
542
543msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
544if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
545
546msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
547cleanup
548cp "$CONFIG_H" "$CONFIG_BAK"
549scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240
550CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
551make
552
553msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
554if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
555
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200556msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200557cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100558cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200559scripts/config.pl full
560scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000561CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200562make
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100563
564msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200565make test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200566
Jaeden Amerod9c71da2018-06-15 20:31:26 +0100567msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
568if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200569
570msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100571if_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 +0200572
Manuel Pégourié-Gonnard9fece7e2018-06-18 11:38:22 +0200573msg "test: compat.sh ARIA + ChachaPoly"
574if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100575
Hanno Becker12bd57b2018-11-19 15:16:12 +0000576# MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
577msg "build: cmake, full config + MBEDTLS_USE_PSA_CRYPTO, ASan"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100578cleanup
579cp "$CONFIG_H" "$CONFIG_BAK"
580scripts/config.pl full
581scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
582scripts/config.pl set MBEDTLS_PSA_CRYPTO_C
583scripts/config.pl set MBEDTLS_USE_PSA_CRYPTO
584CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
585make
586
Hanno Becker12bd57b2018-11-19 15:16:12 +0000587msg "test: main suites (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100588make test
589
Hanno Becker12bd57b2018-11-19 15:16:12 +0000590msg "test: ssl-opt.sh (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100591if_build_succeeded tests/ssl-opt.sh
592
Hanno Becker12bd57b2018-11-19 15:16:12 +0000593msg "test: compat.sh default (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100594if_build_succeeded tests/compat.sh
595
Hanno Becker12bd57b2018-11-19 15:16:12 +0000596msg "test: compat.sh ssl3 (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100597if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
598
Hanno Becker12bd57b2018-11-19 15:16:12 +0000599msg "test: compat.sh RC4, DES & NULL (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100600if_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'
601
Hanno Becker12bd57b2018-11-19 15:16:12 +0000602msg "test: compat.sh ARIA + ChachaPoly (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnarddde44422018-10-30 11:20:45 +0100603if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
604
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100605msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
606cleanup
607cp "$CONFIG_H" "$CONFIG_BAK"
608scripts/config.pl full
Gilles Peskine0afe6242018-02-21 19:28:12 +0100609scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100610# Build with -O -Wextra to catch a maximum of issues.
611make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs
612make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
613
614msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s
615# No cleanup, just tweak the configuration and rebuild
616make clean
617scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
Gilles Peskine0afe6242018-02-21 19:28:12 +0100618scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100619# Build with -O -Wextra to catch a maximum of issues.
620make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs
621make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
Gilles Peskine0afe6242018-02-21 19:28:12 +0100622
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200623msg "test/build: curves.pl (gcc)" # ~ 4 min
624cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100625record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200626
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200627msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
628cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100629record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200630
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200631msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
632cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100633record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200634
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200635msg "test/build: key-exchanges (gcc)" # ~ 1 min
636cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100637record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200638
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000639msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100640cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100641make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100642
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400643msg "test: verify header list in cpp_dummy_build.cpp"
644record_status check_headers_in_cpp
645
646msg "build: Unix make, incremental g++"
647make TEST_CPP=1
648
Simon Butcherf95c1762016-11-10 17:25:58 +0000649# Full configuration build, without platform support, file IO and net sockets.
650# This should catch missing mbedtls_printf definitions, and by disabling file
651# IO, it should catch missing '#include <stdio.h>'
652msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000653cleanup
654cp "$CONFIG_H" "$CONFIG_BAK"
655scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200656scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000657scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200658scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100659scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
660scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
661scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100662scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100663scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100664scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200665scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
666scripts/config.pl unset MBEDTLS_FS_IO
Darryl Greendb2b8db2018-06-15 13:06:04 +0100667scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
668scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Simon Butchercb587002017-01-06 16:14:44 +0000669# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
670# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100671make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
672make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000673
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100674# catch compile bugs in _uninit functions
675msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
676cleanup
677cp "$CONFIG_H" "$CONFIG_BAK"
678scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100679scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100680scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100681make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100682
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200683msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
684cleanup
685cp "$CONFIG_H" "$CONFIG_BAK"
686scripts/config.pl full
687scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100688make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200689
690msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
691cleanup
692cp "$CONFIG_H" "$CONFIG_BAK"
693scripts/config.pl full
694scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000695make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200696
Simon Butcherf95c1762016-11-10 17:25:58 +0000697# Note, C99 compliance can also be tested with the sockets support disabled,
698# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100699msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200700cleanup
701cp "$CONFIG_H" "$CONFIG_BAK"
702scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200703scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
704scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100705make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200706
Angus Grattonc4dd0732018-04-11 16:28:39 +1000707# Run max fragment length tests with MFL disabled
Hanno Becker5175ac62017-09-18 15:36:25 +0100708msg "build: default config except MFL extension (ASan build)" # ~ 30s
709cleanup
710cp "$CONFIG_H" "$CONFIG_BAK"
711scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
712CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
713make
714
715msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100716if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000717
Angus Grattonc4dd0732018-04-11 16:28:39 +1000718msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
719cleanup
720cp "$CONFIG_H" "$CONFIG_BAK"
721scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
722scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
723scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
724CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
725make
726
727msg "test: MFL tests (disabled MFL extension case) & large packet tests"
728if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
729
Simon Butcherab5df402016-06-11 02:31:21 +0100730msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100731cleanup
732cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100733scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100734scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
735scripts/config.pl set MBEDTLS_ENTROPY_C
736scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
737scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
738scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100739CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100740make
741
Simon Butcher8e3afc72016-09-15 17:13:08 +0100742msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100743make test
Janos Follath06c54002016-06-09 13:57:40 +0100744
Hanno Beckere5fecec2018-10-11 11:02:52 +0100745msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
746cleanup
747cp "$CONFIG_H" "$CONFIG_BAK"
748scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
749scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
750scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free
751CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
752make
753
754msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
755make test
756
Hanno Becker83ebf782017-07-07 12:29:15 +0100757msg "build: default config with AES_FEWER_TABLES enabled"
758cleanup
759cp "$CONFIG_H" "$CONFIG_BAK"
760scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100761make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100762
763msg "test: AES_FEWER_TABLES"
764make test
765
766msg "build: default config with AES_ROM_TABLES enabled"
767cleanup
768cp "$CONFIG_H" "$CONFIG_BAK"
769scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100770make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100771
772msg "test: AES_ROM_TABLES"
773make test
774
775msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
776cleanup
777cp "$CONFIG_H" "$CONFIG_BAK"
778scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
779scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100780make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100781
782msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
783make test
784
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200785if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100786 msg "build/test: make shared" # ~ 40s
787 cleanup
788 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200789fi
790
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000791if uname -a | grep -F x86_64 >/dev/null; then
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100792 # Build once with -O0, to compile out the i386 specific inline assembly
793 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100794 cleanup
Simon Butcher7a6da6e2018-06-27 21:52:54 +0100795 cp "$CONFIG_H" "$CONFIG_BAK"
796 scripts/config.pl full
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100797 make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100798
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100799 msg "test: i386, make, gcc -O0 (ASan build)"
800 make test
801
802 # Build again with -O1, to compile in the i386 specific inline assembly
803 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
804 cleanup
805 cp "$CONFIG_H" "$CONFIG_BAK"
806 scripts/config.pl full
807 make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
808
809 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100810 make test
811
812 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
813 cleanup
Simon Butcher7a6da6e2018-06-27 21:52:54 +0100814 cp "$CONFIG_H" "$CONFIG_BAK"
815 scripts/config.pl full
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100816 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
817
818 msg "test: 64-bit ILP32, make, gcc"
819 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000820fi # x86_64
821
Gilles Peskine14c3c062018-01-29 21:25:12 +0100822msg "build: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100823cleanup
824cp "$CONFIG_H" "$CONFIG_BAK"
825scripts/config.pl unset MBEDTLS_HAVE_ASM
826scripts/config.pl unset MBEDTLS_AESNI_C
827scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100828make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100829
Gilles Peskine14c3c062018-01-29 21:25:12 +0100830msg "test: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100831make test
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100832
Gilles Peskine14c3c062018-01-29 21:25:12 +0100833msg "build: gcc, force 64-bit bignum limbs"
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100834cleanup
835cp "$CONFIG_H" "$CONFIG_BAK"
836scripts/config.pl unset MBEDTLS_HAVE_ASM
837scripts/config.pl unset MBEDTLS_AESNI_C
838scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100839make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
840
841msg "test: gcc, force 64-bit bignum limbs"
842make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000843
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200844
845msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
846cleanup
847cp "$CONFIG_H" "$CONFIG_BAK"
848scripts/config.pl full
849scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
850scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
851make CFLAGS='-Werror -O1'
852
853msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
854make test
855
856
857msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
858cleanup
859cp "$CONFIG_H" "$CONFIG_BAK"
860scripts/config.pl full
861scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
862scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
863make CFLAGS='-Werror -O1'
864
865msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
866make test
867
868
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000869msg "build: arm-none-eabi-gcc, make" # ~ 10s
870cleanup
871cp "$CONFIG_H" "$CONFIG_BAK"
872scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200873scripts/config.pl unset MBEDTLS_NET_C
874scripts/config.pl unset MBEDTLS_TIMING_C
875scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100876scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000877scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000878# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200879scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
880scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
881scripts/config.pl unset MBEDTLS_THREADING_C
882scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
883scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Darryl Greendb2b8db2018-06-15 13:06:04 +0100884scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C # depends on MBEDTLS_FS_IO
885scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C # depends on MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100886make 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 +0000887
Gilles Peskineed942f82017-06-08 15:19:20 +0200888msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
889cleanup
Simon Butcher940737f2017-07-23 13:42:36 +0200890cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia05931972017-07-20 13:27:35 +0100891scripts/config.pl full
892scripts/config.pl unset MBEDTLS_NET_C
893scripts/config.pl unset MBEDTLS_TIMING_C
894scripts/config.pl unset MBEDTLS_FS_IO
895scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
896scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
897# following things are not in the default config
898scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
899scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
900scripts/config.pl unset MBEDTLS_THREADING_C
901scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
902scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineed942f82017-06-08 15:19:20 +0200903scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Darryl Greendb2b8db2018-06-15 13:06:04 +0100904scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C # depends on MBEDTLS_FS_IO
905scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C # depends on MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100906make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskineed942f82017-06-08 15:19:20 +0200907echo "Checking that software 64-bit division is not required"
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200908if_build_succeeded not grep __aeabi_uldiv library/*.o
909
910msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
911cleanup
912cp "$CONFIG_H" "$CONFIG_BAK"
913scripts/config.pl full
914scripts/config.pl unset MBEDTLS_NET_C
915scripts/config.pl unset MBEDTLS_TIMING_C
916scripts/config.pl unset MBEDTLS_FS_IO
917scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
918scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
919# following things are not in the default config
920scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
921scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
922scripts/config.pl unset MBEDTLS_THREADING_C
923scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
924scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
925scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
Darryl Greendb2b8db2018-06-15 13:06:04 +0100926scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C # depends on MBEDTLS_FS_IO
927scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C # depends on MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200928make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib
929echo "Checking that software 64-bit multiplication is not required"
930if_build_succeeded not grep __aeabi_lmul library/*.o
Gilles Peskineed942f82017-06-08 15:19:20 +0200931
Andres AG87bb5772016-09-27 15:05:15 +0100932msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100933cleanup
934cp "$CONFIG_H" "$CONFIG_BAK"
935scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200936scripts/config.pl unset MBEDTLS_NET_C
937scripts/config.pl unset MBEDTLS_TIMING_C
938scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100939scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200940scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200941scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000942scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100943# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200944scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
945scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
946scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
947scripts/config.pl unset MBEDTLS_THREADING_C
948scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
949scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300950scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Darryl Greendb2b8db2018-06-15 13:06:04 +0100951scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C # depends on MBEDTLS_FS_IO
952scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C # depends on MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
Andres AG87bb5772016-09-27 15:05:15 +0100953
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100954if [ $RUN_ARMCC -ne 0 ]; then
955 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
956 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100957
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100958 # ARM Compiler 6 - Target ARMv7-A
959 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +0200960
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100961 # ARM Compiler 6 - Target ARMv7-M
962 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +0200963
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100964 # ARM Compiler 6 - Target ARMv8-A - AArch32
965 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +0200966
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100967 # ARM Compiler 6 - Target ARMv8-M
968 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +0200969
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100970 # ARM Compiler 6 - Target ARMv8-A - AArch64
971 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
972fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100973
Gilles Peskine2a458da2017-05-12 15:26:58 +0200974msg "build: allow SHA1 in certificates by default"
975cleanup
976cp "$CONFIG_H" "$CONFIG_BAK"
977scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100978make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200979msg "test: allow SHA1 in certificates by default"
980make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100981if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200982
Hanno Beckerd485c312018-01-05 13:03:53 +0000983msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000984cleanup
985cp "$CONFIG_H" "$CONFIG_BAK"
986scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000987CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
988make
Hanno Beckere963efa2018-01-03 10:03:43 +0000989
990msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
991make test
Simon Butcher002bc622016-11-17 09:27:45 +0000992
993msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
994cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100995make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Manuel Pégourié-Gonnard52fa38a2015-06-23 14:29:58 +0200996
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200997# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100998make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
999make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +01001000
1001msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +01001002make 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
1003make 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
1004make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +01001005
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001006# MemSan currently only available on Linux 64 bits
1007if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001008
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001009 msg "build: MSan (clang)" # ~ 1 min 20s
1010 cleanup
1011 cp "$CONFIG_H" "$CONFIG_BAK"
1012 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
1013 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1014 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02001015
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001016 msg "test: main suites (MSan)" # ~ 10s
1017 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001018
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001019 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +01001020 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001021
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001022 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001023
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001024 if [ "$MEMORY" -gt 0 ]; then
1025 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +01001026 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001027 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001028
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001029else # no MemSan
1030
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001031 msg "build: Release (clang)"
1032 cleanup
1033 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
1034 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001035
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001036 msg "test: main suites valgrind (Release)"
1037 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001038
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001039 # Optional part(s)
1040 # Currently broken, programs don't seem to receive signals
1041 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001042
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001043 if [ "$MEMORY" -gt 0 ]; then
1044 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001045 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001046 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001047
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001048 if [ "$MEMORY" -gt 1 ]; then
1049 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001050 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001051 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001052
1053fi # MemSan
1054
Andres AGdc192212016-08-31 17:33:13 +01001055msg "build: cmake 'out-of-source' build"
1056cleanup
1057MBEDTLS_ROOT_DIR="$PWD"
1058mkdir "$OUT_OF_SOURCE_DIR"
1059cd "$OUT_OF_SOURCE_DIR"
1060cmake "$MBEDTLS_ROOT_DIR"
1061make
1062
1063msg "test: cmake 'out-of-source' build"
1064make test
Gilles Peskine0114ffc2018-03-21 12:17:20 +01001065# Test an SSL option that requires an auxiliary script in test/scripts/.
1066# Also ensure that there are no error messages such as
1067# "No such file or directory", which would indicate that some required
1068# file is missing (ssl-opt.sh tolerates the absence of some files so
1069# may exit with status 0 but emit errors).
1070if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
1071if [ -s ssl-opt.err ]; then
1072 cat ssl-opt.err >&2
1073 record_status [ ! -s ssl-opt.err ]
1074 rm ssl-opt.err
1075fi
Andres AGdc192212016-08-31 17:33:13 +01001076cd "$MBEDTLS_ROOT_DIR"
1077rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskinea71d64c2018-03-21 12:16:57 +01001078unset MBEDTLS_ROOT_DIR
Andres AGdc192212016-08-31 17:33:13 +01001079
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001080# Test that the function mbedtls_platform_zeroize() is not optimized away by
1081# different combinations of compilers and optimization flags by using an
1082# auxiliary GDB script. Unfortunately, GDB does not return error values to the
1083# system in all cases that the script fails, so we must manually search the
1084# output to check whether the pass string is present and no failure strings
1085# were printed.
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001086for optimization_flag in -O2 -O3 -Ofast -Os; do
1087 for compiler in clang gcc; do
Andres Amaya Garcia708c5cb2018-04-24 08:33:31 -05001088 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001089 cleanup
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001090 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Andres Amaya Garcia79947662018-06-20 09:34:54 +01001091 if_build_succeeded gdb -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
Andres Amaya Garcia79947662018-06-20 09:34:54 +01001092 if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log
1093 if_build_succeeded not grep -i "error" test_zeroize.log
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001094 rm -f test_zeroize.log
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001095 done
1096done
Andres Amaya Garciad0d7bf62017-10-25 09:01:31 +01001097
Mohammad Azim Khanee6529e2018-07-06 00:50:34 +01001098msg "Lint: Python scripts"
Gilles Peskine899c6522018-09-26 15:54:40 +02001099record_status tests/scripts/check-python-files.sh
Gilles Peskine192c72f2017-12-21 15:59:21 +01001100
Mohammad Azim Khanee6529e2018-07-06 00:50:34 +01001101msg "uint test: generate_test_code.py"
Gilles Peskine899c6522018-09-26 15:54:40 +02001102record_status ./tests/scripts/test_generate_test_code.py
Gilles Peskine192c72f2017-12-21 15:59:21 +01001103
1104################################################################
1105#### Termination
1106################################################################
1107
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001108msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001109cleanup
1110
Gilles Peskine7c652162017-12-11 00:01:40 +01001111final_report