blob: 9962046621517f71edf31d87cfbf132d0639b42a [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
41# * Yotta build dependencies, unless invoked with --no-yotta
42# * OpenSSL and GnuTLS command line tools, recent enough for the
43# interoperability tests. If they don't support SSLv3 then a legacy
44# version of these tools must be present as well (search for LEGACY
45# below).
46# See the invocation of check_tools below for details.
47#
48# This script must be invoked from the toplevel directory of a git
49# working copy of Mbed TLS.
50#
51# Note that the output is not saved. You may want to run
52# script -c tests/scripts/all.sh
53# or
54# tests/scripts/all.sh >all.log 2>&1
55#
56# Notes for maintainers
57# ---------------------
58#
59# The tests are roughly in order from fastest to slowest. This doesn't
60# have to be exact, but in general you should add slower tests towards
61# the end and fast checks near the beginning.
62#
63# Sanity checks have the following form:
64# 1. msg "short description of what is about to be done"
65# 2. run sanity check (failure stops the script)
66#
67# Build or build-and-test steps have the following form:
68# 1. msg "short description of what is about to be done"
69# 2. cleanup
70# 3. preparation (config.pl, cmake, ...) (failure stops the script)
71# 4. make
72# 5. Run tests if relevant. All tests must be prefixed with
73# if_build_successful for the sake of --keep-going.
74
75
76
77################################################################
78#### Initialization and command line parsing
79################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010080
SimonB2e23c822016-04-16 21:54:39 +010081# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010082set -eu
83
Andres AG38495a32016-07-12 16:54:33 +010084if [ "$( uname )" != "Linux" ]; then
85 echo "This script only works in Linux" >&2
86 exit 1
87elif [ -d library -a -d include -a -d tests ]; then :; else
88 echo "Must be run from mbed TLS root" >&2
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010089 exit 1
90fi
91
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000092CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020093CONFIG_BAK="$CONFIG_H.bak"
94
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010095MEMORY=0
SimonB2e23c822016-04-16 21:54:39 +010096FORCE=0
Gilles Peskine7c652162017-12-11 00:01:40 +010097KEEP_GOING=0
Gilles Peskinebca6ab92017-12-19 18:24:31 +010098RUN_ARMCC=1
Gilles Peskineda519252017-11-30 13:22:04 +010099YOTTA=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100100
Andres AGd9eba4b2016-08-26 14:42:14 +0100101# Default commands, can be overriden by the environment
102: ${OPENSSL:="openssl"}
103: ${OPENSSL_LEGACY:="$OPENSSL"}
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100104: ${OPENSSL_NEXT:="$OPENSSL"}
Andres AGd9eba4b2016-08-26 14:42:14 +0100105: ${GNUTLS_CLI:="gnutls-cli"}
106: ${GNUTLS_SERV:="gnutls-serv"}
107: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
108: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +0100109: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +0100110: ${ARMC5_BIN_DIR:=/usr/bin}
111: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +0100112
Andres AG38495a32016-07-12 16:54:33 +0100113# if MAKEFLAGS is not set add the -j option to speed up invocations of make
114if [ -n "${MAKEFLAGS+set}" ]; then
115 export MAKEFLAGS="-j"
116fi
117
Simon Butcher41eeccf2016-09-07 00:07:09 +0100118usage()
SimonB2e23c822016-04-16 21:54:39 +0100119{
Gilles Peskine709346a2017-12-10 23:43:39 +0100120 cat <<EOF
121Usage: $0 [OPTION]...
122 -h|--help Print this help.
123
124General options:
125 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100126 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100127 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100128 --armcc Run ARM Compiler builds (on by default).
129 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100130 --no-force Refuse to overwrite modified files (default).
131 --no-keep-going Stop at the first error (default).
132 --no-memory No additional memory tests (default).
Gilles Peskine2a22a802017-12-21 15:19:00 +0100133 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +0100134 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine38d81652018-03-21 08:40:26 +0100135 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100136 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
137 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100138 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100139
140Tool path options:
141 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
142 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
143 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
144 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
145 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
146 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
147 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
148 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100149 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100150EOF
SimonB2e23c822016-04-16 21:54:39 +0100151}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100152
153# remove built files as well as the cmake cache/config
154cleanup()
155{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100156 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
157 cd "$MBEDTLS_ROOT_DIR"
158 fi
159
Gilles Peskine7c652162017-12-11 00:01:40 +0100160 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200161
Gilles Peskine31b07e22018-03-21 12:15:06 +0100162 # Remove CMake artefacts
163 find . -name .git -prune -o -name yotta -prune -o \
164 -iname CMakeFiles -exec rm -rf {} \+ -o \
165 \( -iname cmake_install.cmake -o \
166 -iname CTestTestfile.cmake -o \
167 -iname CMakeCache.txt \) -exec rm {} \+
168 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000169 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200170 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
171 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200172
173 if [ -f "$CONFIG_BAK" ]; then
174 mv "$CONFIG_BAK" "$CONFIG_H"
175 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100176}
177
Gilles Peskine7c652162017-12-11 00:01:40 +0100178# Executed on exit. May be redefined depending on command line options.
179final_report () {
180 :
181}
182
183fatal_signal () {
184 cleanup
185 final_report $1
186 trap - $1
187 kill -$1 $$
188}
189
190trap 'fatal_signal HUP' HUP
191trap 'fatal_signal INT' INT
192trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200193
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100194msg()
195{
196 echo ""
197 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100198 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000199 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100200 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100201 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100202}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100203
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100204if [ $RUN_ARMCC -ne 0 ]; then
205 armc6_build_test()
206 {
207 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100208
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100209 msg "build: ARM Compiler 6 ($FLAGS), make"
210 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
211 WARNING_CFLAGS='-xc -std=c99' make lib
212 make clean
213 }
214fi
Andres AGa5cd9732016-10-17 15:23:10 +0100215
Andres AGd9eba4b2016-08-26 14:42:14 +0100216err_msg()
217{
218 echo "$1" >&2
219}
220
221check_tools()
222{
223 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000224 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100225 err_msg "$TOOL not found!"
226 exit 1
227 fi
228 done
229}
230
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400231check_headers_in_cpp () {
232 ls include/mbedtls >headers.txt
233 <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
234 sort |
235 diff headers.txt -
236 rm headers.txt
237}
238
SimonB2e23c822016-04-16 21:54:39 +0100239while [ $# -gt 0 ]; do
240 case "$1" in
Gilles Peskine8a244c92018-03-21 08:39:32 +0100241 --armcc) RUN_ARMCC=1;;
242 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
243 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
244 --force|-f) FORCE=1;;
245 --gnutls-cli) shift; GNUTLS_CLI="$1";;
246 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
247 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
248 --gnutls-serv) shift; GNUTLS_SERV="$1";;
249 --help|-h) usage; exit;;
250 --keep-going|-k) KEEP_GOING=1;;
251 --memory|-m) MEMORY=1;;
252 --no-armcc) RUN_ARMCC=0;;
Gilles Peskine38d81652018-03-21 08:40:26 +0100253 --no-force) FORCE=0;;
254 --no-keep-going) KEEP_GOING=0;;
255 --no-memory) MEMORY=0;;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100256 --no-yotta) YOTTA=0;;
257 --openssl) shift; OPENSSL="$1";;
258 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
Manuel Pégourié-Gonnarda3712be2018-05-22 15:58:50 +0200259 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100260 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Gilles Peskine38d81652018-03-21 08:40:26 +0100261 --random-seed) unset SEED;;
262 --release-test|-r) SEED=1;;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100263 --seed|-s) shift; SEED="$1";;
264 --yotta) YOTTA=1;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100265 *)
266 echo >&2 "Unknown option: $1"
267 echo >&2 "Run $0 --help for usage."
268 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100269 ;;
270 esac
271 shift
272done
273
274if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100275 if [ $YOTTA -eq 1 ]; then
276 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
277 fi
SimonB2e23c822016-04-16 21:54:39 +0100278 git checkout-index -f -q $CONFIG_H
279 cleanup
280else
281
Gilles Peskine2a22a802017-12-21 15:19:00 +0100282 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100283 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100284 echo "You can either delete your work and retry, or force the test to overwrite the"
285 echo "test by rerunning the script as: $0 --force"
286 exit 1
287 fi
288
Andres AGdc192212016-08-31 17:33:13 +0100289 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
290 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
291 echo "You can either delete this directory manually, or force the test by rerunning"
292 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
293 exit 1
294 fi
295
SimonB2e23c822016-04-16 21:54:39 +0100296 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100297 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100298 echo "You can either delete or preserve your work, or force the test by rerunning the"
299 echo "script as: $0 --force"
300 exit 1
301 fi
302fi
303
Gilles Peskine7c652162017-12-11 00:01:40 +0100304build_status=0
305if [ $KEEP_GOING -eq 1 ]; then
306 failure_summary=
307 failure_count=0
308 start_red=
309 end_color=
310 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100311 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100312 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
313 start_red=$(printf '\033[31m')
314 end_color=$(printf '\033[0m')
315 ;;
316 esac
317 fi
318 record_status () {
319 if "$@"; then
320 last_status=0
321 else
322 last_status=$?
323 text="$current_section: $* -> $last_status"
324 failure_summary="$failure_summary
325$text"
326 failure_count=$((failure_count + 1))
327 echo "${start_red}^^^^$text^^^^${end_color}"
328 fi
329 }
330 make () {
331 case "$*" in
332 *test|*check)
333 if [ $build_status -eq 0 ]; then
334 record_status command make "$@"
335 else
336 echo "(skipped because the build failed)"
337 fi
338 ;;
339 *)
340 record_status command make "$@"
341 build_status=$last_status
342 ;;
343 esac
344 }
345 final_report () {
346 if [ $failure_count -gt 0 ]; then
347 echo
348 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
349 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
350 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7c1258d2018-07-20 16:42:14 +0100351 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100352 elif [ -z "${1-}" ]; then
353 echo "SUCCESS :)"
354 fi
355 if [ -n "${1-}" ]; then
356 echo "Killed by SIG$1."
357 fi
358 }
359else
360 record_status () {
361 "$@"
362 }
363fi
364if_build_succeeded () {
365 if [ $build_status -eq 0 ]; then
366 record_status "$@"
367 fi
368}
369
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200370# to be used instead of ! for commands run with
371# record_status or if_build_succeeded
372not() {
373 ! "$@"
374}
375
Andres AGd9eba4b2016-08-26 14:42:14 +0100376msg "info: $0 configuration"
377echo "MEMORY: $MEMORY"
378echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100379echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100380echo "OPENSSL: $OPENSSL"
381echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100382echo "OPENSSL_NEXT: $OPENSSL_NEXT"
Andres AGd9eba4b2016-08-26 14:42:14 +0100383echo "GNUTLS_CLI: $GNUTLS_CLI"
384echo "GNUTLS_SERV: $GNUTLS_SERV"
385echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
386echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100387echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
388echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
389
390ARMC5_CC="$ARMC5_BIN_DIR/armcc"
391ARMC5_AR="$ARMC5_BIN_DIR/armar"
392ARMC6_CC="$ARMC6_BIN_DIR/armclang"
393ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100394
Andres AGb2fdd042016-09-22 14:17:46 +0100395# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
396# we just export the variables they require
397export OPENSSL_CMD="$OPENSSL"
398export GNUTLS_CLI="$GNUTLS_CLI"
399export GNUTLS_SERV="$GNUTLS_SERV"
400
Andres AG7770ea82016-10-10 15:46:20 +0100401# Avoid passing --seed flag in every call to ssl-opt.sh
Gilles Peskine38d81652018-03-21 08:40:26 +0100402if [ -n "${SEED-}" ]; then
403 export SEED
404fi
Andres AG7770ea82016-10-10 15:46:20 +0100405
Andres AGd9eba4b2016-08-26 14:42:14 +0100406# Make sure the tools we need are available.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100407check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
408 "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100409 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Andres Amaya Garciaddebc492017-10-24 22:16:34 +0100410 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc" "gdb"
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100411if [ $RUN_ARMCC -ne 0 ]; then
412 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
413fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100414
Gilles Peskine192c72f2017-12-21 15:59:21 +0100415
416
417################################################################
418#### Basic checks
419################################################################
SimonB2e23c822016-04-16 21:54:39 +0100420
421#
422# Test Suites to be executed
423#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200424# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100425# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200426# and/or are more likely to fail than others (eg I use Clang most of the
427# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200428# 2. Minimize total running time, by avoiding useless rebuilds
429#
430# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100431
Janos Follathb72c6782016-07-19 14:54:17 +0100432msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100433OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
434 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100435 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
Gilles Peskine26232962018-03-21 08:35:07 +0100436 ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100437
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100438msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200439tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100440
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000441msg "test: freshness of generated source files" # < 1s
442tests/scripts/check-generated-files.sh
443
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200444msg "test: doxygen markup outside doxygen blocks" # < 1s
445tests/scripts/check-doxy-blocks.pl
446
Darryl Greena07039c2018-03-13 16:48:16 +0000447msg "test: check-files.py" # < 1s
448cleanup
449tests/scripts/check-files.py
450
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200451msg "test/build: declared and exported names" # < 3s
452cleanup
453tests/scripts/check-names.sh
454
Andres AGd9eba4b2016-08-26 14:42:14 +0100455msg "test: doxygen warnings" # ~ 3s
456cleanup
457tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100458
Jaeden Amero80e317a2018-07-11 15:45:23 +0100459msg "test: Mbed Crypto exporter " # ~ 30s
460cleanup
461make -f scripts/mbed_crypto.make
462cd crypto
463make test
464make clean
465cd ..
466make -f scripts/mbed_crypto.make clean
Gilles Peskine192c72f2017-12-21 15:59:21 +0100467
468
469################################################################
470#### Build and test many configurations and targets
471################################################################
472
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100473if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
474 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
475 # path, and uses whatever version of armcc it finds there.
Gilles Peskineda519252017-11-30 13:22:04 +0100476 msg "build: create and build yotta module" # ~ 30s
477 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100478 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100479fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200480
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100481msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100482cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100483CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100484make
485
Simon Butcher8e3afc72016-09-15 17:13:08 +0100486msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100487make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200488
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100489msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100490if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200491
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100492msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine396fac12018-03-22 22:26:03 +0100493record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200494
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200495msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
496make
497
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100498msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100499if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200500
Simon Butcher3ea7f522016-03-07 23:22:10 +0000501msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
502cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000503cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000504scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
505CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
506make
507
Simon Butcher8e3afc72016-09-15 17:13:08 +0100508msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000509make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000510
511msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100512if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
513if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000514
515msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100516if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000517
Hanno Becker134c2ab2017-10-12 15:29:50 +0100518msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
519cleanup
520cp "$CONFIG_H" "$CONFIG_BAK"
521scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
522CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
523make
524
525msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
526make test
527
528msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100529if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100530
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100531msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
532cleanup
533cp "$CONFIG_H" "$CONFIG_BAK"
534scripts/config.pl set MBEDTLS_RSA_NO_CRT
535CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
536make
537
538msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
539make test
540
541msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
542tests/ssl-opt.sh -f RSA
543
544msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
545tests/compat.sh -t RSA
546
Angus Grattonc4dd0732018-04-11 16:28:39 +1000547msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
548cleanup
549cp "$CONFIG_H" "$CONFIG_BAK"
550scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
551scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
552CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
553make
554
555msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
556if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet"
557
558msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
559cleanup
560cp "$CONFIG_H" "$CONFIG_BAK"
561scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096
562scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
563CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
564make
565
566msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
567if_build_succeeded tests/ssl-opt.sh -f "Max fragment"
568
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100569msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
570cleanup
571cp "$CONFIG_H" "$CONFIG_BAK"
572scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
573CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
574make
575
576msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
577if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
578
579msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
580cleanup
581cp "$CONFIG_H" "$CONFIG_BAK"
582scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240
583CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
584make
585
586msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
587if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
588
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200589msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200590cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100591cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200592scripts/config.pl full
593scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000594CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200595make
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100596
597msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200598make test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200599
Jaeden Amerod9c71da2018-06-15 20:31:26 +0100600msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
601if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200602
603msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100604if_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 +0200605
Manuel Pégourié-Gonnard9fece7e2018-06-18 11:38:22 +0200606msg "test: compat.sh ARIA + ChachaPoly"
607if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100608
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100609msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
610cleanup
611cp "$CONFIG_H" "$CONFIG_BAK"
612scripts/config.pl full
Gilles Peskine0afe6242018-02-21 19:28:12 +0100613scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100614# Build with -O -Wextra to catch a maximum of issues.
615make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs
616make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
617
618msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s
619# No cleanup, just tweak the configuration and rebuild
620make clean
621scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
Gilles Peskine0afe6242018-02-21 19:28:12 +0100622scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100623# Build with -O -Wextra to catch a maximum of issues.
624make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs
625make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
Gilles Peskine0afe6242018-02-21 19:28:12 +0100626
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200627msg "test/build: curves.pl (gcc)" # ~ 4 min
628cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100629record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200630
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200631msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
632cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100633record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200634
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200635msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
636cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100637record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200638
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200639msg "test/build: key-exchanges (gcc)" # ~ 1 min
640cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100641record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200642
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000643msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100644cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100645make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100646
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400647msg "test: verify header list in cpp_dummy_build.cpp"
648record_status check_headers_in_cpp
649
650msg "build: Unix make, incremental g++"
651make TEST_CPP=1
652
Simon Butcherf95c1762016-11-10 17:25:58 +0000653# Full configuration build, without platform support, file IO and net sockets.
654# This should catch missing mbedtls_printf definitions, and by disabling file
655# IO, it should catch missing '#include <stdio.h>'
656msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000657cleanup
658cp "$CONFIG_H" "$CONFIG_BAK"
659scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200660scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000661scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200662scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100663scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
664scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
665scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100666scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100667scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100668scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200669scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
670scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000671# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
672# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100673make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
674make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000675
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100676# catch compile bugs in _uninit functions
677msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
678cleanup
679cp "$CONFIG_H" "$CONFIG_BAK"
680scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100681scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100682scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100683make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100684
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200685msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
686cleanup
687cp "$CONFIG_H" "$CONFIG_BAK"
688scripts/config.pl full
689scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100690make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200691
692msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
693cleanup
694cp "$CONFIG_H" "$CONFIG_BAK"
695scripts/config.pl full
696scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000697make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200698
Simon Butcherf95c1762016-11-10 17:25:58 +0000699# Note, C99 compliance can also be tested with the sockets support disabled,
700# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100701msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200702cleanup
703cp "$CONFIG_H" "$CONFIG_BAK"
704scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200705scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
706scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100707make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200708
Angus Grattonc4dd0732018-04-11 16:28:39 +1000709# Run max fragment length tests with MFL disabled
Hanno Becker5175ac62017-09-18 15:36:25 +0100710msg "build: default config except MFL extension (ASan build)" # ~ 30s
711cleanup
712cp "$CONFIG_H" "$CONFIG_BAK"
713scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
714CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
715make
716
717msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100718if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000719
Angus Grattonc4dd0732018-04-11 16:28:39 +1000720msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
721cleanup
722cp "$CONFIG_H" "$CONFIG_BAK"
723scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
724scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
725scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
726CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
727make
728
729msg "test: MFL tests (disabled MFL extension case) & large packet tests"
730if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
731
Simon Butcherab5df402016-06-11 02:31:21 +0100732msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100733cleanup
734cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100735scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100736scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
737scripts/config.pl set MBEDTLS_ENTROPY_C
738scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
739scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
740scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100741CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100742make
743
Simon Butcher8e3afc72016-09-15 17:13:08 +0100744msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100745make test
Janos Follath06c54002016-06-09 13:57:40 +0100746
Hanno Becker83ebf782017-07-07 12:29:15 +0100747msg "build: default config with AES_FEWER_TABLES enabled"
748cleanup
749cp "$CONFIG_H" "$CONFIG_BAK"
750scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100751make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100752
753msg "test: AES_FEWER_TABLES"
754make test
755
756msg "build: default config with AES_ROM_TABLES enabled"
757cleanup
758cp "$CONFIG_H" "$CONFIG_BAK"
759scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100760make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100761
762msg "test: AES_ROM_TABLES"
763make test
764
765msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
766cleanup
767cp "$CONFIG_H" "$CONFIG_BAK"
768scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
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_FEWER_TABLES + AES_ROM_TABLES"
773make test
774
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200775if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100776 msg "build/test: make shared" # ~ 40s
777 cleanup
778 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200779fi
780
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000781if uname -a | grep -F x86_64 >/dev/null; then
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100782 # Build once with -O0, to compile out the i386 specific inline assembly
783 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100784 cleanup
Simon Butcher7a6da6e2018-06-27 21:52:54 +0100785 cp "$CONFIG_H" "$CONFIG_BAK"
786 scripts/config.pl full
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100787 make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100788
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100789 msg "test: i386, make, gcc -O0 (ASan build)"
790 make test
791
792 # Build again with -O1, to compile in the i386 specific inline assembly
793 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
794 cleanup
795 cp "$CONFIG_H" "$CONFIG_BAK"
796 scripts/config.pl full
797 make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
798
799 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100800 make test
801
802 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
803 cleanup
Simon Butcher7a6da6e2018-06-27 21:52:54 +0100804 cp "$CONFIG_H" "$CONFIG_BAK"
805 scripts/config.pl full
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100806 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
807
808 msg "test: 64-bit ILP32, make, gcc"
809 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000810fi # x86_64
811
Gilles Peskine14c3c062018-01-29 21:25:12 +0100812msg "build: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100813cleanup
814cp "$CONFIG_H" "$CONFIG_BAK"
815scripts/config.pl unset MBEDTLS_HAVE_ASM
816scripts/config.pl unset MBEDTLS_AESNI_C
817scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100818make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100819
Gilles Peskine14c3c062018-01-29 21:25:12 +0100820msg "test: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100821make test
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100822
Gilles Peskine14c3c062018-01-29 21:25:12 +0100823msg "build: gcc, force 64-bit bignum limbs"
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100824cleanup
825cp "$CONFIG_H" "$CONFIG_BAK"
826scripts/config.pl unset MBEDTLS_HAVE_ASM
827scripts/config.pl unset MBEDTLS_AESNI_C
828scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100829make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
830
831msg "test: gcc, force 64-bit bignum limbs"
832make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000833
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200834
835msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
836cleanup
837cp "$CONFIG_H" "$CONFIG_BAK"
838scripts/config.pl full
839scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
840scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
841make CFLAGS='-Werror -O1'
842
843msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
844make test
845
846
847msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
848cleanup
849cp "$CONFIG_H" "$CONFIG_BAK"
850scripts/config.pl full
851scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
852scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
853make CFLAGS='-Werror -O1'
854
855msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
856make test
857
858
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000859msg "build: arm-none-eabi-gcc, make" # ~ 10s
860cleanup
861cp "$CONFIG_H" "$CONFIG_BAK"
862scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200863scripts/config.pl unset MBEDTLS_NET_C
864scripts/config.pl unset MBEDTLS_TIMING_C
865scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100866scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000867scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000868# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200869scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
870scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
871scripts/config.pl unset MBEDTLS_THREADING_C
872scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
873scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100874make 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 +0000875
Gilles Peskineed942f82017-06-08 15:19:20 +0200876msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
877cleanup
Simon Butcher940737f2017-07-23 13:42:36 +0200878cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia05931972017-07-20 13:27:35 +0100879scripts/config.pl full
880scripts/config.pl unset MBEDTLS_NET_C
881scripts/config.pl unset MBEDTLS_TIMING_C
882scripts/config.pl unset MBEDTLS_FS_IO
883scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
884scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
885# following things are not in the default config
886scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
887scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
888scripts/config.pl unset MBEDTLS_THREADING_C
889scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
890scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineed942f82017-06-08 15:19:20 +0200891scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100892make 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 +0200893echo "Checking that software 64-bit division is not required"
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200894if_build_succeeded not grep __aeabi_uldiv library/*.o
895
896msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
897cleanup
898cp "$CONFIG_H" "$CONFIG_BAK"
899scripts/config.pl full
900scripts/config.pl unset MBEDTLS_NET_C
901scripts/config.pl unset MBEDTLS_TIMING_C
902scripts/config.pl unset MBEDTLS_FS_IO
903scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
904scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
905# following things are not in the default config
906scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
907scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
908scripts/config.pl unset MBEDTLS_THREADING_C
909scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
910scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
911scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
912make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib
913echo "Checking that software 64-bit multiplication is not required"
914if_build_succeeded not grep __aeabi_lmul library/*.o
Gilles Peskineed942f82017-06-08 15:19:20 +0200915
Andres AG87bb5772016-09-27 15:05:15 +0100916msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100917cleanup
918cp "$CONFIG_H" "$CONFIG_BAK"
919scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200920scripts/config.pl unset MBEDTLS_NET_C
921scripts/config.pl unset MBEDTLS_TIMING_C
922scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100923scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200924scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200925scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000926scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100927# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200928scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
929scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
930scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
931scripts/config.pl unset MBEDTLS_THREADING_C
932scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
933scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300934scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100935
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100936if [ $RUN_ARMCC -ne 0 ]; then
937 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
938 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100939
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100940 # ARM Compiler 6 - Target ARMv7-A
941 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +0200942
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100943 # ARM Compiler 6 - Target ARMv7-M
944 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +0200945
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100946 # ARM Compiler 6 - Target ARMv8-A - AArch32
947 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +0200948
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100949 # ARM Compiler 6 - Target ARMv8-M
950 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +0200951
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100952 # ARM Compiler 6 - Target ARMv8-A - AArch64
953 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
954fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100955
Gilles Peskine2a458da2017-05-12 15:26:58 +0200956msg "build: allow SHA1 in certificates by default"
957cleanup
958cp "$CONFIG_H" "$CONFIG_BAK"
959scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100960make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200961msg "test: allow SHA1 in certificates by default"
962make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100963if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200964
Hanno Beckerd485c312018-01-05 13:03:53 +0000965msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000966cleanup
967cp "$CONFIG_H" "$CONFIG_BAK"
968scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000969CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
970make
Hanno Beckere963efa2018-01-03 10:03:43 +0000971
972msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
973make test
Simon Butcher002bc622016-11-17 09:27:45 +0000974
975msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
976cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100977make 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 +0200978
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200979# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100980make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
981make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100982
983msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100984make 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
985make 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
986make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100987
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000988# MemSan currently only available on Linux 64 bits
989if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000990
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100991 msg "build: MSan (clang)" # ~ 1 min 20s
992 cleanup
993 cp "$CONFIG_H" "$CONFIG_BAK"
994 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
995 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
996 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200997
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100998 msg "test: main suites (MSan)" # ~ 10s
999 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001000
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001001 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +01001002 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001003
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001004 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001005
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001006 if [ "$MEMORY" -gt 0 ]; then
1007 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +01001008 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001009 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001010
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001011else # no MemSan
1012
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001013 msg "build: Release (clang)"
1014 cleanup
1015 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
1016 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001017
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001018 msg "test: main suites valgrind (Release)"
1019 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001020
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001021 # Optional part(s)
1022 # Currently broken, programs don't seem to receive signals
1023 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001024
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001025 if [ "$MEMORY" -gt 0 ]; then
1026 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001027 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001028 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001029
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001030 if [ "$MEMORY" -gt 1 ]; then
1031 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001032 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001033 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001034
1035fi # MemSan
1036
Andres AGdc192212016-08-31 17:33:13 +01001037msg "build: cmake 'out-of-source' build"
1038cleanup
1039MBEDTLS_ROOT_DIR="$PWD"
1040mkdir "$OUT_OF_SOURCE_DIR"
1041cd "$OUT_OF_SOURCE_DIR"
1042cmake "$MBEDTLS_ROOT_DIR"
1043make
1044
1045msg "test: cmake 'out-of-source' build"
1046make test
Gilles Peskine0114ffc2018-03-21 12:17:20 +01001047# Test an SSL option that requires an auxiliary script in test/scripts/.
1048# Also ensure that there are no error messages such as
1049# "No such file or directory", which would indicate that some required
1050# file is missing (ssl-opt.sh tolerates the absence of some files so
1051# may exit with status 0 but emit errors).
1052if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
1053if [ -s ssl-opt.err ]; then
1054 cat ssl-opt.err >&2
1055 record_status [ ! -s ssl-opt.err ]
1056 rm ssl-opt.err
1057fi
Andres AGdc192212016-08-31 17:33:13 +01001058cd "$MBEDTLS_ROOT_DIR"
1059rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskinea71d64c2018-03-21 12:16:57 +01001060unset MBEDTLS_ROOT_DIR
Andres AGdc192212016-08-31 17:33:13 +01001061
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001062# Test that the function mbedtls_platform_zeroize() is not optimized away by
1063# different combinations of compilers and optimization flags by using an
1064# auxiliary GDB script. Unfortunately, GDB does not return error values to the
1065# system in all cases that the script fails, so we must manually search the
1066# output to check whether the pass string is present and no failure strings
1067# were printed.
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001068for optimization_flag in -O2 -O3 -Ofast -Os; do
1069 for compiler in clang gcc; do
Andres Amaya Garcia708c5cb2018-04-24 08:33:31 -05001070 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001071 cleanup
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001072 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Andres Amaya Garcia79947662018-06-20 09:34:54 +01001073 if_build_succeeded gdb -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
1074 if_build_succeeded [ -s test_zeroize.log ]
1075 if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log
1076 if_build_succeeded not grep -i "error" test_zeroize.log
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001077 rm -f test_zeroize.log
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001078 done
1079done
Andres Amaya Garciad0d7bf62017-10-25 09:01:31 +01001080
Mohammad Azim Khanee6529e2018-07-06 00:50:34 +01001081msg "Lint: Python scripts"
Mohammad Azim Khan21798102018-07-06 00:41:08 +01001082tests/scripts/check-python-files.sh
Gilles Peskine192c72f2017-12-21 15:59:21 +01001083
Mohammad Azim Khanee6529e2018-07-06 00:50:34 +01001084msg "uint test: generate_test_code.py"
1085./tests/scripts/test_generate_test_code.py
Gilles Peskine192c72f2017-12-21 15:59:21 +01001086
1087################################################################
1088#### Termination
1089################################################################
1090
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001091msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001092cleanup
1093
Gilles Peskine7c652162017-12-11 00:01:40 +01001094final_report