blob: c23f1612db30fa2da8770c0689d9dd1611a3d30a [file] [log] [blame]
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001#!/bin/sh
2
Simon Butcher123fb022016-10-15 22:18:05 +01003# all.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01004#
Simon Butcher123fb022016-10-15 22:18:05 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01006#
Simon Butcher123fb022016-10-15 22:18:05 +01007# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# To run all tests possible or available on the platform.
12#
13# Warning: the test is destructive. It includes various build modes and
14# configurations, and can and will arbitrarily change the current CMake
15# configuration. After this script has been run, the CMake cache will be lost
16# and CMake will no longer be initialised.
17#
18# The script assumes the presence of gcc and clang (recent enough for using
19# ASan with gcc and MemSan with clang, or valgrind) are available, as well as
20# cmake and a "good" find.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010021
Simon Butcher123fb022016-10-15 22:18:05 +010022# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010023set -eu
24
25if [ -d library -a -d include -a -d tests ]; then :; else
Simon Butcher123fb022016-10-15 22:18:05 +010026 err_msg "Must be run from mbed TLS root"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010027 exit 1
28fi
29
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020030CONFIG_H='include/polarssl/config.h'
31CONFIG_BAK="$CONFIG_H.bak"
32
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010033MEMORY=0
Simon Butcher123fb022016-10-15 22:18:05 +010034FORCE=0
Gilles Peskineded50da2017-12-11 00:01:40 +010035KEEP_GOING=0
Simon Butcher123fb022016-10-15 22:18:05 +010036RELEASE=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010037
Simon Butcher123fb022016-10-15 22:18:05 +010038# Default commands, can be overriden by the environment
39: ${OPENSSL:="openssl"}
40: ${OPENSSL_LEGACY:="$OPENSSL"}
41: ${GNUTLS_CLI:="gnutls-cli"}
42: ${GNUTLS_SERV:="gnutls-serv"}
43: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
44: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
45: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
46
47usage()
48{
Gilles Peskine4d4872a2017-12-10 23:43:39 +010049 cat <<EOF
50Usage: $0 [OPTION]...
51 -h|--help Print this help.
52
53General options:
54 -f|--force Force the tests to overwrite any modified files.
Gilles Peskineded50da2017-12-11 00:01:40 +010055 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine4d4872a2017-12-10 23:43:39 +010056 -m|--memory Additional optional memory tests.
57 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
58 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
59 -s|--seed Integer seed value to use for this test run.
60
61Tool path options:
62 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
63 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
64 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
65 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
66 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
67 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
68EOF
Simon Butcher123fb022016-10-15 22:18:05 +010069}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010070
71# remove built files as well as the cmake cache/config
72cleanup()
73{
Gilles Peskineded50da2017-12-11 00:01:40 +010074 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020075
Manuel Pégourié-Gonnard76c99a02014-12-11 10:33:43 +010076 find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard897a5952014-03-25 13:23:04 +010077 rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020078 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
79 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020080
81 if [ -f "$CONFIG_BAK" ]; then
82 mv "$CONFIG_BAK" "$CONFIG_H"
83 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010084}
85
Gilles Peskineded50da2017-12-11 00:01:40 +010086# Executed on exit. May be redefined depending on command line options.
87final_report () {
88 :
89}
90
91fatal_signal () {
92 cleanup
93 final_report $1
94 trap - $1
95 kill -$1 $$
96}
97
98trap 'fatal_signal HUP' HUP
99trap 'fatal_signal INT' INT
100trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200101
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100102msg()
103{
104 echo ""
105 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100106 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000107 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100108 echo "******************************************************************"
Gilles Peskineded50da2017-12-11 00:01:40 +0100109 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100110}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100111
Simon Butcher123fb022016-10-15 22:18:05 +0100112err_msg()
113{
114 echo "$1" >&2
115}
116
117check_tools()
118{
119 for TOOL in "$@"; do
120 if ! `hash "$TOOL" >/dev/null 2>&1`; then
121 err_msg "$TOOL not found!"
122 exit 1
123 fi
124 done
125}
126
127while [ $# -gt 0 ]; do
128 case "$1" in
Simon Butcher123fb022016-10-15 22:18:05 +0100129 --force|-f)
130 FORCE=1
131 ;;
Simon Butcher123fb022016-10-15 22:18:05 +0100132 --gnutls-cli)
133 shift
134 GNUTLS_CLI="$1"
135 ;;
Simon Butcher123fb022016-10-15 22:18:05 +0100136 --gnutls-legacy-cli)
137 shift
138 GNUTLS_LEGACY_CLI="$1"
139 ;;
140 --gnutls-legacy-serv)
141 shift
142 GNUTLS_LEGACY_SERV="$1"
143 ;;
Gilles Peskine4d4872a2017-12-10 23:43:39 +0100144 --gnutls-serv)
145 shift
146 GNUTLS_SERV="$1"
147 ;;
148 --help|-h)
Simon Butcher123fb022016-10-15 22:18:05 +0100149 usage
Gilles Peskine4d4872a2017-12-10 23:43:39 +0100150 exit
151 ;;
Gilles Peskineded50da2017-12-11 00:01:40 +0100152 --keep-going|-k)
153 KEEP_GOING=1
154 ;;
Gilles Peskine4d4872a2017-12-10 23:43:39 +0100155 --memory|-m)
156 MEMORY=1
157 ;;
158 --openssl)
159 shift
160 OPENSSL="$1"
161 ;;
162 --openssl-legacy)
163 shift
164 OPENSSL_LEGACY="$1"
165 ;;
166 --out-of-source-dir)
167 shift
168 OUT_OF_SOURCE_DIR="$1"
169 ;;
170 --release-test|-r)
171 RELEASE=1
172 ;;
173 --seed|-s)
174 shift
175 SEED="$1"
176 ;;
177 *)
178 echo >&2 "Unknown option: $1"
179 echo >&2 "Run $0 --help for usage."
180 exit 120
Simon Butcher123fb022016-10-15 22:18:05 +0100181 ;;
182 esac
183 shift
184done
185
186if [ $FORCE -eq 1 ]; then
187 git checkout-index -f -q $CONFIG_H
188 cleanup
189else
190
191 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
192 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
193 echo "You can either delete this directory manually, or force the test by rerunning"
194 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
195 exit 1
196 fi
197
198 if ! git diff-files --quiet include/polarssl/config.h; then
Simon Butcher123fb022016-10-15 22:18:05 +0100199 err_msg "Warning - the configuration file 'include/polarssl/config.h' has been edited. "
200 echo "You can either delete or preserve your work, or force the test by rerunning the"
201 echo "script as: $0 --force"
202 exit 1
203 fi
204fi
205
Gilles Peskineded50da2017-12-11 00:01:40 +0100206build_status=0
207if [ $KEEP_GOING -eq 1 ]; then
208 failure_summary=
209 failure_count=0
210 start_red=
211 end_color=
212 if [ -t 1 ]; then
213 case "$TERM" in
214 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
215 start_red=$(printf '\033[31m')
216 end_color=$(printf '\033[0m')
217 ;;
218 esac
219 fi
220 record_status () {
221 if "$@"; then
222 last_status=0
223 else
224 last_status=$?
225 text="$current_section: $* -> $last_status"
226 failure_summary="$failure_summary
227$text"
228 failure_count=$((failure_count + 1))
229 echo "${start_red}^^^^$text^^^^${end_color}"
230 fi
231 }
232 make () {
233 case "$*" in
234 *test|*check)
235 if [ $build_status -eq 0 ]; then
236 record_status command make "$@"
237 else
238 echo "(skipped because the build failed)"
239 fi
240 ;;
241 *)
242 record_status command make "$@"
243 build_status=$last_status
244 ;;
245 esac
246 }
247 final_report () {
248 if [ $failure_count -gt 0 ]; then
249 echo
250 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
251 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
252 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
253 elif [ -z "${1-}" ]; then
254 echo "SUCCESS :)"
255 fi
256 if [ -n "${1-}" ]; then
257 echo "Killed by SIG$1."
258 fi
259 }
260else
261 record_status () {
262 "$@"
263 }
264fi
265if_build_succeeded () {
266 if [ $build_status -eq 0 ]; then
267 record_status "$@"
268 fi
269}
270
Simon Butcher123fb022016-10-15 22:18:05 +0100271if [ $RELEASE -eq 1 ]; then
272 # Fix the seed value to 1 to ensure that the tests are deterministic.
273 SEED=1
274fi
275
276msg "info: $0 configuration"
277echo "MEMORY: $MEMORY"
278echo "FORCE: $FORCE"
279echo "SEED: ${SEED-"UNSET"}"
280echo "OPENSSL: $OPENSSL"
281echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
282echo "GNUTLS_CLI: $GNUTLS_CLI"
283echo "GNUTLS_SERV: $GNUTLS_SERV"
284echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
285echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
286
287# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
288# we just export the variables they require
289export OPENSSL_CMD="$OPENSSL"
290export GNUTLS_CLI="$GNUTLS_CLI"
291export GNUTLS_SERV="$GNUTLS_SERV"
292
293# Avoid passing --seed flag in every call to ssl-opt.sh
294[ ! -z ${SEED+set} ] && export SEED
295
296# Make sure the tools we need are available.
297check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100298 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
299 "arm-none-eabi-gcc" "armcc"
Simon Butcher123fb022016-10-15 22:18:05 +0100300
301#
302# Test Suites to be executed
303#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200304# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100305# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200306# and/or are more likely to fail than others (eg I use Clang most of the
307# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200308# 2. Minimize total running time, by avoiding useless rebuilds
309#
310# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100311
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100312msg "test: recursion.pl" # < 1s
313scripts/recursion.pl library/*.c
314
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000315msg "test: freshness of generated source files" # < 1s
316tests/scripts/check-generated-files.sh
317
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100318msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100319cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100320CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100321make
322
Simon Butcher123fb022016-10-15 22:18:05 +0100323msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100324make test
325programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200326
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100327msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100328if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200329
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100330msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskineded50da2017-12-11 00:01:40 +0100331if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200332
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200333msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
334make
335
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100336msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100337if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200338
Janos Follath4dfecab2016-03-14 13:40:43 +0000339msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
340cleanup
341cp "$CONFIG_H" "$CONFIG_BAK"
342scripts/config.pl set POLARSSL_SSL_PROTO_SSL3
343CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
344make
345
Simon Butcher123fb022016-10-15 22:18:05 +0100346msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Janos Follath4dfecab2016-03-14 13:40:43 +0000347make test
348programs/test/selftest
349
350msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100351if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2'
352if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Janos Follath4dfecab2016-03-14 13:40:43 +0000353
354msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100355if_build_succeeded tests/ssl-opt.sh
Janos Follath4dfecab2016-03-14 13:40:43 +0000356
Hanno Beckerbe812f62017-10-25 09:49:13 +0100357msg "build: Default + POLARSSL_SSL_DISABLE_RENEGOTIATION (ASan build)" # ~ 6 min
358cleanup
359cp "$CONFIG_H" "$CONFIG_BAK"
360scripts/config.pl set POLARSSL_SSL_DISABLE_RENEGOTIATION
361CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
362make
363
364msg "test: POLARSSL_SSL_DISABLE_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
365make test
366
367msg "test: POLARSSL_SSL_DISABLE_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100368if_build_succeeded tests/ssl-opt.sh
Hanno Beckerbe812f62017-10-25 09:49:13 +0100369
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100370msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100371cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200372cp "$CONFIG_H" "$CONFIG_BAK"
373scripts/config.pl full
374scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard4d9e36a2015-09-02 10:10:32 +0200375scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
376scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100377CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100378make
379
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100380msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200381make test
382
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100383msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskineded50da2017-12-11 00:01:40 +0100384if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200385
Simon Butcher123fb022016-10-15 22:18:05 +0100386msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100387if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|3DES-EDE-CBC\|DES-CBC3'
Simon Butcher123fb022016-10-15 22:18:05 +0100388
389msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100390cleanup
391cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskineded50da2017-12-11 00:01:40 +0100392if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100393
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000394msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100395cleanup
Gilles Peskineded50da2017-12-11 00:01:40 +0100396make CC=gcc CFLAGS='-Werror -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100397
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000398# this is meant to cath missing #define polarssl_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000399# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100400msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000401cleanup
402cp "$CONFIG_H" "$CONFIG_BAK"
403scripts/config.pl full
404scripts/config.pl unset POLARSSL_PLATFORM_C
Manuel Pégourié-Gonnard6ca40762015-02-13 15:57:35 +0000405scripts/config.pl unset POLARSSL_PLATFORM_MEMORY
Manuel Pégourié-Gonnard721e6bb2015-06-03 13:38:20 +0100406scripts/config.pl unset POLARSSL_PLATFORM_PRINTF_ALT
407scripts/config.pl unset POLARSSL_PLATFORM_FPRINTF_ALT
408scripts/config.pl unset POLARSSL_PLATFORM_SNPRINTF_ALT
409scripts/config.pl unset POLARSSL_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000410scripts/config.pl unset POLARSSL_MEMORY_C
411scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000412scripts/config.pl unset POLARSSL_FS_IO
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200413scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
414scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Gilles Peskineded50da2017-12-11 00:01:40 +0100415make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000416
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100417# catch compile bugs in _uninit functions
418msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
419cleanup
420cp "$CONFIG_H" "$CONFIG_BAK"
421scripts/config.pl full
422scripts/config.pl set POLARSSL_PLATFORM_NO_STD_FUNCTIONS
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200423scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
424scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Gilles Peskineded50da2017-12-11 00:01:40 +0100425make CC=gcc CFLAGS='-Werror -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100426
Simon Butcher123fb022016-10-15 22:18:05 +0100427msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
428cleanup
429cp "$CONFIG_H" "$CONFIG_BAK"
430scripts/config.pl full
431scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
432scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
433scripts/config.pl unset POLARSSL_SSL_SRV_C
Gilles Peskineded50da2017-12-11 00:01:40 +0100434make CC=gcc CFLAGS='-Werror -O0'
Simon Butcher123fb022016-10-15 22:18:05 +0100435
436msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
437cleanup
438cp "$CONFIG_H" "$CONFIG_BAK"
439scripts/config.pl full
440scripts/config.pl unset POLARSSL_SSL_CLI_C
441scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
442scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Gilles Peskineded50da2017-12-11 00:01:40 +0100443make CC=gcc CFLAGS='-Werror -O0'
Simon Butcher123fb022016-10-15 22:18:05 +0100444
Manuel Pégourié-Gonnard1b1254f2015-08-10 11:56:06 +0200445if uname -a | grep -F Linux >/dev/null; then
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100446 msg "build/test: make shared" # ~ 40s
447 cleanup
448 make SHARED=1 all check
Manuel Pégourié-Gonnard1b1254f2015-08-10 11:56:06 +0200449fi
450
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000451if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100452 msg "build: i386, make, gcc" # ~ 30s
453 cleanup
Gilles Peskineded50da2017-12-11 00:01:40 +0100454 make CC=gcc CFLAGS='-Werror -m32'
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000455fi # x86_64
456
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000457msg "build: arm-none-eabi-gcc, make" # ~ 10s
458cleanup
459cp "$CONFIG_H" "$CONFIG_BAK"
460scripts/config.pl full
461scripts/config.pl unset POLARSSL_NET_C
462scripts/config.pl unset POLARSSL_TIMING_C
463scripts/config.pl unset POLARSSL_FS_IO
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200464scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
465scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Simon Butcher123fb022016-10-15 22:18:05 +0100466scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000467# following things are not in the default config
468scripts/config.pl unset POLARSSL_HAVEGE_C # depends on timing.c
469scripts/config.pl unset POLARSSL_THREADING_PTHREAD
470scripts/config.pl unset POLARSSL_THREADING_C
471scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # execinfo.h
472scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineded50da2017-12-11 00:01:40 +0100473make 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 +0000474
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100475msg "build: armcc, make"
476cleanup
477cp "$CONFIG_H" "$CONFIG_BAK"
478scripts/config.pl full
479scripts/config.pl unset POLARSSL_NET_C
480scripts/config.pl unset POLARSSL_TIMING_C
481scripts/config.pl unset POLARSSL_FS_IO
482scripts/config.pl unset POLARSSL_HAVE_TIME
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200483scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
484scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Simon Butcher123fb022016-10-15 22:18:05 +0100485scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100486# following things are not in the default config
Manuel Pégourié-Gonnardf1002f82015-03-25 16:44:26 +0100487scripts/config.pl unset POLARSSL_DEPRECATED_WARNING
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100488scripts/config.pl unset POLARSSL_HAVEGE_C # depends on timing.c
489scripts/config.pl unset POLARSSL_THREADING_PTHREAD
490scripts/config.pl unset POLARSSL_THREADING_C
491scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # execinfo.h
492scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineded50da2017-12-11 00:01:40 +0100493make CC=armcc AR=armar WARNING_CFLAGS= lib
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100494
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100495if which i686-w64-mingw32-gcc >/dev/null; then
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100496 msg "build: cross-mingw64, make" # ~ 30s
497 cleanup
Gilles Peskineded50da2017-12-11 00:01:40 +0100498 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1
499 make WINDOWS_BUILD=1 clean
500 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1
501 make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100502fi
503
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000504# MemSan currently only available on Linux 64 bits
505if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000506
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100507 msg "build: MSan (clang)" # ~ 1 min 20s
508 cleanup
509 cp "$CONFIG_H" "$CONFIG_BAK"
510 scripts/config.pl unset POLARSSL_AESNI_C # memsan doesn't grok asm
511 scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY # memsan vs getrandom()
512 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
513 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200514
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100515 msg "test: main suites (MSan)" # ~ 10s
516 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100517
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100518 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskineded50da2017-12-11 00:01:40 +0100519 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100520
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100521 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100522
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100523 if [ "$MEMORY" -gt 0 ]; then
524 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskineded50da2017-12-11 00:01:40 +0100525 if_build_succeeded tests/compat.sh
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100526 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100527
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000528else # no MemSan
529
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100530 msg "build: Release (clang)"
531 cleanup
532 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
533 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000534
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100535 msg "test: main suites valgrind (Release)"
536 make test
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000537
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100538 # Optional part(s)
539 # Currently broken, programs don't seem to receive signals
540 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000541
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100542 if [ "$MEMORY" -gt 0 ]; then
543 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskineded50da2017-12-11 00:01:40 +0100544 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100545 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000546
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100547 if [ "$MEMORY" -gt 1 ]; then
548 msg "test: compat.sh --memcheck (Release)"
Gilles Peskineded50da2017-12-11 00:01:40 +0100549 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100550 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000551
552fi # MemSan
553
Simon Butcher123fb022016-10-15 22:18:05 +0100554msg "build: cmake 'out-of-source' build"
555cleanup
556MBEDTLS_ROOT_DIR="$PWD"
557mkdir "$OUT_OF_SOURCE_DIR"
558cd "$OUT_OF_SOURCE_DIR"
559cmake "$MBEDTLS_ROOT_DIR"
560make
561
562msg "test: cmake 'out-of-source' build"
563make test
564cd "$MBEDTLS_ROOT_DIR"
565rm -rf "$OUT_OF_SOURCE_DIR"
566
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100567msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100568cleanup
569
Gilles Peskineded50da2017-12-11 00:01:40 +0100570final_report