blob: 764fa2c2611abcfdd2487dedc234f137d2c7073b [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"}
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100104: ${OPENSSL_NEXT:="$OPENSSL"}
Andres AGd9eba4b2016-08-26 14:42:14 +0100105: ${GNUTLS_CLI:="gnutls-cli"}
106: ${GNUTLS_SERV:="gnutls-serv"}
107: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
108: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +0100109: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +0100110: ${ARMC5_BIN_DIR:=/usr/bin}
111: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +0100112
Andres AG38495a32016-07-12 16:54:33 +0100113# if MAKEFLAGS is not set add the -j option to speed up invocations of make
114if [ -n "${MAKEFLAGS+set}" ]; then
115 export MAKEFLAGS="-j"
116fi
117
Simon Butcher41eeccf2016-09-07 00:07:09 +0100118usage()
SimonB2e23c822016-04-16 21:54:39 +0100119{
Gilles Peskine709346a2017-12-10 23:43:39 +0100120 cat <<EOF
121Usage: $0 [OPTION]...
122 -h|--help Print this help.
123
124General options:
125 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100126 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100127 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100128 --armcc Run ARM Compiler builds (on by default).
129 --no-armcc Skip ARM Compiler builds.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100130 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +0100131 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
132 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
133 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100134 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100135
136Tool path options:
137 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
138 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
139 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
140 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
141 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
142 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
143 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
144 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100145 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100146EOF
SimonB2e23c822016-04-16 21:54:39 +0100147}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100148
149# remove built files as well as the cmake cache/config
150cleanup()
151{
Gilles Peskine7c652162017-12-11 00:01:40 +0100152 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200153
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200154 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000155 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200156 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
157 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200158
159 if [ -f "$CONFIG_BAK" ]; then
160 mv "$CONFIG_BAK" "$CONFIG_H"
161 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100162}
163
Gilles Peskine7c652162017-12-11 00:01:40 +0100164# Executed on exit. May be redefined depending on command line options.
165final_report () {
166 :
167}
168
169fatal_signal () {
170 cleanup
171 final_report $1
172 trap - $1
173 kill -$1 $$
174}
175
176trap 'fatal_signal HUP' HUP
177trap 'fatal_signal INT' INT
178trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200179
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100180msg()
181{
182 echo ""
183 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100184 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000185 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100186 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100187 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100188}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100189
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100190if [ $RUN_ARMCC -ne 0 ]; then
191 armc6_build_test()
192 {
193 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100194
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100195 msg "build: ARM Compiler 6 ($FLAGS), make"
196 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
197 WARNING_CFLAGS='-xc -std=c99' make lib
198 make clean
199 }
200fi
Andres AGa5cd9732016-10-17 15:23:10 +0100201
Andres AGd9eba4b2016-08-26 14:42:14 +0100202err_msg()
203{
204 echo "$1" >&2
205}
206
207check_tools()
208{
209 for TOOL in "$@"; do
210 if ! `hash "$TOOL" >/dev/null 2>&1`; then
211 err_msg "$TOOL not found!"
212 exit 1
213 fi
214 done
215}
216
SimonB2e23c822016-04-16 21:54:39 +0100217while [ $# -gt 0 ]; do
218 case "$1" in
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100219 --armcc)
220 RUN_ARMCC=1
Andres AGd9eba4b2016-08-26 14:42:14 +0100221 ;;
Andres AG87bb5772016-09-27 15:05:15 +0100222 --armc5-bin-dir)
223 shift
224 ARMC5_BIN_DIR="$1"
225 ;;
226 --armc6-bin-dir)
227 shift
228 ARMC6_BIN_DIR="$1"
229 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100230 --force|-f)
231 FORCE=1
232 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100233 --gnutls-cli)
234 shift
235 GNUTLS_CLI="$1"
236 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100237 --gnutls-legacy-cli)
SimonB2e23c822016-04-16 21:54:39 +0100238 shift
239 GNUTLS_LEGACY_CLI="$1"
240 ;;
241 --gnutls-legacy-serv)
242 shift
243 GNUTLS_LEGACY_SERV="$1"
244 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100245 --gnutls-serv)
SimonB2e23c822016-04-16 21:54:39 +0100246 shift
Gilles Peskine709346a2017-12-10 23:43:39 +0100247 GNUTLS_SERV="$1"
SimonB2e23c822016-04-16 21:54:39 +0100248 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100249 --help|-h)
Andres AGd9eba4b2016-08-26 14:42:14 +0100250 usage
Gilles Peskine709346a2017-12-10 23:43:39 +0100251 exit
252 ;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100253 --keep-going|-k)
254 KEEP_GOING=1
255 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100256 --memory|-m)
257 MEMORY=1
258 ;;
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100259 --no-armcc)
260 RUN_ARMCC=0
261 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100262 --no-yotta)
263 YOTTA=0
264 ;;
265 --openssl)
266 shift
267 OPENSSL="$1"
268 ;;
269 --openssl-legacy)
270 shift
271 OPENSSL_LEGACY="$1"
272 ;;
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100273 --openssl-next)
274 shift
275 OPENSSL_NEXT="$1"
276 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100277 --out-of-source-dir)
278 shift
279 OUT_OF_SOURCE_DIR="$1"
280 ;;
281 --release-test|-r)
282 RELEASE=1
283 ;;
284 --seed|-s)
285 shift
286 SEED="$1"
287 ;;
Gilles Peskine2a22a802017-12-21 15:19:00 +0100288 --yotta)
289 YOTTA=1
290 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100291 *)
292 echo >&2 "Unknown option: $1"
293 echo >&2 "Run $0 --help for usage."
294 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100295 ;;
296 esac
297 shift
298done
299
300if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100301 if [ $YOTTA -eq 1 ]; then
302 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
303 fi
SimonB2e23c822016-04-16 21:54:39 +0100304 git checkout-index -f -q $CONFIG_H
305 cleanup
306else
307
Gilles Peskine2a22a802017-12-21 15:19:00 +0100308 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100309 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100310 echo "You can either delete your work and retry, or force the test to overwrite the"
311 echo "test by rerunning the script as: $0 --force"
312 exit 1
313 fi
314
Andres AGdc192212016-08-31 17:33:13 +0100315 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
316 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
317 echo "You can either delete this directory manually, or force the test by rerunning"
318 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
319 exit 1
320 fi
321
SimonB2e23c822016-04-16 21:54:39 +0100322 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100323 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100324 echo "You can either delete or preserve your work, or force the test by rerunning the"
325 echo "script as: $0 --force"
326 exit 1
327 fi
328fi
329
Gilles Peskine7c652162017-12-11 00:01:40 +0100330build_status=0
331if [ $KEEP_GOING -eq 1 ]; then
332 failure_summary=
333 failure_count=0
334 start_red=
335 end_color=
336 if [ -t 1 ]; then
337 case "$TERM" in
338 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
339 start_red=$(printf '\033[31m')
340 end_color=$(printf '\033[0m')
341 ;;
342 esac
343 fi
344 record_status () {
345 if "$@"; then
346 last_status=0
347 else
348 last_status=$?
349 text="$current_section: $* -> $last_status"
350 failure_summary="$failure_summary
351$text"
352 failure_count=$((failure_count + 1))
353 echo "${start_red}^^^^$text^^^^${end_color}"
354 fi
355 }
356 make () {
357 case "$*" in
358 *test|*check)
359 if [ $build_status -eq 0 ]; then
360 record_status command make "$@"
361 else
362 echo "(skipped because the build failed)"
363 fi
364 ;;
365 *)
366 record_status command make "$@"
367 build_status=$last_status
368 ;;
369 esac
370 }
371 final_report () {
372 if [ $failure_count -gt 0 ]; then
373 echo
374 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
375 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
376 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
377 elif [ -z "${1-}" ]; then
378 echo "SUCCESS :)"
379 fi
380 if [ -n "${1-}" ]; then
381 echo "Killed by SIG$1."
382 fi
383 }
384else
385 record_status () {
386 "$@"
387 }
388fi
389if_build_succeeded () {
390 if [ $build_status -eq 0 ]; then
391 record_status "$@"
392 fi
393}
394
Andres AG7770ea82016-10-10 15:46:20 +0100395if [ $RELEASE -eq 1 ]; then
396 # Fix the seed value to 1 to ensure that the tests are deterministic.
397 SEED=1
398fi
399
Andres AGd9eba4b2016-08-26 14:42:14 +0100400msg "info: $0 configuration"
401echo "MEMORY: $MEMORY"
402echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100403echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100404echo "OPENSSL: $OPENSSL"
405echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100406echo "OPENSSL_NEXT: $OPENSSL_NEXT"
Andres AGd9eba4b2016-08-26 14:42:14 +0100407echo "GNUTLS_CLI: $GNUTLS_CLI"
408echo "GNUTLS_SERV: $GNUTLS_SERV"
409echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
410echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100411echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
412echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
413
414ARMC5_CC="$ARMC5_BIN_DIR/armcc"
415ARMC5_AR="$ARMC5_BIN_DIR/armar"
416ARMC6_CC="$ARMC6_BIN_DIR/armclang"
417ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100418
Andres AGb2fdd042016-09-22 14:17:46 +0100419# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
420# we just export the variables they require
421export OPENSSL_CMD="$OPENSSL"
422export GNUTLS_CLI="$GNUTLS_CLI"
423export GNUTLS_SERV="$GNUTLS_SERV"
424
Andres AG7770ea82016-10-10 15:46:20 +0100425# Avoid passing --seed flag in every call to ssl-opt.sh
426[ ! -z ${SEED+set} ] && export SEED
427
Andres AGd9eba4b2016-08-26 14:42:14 +0100428# Make sure the tools we need are available.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100429check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
430 "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100431 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100432 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
433if [ $RUN_ARMCC -ne 0 ]; then
434 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
435fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100436
Gilles Peskine192c72f2017-12-21 15:59:21 +0100437
438
439################################################################
440#### Basic checks
441################################################################
SimonB2e23c822016-04-16 21:54:39 +0100442
443#
444# Test Suites to be executed
445#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200446# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100447# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200448# and/or are more likely to fail than others (eg I use Clang most of the
449# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200450# 2. Minimize total running time, by avoiding useless rebuilds
451#
452# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100453
Janos Follathb72c6782016-07-19 14:54:17 +0100454msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100455OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
456 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100457 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
458 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100459
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100460msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200461tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100462
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000463msg "test: freshness of generated source files" # < 1s
464tests/scripts/check-generated-files.sh
465
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200466msg "test: doxygen markup outside doxygen blocks" # < 1s
467tests/scripts/check-doxy-blocks.pl
468
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200469msg "test/build: declared and exported names" # < 3s
470cleanup
471tests/scripts/check-names.sh
472
Andres AGd9eba4b2016-08-26 14:42:14 +0100473msg "test: doxygen warnings" # ~ 3s
474cleanup
475tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100476
Gilles Peskine192c72f2017-12-21 15:59:21 +0100477
478
479################################################################
480#### Build and test many configurations and targets
481################################################################
482
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100483if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
484 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
485 # path, and uses whatever version of armcc it finds there.
Gilles Peskineda519252017-11-30 13:22:04 +0100486 msg "build: create and build yotta module" # ~ 30s
487 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100488 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100489fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200490
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100491msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100492cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100493CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100494make
495
Simon Butcher8e3afc72016-09-15 17:13:08 +0100496msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100497make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200498
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100499msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100500if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200501
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100502msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100503if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200504
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200505msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
506make
507
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100508msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100509if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200510
Simon Butcher3ea7f522016-03-07 23:22:10 +0000511msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
512cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000513cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000514scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
515CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
516make
517
Simon Butcher8e3afc72016-09-15 17:13:08 +0100518msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000519make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000520
521msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100522if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
523if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000524
525msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100526if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000527
Hanno Becker134c2ab2017-10-12 15:29:50 +0100528msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
529cleanup
530cp "$CONFIG_H" "$CONFIG_BAK"
531scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
532CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
533make
534
535msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
536make test
537
538msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100539if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100540
Simon Butcherf95c1762016-11-10 17:25:58 +0000541msg "build: cmake, full config, clang, C99" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100542cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100543cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200544scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200545scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000546CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Gilles Peskine7c652162017-12-11 00:01:40 +0100547make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100548
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100549msg "test: main suites (full config)" # ~ 5s
Gilles Peskine7c652162017-12-11 00:01:40 +0100550make CFLAGS='-Werror -Wall -Wextra' test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200551
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100552msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100553if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200554
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100555msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100556if_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 +0200557
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100558msg "test: compat.sh ARIA"
559if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA'
560
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200561msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100562cleanup
563cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskine7c652162017-12-11 00:01:40 +0100564if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100565
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200566msg "test/build: key-exchanges (gcc)" # ~ 1 min
567cleanup
568cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine7c652162017-12-11 00:01:40 +0100569if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200570
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000571msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100572cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100573make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100574
Simon Butcherf95c1762016-11-10 17:25:58 +0000575# Full configuration build, without platform support, file IO and net sockets.
576# This should catch missing mbedtls_printf definitions, and by disabling file
577# IO, it should catch missing '#include <stdio.h>'
578msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000579cleanup
580cp "$CONFIG_H" "$CONFIG_BAK"
581scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200582scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000583scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200584scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100585scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
586scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
587scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100588scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100589scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100590scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200591scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
592scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000593# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
594# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100595make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
596make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000597
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100598# catch compile bugs in _uninit functions
599msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
600cleanup
601cp "$CONFIG_H" "$CONFIG_BAK"
602scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100603scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100604scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100605make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100606
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200607msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
608cleanup
609cp "$CONFIG_H" "$CONFIG_BAK"
610scripts/config.pl full
611scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100612make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200613
614msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
615cleanup
616cp "$CONFIG_H" "$CONFIG_BAK"
617scripts/config.pl full
618scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000619make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200620
Simon Butcherf95c1762016-11-10 17:25:58 +0000621# Note, C99 compliance can also be tested with the sockets support disabled,
622# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100623msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200624cleanup
625cp "$CONFIG_H" "$CONFIG_BAK"
626scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200627scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
628scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100629make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200630
Hanno Becker5175ac62017-09-18 15:36:25 +0100631msg "build: default config except MFL extension (ASan build)" # ~ 30s
632cleanup
633cp "$CONFIG_H" "$CONFIG_BAK"
634scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
635CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
636make
637
638msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100639if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100640
Simon Butcherab5df402016-06-11 02:31:21 +0100641msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100642cleanup
643cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100644scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100645scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
646scripts/config.pl set MBEDTLS_ENTROPY_C
647scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
648scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
649scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100650CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100651make
652
Simon Butcher8e3afc72016-09-15 17:13:08 +0100653msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100654make test
Janos Follath06c54002016-06-09 13:57:40 +0100655
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200656if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100657 msg "build/test: make shared" # ~ 40s
658 cleanup
659 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200660fi
661
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000662if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100663 msg "build: i386, make, gcc" # ~ 30s
664 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100665 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garciadd29c2f2017-05-04 11:35:51 +0100666
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100667 msg "test: i386, make, gcc"
668 make test
669
670 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
671 cleanup
672 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
673
674 msg "test: 64-bit ILP32, make, gcc"
675 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000676fi # x86_64
677
Gilles Peskine14c3c062018-01-29 21:25:12 +0100678msg "build: gcc, force 32-bit bignum limbs"
679cleanup
680cp "$CONFIG_H" "$CONFIG_BAK"
681scripts/config.pl unset MBEDTLS_HAVE_ASM
682scripts/config.pl unset MBEDTLS_AESNI_C
683scripts/config.pl unset MBEDTLS_PADLOCK_C
684make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
685
686msg "test: gcc, force 32-bit bignum limbs"
687make test
688
689msg "build: gcc, force 64-bit bignum limbs"
690cleanup
691cp "$CONFIG_H" "$CONFIG_BAK"
692scripts/config.pl unset MBEDTLS_HAVE_ASM
693scripts/config.pl unset MBEDTLS_AESNI_C
694scripts/config.pl unset MBEDTLS_PADLOCK_C
695make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
696
697msg "test: gcc, force 64-bit bignum limbs"
698make test
699
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000700msg "build: arm-none-eabi-gcc, make" # ~ 10s
701cleanup
702cp "$CONFIG_H" "$CONFIG_BAK"
703scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200704scripts/config.pl unset MBEDTLS_NET_C
705scripts/config.pl unset MBEDTLS_TIMING_C
706scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100707scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000708scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000709# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200710scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
711scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
712scripts/config.pl unset MBEDTLS_THREADING_C
713scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
714scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100715make 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 +0000716
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200717msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
718cleanup
Simon Butcher51aaa992017-07-23 13:42:36 +0200719cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia6fb65862017-07-20 13:27:35 +0100720scripts/config.pl full
721scripts/config.pl unset MBEDTLS_NET_C
722scripts/config.pl unset MBEDTLS_TIMING_C
723scripts/config.pl unset MBEDTLS_FS_IO
724scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
725scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
726# following things are not in the default config
727scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
728scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
729scripts/config.pl unset MBEDTLS_THREADING_C
730scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
731scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200732scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100733make 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 +0200734echo "Checking that software 64-bit division is not required"
735! grep __aeabi_uldiv library/*.o
736
Andres AG87bb5772016-09-27 15:05:15 +0100737msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100738cleanup
739cp "$CONFIG_H" "$CONFIG_BAK"
740scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200741scripts/config.pl unset MBEDTLS_NET_C
742scripts/config.pl unset MBEDTLS_TIMING_C
743scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100744scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200745scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200746scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000747scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100748# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200749scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
750scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
751scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
752scripts/config.pl unset MBEDTLS_THREADING_C
753scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
754scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300755scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100756
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100757if [ $RUN_ARMCC -ne 0 ]; then
758 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
759 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100760
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100761 # ARM Compiler 6 - Target ARMv7-A
762 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200763
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100764 # ARM Compiler 6 - Target ARMv7-M
765 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher51aaa992017-07-23 13:42:36 +0200766
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100767 # ARM Compiler 6 - Target ARMv8-A - AArch32
768 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200769
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100770 # ARM Compiler 6 - Target ARMv8-M
771 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher51aaa992017-07-23 13:42:36 +0200772
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100773 # ARM Compiler 6 - Target ARMv8-A - AArch64
774 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
775fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100776
Gilles Peskine2a458da2017-05-12 15:26:58 +0200777msg "build: allow SHA1 in certificates by default"
778cleanup
779cp "$CONFIG_H" "$CONFIG_BAK"
780scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100781make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200782msg "test: allow SHA1 in certificates by default"
783make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100784if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200785
Hanno Beckerd485c312018-01-05 13:03:53 +0000786msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000787cleanup
788cp "$CONFIG_H" "$CONFIG_BAK"
789scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000790CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
791make
Hanno Beckere963efa2018-01-03 10:03:43 +0000792
793msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
794make test
795
Simon Butcher002bc622016-11-17 09:27:45 +0000796msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100797cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100798make 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 +0000799
Simon Butcher002bc622016-11-17 09:27:45 +0000800# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100801make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
802make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000803
Simon Butcher002bc622016-11-17 09:27:45 +0000804msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100805make 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
806make 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
807make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100808
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000809# MemSan currently only available on Linux 64 bits
810if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000811
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100812 msg "build: MSan (clang)" # ~ 1 min 20s
813 cleanup
814 cp "$CONFIG_H" "$CONFIG_BAK"
815 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
816 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
817 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200818
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100819 msg "test: main suites (MSan)" # ~ 10s
820 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100821
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100822 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100823 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100824
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100825 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100826
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100827 if [ "$MEMORY" -gt 0 ]; then
828 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100829 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100830 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100831
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000832else # no MemSan
833
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100834 msg "build: Release (clang)"
835 cleanup
836 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
837 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000838
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100839 msg "test: main suites valgrind (Release)"
840 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000841
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100842 # Optional part(s)
843 # Currently broken, programs don't seem to receive signals
844 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000845
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100846 if [ "$MEMORY" -gt 0 ]; then
847 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100848 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100849 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000850
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100851 if [ "$MEMORY" -gt 1 ]; then
852 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100853 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100854 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000855
856fi # MemSan
857
Andres AGdc192212016-08-31 17:33:13 +0100858msg "build: cmake 'out-of-source' build"
859cleanup
860MBEDTLS_ROOT_DIR="$PWD"
861mkdir "$OUT_OF_SOURCE_DIR"
862cd "$OUT_OF_SOURCE_DIR"
863cmake "$MBEDTLS_ROOT_DIR"
864make
865
866msg "test: cmake 'out-of-source' build"
867make test
868cd "$MBEDTLS_ROOT_DIR"
869rm -rf "$OUT_OF_SOURCE_DIR"
870
Gilles Peskine192c72f2017-12-21 15:59:21 +0100871
872
873################################################################
874#### Termination
875################################################################
876
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100877msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100878cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100879
880final_report