blob: ffef9ed3cbd6dd84b6aeea293851dc96c1a01062 [file] [log] [blame]
Andres AG31f9b5b2016-10-04 17:14:38 +01001#! /usr/bin/env sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002
Simon Butcher3ea7f522016-03-07 23:22:10 +00003# all.sh
4#
SimonB2e23c822016-04-16 21:54:39 +01005# This file is part of mbed TLS (https://tls.mbed.org)
6#
Gilles Peskine192c72f2017-12-21 15:59:21 +01007# Copyright (c) 2014-2017, ARM Limited, All Rights Reserved
8
9
10
11################################################################
12#### Documentation
13################################################################
14
Simon Butcher3ea7f522016-03-07 23:22:10 +000015# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010016# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000017#
SimonB2e23c822016-04-16 21:54:39 +010018# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010019#
Gilles Peskine192c72f2017-12-21 15:59:21 +010020# Notes for users
21# ---------------
22#
SimonB2e23c822016-04-16 21:54:39 +010023# Warning: the test is destructive. It includes various build modes and
24# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010025# configuration. The following files must be committed into git:
26# * include/mbedtls/config.h
27# * Makefile, library/Makefile, programs/Makefile, tests/Makefile
28# After running this script, the CMake cache will be lost and CMake
29# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010030#
Gilles Peskine192c72f2017-12-21 15:59:21 +010031# The script assumes the presence of a number of tools:
32# * Basic Unix tools (Windows users note: a Unix-style find must be before
33# the Windows find in the PATH)
34# * Perl
35# * GNU Make
36# * CMake
37# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
38# * arm-gcc and mingw-gcc
39# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
40# * Yotta build dependencies, unless invoked with --no-yotta
41# * OpenSSL and GnuTLS command line tools, recent enough for the
42# interoperability tests. If they don't support SSLv3 then a legacy
43# version of these tools must be present as well (search for LEGACY
44# below).
45# See the invocation of check_tools below for details.
46#
47# This script must be invoked from the toplevel directory of a git
48# working copy of Mbed TLS.
49#
50# Note that the output is not saved. You may want to run
51# script -c tests/scripts/all.sh
52# or
53# tests/scripts/all.sh >all.log 2>&1
54#
55# Notes for maintainers
56# ---------------------
57#
58# The tests are roughly in order from fastest to slowest. This doesn't
59# have to be exact, but in general you should add slower tests towards
60# the end and fast checks near the beginning.
61#
62# Sanity checks have the following form:
63# 1. msg "short description of what is about to be done"
64# 2. run sanity check (failure stops the script)
65#
66# Build or build-and-test steps have the following form:
67# 1. msg "short description of what is about to be done"
68# 2. cleanup
69# 3. preparation (config.pl, cmake, ...) (failure stops the script)
70# 4. make
71# 5. Run tests if relevant. All tests must be prefixed with
72# if_build_successful for the sake of --keep-going.
73
74
75
76################################################################
77#### Initialization and command line parsing
78################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010079
SimonB2e23c822016-04-16 21:54:39 +010080# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010081set -eu
82
Andres AG38495a32016-07-12 16:54:33 +010083if [ "$( uname )" != "Linux" ]; then
84 echo "This script only works in Linux" >&2
85 exit 1
86elif [ -d library -a -d include -a -d tests ]; then :; else
87 echo "Must be run from mbed TLS root" >&2
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088 exit 1
89fi
90
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000091CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020092CONFIG_BAK="$CONFIG_H.bak"
93
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010094MEMORY=0
SimonB2e23c822016-04-16 21:54:39 +010095FORCE=0
Gilles Peskine7c652162017-12-11 00:01:40 +010096KEEP_GOING=0
Andres AG7770ea82016-10-10 15:46:20 +010097RELEASE=0
Gilles Peskinebca6ab92017-12-19 18:24:31 +010098RUN_ARMCC=1
Gilles Peskineda519252017-11-30 13:22:04 +010099YOTTA=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100100
Andres AGd9eba4b2016-08-26 14:42:14 +0100101# Default commands, can be overriden by the environment
102: ${OPENSSL:="openssl"}
103: ${OPENSSL_LEGACY:="$OPENSSL"}
104: ${GNUTLS_CLI:="gnutls-cli"}
105: ${GNUTLS_SERV:="gnutls-serv"}
106: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
107: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +0100108: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +0100109: ${ARMC5_BIN_DIR:=/usr/bin}
110: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +0100111
Andres AG38495a32016-07-12 16:54:33 +0100112# if MAKEFLAGS is not set add the -j option to speed up invocations of make
113if [ -n "${MAKEFLAGS+set}" ]; then
114 export MAKEFLAGS="-j"
115fi
116
Simon Butcher41eeccf2016-09-07 00:07:09 +0100117usage()
SimonB2e23c822016-04-16 21:54:39 +0100118{
Gilles Peskine709346a2017-12-10 23:43:39 +0100119 cat <<EOF
120Usage: $0 [OPTION]...
121 -h|--help Print this help.
122
123General options:
124 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100125 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100126 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100127 --armcc Run ARM Compiler builds (on by default).
128 --no-armcc Skip ARM Compiler builds.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100129 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +0100130 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
131 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
132 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100133 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100134
135Tool path options:
136 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
137 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
138 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
139 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
140 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
141 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
142 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
143 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
144EOF
SimonB2e23c822016-04-16 21:54:39 +0100145}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100146
147# remove built files as well as the cmake cache/config
148cleanup()
149{
Gilles Peskine7c652162017-12-11 00:01:40 +0100150 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200151
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200152 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000153 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200154 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
155 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200156
157 if [ -f "$CONFIG_BAK" ]; then
158 mv "$CONFIG_BAK" "$CONFIG_H"
159 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100160}
161
Gilles Peskine7c652162017-12-11 00:01:40 +0100162# Executed on exit. May be redefined depending on command line options.
163final_report () {
164 :
165}
166
167fatal_signal () {
168 cleanup
169 final_report $1
170 trap - $1
171 kill -$1 $$
172}
173
174trap 'fatal_signal HUP' HUP
175trap 'fatal_signal INT' INT
176trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200177
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100178msg()
179{
180 echo ""
181 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100182 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000183 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100184 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100185 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100186}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100187
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100188if [ $RUN_ARMCC -ne 0 ]; then
189 armc6_build_test()
190 {
191 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100192
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100193 msg "build: ARM Compiler 6 ($FLAGS), make"
194 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
195 WARNING_CFLAGS='-xc -std=c99' make lib
196 make clean
197 }
198fi
Andres AGa5cd9732016-10-17 15:23:10 +0100199
Andres AGd9eba4b2016-08-26 14:42:14 +0100200err_msg()
201{
202 echo "$1" >&2
203}
204
205check_tools()
206{
207 for TOOL in "$@"; do
208 if ! `hash "$TOOL" >/dev/null 2>&1`; then
209 err_msg "$TOOL not found!"
210 exit 1
211 fi
212 done
213}
214
SimonB2e23c822016-04-16 21:54:39 +0100215while [ $# -gt 0 ]; do
216 case "$1" in
Gilles Peskine8a244c92018-03-21 08:39:32 +0100217 --armcc) RUN_ARMCC=1;;
218 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
219 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
220 --force|-f) FORCE=1;;
221 --gnutls-cli) shift; GNUTLS_CLI="$1";;
222 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
223 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
224 --gnutls-serv) shift; GNUTLS_SERV="$1";;
225 --help|-h) usage; exit;;
226 --keep-going|-k) KEEP_GOING=1;;
227 --memory|-m) MEMORY=1;;
228 --no-armcc) RUN_ARMCC=0;;
229 --no-yotta) YOTTA=0;;
230 --openssl) shift; OPENSSL="$1";;
231 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
232 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
233 --release-test|-r) RELEASE=1;;
234 --seed|-s) shift; SEED="$1";;
235 --yotta) YOTTA=1;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100236 *)
237 echo >&2 "Unknown option: $1"
238 echo >&2 "Run $0 --help for usage."
239 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100240 ;;
241 esac
242 shift
243done
244
245if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100246 if [ $YOTTA -eq 1 ]; then
247 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
248 fi
SimonB2e23c822016-04-16 21:54:39 +0100249 git checkout-index -f -q $CONFIG_H
250 cleanup
251else
252
Gilles Peskine2a22a802017-12-21 15:19:00 +0100253 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100254 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100255 echo "You can either delete your work and retry, or force the test to overwrite the"
256 echo "test by rerunning the script as: $0 --force"
257 exit 1
258 fi
259
Andres AGdc192212016-08-31 17:33:13 +0100260 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
261 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
262 echo "You can either delete this directory manually, or force the test by rerunning"
263 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
264 exit 1
265 fi
266
SimonB2e23c822016-04-16 21:54:39 +0100267 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100268 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100269 echo "You can either delete or preserve your work, or force the test by rerunning the"
270 echo "script as: $0 --force"
271 exit 1
272 fi
273fi
274
Gilles Peskine7c652162017-12-11 00:01:40 +0100275build_status=0
276if [ $KEEP_GOING -eq 1 ]; then
277 failure_summary=
278 failure_count=0
279 start_red=
280 end_color=
281 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100282 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100283 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
284 start_red=$(printf '\033[31m')
285 end_color=$(printf '\033[0m')
286 ;;
287 esac
288 fi
289 record_status () {
290 if "$@"; then
291 last_status=0
292 else
293 last_status=$?
294 text="$current_section: $* -> $last_status"
295 failure_summary="$failure_summary
296$text"
297 failure_count=$((failure_count + 1))
298 echo "${start_red}^^^^$text^^^^${end_color}"
299 fi
300 }
301 make () {
302 case "$*" in
303 *test|*check)
304 if [ $build_status -eq 0 ]; then
305 record_status command make "$@"
306 else
307 echo "(skipped because the build failed)"
308 fi
309 ;;
310 *)
311 record_status command make "$@"
312 build_status=$last_status
313 ;;
314 esac
315 }
316 final_report () {
317 if [ $failure_count -gt 0 ]; then
318 echo
319 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
320 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
321 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
322 elif [ -z "${1-}" ]; then
323 echo "SUCCESS :)"
324 fi
325 if [ -n "${1-}" ]; then
326 echo "Killed by SIG$1."
327 fi
328 }
329else
330 record_status () {
331 "$@"
332 }
333fi
334if_build_succeeded () {
335 if [ $build_status -eq 0 ]; then
336 record_status "$@"
337 fi
338}
339
Andres AG7770ea82016-10-10 15:46:20 +0100340if [ $RELEASE -eq 1 ]; then
341 # Fix the seed value to 1 to ensure that the tests are deterministic.
342 SEED=1
343fi
344
Andres AGd9eba4b2016-08-26 14:42:14 +0100345msg "info: $0 configuration"
346echo "MEMORY: $MEMORY"
347echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100348echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100349echo "OPENSSL: $OPENSSL"
350echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
351echo "GNUTLS_CLI: $GNUTLS_CLI"
352echo "GNUTLS_SERV: $GNUTLS_SERV"
353echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
354echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100355echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
356echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
357
358ARMC5_CC="$ARMC5_BIN_DIR/armcc"
359ARMC5_AR="$ARMC5_BIN_DIR/armar"
360ARMC6_CC="$ARMC6_BIN_DIR/armclang"
361ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100362
Andres AGb2fdd042016-09-22 14:17:46 +0100363# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
364# we just export the variables they require
365export OPENSSL_CMD="$OPENSSL"
366export GNUTLS_CLI="$GNUTLS_CLI"
367export GNUTLS_SERV="$GNUTLS_SERV"
368
Andres AG7770ea82016-10-10 15:46:20 +0100369# Avoid passing --seed flag in every call to ssl-opt.sh
370[ ! -z ${SEED+set} ] && export SEED
371
Andres AGd9eba4b2016-08-26 14:42:14 +0100372# Make sure the tools we need are available.
373check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100374 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100375 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
376if [ $RUN_ARMCC -ne 0 ]; then
377 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
378fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100379
Gilles Peskine192c72f2017-12-21 15:59:21 +0100380
381
382################################################################
383#### Basic checks
384################################################################
SimonB2e23c822016-04-16 21:54:39 +0100385
386#
387# Test Suites to be executed
388#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200389# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100390# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200391# and/or are more likely to fail than others (eg I use Clang most of the
392# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200393# 2. Minimize total running time, by avoiding useless rebuilds
394#
395# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100396
Janos Follathb72c6782016-07-19 14:54:17 +0100397msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100398OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
399 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100400 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
Gilles Peskine26232962018-03-21 08:35:07 +0100401 ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100402
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100403msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200404tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100405
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000406msg "test: freshness of generated source files" # < 1s
407tests/scripts/check-generated-files.sh
408
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200409msg "test: doxygen markup outside doxygen blocks" # < 1s
410tests/scripts/check-doxy-blocks.pl
411
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200412msg "test/build: declared and exported names" # < 3s
413cleanup
414tests/scripts/check-names.sh
415
Andres AGd9eba4b2016-08-26 14:42:14 +0100416msg "test: doxygen warnings" # ~ 3s
417cleanup
418tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100419
Gilles Peskine192c72f2017-12-21 15:59:21 +0100420
421
422################################################################
423#### Build and test many configurations and targets
424################################################################
425
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100426if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
427 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
428 # path, and uses whatever version of armcc it finds there.
Gilles Peskineda519252017-11-30 13:22:04 +0100429 msg "build: create and build yotta module" # ~ 30s
430 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100431 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100432fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200433
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100434msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100435cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100436CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100437make
438
Simon Butcher8e3afc72016-09-15 17:13:08 +0100439msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100440make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200441
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100442msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100443if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200444
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100445msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100446if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200447
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200448msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
449make
450
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100451msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100452if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200453
Simon Butcher3ea7f522016-03-07 23:22:10 +0000454msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
455cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000456cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000457scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
458CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
459make
460
Simon Butcher8e3afc72016-09-15 17:13:08 +0100461msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000462make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000463
464msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100465if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
466if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000467
468msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100469if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000470
Hanno Becker134c2ab2017-10-12 15:29:50 +0100471msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
472cleanup
473cp "$CONFIG_H" "$CONFIG_BAK"
474scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
475CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
476make
477
478msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
479make test
480
481msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100482if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100483
Simon Butcherf95c1762016-11-10 17:25:58 +0000484msg "build: cmake, full config, clang, C99" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100485cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100486cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200487scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200488scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000489CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Gilles Peskine7c652162017-12-11 00:01:40 +0100490make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100491
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100492msg "test: main suites (full config)" # ~ 5s
Gilles Peskine7c652162017-12-11 00:01:40 +0100493make CFLAGS='-Werror -Wall -Wextra' test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200494
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100495msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100496if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200497
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100498msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100499if_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 +0200500
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200501msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100502cleanup
503cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskine7c652162017-12-11 00:01:40 +0100504if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100505
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200506msg "test/build: key-exchanges (gcc)" # ~ 1 min
507cleanup
508cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine7c652162017-12-11 00:01:40 +0100509if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-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 Peskine7c652162017-12-11 00:01:40 +0100513make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100514
Simon Butcherf95c1762016-11-10 17:25:58 +0000515# Full configuration build, without platform support, file IO and net sockets.
516# This should catch missing mbedtls_printf definitions, and by disabling file
517# IO, it should catch missing '#include <stdio.h>'
518msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000519cleanup
520cp "$CONFIG_H" "$CONFIG_BAK"
521scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200522scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000523scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200524scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100525scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
526scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
527scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100528scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100529scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100530scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200531scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
532scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000533# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
534# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100535make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
536make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
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
Simon Butchereebf1b92016-06-27 01:42:39 +0100544scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100545make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100546
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200547msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
548cleanup
549cp "$CONFIG_H" "$CONFIG_BAK"
550scripts/config.pl full
551scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100552make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200553
554msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
555cleanup
556cp "$CONFIG_H" "$CONFIG_BAK"
557scripts/config.pl full
558scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000559make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200560
Simon Butcherf95c1762016-11-10 17:25:58 +0000561# Note, C99 compliance can also be tested with the sockets support disabled,
562# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100563msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200564cleanup
565cp "$CONFIG_H" "$CONFIG_BAK"
566scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200567scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
568scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100569make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200570
Hanno Becker5175ac62017-09-18 15:36:25 +0100571msg "build: default config except MFL extension (ASan build)" # ~ 30s
572cleanup
573cp "$CONFIG_H" "$CONFIG_BAK"
574scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
575CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
576make
577
578msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100579if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100580
Simon Butcherab5df402016-06-11 02:31:21 +0100581msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100582cleanup
583cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100584scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100585scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
586scripts/config.pl set MBEDTLS_ENTROPY_C
587scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
588scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
589scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100590CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100591make
592
Simon Butcher8e3afc72016-09-15 17:13:08 +0100593msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100594make test
Janos Follath06c54002016-06-09 13:57:40 +0100595
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200596if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100597 msg "build/test: make shared" # ~ 40s
598 cleanup
599 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200600fi
601
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000602if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100603 msg "build: i386, make, gcc" # ~ 30s
604 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100605 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garciadd29c2f2017-05-04 11:35:51 +0100606
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100607 msg "test: i386, make, gcc"
608 make test
609
610 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
611 cleanup
612 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
613
614 msg "test: 64-bit ILP32, make, gcc"
615 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000616fi # x86_64
617
Gilles Peskine14c3c062018-01-29 21:25:12 +0100618msg "build: gcc, force 32-bit bignum limbs"
619cleanup
620cp "$CONFIG_H" "$CONFIG_BAK"
621scripts/config.pl unset MBEDTLS_HAVE_ASM
622scripts/config.pl unset MBEDTLS_AESNI_C
623scripts/config.pl unset MBEDTLS_PADLOCK_C
624make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
625
626msg "test: gcc, force 32-bit bignum limbs"
627make test
628
629msg "build: gcc, force 64-bit bignum limbs"
630cleanup
631cp "$CONFIG_H" "$CONFIG_BAK"
632scripts/config.pl unset MBEDTLS_HAVE_ASM
633scripts/config.pl unset MBEDTLS_AESNI_C
634scripts/config.pl unset MBEDTLS_PADLOCK_C
635make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
636
637msg "test: gcc, force 64-bit bignum limbs"
638make test
639
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000640msg "build: arm-none-eabi-gcc, make" # ~ 10s
641cleanup
642cp "$CONFIG_H" "$CONFIG_BAK"
643scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200644scripts/config.pl unset MBEDTLS_NET_C
645scripts/config.pl unset MBEDTLS_TIMING_C
646scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100647scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000648scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000649# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200650scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
651scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
652scripts/config.pl unset MBEDTLS_THREADING_C
653scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
654scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100655make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000656
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200657msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
658cleanup
Simon Butcher51aaa992017-07-23 13:42:36 +0200659cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia6fb65862017-07-20 13:27:35 +0100660scripts/config.pl full
661scripts/config.pl unset MBEDTLS_NET_C
662scripts/config.pl unset MBEDTLS_TIMING_C
663scripts/config.pl unset MBEDTLS_FS_IO
664scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
665scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
666# following things are not in the default config
667scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
668scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
669scripts/config.pl unset MBEDTLS_THREADING_C
670scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
671scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200672scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100673make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200674echo "Checking that software 64-bit division is not required"
675! grep __aeabi_uldiv library/*.o
676
Andres AG87bb5772016-09-27 15:05:15 +0100677msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100678cleanup
679cp "$CONFIG_H" "$CONFIG_BAK"
680scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200681scripts/config.pl unset MBEDTLS_NET_C
682scripts/config.pl unset MBEDTLS_TIMING_C
683scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100684scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200685scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200686scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000687scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100688# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200689scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
690scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
691scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
692scripts/config.pl unset MBEDTLS_THREADING_C
693scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
694scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300695scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100696
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100697if [ $RUN_ARMCC -ne 0 ]; then
698 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
699 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100700
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100701 # ARM Compiler 6 - Target ARMv7-A
702 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200703
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100704 # ARM Compiler 6 - Target ARMv7-M
705 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher51aaa992017-07-23 13:42:36 +0200706
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100707 # ARM Compiler 6 - Target ARMv8-A - AArch32
708 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200709
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100710 # ARM Compiler 6 - Target ARMv8-M
711 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher51aaa992017-07-23 13:42:36 +0200712
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100713 # ARM Compiler 6 - Target ARMv8-A - AArch64
714 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
715fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100716
Gilles Peskine2a458da2017-05-12 15:26:58 +0200717msg "build: allow SHA1 in certificates by default"
718cleanup
719cp "$CONFIG_H" "$CONFIG_BAK"
720scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100721make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200722msg "test: allow SHA1 in certificates by default"
723make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100724if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200725
Hanno Beckerd485c312018-01-05 13:03:53 +0000726msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000727cleanup
728cp "$CONFIG_H" "$CONFIG_BAK"
729scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000730CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
731make
Hanno Beckere963efa2018-01-03 10:03:43 +0000732
733msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
734make test
735
Simon Butcher002bc622016-11-17 09:27:45 +0000736msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100737cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100738make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Simon Butcher91aef332016-11-17 09:20:50 +0000739
Simon Butcher002bc622016-11-17 09:27:45 +0000740# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100741make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
742make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000743
Simon Butcher002bc622016-11-17 09:27:45 +0000744msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100745make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
746make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests
747make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100748
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000749# MemSan currently only available on Linux 64 bits
750if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000751
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100752 msg "build: MSan (clang)" # ~ 1 min 20s
753 cleanup
754 cp "$CONFIG_H" "$CONFIG_BAK"
755 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
756 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
757 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200758
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100759 msg "test: main suites (MSan)" # ~ 10s
760 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100761
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100762 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100763 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100764
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100765 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100766
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100767 if [ "$MEMORY" -gt 0 ]; then
768 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100769 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100770 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100771
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000772else # no MemSan
773
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100774 msg "build: Release (clang)"
775 cleanup
776 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
777 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000778
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100779 msg "test: main suites valgrind (Release)"
780 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000781
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100782 # Optional part(s)
783 # Currently broken, programs don't seem to receive signals
784 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000785
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100786 if [ "$MEMORY" -gt 0 ]; then
787 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100788 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100789 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000790
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100791 if [ "$MEMORY" -gt 1 ]; then
792 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100793 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100794 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000795
796fi # MemSan
797
Andres AGdc192212016-08-31 17:33:13 +0100798msg "build: cmake 'out-of-source' build"
799cleanup
800MBEDTLS_ROOT_DIR="$PWD"
801mkdir "$OUT_OF_SOURCE_DIR"
802cd "$OUT_OF_SOURCE_DIR"
803cmake "$MBEDTLS_ROOT_DIR"
804make
805
806msg "test: cmake 'out-of-source' build"
807make test
808cd "$MBEDTLS_ROOT_DIR"
809rm -rf "$OUT_OF_SOURCE_DIR"
810
Gilles Peskine192c72f2017-12-21 15:59:21 +0100811
812
813################################################################
814#### Termination
815################################################################
816
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100817msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100818cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100819
820final_report