blob: ffc5f77204d80ce16c5395c71a07805d91efe8bd [file] [log] [blame]
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001#!/bin/sh
2
Simon Butcherd7f19022016-10-14 09:49:48 +01003# all.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01004#
Simon Butcherd7f19022016-10-14 09:49:48 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01006#
Gilles Peskined7602c22017-12-21 15:59:21 +01007# Copyright (c) 2014-2017, ARM Limited, All Rights Reserved
8
9
10
11################################################################
12#### Documentation
13################################################################
14
Simon Butcherd7f19022016-10-14 09:49:48 +010015# Purpose
Gilles Peskined7602c22017-12-21 15:59:21 +010016# -------
Simon Butcherd7f19022016-10-14 09:49:48 +010017#
18# To run all tests possible or available on the platform.
19#
Gilles Peskined7602c22017-12-21 15:59:21 +010020# Notes for users
21# ---------------
22#
Simon Butcherd7f19022016-10-14 09:49:48 +010023# Warning: the test is destructive. It includes various build modes and
24# configurations, and can and will arbitrarily change the current CMake
Gilles Peskined7602c22017-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.
Simon Butcherd7f19022016-10-14 09:49:48 +010030#
Gilles Peskined7602c22017-12-21 15:59:21 +010031# The script assumes the presence of a number of tools:
32# * Basic Unix tools (Windows users note: a Unix-style find must be before
33# the Windows find in the PATH)
34# * Perl
35# * GNU Make
36# * CMake
37# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
38# * arm-gcc and mingw-gcc
39# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
40# * OpenSSL and GnuTLS command line tools, recent enough for the
41# interoperability tests. If they don't support SSLv3 then a legacy
42# version of these tools must be present as well (search for LEGACY
43# below).
44# See the invocation of check_tools below for details.
45#
46# This script must be invoked from the toplevel directory of a git
47# working copy of Mbed TLS.
48#
49# Note that the output is not saved. You may want to run
50# script -c tests/scripts/all.sh
51# or
52# tests/scripts/all.sh >all.log 2>&1
53#
54# Notes for maintainers
55# ---------------------
56#
57# The tests are roughly in order from fastest to slowest. This doesn't
58# have to be exact, but in general you should add slower tests towards
59# the end and fast checks near the beginning.
60#
61# Sanity checks have the following form:
62# 1. msg "short description of what is about to be done"
63# 2. run sanity check (failure stops the script)
64#
65# Build or build-and-test steps have the following form:
66# 1. msg "short description of what is about to be done"
67# 2. cleanup
68# 3. preparation (config.pl, cmake, ...) (failure stops the script)
69# 4. make
70# 5. Run tests if relevant. All tests must be prefixed with
71# if_build_successful for the sake of --keep-going.
72
73
74
75################################################################
76#### Initialization and command line parsing
77################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010078
Simon Butcherd7f19022016-10-14 09:49:48 +010079# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010080set -eu
81
82if [ -d library -a -d include -a -d tests ]; then :; else
Simon Butcherd7f19022016-10-14 09:49:48 +010083 err_msg "Must be run from mbed TLS root"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010084 exit 1
85fi
86
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000087CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020088CONFIG_BAK="$CONFIG_H.bak"
89
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010090MEMORY=0
Simon Butcherd7f19022016-10-14 09:49:48 +010091FORCE=0
Gilles Peskinea8bf9862017-12-11 00:01:40 +010092KEEP_GOING=0
Gilles Peskineb9344e32017-12-19 18:24:31 +010093RUN_ARMCC=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010094
Simon Butcherd7f19022016-10-14 09:49:48 +010095# Default commands, can be overriden by the environment
96: ${OPENSSL:="openssl"}
97: ${OPENSSL_LEGACY:="$OPENSSL"}
98: ${GNUTLS_CLI:="gnutls-cli"}
99: ${GNUTLS_SERV:="gnutls-serv"}
100: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
101: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
102: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
103
104usage()
105{
Gilles Peskinea6901f42017-12-10 23:43:39 +0100106 cat <<EOF
107Usage: $0 [OPTION]...
108 -h|--help Print this help.
109
110General options:
111 -f|--force Force the tests to overwrite any modified files.
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100112 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskinea6901f42017-12-10 23:43:39 +0100113 -m|--memory Additional optional memory tests.
Gilles Peskineb9344e32017-12-19 18:24:31 +0100114 --armcc Run ARM Compiler builds (on by default).
115 --no-armcc Skip ARM Compiler builds.
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100116 --no-force Refuse to overwrite modified files (default).
117 --no-keep-going Stop at the first error (default).
118 --no-memory No additional memory tests (default).
Gilles Peskine32d92932018-03-21 10:14:05 +0100119 --no-yotta Ignored for compatibility with other Mbed TLS versions.
Gilles Peskinea6901f42017-12-10 23:43:39 +0100120 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100121 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskinea6901f42017-12-10 23:43:39 +0100122 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
123 -s|--seed Integer seed value to use for this test run.
124
125Tool path options:
Gilles Peskine37c88db2018-03-21 11:44:52 +0100126 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
127 --armc6-bin-dir=<ARMC6_bin_dir_path> Ignored for compatibility with other Mbed TLS versions.
Gilles Peskinea6901f42017-12-10 23:43:39 +0100128 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
129 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
130 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
131 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
132 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
133 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
134EOF
Simon Butcherd7f19022016-10-14 09:49:48 +0100135}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100136
137# remove built files as well as the cmake cache/config
138cleanup()
139{
Gilles Peskine00de2fd2018-03-21 12:16:57 +0100140 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
141 cd "$MBEDTLS_ROOT_DIR"
142 fi
143
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100144 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200145
Gilles Peskine341ea252018-03-21 12:15:06 +0100146 # Remove CMake artefacts
147 find . -name .git -prune -o -name yotta -prune -o \
148 -iname CMakeFiles -exec rm -rf {} \+ -o \
149 \( -iname cmake_install.cmake -o \
150 -iname CTestTestfile.cmake -o \
151 -iname CMakeCache.txt \) -exec rm {} \+
152 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000153 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200154 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
155 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200156
157 if [ -f "$CONFIG_BAK" ]; then
158 mv "$CONFIG_BAK" "$CONFIG_H"
159 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100160}
161
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100162# Executed on exit. May be redefined depending on command line options.
163final_report () {
164 :
165}
166
167fatal_signal () {
168 cleanup
169 final_report $1
170 trap - $1
171 kill -$1 $$
172}
173
174trap 'fatal_signal HUP' HUP
175trap 'fatal_signal INT' INT
176trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200177
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100178msg()
179{
180 echo ""
181 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100182 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000183 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100184 echo "******************************************************************"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100185 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100186}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100187
Simon Butcherd7f19022016-10-14 09:49:48 +0100188err_msg()
189{
190 echo "$1" >&2
191}
192
193check_tools()
194{
195 for TOOL in "$@"; do
Andres AG63cc7162017-01-31 17:04:45 +0000196 if ! `type "$TOOL" >/dev/null 2>&1`; then
Simon Butcherd7f19022016-10-14 09:49:48 +0100197 err_msg "$TOOL not found!"
198 exit 1
199 fi
200 done
201}
202
203while [ $# -gt 0 ]; do
204 case "$1" in
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100205 --armcc) RUN_ARMCC=1;;
Gilles Peskine37c88db2018-03-21 11:44:52 +0100206 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
207 --armc6-bin-dir) shift;; # Ignore for compatibility with later Mbed TLS versions
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100208 --force|-f) FORCE=1;;
209 --gnutls-cli) shift; GNUTLS_CLI="$1";;
210 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
211 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
212 --gnutls-serv) shift; GNUTLS_SERV="$1";;
213 --help|-h) usage; exit;;
214 --keep-going|-k) KEEP_GOING=1;;
215 --memory|-m) MEMORY=1;;
216 --no-armcc) RUN_ARMCC=0;;
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100217 --no-force) FORCE=0;;
218 --no-keep-going) KEEP_GOING=0;;
219 --no-memory) MEMORY=0;;
Gilles Peskine32d92932018-03-21 10:14:05 +0100220 --no-yotta) :;; # No Yotta support anyway, so just ignore --no-yotta
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100221 --openssl) shift; OPENSSL="$1";;
222 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
223 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100224 --random-seed) unset SEED;;
225 --release-test|-r) SEED=1;;
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100226 --seed|-s) shift; SEED="$1";;
Gilles Peskinea6901f42017-12-10 23:43:39 +0100227 *)
228 echo >&2 "Unknown option: $1"
229 echo >&2 "Run $0 --help for usage."
230 exit 120
Simon Butcherd7f19022016-10-14 09:49:48 +0100231 ;;
232 esac
233 shift
234done
235
236if [ $FORCE -eq 1 ]; then
237 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
238 git checkout-index -f -q $CONFIG_H
239 cleanup
240else
241
242 if [ -d yotta/module ]; then
243 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
244 echo "You can either delete your work and retry, or force the test to overwrite the"
245 echo "test by rerunning the script as: $0 --force"
246 exit 1
247 fi
248
249 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
250 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
251 echo "You can either delete this directory manually, or force the test by rerunning"
252 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
253 exit 1
254 fi
255
256 if ! git diff-files --quiet include/mbedtls/config.h; then
Simon Butcherd7f19022016-10-14 09:49:48 +0100257 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
258 echo "You can either delete or preserve your work, or force the test by rerunning the"
259 echo "script as: $0 --force"
260 exit 1
261 fi
262fi
263
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100264build_status=0
265if [ $KEEP_GOING -eq 1 ]; then
266 failure_summary=
267 failure_count=0
268 start_red=
269 end_color=
270 if [ -t 1 ]; then
Gilles Peskine92deeaa2018-01-02 21:54:17 +0100271 case "${TERM:-}" in
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100272 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
273 start_red=$(printf '\033[31m')
274 end_color=$(printf '\033[0m')
275 ;;
276 esac
277 fi
278 record_status () {
279 if "$@"; then
280 last_status=0
281 else
282 last_status=$?
283 text="$current_section: $* -> $last_status"
284 failure_summary="$failure_summary
285$text"
286 failure_count=$((failure_count + 1))
287 echo "${start_red}^^^^$text^^^^${end_color}"
288 fi
289 }
290 make () {
291 case "$*" in
292 *test|*check)
293 if [ $build_status -eq 0 ]; then
294 record_status command make "$@"
295 else
296 echo "(skipped because the build failed)"
297 fi
298 ;;
299 *)
300 record_status command make "$@"
301 build_status=$last_status
302 ;;
303 esac
304 }
305 final_report () {
306 if [ $failure_count -gt 0 ]; then
307 echo
308 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
309 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
310 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7ef1f5b2018-07-20 16:42:14 +0100311 exit 1
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100312 elif [ -z "${1-}" ]; then
313 echo "SUCCESS :)"
314 fi
315 if [ -n "${1-}" ]; then
316 echo "Killed by SIG$1."
317 fi
318 }
319else
320 record_status () {
321 "$@"
322 }
323fi
324if_build_succeeded () {
325 if [ $build_status -eq 0 ]; then
326 record_status "$@"
327 fi
328}
329
Simon Butcherd7f19022016-10-14 09:49:48 +0100330msg "info: $0 configuration"
331echo "MEMORY: $MEMORY"
332echo "FORCE: $FORCE"
333echo "SEED: ${SEED-"UNSET"}"
334echo "OPENSSL: $OPENSSL"
335echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
336echo "GNUTLS_CLI: $GNUTLS_CLI"
337echo "GNUTLS_SERV: $GNUTLS_SERV"
338echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
339echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Gilles Peskine37c88db2018-03-21 11:44:52 +0100340echo "ARMC5_BIN_DIR: ${ARMC5_BIN_DIR:-UNSET}"
341
342if [ -n "${ARMC5_BIN_DIR-}" ]; then
343 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
344 ARMC5_AR="$ARMC5_BIN_DIR/armar"
345else
346 ARMC5_CC=armcc
347 ARMC5_AR=armar
348fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100349
350# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
351# we just export the variables they require
352export OPENSSL_CMD="$OPENSSL"
353export GNUTLS_CLI="$GNUTLS_CLI"
354export GNUTLS_SERV="$GNUTLS_SERV"
355
356# Avoid passing --seed flag in every call to ssl-opt.sh
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100357if [ -n "${SEED-}" ]; then
358 export SEED
359fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100360
361# Make sure the tools we need are available.
362check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100363 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskineb9344e32017-12-19 18:24:31 +0100364 "arm-none-eabi-gcc"
365if [ $RUN_ARMCC -ne 0 ]; then
Gilles Peskine37c88db2018-03-21 11:44:52 +0100366 check_tools "$ARMC5_CC" "$ARMC5_AR"
Gilles Peskineb9344e32017-12-19 18:24:31 +0100367fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100368
Gilles Peskined7602c22017-12-21 15:59:21 +0100369
370
371################################################################
372#### Basic checks
373################################################################
374
Simon Butcherd7f19022016-10-14 09:49:48 +0100375#
376# Test Suites to be executed
377#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200378# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100379# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200380# and/or are more likely to fail than others (eg I use Clang most of the
381# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200382# 2. Minimize total running time, by avoiding useless rebuilds
383#
384# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100385
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100386msg "test: recursion.pl" # < 1s
Gilles Peskine665ca232018-09-26 15:54:40 +0200387record_status tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100388
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000389msg "test: freshness of generated source files" # < 1s
Gilles Peskine665ca232018-09-26 15:54:40 +0200390record_status tests/scripts/check-generated-files.sh
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000391
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200392msg "test: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskine665ca232018-09-26 15:54:40 +0200393record_status tests/scripts/check-doxy-blocks.pl
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200394
Darryl Greenf8277f92018-03-13 16:48:16 +0000395msg "test: check-files.py" # < 1s
396cleanup
Gilles Peskine665ca232018-09-26 15:54:40 +0200397record_status tests/scripts/check-files.py
Darryl Greenf8277f92018-03-13 16:48:16 +0000398
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200399msg "test/build: declared and exported names" # < 3s
400cleanup
Gilles Peskine665ca232018-09-26 15:54:40 +0200401record_status tests/scripts/check-names.sh
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200402
Manuel Pégourié-Gonnard9c81d012016-01-04 16:49:09 +0100403if which doxygen >/dev/null; then
404 msg "test: doxygen warnings" # ~ 3s
405 cleanup
406 tests/scripts/doxygen.sh
407fi
408
Gilles Peskined7602c22017-12-21 15:59:21 +0100409
410
411################################################################
412#### Build and test many configurations and targets
413################################################################
414
Simon Butcher73156352015-11-04 00:36:30 +0000415# Yotta not supported in 2.1 branch
416#msg "build: create and build yotta module" # ~ 30s
417#cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100418#record_status tests/scripts/yotta-build.sh
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200419
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100420msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100421cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100422CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100423make
424
Simon Butcherd7f19022016-10-14 09:49:48 +0100425msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100426make test
427programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200428
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100429msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100430if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200431
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100432msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskinea1931692018-03-22 22:26:03 +0100433record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200434
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200435msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
436make
437
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100438msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100439if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200440
Hanno Becker797c0842017-10-19 15:49:21 +0100441msg "build: default config except MFL extension (ASan build)" # ~ 30s
442cleanup
443cp "$CONFIG_H" "$CONFIG_BAK"
444scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
445CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
446make
447
448msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskinec4859b02018-09-27 10:12:58 +0200449if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker797c0842017-10-19 15:49:21 +0100450
Simon Butcher02b8d482016-03-15 20:39:52 +0000451msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
452cleanup
453cp "$CONFIG_H" "$CONFIG_BAK"
454scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
455CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
456make
457
Simon Butcherd7f19022016-10-14 09:49:48 +0100458msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher02b8d482016-03-15 20:39:52 +0000459make test
460programs/test/selftest
461
462msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100463if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
464if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher02b8d482016-03-15 20:39:52 +0000465
466msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100467if_build_succeeded tests/ssl-opt.sh
Simon Butcher02b8d482016-03-15 20:39:52 +0000468
Hanno Becker4f9973e2017-10-24 11:56:28 +0100469msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
470cleanup
471cp "$CONFIG_H" "$CONFIG_BAK"
472scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
473CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
474make
475
476msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
477make test
478
479msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100480if_build_succeeded tests/ssl-opt.sh
Hanno Becker4f9973e2017-10-24 11:56:28 +0100481
Hanno Becker92935922017-11-06 15:07:09 +0000482msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
483cleanup
484cp "$CONFIG_H" "$CONFIG_BAK"
485scripts/config.pl set MBEDTLS_RSA_NO_CRT
486CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
487make
488
489msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
490make test
491
492msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinec4859b02018-09-27 10:12:58 +0200493if_build_succeeded tests/ssl-opt.sh -f RSA
Hanno Becker92935922017-11-06 15:07:09 +0000494
495msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
Gilles Peskinec4859b02018-09-27 10:12:58 +0200496if_build_succeeded tests/compat.sh -t RSA
Hanno Becker92935922017-11-06 15:07:09 +0000497
498
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100499msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100500cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200501cp "$CONFIG_H" "$CONFIG_BAK"
502scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200503scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnardac92a482017-06-20 10:49:24 +0200504CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100505make
506
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100507msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200508make test
509
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100510msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100511if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200512
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100513msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100514if_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 +0200515
Gilles Peskine31ed29d2018-03-01 22:23:50 +0100516msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
517cleanup
518cp "$CONFIG_H" "$CONFIG_BAK"
519scripts/config.pl full
Gilles Peskine29af5f32018-02-21 19:28:12 +0100520scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine31ed29d2018-03-01 22:23:50 +0100521# Build with -O -Wextra to catch a maximum of issues.
522make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs
523make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
524
525msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s
526# No cleanup, just tweak the configuration and rebuild
527make clean
528scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
Gilles Peskine29af5f32018-02-21 19:28:12 +0100529scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED
Gilles Peskine31ed29d2018-03-01 22:23:50 +0100530# Build with -O -Wextra to catch a maximum of issues.
531make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs
532make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
Gilles Peskine29af5f32018-02-21 19:28:12 +0100533
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200534msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100535cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100536record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100537
Manuel Pégourié-Gonnard57176e52017-06-06 11:36:16 +0200538msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
539cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100540record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard57176e52017-06-06 11:36:16 +0200541
Manuel Pégourié-Gonnardf2fd5462017-06-20 09:53:42 +0200542msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
543cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100544record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnardf2fd5462017-06-20 09:53:42 +0200545
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200546msg "test/build: key-exchanges (gcc)" # ~ 1 min
547cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100548record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200549
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000550msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100551cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100552make CC=gcc CFLAGS='-Werror -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100553
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200554# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000555# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100556msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000557cleanup
558cp "$CONFIG_H" "$CONFIG_BAK"
559scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200560scripts/config.pl unset MBEDTLS_PLATFORM_C
561scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100562scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
563scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
564scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
565scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200566scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
567scripts/config.pl unset MBEDTLS_FS_IO
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100568make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000569
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100570# catch compile bugs in _uninit functions
571msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
572cleanup
573cp "$CONFIG_H" "$CONFIG_BAK"
574scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100575scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100576make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100577
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200578msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
579cleanup
580cp "$CONFIG_H" "$CONFIG_BAK"
581scripts/config.pl full
582scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100583make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200584
585msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
586cleanup
587cp "$CONFIG_H" "$CONFIG_BAK"
588scripts/config.pl full
589scripts/config.pl unset MBEDTLS_SSL_CLI_C
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100590make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200591
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200592msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200593cleanup
594cp "$CONFIG_H" "$CONFIG_BAK"
595scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200596scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
597scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100598make CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200599
Hanno Becker864e9982018-10-11 11:15:14 +0100600msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
601cleanup
602cp "$CONFIG_H" "$CONFIG_BAK"
603scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
604scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
605scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free
606CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
607make
608
609msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
610make test
611
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200612if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100613 msg "build/test: make shared" # ~ 40s
614 cleanup
615 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200616fi
617
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000618if uname -a | grep -F x86_64 >/dev/null; then
Simon Butcher698cb342018-07-20 21:27:33 +0100619 # Build once with -O0, to compile out the i386 specific inline assembly
620 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100621 cleanup
Simon Butcherf218c0c2018-06-27 21:52:54 +0100622 cp "$CONFIG_H" "$CONFIG_BAK"
623 scripts/config.pl full
Simon Butcher698cb342018-07-20 21:27:33 +0100624 make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
Andres Amaya Garcia401441b2017-05-08 11:19:19 +0100625
Simon Butcher698cb342018-07-20 21:27:33 +0100626 msg "test: i386, make, gcc -O0 (ASan build)"
627 make test
628
629 # Build again with -O1, to compile in the i386 specific inline assembly
630 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
631 cleanup
632 cp "$CONFIG_H" "$CONFIG_BAK"
633 scripts/config.pl full
634 make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
635
636 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garcia401441b2017-05-08 11:19:19 +0100637 make test
638
639 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
640 cleanup
Simon Butcherf218c0c2018-06-27 21:52:54 +0100641 cp "$CONFIG_H" "$CONFIG_BAK"
642 scripts/config.pl full
Andres Amaya Garcia401441b2017-05-08 11:19:19 +0100643 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
644
645 msg "test: 64-bit ILP32, make, gcc"
646 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000647fi # x86_64
648
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000649msg "build: arm-none-eabi-gcc, make" # ~ 10s
650cleanup
651cp "$CONFIG_H" "$CONFIG_BAK"
652scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200653scripts/config.pl unset MBEDTLS_NET_C
654scripts/config.pl unset MBEDTLS_TIMING_C
655scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcherd7f19022016-10-14 09:49:48 +0100656scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000657# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200658scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
659scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
660scripts/config.pl unset MBEDTLS_THREADING_C
661scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
662scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100663make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror lib
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000664
Gilles Peskineb9344e32017-12-19 18:24:31 +0100665if [ $RUN_ARMCC -ne 0 ]; then
666 msg "build: armcc, make"
667 cleanup
668 cp "$CONFIG_H" "$CONFIG_BAK"
669 scripts/config.pl full
670 scripts/config.pl unset MBEDTLS_NET_C
671 scripts/config.pl unset MBEDTLS_TIMING_C
672 scripts/config.pl unset MBEDTLS_FS_IO
673 scripts/config.pl unset MBEDTLS_HAVE_TIME
674 scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
675 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
676 # following things are not in the default config
677 scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
678 scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
679 scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
680 scripts/config.pl unset MBEDTLS_THREADING_C
681 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
682 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine37c88db2018-03-21 11:44:52 +0100683 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= lib
Gilles Peskineb9344e32017-12-19 18:24:31 +0100684fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100685
Gilles Peskineb49351d2017-05-12 15:26:58 +0200686msg "build: allow SHA1 in certificates by default"
687cleanup
688cp "$CONFIG_H" "$CONFIG_BAK"
689scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100690make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskineb49351d2017-05-12 15:26:58 +0200691msg "test: allow SHA1 in certificates by default"
692make test
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100693if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskineb49351d2017-05-12 15:26:58 +0200694
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100695if which i686-w64-mingw32-gcc >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100696 msg "build: cross-mingw64, make" # ~ 30s
697 cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100698 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1
699 make WINDOWS_BUILD=1 clean
700 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1
701 make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100702fi
703
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000704# MemSan currently only available on Linux 64 bits
705if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000706
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100707 msg "build: MSan (clang)" # ~ 1 min 20s
708 cleanup
709 cp "$CONFIG_H" "$CONFIG_BAK"
710 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
711 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
712 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200713
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100714 msg "test: main suites (MSan)" # ~ 10s
715 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100716
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100717 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100718 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100719
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100720 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100721
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100722 if [ "$MEMORY" -gt 0 ]; then
723 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100724 if_build_succeeded tests/compat.sh
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100725 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100726
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000727else # no MemSan
728
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100729 msg "build: Release (clang)"
730 cleanup
731 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
732 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000733
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100734 msg "test: main suites valgrind (Release)"
735 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000736
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100737 # Optional part(s)
738 # Currently broken, programs don't seem to receive signals
739 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000740
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100741 if [ "$MEMORY" -gt 0 ]; then
742 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100743 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100744 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000745
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100746 if [ "$MEMORY" -gt 1 ]; then
747 msg "test: compat.sh --memcheck (Release)"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100748 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100749 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000750
751fi # MemSan
752
Simon Butcherd7f19022016-10-14 09:49:48 +0100753msg "build: cmake 'out-of-source' build"
754cleanup
755MBEDTLS_ROOT_DIR="$PWD"
756mkdir "$OUT_OF_SOURCE_DIR"
757cd "$OUT_OF_SOURCE_DIR"
758cmake "$MBEDTLS_ROOT_DIR"
759make
760
761msg "test: cmake 'out-of-source' build"
762make test
Gilles Peskineaebcfbb2018-03-21 12:17:20 +0100763# Test an SSL option that requires an auxiliary script in test/scripts/.
764# Also ensure that there are no error messages such as
765# "No such file or directory", which would indicate that some required
766# file is missing (ssl-opt.sh tolerates the absence of some files so
767# may exit with status 0 but emit errors).
768if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
769if [ -s ssl-opt.err ]; then
770 cat ssl-opt.err >&2
771 record_status [ ! -s ssl-opt.err ]
772 rm ssl-opt.err
773fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100774cd "$MBEDTLS_ROOT_DIR"
775rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine00de2fd2018-03-21 12:16:57 +0100776unset MBEDTLS_ROOT_DIR
Simon Butcherd7f19022016-10-14 09:49:48 +0100777
Gilles Peskined7602c22017-12-21 15:59:21 +0100778
779
780################################################################
781#### Termination
782################################################################
783
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100784msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100785cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100786
787final_report