blob: fe1529d236b74f55e9a2685bb8bec2d4e907524a [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 Peskinea8bf9862017-12-11 00:01:40 +0100140 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200141
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200142 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000143 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200144 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
145 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200146
147 if [ -f "$CONFIG_BAK" ]; then
148 mv "$CONFIG_BAK" "$CONFIG_H"
149 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100150}
151
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100152# Executed on exit. May be redefined depending on command line options.
153final_report () {
154 :
155}
156
157fatal_signal () {
158 cleanup
159 final_report $1
160 trap - $1
161 kill -$1 $$
162}
163
164trap 'fatal_signal HUP' HUP
165trap 'fatal_signal INT' INT
166trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200167
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100168msg()
169{
170 echo ""
171 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100172 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000173 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100174 echo "******************************************************************"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100175 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100176}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100177
Simon Butcherd7f19022016-10-14 09:49:48 +0100178err_msg()
179{
180 echo "$1" >&2
181}
182
183check_tools()
184{
185 for TOOL in "$@"; do
186 if ! `hash "$TOOL" >/dev/null 2>&1`; then
187 err_msg "$TOOL not found!"
188 exit 1
189 fi
190 done
191}
192
193while [ $# -gt 0 ]; do
194 case "$1" in
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100195 --armcc) RUN_ARMCC=1;;
Gilles Peskine37c88db2018-03-21 11:44:52 +0100196 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
197 --armc6-bin-dir) shift;; # Ignore for compatibility with later Mbed TLS versions
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100198 --force|-f) FORCE=1;;
199 --gnutls-cli) shift; GNUTLS_CLI="$1";;
200 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
201 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
202 --gnutls-serv) shift; GNUTLS_SERV="$1";;
203 --help|-h) usage; exit;;
204 --keep-going|-k) KEEP_GOING=1;;
205 --memory|-m) MEMORY=1;;
206 --no-armcc) RUN_ARMCC=0;;
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100207 --no-force) FORCE=0;;
208 --no-keep-going) KEEP_GOING=0;;
209 --no-memory) MEMORY=0;;
Gilles Peskine32d92932018-03-21 10:14:05 +0100210 --no-yotta) :;; # No Yotta support anyway, so just ignore --no-yotta
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100211 --openssl) shift; OPENSSL="$1";;
212 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
213 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100214 --random-seed) unset SEED;;
215 --release-test|-r) SEED=1;;
Gilles Peskine7efa8cf2018-03-21 10:04:49 +0100216 --seed|-s) shift; SEED="$1";;
Gilles Peskinea6901f42017-12-10 23:43:39 +0100217 *)
218 echo >&2 "Unknown option: $1"
219 echo >&2 "Run $0 --help for usage."
220 exit 120
Simon Butcherd7f19022016-10-14 09:49:48 +0100221 ;;
222 esac
223 shift
224done
225
226if [ $FORCE -eq 1 ]; then
227 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
228 git checkout-index -f -q $CONFIG_H
229 cleanup
230else
231
232 if [ -d yotta/module ]; then
233 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
234 echo "You can either delete your work and retry, or force the test to overwrite the"
235 echo "test by rerunning the script as: $0 --force"
236 exit 1
237 fi
238
239 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
240 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
241 echo "You can either delete this directory manually, or force the test by rerunning"
242 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
243 exit 1
244 fi
245
246 if ! git diff-files --quiet include/mbedtls/config.h; then
Simon Butcherd7f19022016-10-14 09:49:48 +0100247 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
248 echo "You can either delete or preserve your work, or force the test by rerunning the"
249 echo "script as: $0 --force"
250 exit 1
251 fi
252fi
253
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100254build_status=0
255if [ $KEEP_GOING -eq 1 ]; then
256 failure_summary=
257 failure_count=0
258 start_red=
259 end_color=
260 if [ -t 1 ]; then
Gilles Peskine92deeaa2018-01-02 21:54:17 +0100261 case "${TERM:-}" in
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100262 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
263 start_red=$(printf '\033[31m')
264 end_color=$(printf '\033[0m')
265 ;;
266 esac
267 fi
268 record_status () {
269 if "$@"; then
270 last_status=0
271 else
272 last_status=$?
273 text="$current_section: $* -> $last_status"
274 failure_summary="$failure_summary
275$text"
276 failure_count=$((failure_count + 1))
277 echo "${start_red}^^^^$text^^^^${end_color}"
278 fi
279 }
280 make () {
281 case "$*" in
282 *test|*check)
283 if [ $build_status -eq 0 ]; then
284 record_status command make "$@"
285 else
286 echo "(skipped because the build failed)"
287 fi
288 ;;
289 *)
290 record_status command make "$@"
291 build_status=$last_status
292 ;;
293 esac
294 }
295 final_report () {
296 if [ $failure_count -gt 0 ]; then
297 echo
298 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
299 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
300 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
301 elif [ -z "${1-}" ]; then
302 echo "SUCCESS :)"
303 fi
304 if [ -n "${1-}" ]; then
305 echo "Killed by SIG$1."
306 fi
307 }
308else
309 record_status () {
310 "$@"
311 }
312fi
313if_build_succeeded () {
314 if [ $build_status -eq 0 ]; then
315 record_status "$@"
316 fi
317}
318
Simon Butcherd7f19022016-10-14 09:49:48 +0100319msg "info: $0 configuration"
320echo "MEMORY: $MEMORY"
321echo "FORCE: $FORCE"
322echo "SEED: ${SEED-"UNSET"}"
323echo "OPENSSL: $OPENSSL"
324echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
325echo "GNUTLS_CLI: $GNUTLS_CLI"
326echo "GNUTLS_SERV: $GNUTLS_SERV"
327echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
328echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Gilles Peskine37c88db2018-03-21 11:44:52 +0100329echo "ARMC5_BIN_DIR: ${ARMC5_BIN_DIR:-UNSET}"
330
331if [ -n "${ARMC5_BIN_DIR-}" ]; then
332 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
333 ARMC5_AR="$ARMC5_BIN_DIR/armar"
334else
335 ARMC5_CC=armcc
336 ARMC5_AR=armar
337fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100338
339# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
340# we just export the variables they require
341export OPENSSL_CMD="$OPENSSL"
342export GNUTLS_CLI="$GNUTLS_CLI"
343export GNUTLS_SERV="$GNUTLS_SERV"
344
345# Avoid passing --seed flag in every call to ssl-opt.sh
Gilles Peskine243bb4c2018-03-21 08:40:26 +0100346if [ -n "${SEED-}" ]; then
347 export SEED
348fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100349
350# Make sure the tools we need are available.
351check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100352 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskineb9344e32017-12-19 18:24:31 +0100353 "arm-none-eabi-gcc"
354if [ $RUN_ARMCC -ne 0 ]; then
Gilles Peskine37c88db2018-03-21 11:44:52 +0100355 check_tools "$ARMC5_CC" "$ARMC5_AR"
Gilles Peskineb9344e32017-12-19 18:24:31 +0100356fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100357
Gilles Peskined7602c22017-12-21 15:59:21 +0100358
359
360################################################################
361#### Basic checks
362################################################################
363
Simon Butcherd7f19022016-10-14 09:49:48 +0100364#
365# Test Suites to be executed
366#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200367# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100368# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200369# and/or are more likely to fail than others (eg I use Clang most of the
370# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200371# 2. Minimize total running time, by avoiding useless rebuilds
372#
373# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100374
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100375msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200376tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100377
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000378msg "test: freshness of generated source files" # < 1s
379tests/scripts/check-generated-files.sh
380
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200381msg "test: doxygen markup outside doxygen blocks" # < 1s
382tests/scripts/check-doxy-blocks.pl
383
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200384msg "test/build: declared and exported names" # < 3s
385cleanup
386tests/scripts/check-names.sh
387
Gilles Peskined7602c22017-12-21 15:59:21 +0100388
389
390################################################################
391#### Build and test many configurations and targets
392################################################################
393
Simon Butcher73156352015-11-04 00:36:30 +0000394# Yotta not supported in 2.1 branch
395#msg "build: create and build yotta module" # ~ 30s
396#cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100397#record_status tests/scripts/yotta-build.sh
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200398
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100399msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100400cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100401CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100402make
403
Simon Butcherd7f19022016-10-14 09:49:48 +0100404msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100405make test
406programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200407
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100408msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100409if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200410
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100411msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskinea1931692018-03-22 22:26:03 +0100412record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200413
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200414msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
415make
416
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100417msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100418if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200419
Hanno Becker797c0842017-10-19 15:49:21 +0100420msg "build: default config except MFL extension (ASan build)" # ~ 30s
421cleanup
422cp "$CONFIG_H" "$CONFIG_BAK"
423scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
424CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
425make
426
427msg "test: ssl-opt.sh, MFL-related tests"
428tests/ssl-opt.sh -f "Max fragment length"
429
Simon Butcher02b8d482016-03-15 20:39:52 +0000430msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
431cleanup
432cp "$CONFIG_H" "$CONFIG_BAK"
433scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
434CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
435make
436
Simon Butcherd7f19022016-10-14 09:49:48 +0100437msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher02b8d482016-03-15 20:39:52 +0000438make test
439programs/test/selftest
440
441msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100442if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
443if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher02b8d482016-03-15 20:39:52 +0000444
445msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100446if_build_succeeded tests/ssl-opt.sh
Simon Butcher02b8d482016-03-15 20:39:52 +0000447
Hanno Becker4f9973e2017-10-24 11:56:28 +0100448msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
449cleanup
450cp "$CONFIG_H" "$CONFIG_BAK"
451scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
452CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
453make
454
455msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
456make test
457
458msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100459if_build_succeeded tests/ssl-opt.sh
Hanno Becker4f9973e2017-10-24 11:56:28 +0100460
Hanno Becker92935922017-11-06 15:07:09 +0000461msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
462cleanup
463cp "$CONFIG_H" "$CONFIG_BAK"
464scripts/config.pl set MBEDTLS_RSA_NO_CRT
465CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
466make
467
468msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
469make test
470
471msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
472tests/ssl-opt.sh -f RSA
473
474msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
475tests/compat.sh -t RSA
476
477
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100478msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100479cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200480cp "$CONFIG_H" "$CONFIG_BAK"
481scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200482scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnardac92a482017-06-20 10:49:24 +0200483CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100484make
485
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100486msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200487make test
488
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100489msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100490if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200491
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100492msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100493if_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 +0200494
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200495msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100496cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100497record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100498
Manuel Pégourié-Gonnard57176e52017-06-06 11:36:16 +0200499msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
500cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100501record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard57176e52017-06-06 11:36:16 +0200502
Manuel Pégourié-Gonnardf2fd5462017-06-20 09:53:42 +0200503msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
504cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100505record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnardf2fd5462017-06-20 09:53:42 +0200506
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200507msg "test/build: key-exchanges (gcc)" # ~ 1 min
508cleanup
Gilles Peskinea1931692018-03-22 22:26:03 +0100509record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200510
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000511msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100512cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100513make CC=gcc CFLAGS='-Werror -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100514
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200515# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000516# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100517msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000518cleanup
519cp "$CONFIG_H" "$CONFIG_BAK"
520scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200521scripts/config.pl unset MBEDTLS_PLATFORM_C
522scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100523scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
524scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
525scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
526scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200527scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
528scripts/config.pl unset MBEDTLS_FS_IO
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100529make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000530
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100531# catch compile bugs in _uninit functions
532msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
533cleanup
534cp "$CONFIG_H" "$CONFIG_BAK"
535scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100536scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100537make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100538
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200539msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
540cleanup
541cp "$CONFIG_H" "$CONFIG_BAK"
542scripts/config.pl full
543scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100544make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200545
546msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
547cleanup
548cp "$CONFIG_H" "$CONFIG_BAK"
549scripts/config.pl full
550scripts/config.pl unset MBEDTLS_SSL_CLI_C
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100551make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200552
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200553msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200554cleanup
555cp "$CONFIG_H" "$CONFIG_BAK"
556scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200557scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
558scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100559make CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200560
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200561if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100562 msg "build/test: make shared" # ~ 40s
563 cleanup
564 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200565fi
566
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000567if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100568 msg "build: i386, make, gcc" # ~ 30s
569 cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100570 make CC=gcc CFLAGS='-Werror -m32'
Andres Amaya Garcia401441b2017-05-08 11:19:19 +0100571
572 msg "test: i386, make, gcc"
573 make test
574
575 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
576 cleanup
577 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
578
579 msg "test: 64-bit ILP32, make, gcc"
580 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000581fi # x86_64
582
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000583msg "build: arm-none-eabi-gcc, make" # ~ 10s
584cleanup
585cp "$CONFIG_H" "$CONFIG_BAK"
586scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200587scripts/config.pl unset MBEDTLS_NET_C
588scripts/config.pl unset MBEDTLS_TIMING_C
589scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcherd7f19022016-10-14 09:49:48 +0100590scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000591# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200592scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
593scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
594scripts/config.pl unset MBEDTLS_THREADING_C
595scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
596scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100597make 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 +0000598
Gilles Peskineb9344e32017-12-19 18:24:31 +0100599if [ $RUN_ARMCC -ne 0 ]; then
600 msg "build: armcc, make"
601 cleanup
602 cp "$CONFIG_H" "$CONFIG_BAK"
603 scripts/config.pl full
604 scripts/config.pl unset MBEDTLS_NET_C
605 scripts/config.pl unset MBEDTLS_TIMING_C
606 scripts/config.pl unset MBEDTLS_FS_IO
607 scripts/config.pl unset MBEDTLS_HAVE_TIME
608 scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
609 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
610 # following things are not in the default config
611 scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
612 scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
613 scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
614 scripts/config.pl unset MBEDTLS_THREADING_C
615 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
616 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine37c88db2018-03-21 11:44:52 +0100617 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= lib
Gilles Peskineb9344e32017-12-19 18:24:31 +0100618fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100619
Gilles Peskineb49351d2017-05-12 15:26:58 +0200620msg "build: allow SHA1 in certificates by default"
621cleanup
622cp "$CONFIG_H" "$CONFIG_BAK"
623scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100624make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskineb49351d2017-05-12 15:26:58 +0200625msg "test: allow SHA1 in certificates by default"
626make test
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100627if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskineb49351d2017-05-12 15:26:58 +0200628
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100629if which i686-w64-mingw32-gcc >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100630 msg "build: cross-mingw64, make" # ~ 30s
631 cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100632 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1
633 make WINDOWS_BUILD=1 clean
634 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1
635 make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100636fi
637
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000638# MemSan currently only available on Linux 64 bits
639if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000640
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100641 msg "build: MSan (clang)" # ~ 1 min 20s
642 cleanup
643 cp "$CONFIG_H" "$CONFIG_BAK"
644 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
645 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
646 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200647
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100648 msg "test: main suites (MSan)" # ~ 10s
649 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100650
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100651 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100652 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100653
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100654 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100655
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100656 if [ "$MEMORY" -gt 0 ]; then
657 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100658 if_build_succeeded tests/compat.sh
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100659 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100660
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000661else # no MemSan
662
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100663 msg "build: Release (clang)"
664 cleanup
665 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
666 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000667
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100668 msg "test: main suites valgrind (Release)"
669 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000670
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100671 # Optional part(s)
672 # Currently broken, programs don't seem to receive signals
673 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000674
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100675 if [ "$MEMORY" -gt 0 ]; then
676 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100677 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100678 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000679
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100680 if [ "$MEMORY" -gt 1 ]; then
681 msg "test: compat.sh --memcheck (Release)"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100682 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100683 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000684
685fi # MemSan
686
Simon Butcherd7f19022016-10-14 09:49:48 +0100687msg "build: cmake 'out-of-source' build"
688cleanup
689MBEDTLS_ROOT_DIR="$PWD"
690mkdir "$OUT_OF_SOURCE_DIR"
691cd "$OUT_OF_SOURCE_DIR"
692cmake "$MBEDTLS_ROOT_DIR"
693make
694
695msg "test: cmake 'out-of-source' build"
696make test
697cd "$MBEDTLS_ROOT_DIR"
698rm -rf "$OUT_OF_SOURCE_DIR"
699
Gilles Peskined7602c22017-12-21 15:59:21 +0100700
701
702################################################################
703#### Termination
704################################################################
705
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100706msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100707cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100708
709final_report