blob: 312ca82c4097e4b3c8a6957139a8bb1b3528ff32 [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
Simon Butcherd7f19022016-10-14 09:49:48 +010093RELEASE=0
Gilles Peskineb9344e32017-12-19 18:24:31 +010094RUN_ARMCC=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010095
Simon Butcherd7f19022016-10-14 09:49:48 +010096# Default commands, can be overriden by the environment
97: ${OPENSSL:="openssl"}
98: ${OPENSSL_LEGACY:="$OPENSSL"}
99: ${GNUTLS_CLI:="gnutls-cli"}
100: ${GNUTLS_SERV:="gnutls-serv"}
101: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
102: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
103: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
104
105usage()
106{
Gilles Peskinea6901f42017-12-10 23:43:39 +0100107 cat <<EOF
108Usage: $0 [OPTION]...
109 -h|--help Print this help.
110
111General options:
112 -f|--force Force the tests to overwrite any modified files.
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100113 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskinea6901f42017-12-10 23:43:39 +0100114 -m|--memory Additional optional memory tests.
Gilles Peskineb9344e32017-12-19 18:24:31 +0100115 --armcc Run ARM Compiler builds (on by default).
116 --no-armcc Skip ARM Compiler builds.
Gilles Peskinea6901f42017-12-10 23:43:39 +0100117 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
118 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
119 -s|--seed Integer seed value to use for this test run.
120
121Tool path options:
122 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
123 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
124 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
125 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
126 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
127 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
128EOF
Simon Butcherd7f19022016-10-14 09:49:48 +0100129}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100130
131# remove built files as well as the cmake cache/config
132cleanup()
133{
Gilles Peskine00de2fd2018-03-21 12:16:57 +0100134 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
135 cd "$MBEDTLS_ROOT_DIR"
136 fi
137
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100138 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200139
Gilles Peskine341ea252018-03-21 12:15:06 +0100140 # Remove CMake artefacts
141 find . -name .git -prune -o -name yotta -prune -o \
142 -iname CMakeFiles -exec rm -rf {} \+ -o \
143 \( -iname cmake_install.cmake -o \
144 -iname CTestTestfile.cmake -o \
145 -iname CMakeCache.txt \) -exec rm {} \+
146 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000147 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200148 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
149 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200150
151 if [ -f "$CONFIG_BAK" ]; then
152 mv "$CONFIG_BAK" "$CONFIG_H"
153 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100154}
155
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100156# Executed on exit. May be redefined depending on command line options.
157final_report () {
158 :
159}
160
161fatal_signal () {
162 cleanup
163 final_report $1
164 trap - $1
165 kill -$1 $$
166}
167
168trap 'fatal_signal HUP' HUP
169trap 'fatal_signal INT' INT
170trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200171
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100172msg()
173{
174 echo ""
175 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100176 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000177 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100178 echo "******************************************************************"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100179 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100180}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100181
Simon Butcherd7f19022016-10-14 09:49:48 +0100182err_msg()
183{
184 echo "$1" >&2
185}
186
187check_tools()
188{
189 for TOOL in "$@"; do
190 if ! `hash "$TOOL" >/dev/null 2>&1`; then
191 err_msg "$TOOL not found!"
192 exit 1
193 fi
194 done
195}
196
197while [ $# -gt 0 ]; do
198 case "$1" in
Gilles Peskineb9344e32017-12-19 18:24:31 +0100199 --armcc)
200 RUN_ARMCC=1
201 ;;
Simon Butcherd7f19022016-10-14 09:49:48 +0100202 --force|-f)
203 FORCE=1
204 ;;
Simon Butcherd7f19022016-10-14 09:49:48 +0100205 --gnutls-cli)
206 shift
207 GNUTLS_CLI="$1"
208 ;;
Simon Butcherd7f19022016-10-14 09:49:48 +0100209 --gnutls-legacy-cli)
210 shift
211 GNUTLS_LEGACY_CLI="$1"
212 ;;
213 --gnutls-legacy-serv)
214 shift
215 GNUTLS_LEGACY_SERV="$1"
216 ;;
Gilles Peskinea6901f42017-12-10 23:43:39 +0100217 --gnutls-serv)
218 shift
219 GNUTLS_SERV="$1"
220 ;;
221 --help|-h)
Simon Butcherd7f19022016-10-14 09:49:48 +0100222 usage
Gilles Peskinea6901f42017-12-10 23:43:39 +0100223 exit
224 ;;
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100225 --keep-going|-k)
226 KEEP_GOING=1
227 ;;
Gilles Peskinea6901f42017-12-10 23:43:39 +0100228 --memory|-m)
229 MEMORY=1
230 ;;
Gilles Peskineb9344e32017-12-19 18:24:31 +0100231 --no-armcc)
232 RUN_ARMCC=0
233 ;;
Gilles Peskinea6901f42017-12-10 23:43:39 +0100234 --openssl)
235 shift
236 OPENSSL="$1"
237 ;;
238 --openssl-legacy)
239 shift
240 OPENSSL_LEGACY="$1"
241 ;;
242 --out-of-source-dir)
243 shift
244 OUT_OF_SOURCE_DIR="$1"
245 ;;
246 --release-test|-r)
247 RELEASE=1
248 ;;
249 --seed|-s)
250 shift
251 SEED="$1"
252 ;;
253 *)
254 echo >&2 "Unknown option: $1"
255 echo >&2 "Run $0 --help for usage."
256 exit 120
Simon Butcherd7f19022016-10-14 09:49:48 +0100257 ;;
258 esac
259 shift
260done
261
262if [ $FORCE -eq 1 ]; then
263 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
264 git checkout-index -f -q $CONFIG_H
265 cleanup
266else
267
268 if [ -d yotta/module ]; then
269 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
270 echo "You can either delete your work and retry, or force the test to overwrite the"
271 echo "test by rerunning the script as: $0 --force"
272 exit 1
273 fi
274
275 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
276 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
277 echo "You can either delete this directory manually, or force the test by rerunning"
278 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
279 exit 1
280 fi
281
282 if ! git diff-files --quiet include/mbedtls/config.h; then
Simon Butcherd7f19022016-10-14 09:49:48 +0100283 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
284 echo "You can either delete or preserve your work, or force the test by rerunning the"
285 echo "script as: $0 --force"
286 exit 1
287 fi
288fi
289
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100290build_status=0
291if [ $KEEP_GOING -eq 1 ]; then
292 failure_summary=
293 failure_count=0
294 start_red=
295 end_color=
296 if [ -t 1 ]; then
Gilles Peskine92deeaa2018-01-02 21:54:17 +0100297 case "${TERM:-}" in
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100298 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
299 start_red=$(printf '\033[31m')
300 end_color=$(printf '\033[0m')
301 ;;
302 esac
303 fi
304 record_status () {
305 if "$@"; then
306 last_status=0
307 else
308 last_status=$?
309 text="$current_section: $* -> $last_status"
310 failure_summary="$failure_summary
311$text"
312 failure_count=$((failure_count + 1))
313 echo "${start_red}^^^^$text^^^^${end_color}"
314 fi
315 }
316 make () {
317 case "$*" in
318 *test|*check)
319 if [ $build_status -eq 0 ]; then
320 record_status command make "$@"
321 else
322 echo "(skipped because the build failed)"
323 fi
324 ;;
325 *)
326 record_status command make "$@"
327 build_status=$last_status
328 ;;
329 esac
330 }
331 final_report () {
332 if [ $failure_count -gt 0 ]; then
333 echo
334 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
335 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
336 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
337 elif [ -z "${1-}" ]; then
338 echo "SUCCESS :)"
339 fi
340 if [ -n "${1-}" ]; then
341 echo "Killed by SIG$1."
342 fi
343 }
344else
345 record_status () {
346 "$@"
347 }
348fi
349if_build_succeeded () {
350 if [ $build_status -eq 0 ]; then
351 record_status "$@"
352 fi
353}
354
Simon Butcherd7f19022016-10-14 09:49:48 +0100355if [ $RELEASE -eq 1 ]; then
356 # Fix the seed value to 1 to ensure that the tests are deterministic.
357 SEED=1
358fi
359
360msg "info: $0 configuration"
361echo "MEMORY: $MEMORY"
362echo "FORCE: $FORCE"
363echo "SEED: ${SEED-"UNSET"}"
364echo "OPENSSL: $OPENSSL"
365echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
366echo "GNUTLS_CLI: $GNUTLS_CLI"
367echo "GNUTLS_SERV: $GNUTLS_SERV"
368echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
369echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
370
371# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
372# we just export the variables they require
373export OPENSSL_CMD="$OPENSSL"
374export GNUTLS_CLI="$GNUTLS_CLI"
375export GNUTLS_SERV="$GNUTLS_SERV"
376
377# Avoid passing --seed flag in every call to ssl-opt.sh
378[ ! -z ${SEED+set} ] && export SEED
379
380# Make sure the tools we need are available.
381check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100382 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskineb9344e32017-12-19 18:24:31 +0100383 "arm-none-eabi-gcc"
384if [ $RUN_ARMCC -ne 0 ]; then
385 check_tools "armcc"
386fi
Simon Butcherd7f19022016-10-14 09:49:48 +0100387
Gilles Peskined7602c22017-12-21 15:59:21 +0100388
389
390################################################################
391#### Basic checks
392################################################################
393
Simon Butcherd7f19022016-10-14 09:49:48 +0100394#
395# Test Suites to be executed
396#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200397# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100398# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200399# and/or are more likely to fail than others (eg I use Clang most of the
400# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200401# 2. Minimize total running time, by avoiding useless rebuilds
402#
403# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100404
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100405msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200406tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100407
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000408msg "test: freshness of generated source files" # < 1s
409tests/scripts/check-generated-files.sh
410
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200411msg "test: doxygen markup outside doxygen blocks" # < 1s
412tests/scripts/check-doxy-blocks.pl
413
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200414msg "test/build: declared and exported names" # < 3s
415cleanup
416tests/scripts/check-names.sh
417
Gilles Peskined7602c22017-12-21 15:59:21 +0100418
419
420################################################################
421#### Build and test many configurations and targets
422################################################################
423
Simon Butcher73156352015-11-04 00:36:30 +0000424# Yotta not supported in 2.1 branch
425#msg "build: create and build yotta module" # ~ 30s
426#cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100427#record_status tests/scripts/yotta-build.sh
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200428
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100429msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100430cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100431CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100432make
433
Simon Butcherd7f19022016-10-14 09:49:48 +0100434msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100435make test
436programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200437
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100438msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100439if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200440
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100441msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100442if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200443
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200444msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
445make
446
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100447msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100448if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200449
Hanno Becker797c0842017-10-19 15:49:21 +0100450msg "build: default config except MFL extension (ASan build)" # ~ 30s
451cleanup
452cp "$CONFIG_H" "$CONFIG_BAK"
453scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
454CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
455make
456
457msg "test: ssl-opt.sh, MFL-related tests"
458tests/ssl-opt.sh -f "Max fragment length"
459
Simon Butcher02b8d482016-03-15 20:39:52 +0000460msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
461cleanup
462cp "$CONFIG_H" "$CONFIG_BAK"
463scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
464CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
465make
466
Simon Butcherd7f19022016-10-14 09:49:48 +0100467msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher02b8d482016-03-15 20:39:52 +0000468make test
469programs/test/selftest
470
471msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100472if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
473if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher02b8d482016-03-15 20:39:52 +0000474
475msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100476if_build_succeeded tests/ssl-opt.sh
Simon Butcher02b8d482016-03-15 20:39:52 +0000477
Hanno Becker4f9973e2017-10-24 11:56:28 +0100478msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
479cleanup
480cp "$CONFIG_H" "$CONFIG_BAK"
481scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
482CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
483make
484
485msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
486make test
487
488msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100489if_build_succeeded tests/ssl-opt.sh
Hanno Becker4f9973e2017-10-24 11:56:28 +0100490
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100491msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100492cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200493cp "$CONFIG_H" "$CONFIG_BAK"
494scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200495scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100496CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100497make
498
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100499msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200500make test
501
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100502msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100503if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200504
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100505msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100506if_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 +0200507
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200508msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100509cleanup
510cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100511if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100512
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200513msg "test/build: key-exchanges (gcc)" # ~ 1 min
514cleanup
515cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100516if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200517
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000518msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100519cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100520make CC=gcc CFLAGS='-Werror -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100521
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200522# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000523# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100524msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000525cleanup
526cp "$CONFIG_H" "$CONFIG_BAK"
527scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200528scripts/config.pl unset MBEDTLS_PLATFORM_C
529scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100530scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
531scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
532scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
533scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200534scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
535scripts/config.pl unset MBEDTLS_FS_IO
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100536make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000537
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100538# catch compile bugs in _uninit functions
539msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
540cleanup
541cp "$CONFIG_H" "$CONFIG_BAK"
542scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100543scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100544make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100545
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200546msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
547cleanup
548cp "$CONFIG_H" "$CONFIG_BAK"
549scripts/config.pl full
550scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100551make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200552
553msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
554cleanup
555cp "$CONFIG_H" "$CONFIG_BAK"
556scripts/config.pl full
557scripts/config.pl unset MBEDTLS_SSL_CLI_C
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100558make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200559
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200560msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200561cleanup
562cp "$CONFIG_H" "$CONFIG_BAK"
563scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200564scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
565scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100566make CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200567
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200568if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100569 msg "build/test: make shared" # ~ 40s
570 cleanup
571 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200572fi
573
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000574if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100575 msg "build: i386, make, gcc" # ~ 30s
576 cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100577 make CC=gcc CFLAGS='-Werror -m32'
Andres Amaya Garcia401441b2017-05-08 11:19:19 +0100578
579 msg "test: i386, make, gcc"
580 make test
581
582 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
583 cleanup
584 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
585
586 msg "test: 64-bit ILP32, make, gcc"
587 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000588fi # x86_64
589
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000590msg "build: arm-none-eabi-gcc, make" # ~ 10s
591cleanup
592cp "$CONFIG_H" "$CONFIG_BAK"
593scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200594scripts/config.pl unset MBEDTLS_NET_C
595scripts/config.pl unset MBEDTLS_TIMING_C
596scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcherd7f19022016-10-14 09:49:48 +0100597scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000598# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200599scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
600scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
601scripts/config.pl unset MBEDTLS_THREADING_C
602scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
603scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100604make 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 +0000605
Gilles Peskineb9344e32017-12-19 18:24:31 +0100606if [ $RUN_ARMCC -ne 0 ]; then
607 msg "build: armcc, make"
608 cleanup
609 cp "$CONFIG_H" "$CONFIG_BAK"
610 scripts/config.pl full
611 scripts/config.pl unset MBEDTLS_NET_C
612 scripts/config.pl unset MBEDTLS_TIMING_C
613 scripts/config.pl unset MBEDTLS_FS_IO
614 scripts/config.pl unset MBEDTLS_HAVE_TIME
615 scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
616 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
617 # following things are not in the default config
618 scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
619 scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
620 scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
621 scripts/config.pl unset MBEDTLS_THREADING_C
622 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
623 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
624 make CC=armcc AR=armar WARNING_CFLAGS= lib
625fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100626
Gilles Peskineb49351d2017-05-12 15:26:58 +0200627msg "build: allow SHA1 in certificates by default"
628cleanup
629cp "$CONFIG_H" "$CONFIG_BAK"
630scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100631make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskineb49351d2017-05-12 15:26:58 +0200632msg "test: allow SHA1 in certificates by default"
633make test
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100634if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskineb49351d2017-05-12 15:26:58 +0200635
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100636if which i686-w64-mingw32-gcc >/dev/null; then
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100637 msg "build: cross-mingw64, make" # ~ 30s
638 cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100639 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1
640 make WINDOWS_BUILD=1 clean
641 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1
642 make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100643fi
644
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000645# MemSan currently only available on Linux 64 bits
646if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000647
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100648 msg "build: MSan (clang)" # ~ 1 min 20s
649 cleanup
650 cp "$CONFIG_H" "$CONFIG_BAK"
651 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
652 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
653 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200654
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100655 msg "test: main suites (MSan)" # ~ 10s
656 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100657
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100658 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100659 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100660
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100661 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100662
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100663 if [ "$MEMORY" -gt 0 ]; then
664 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100665 if_build_succeeded tests/compat.sh
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100666 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100667
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000668else # no MemSan
669
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100670 msg "build: Release (clang)"
671 cleanup
672 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
673 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000674
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100675 msg "test: main suites valgrind (Release)"
676 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000677
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100678 # Optional part(s)
679 # Currently broken, programs don't seem to receive signals
680 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000681
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100682 if [ "$MEMORY" -gt 0 ]; then
683 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100684 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100685 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000686
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100687 if [ "$MEMORY" -gt 1 ]; then
688 msg "test: compat.sh --memcheck (Release)"
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100689 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine30dfbaf2017-12-10 23:22:20 +0100690 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000691
692fi # MemSan
693
Simon Butcherd7f19022016-10-14 09:49:48 +0100694msg "build: cmake 'out-of-source' build"
695cleanup
696MBEDTLS_ROOT_DIR="$PWD"
697mkdir "$OUT_OF_SOURCE_DIR"
698cd "$OUT_OF_SOURCE_DIR"
699cmake "$MBEDTLS_ROOT_DIR"
700make
701
702msg "test: cmake 'out-of-source' build"
703make test
704cd "$MBEDTLS_ROOT_DIR"
705rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine00de2fd2018-03-21 12:16:57 +0100706unset MBEDTLS_ROOT_DIR
Simon Butcherd7f19022016-10-14 09:49:48 +0100707
Gilles Peskined7602c22017-12-21 15:59:21 +0100708
709
710################################################################
711#### Termination
712################################################################
713
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100714msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100715cleanup
Gilles Peskinea8bf9862017-12-11 00:01:40 +0100716
717final_report