blob: c60eaaf65aefcc5c4552e532a4729c5186f65296 [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 Peskinebca6ab92017-12-19 18:24:31 +0100217 --armcc)
218 RUN_ARMCC=1
Andres AGd9eba4b2016-08-26 14:42:14 +0100219 ;;
Andres AG87bb5772016-09-27 15:05:15 +0100220 --armc5-bin-dir)
221 shift
222 ARMC5_BIN_DIR="$1"
223 ;;
224 --armc6-bin-dir)
225 shift
226 ARMC6_BIN_DIR="$1"
227 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100228 --force|-f)
229 FORCE=1
230 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100231 --gnutls-cli)
232 shift
233 GNUTLS_CLI="$1"
234 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100235 --gnutls-legacy-cli)
SimonB2e23c822016-04-16 21:54:39 +0100236 shift
237 GNUTLS_LEGACY_CLI="$1"
238 ;;
239 --gnutls-legacy-serv)
240 shift
241 GNUTLS_LEGACY_SERV="$1"
242 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100243 --gnutls-serv)
SimonB2e23c822016-04-16 21:54:39 +0100244 shift
Gilles Peskine709346a2017-12-10 23:43:39 +0100245 GNUTLS_SERV="$1"
SimonB2e23c822016-04-16 21:54:39 +0100246 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100247 --help|-h)
Andres AGd9eba4b2016-08-26 14:42:14 +0100248 usage
Gilles Peskine709346a2017-12-10 23:43:39 +0100249 exit
250 ;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100251 --keep-going|-k)
252 KEEP_GOING=1
253 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100254 --memory|-m)
255 MEMORY=1
256 ;;
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100257 --no-armcc)
258 RUN_ARMCC=0
259 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100260 --no-yotta)
261 YOTTA=0
262 ;;
263 --openssl)
264 shift
265 OPENSSL="$1"
266 ;;
267 --openssl-legacy)
268 shift
269 OPENSSL_LEGACY="$1"
270 ;;
271 --out-of-source-dir)
272 shift
273 OUT_OF_SOURCE_DIR="$1"
274 ;;
275 --release-test|-r)
276 RELEASE=1
277 ;;
278 --seed|-s)
279 shift
280 SEED="$1"
281 ;;
Gilles Peskine2a22a802017-12-21 15:19:00 +0100282 --yotta)
283 YOTTA=1
284 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100285 *)
286 echo >&2 "Unknown option: $1"
287 echo >&2 "Run $0 --help for usage."
288 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100289 ;;
290 esac
291 shift
292done
293
294if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100295 if [ $YOTTA -eq 1 ]; then
296 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
297 fi
SimonB2e23c822016-04-16 21:54:39 +0100298 git checkout-index -f -q $CONFIG_H
299 cleanup
300else
301
Gilles Peskine2a22a802017-12-21 15:19:00 +0100302 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100303 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100304 echo "You can either delete your work and retry, or force the test to overwrite the"
305 echo "test by rerunning the script as: $0 --force"
306 exit 1
307 fi
308
Andres AGdc192212016-08-31 17:33:13 +0100309 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
310 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
311 echo "You can either delete this directory manually, or force the test by rerunning"
312 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
313 exit 1
314 fi
315
SimonB2e23c822016-04-16 21:54:39 +0100316 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100317 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100318 echo "You can either delete or preserve your work, or force the test by rerunning the"
319 echo "script as: $0 --force"
320 exit 1
321 fi
322fi
323
Gilles Peskine7c652162017-12-11 00:01:40 +0100324build_status=0
325if [ $KEEP_GOING -eq 1 ]; then
326 failure_summary=
327 failure_count=0
328 start_red=
329 end_color=
330 if [ -t 1 ]; then
331 case "$TERM" in
332 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
333 start_red=$(printf '\033[31m')
334 end_color=$(printf '\033[0m')
335 ;;
336 esac
337 fi
338 record_status () {
339 if "$@"; then
340 last_status=0
341 else
342 last_status=$?
343 text="$current_section: $* -> $last_status"
344 failure_summary="$failure_summary
345$text"
346 failure_count=$((failure_count + 1))
347 echo "${start_red}^^^^$text^^^^${end_color}"
348 fi
349 }
350 make () {
351 case "$*" in
352 *test|*check)
353 if [ $build_status -eq 0 ]; then
354 record_status command make "$@"
355 else
356 echo "(skipped because the build failed)"
357 fi
358 ;;
359 *)
360 record_status command make "$@"
361 build_status=$last_status
362 ;;
363 esac
364 }
365 final_report () {
366 if [ $failure_count -gt 0 ]; then
367 echo
368 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
369 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
370 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
371 elif [ -z "${1-}" ]; then
372 echo "SUCCESS :)"
373 fi
374 if [ -n "${1-}" ]; then
375 echo "Killed by SIG$1."
376 fi
377 }
378else
379 record_status () {
380 "$@"
381 }
382fi
383if_build_succeeded () {
384 if [ $build_status -eq 0 ]; then
385 record_status "$@"
386 fi
387}
388
Andres AG7770ea82016-10-10 15:46:20 +0100389if [ $RELEASE -eq 1 ]; then
390 # Fix the seed value to 1 to ensure that the tests are deterministic.
391 SEED=1
392fi
393
Andres AGd9eba4b2016-08-26 14:42:14 +0100394msg "info: $0 configuration"
395echo "MEMORY: $MEMORY"
396echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100397echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100398echo "OPENSSL: $OPENSSL"
399echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
400echo "GNUTLS_CLI: $GNUTLS_CLI"
401echo "GNUTLS_SERV: $GNUTLS_SERV"
402echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
403echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100404echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
405echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
406
407ARMC5_CC="$ARMC5_BIN_DIR/armcc"
408ARMC5_AR="$ARMC5_BIN_DIR/armar"
409ARMC6_CC="$ARMC6_BIN_DIR/armclang"
410ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100411
Andres AGb2fdd042016-09-22 14:17:46 +0100412# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
413# we just export the variables they require
414export OPENSSL_CMD="$OPENSSL"
415export GNUTLS_CLI="$GNUTLS_CLI"
416export GNUTLS_SERV="$GNUTLS_SERV"
417
Andres AG7770ea82016-10-10 15:46:20 +0100418# Avoid passing --seed flag in every call to ssl-opt.sh
419[ ! -z ${SEED+set} ] && export SEED
420
Andres AGd9eba4b2016-08-26 14:42:14 +0100421# Make sure the tools we need are available.
422check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100423 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100424 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
425if [ $RUN_ARMCC -ne 0 ]; then
426 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
427fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100428
Gilles Peskine192c72f2017-12-21 15:59:21 +0100429
430
431################################################################
432#### Basic checks
433################################################################
SimonB2e23c822016-04-16 21:54:39 +0100434
435#
436# Test Suites to be executed
437#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200438# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100439# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200440# and/or are more likely to fail than others (eg I use Clang most of the
441# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200442# 2. Minimize total running time, by avoiding useless rebuilds
443#
444# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100445
Janos Follathb72c6782016-07-19 14:54:17 +0100446msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100447OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
448 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100449 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
450 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100451
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100452msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200453tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100454
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000455msg "test: freshness of generated source files" # < 1s
456tests/scripts/check-generated-files.sh
457
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200458msg "test: doxygen markup outside doxygen blocks" # < 1s
459tests/scripts/check-doxy-blocks.pl
460
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200461msg "test/build: declared and exported names" # < 3s
462cleanup
463tests/scripts/check-names.sh
464
Andres AGd9eba4b2016-08-26 14:42:14 +0100465msg "test: doxygen warnings" # ~ 3s
466cleanup
467tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100468
Gilles Peskine192c72f2017-12-21 15:59:21 +0100469
470
471################################################################
472#### Build and test many configurations and targets
473################################################################
474
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100475if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
476 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
477 # path, and uses whatever version of armcc it finds there.
Gilles Peskineda519252017-11-30 13:22:04 +0100478 msg "build: create and build yotta module" # ~ 30s
479 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100480 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100481fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200482
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100483msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100484cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100485CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100486make
487
Simon Butcher8e3afc72016-09-15 17:13:08 +0100488msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100489make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200490
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100491msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100492if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200493
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100494msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100495if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200496
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200497msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
498make
499
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100500msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100501if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200502
Simon Butcher3ea7f522016-03-07 23:22:10 +0000503msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
504cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000505cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000506scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
507CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
508make
509
Simon Butcher8e3afc72016-09-15 17:13:08 +0100510msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000511make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000512
513msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100514if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
515if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000516
517msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100518if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000519
Hanno Becker134c2ab2017-10-12 15:29:50 +0100520msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
521cleanup
522cp "$CONFIG_H" "$CONFIG_BAK"
523scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
524CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
525make
526
527msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
528make test
529
530msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100531if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100532
Simon Butcherf95c1762016-11-10 17:25:58 +0000533msg "build: cmake, full config, clang, C99" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100534cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100535cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200536scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200537scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000538CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Gilles Peskine7c652162017-12-11 00:01:40 +0100539make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100540
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100541msg "test: main suites (full config)" # ~ 5s
Gilles Peskine7c652162017-12-11 00:01:40 +0100542make CFLAGS='-Werror -Wall -Wextra' test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200543
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100544msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100545if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200546
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100547msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100548if_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 +0200549
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200550msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100551cleanup
552cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskine7c652162017-12-11 00:01:40 +0100553if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100554
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200555msg "test/build: key-exchanges (gcc)" # ~ 1 min
556cleanup
557cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine7c652162017-12-11 00:01:40 +0100558if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200559
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000560msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100561cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100562make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100563
Simon Butcherf95c1762016-11-10 17:25:58 +0000564# Full configuration build, without platform support, file IO and net sockets.
565# This should catch missing mbedtls_printf definitions, and by disabling file
566# IO, it should catch missing '#include <stdio.h>'
567msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000568cleanup
569cp "$CONFIG_H" "$CONFIG_BAK"
570scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200571scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000572scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200573scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100574scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
575scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
576scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100577scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100578scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100579scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200580scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
581scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000582# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
583# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100584make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
585make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000586
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100587# catch compile bugs in _uninit functions
588msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
589cleanup
590cp "$CONFIG_H" "$CONFIG_BAK"
591scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100592scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100593scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100594make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100595
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200596msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
597cleanup
598cp "$CONFIG_H" "$CONFIG_BAK"
599scripts/config.pl full
600scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100601make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200602
603msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
604cleanup
605cp "$CONFIG_H" "$CONFIG_BAK"
606scripts/config.pl full
607scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000608make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200609
Simon Butcherf95c1762016-11-10 17:25:58 +0000610# Note, C99 compliance can also be tested with the sockets support disabled,
611# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100612msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200613cleanup
614cp "$CONFIG_H" "$CONFIG_BAK"
615scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200616scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
617scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100618make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200619
Hanno Becker5175ac62017-09-18 15:36:25 +0100620msg "build: default config except MFL extension (ASan build)" # ~ 30s
621cleanup
622cp "$CONFIG_H" "$CONFIG_BAK"
623scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
624CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
625make
626
627msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100628if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100629
Simon Butcherab5df402016-06-11 02:31:21 +0100630msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100631cleanup
632cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100633scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100634scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
635scripts/config.pl set MBEDTLS_ENTROPY_C
636scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
637scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
638scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100639CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100640make
641
Simon Butcher8e3afc72016-09-15 17:13:08 +0100642msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100643make test
Janos Follath06c54002016-06-09 13:57:40 +0100644
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200645if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100646 msg "build/test: make shared" # ~ 40s
647 cleanup
648 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200649fi
650
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000651if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100652 msg "build: i386, make, gcc" # ~ 30s
653 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100654 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garciadd29c2f2017-05-04 11:35:51 +0100655
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100656 msg "test: i386, make, gcc"
657 make test
658
659 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
660 cleanup
661 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
662
663 msg "test: 64-bit ILP32, make, gcc"
664 make test
665
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100666 msg "build: gcc, force 32-bit compilation"
667 cleanup
668 cp "$CONFIG_H" "$CONFIG_BAK"
669 scripts/config.pl unset MBEDTLS_HAVE_ASM
670 scripts/config.pl unset MBEDTLS_AESNI_C
671 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100672 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garciadd29c2f2017-05-04 11:35:51 +0100673
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100674 msg "build: gcc, force 64-bit compilation"
675 cleanup
676 cp "$CONFIG_H" "$CONFIG_BAK"
677 scripts/config.pl unset MBEDTLS_HAVE_ASM
678 scripts/config.pl unset MBEDTLS_AESNI_C
679 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100680 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Andres Amaya Garcia33264d72017-07-20 13:21:34 +0100681
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100682 msg "test: gcc, force 64-bit compilation"
683 make test
Andres Amaya Garcia33264d72017-07-20 13:21:34 +0100684
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100685 msg "build: gcc, force 64-bit compilation"
686 cleanup
687 cp "$CONFIG_H" "$CONFIG_BAK"
688 scripts/config.pl unset MBEDTLS_HAVE_ASM
689 scripts/config.pl unset MBEDTLS_AESNI_C
690 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100691 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000692fi # x86_64
693
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000694msg "build: arm-none-eabi-gcc, make" # ~ 10s
695cleanup
696cp "$CONFIG_H" "$CONFIG_BAK"
697scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200698scripts/config.pl unset MBEDTLS_NET_C
699scripts/config.pl unset MBEDTLS_TIMING_C
700scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100701scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000702scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000703# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200704scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
705scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
706scripts/config.pl unset MBEDTLS_THREADING_C
707scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
708scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100709make 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 +0000710
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200711msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
712cleanup
Simon Butcher51aaa992017-07-23 13:42:36 +0200713cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia6fb65862017-07-20 13:27:35 +0100714scripts/config.pl full
715scripts/config.pl unset MBEDTLS_NET_C
716scripts/config.pl unset MBEDTLS_TIMING_C
717scripts/config.pl unset MBEDTLS_FS_IO
718scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
719scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
720# following things are not in the default config
721scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
722scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
723scripts/config.pl unset MBEDTLS_THREADING_C
724scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
725scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine9a9adcd2017-06-08 15:19:20 +0200726scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100727make 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 +0200728echo "Checking that software 64-bit division is not required"
729! grep __aeabi_uldiv library/*.o
730
Andres AG87bb5772016-09-27 15:05:15 +0100731msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100732cleanup
733cp "$CONFIG_H" "$CONFIG_BAK"
734scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200735scripts/config.pl unset MBEDTLS_NET_C
736scripts/config.pl unset MBEDTLS_TIMING_C
737scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100738scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200739scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200740scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000741scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100742# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200743scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
744scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
745scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
746scripts/config.pl unset MBEDTLS_THREADING_C
747scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
748scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300749scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100750
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100751if [ $RUN_ARMCC -ne 0 ]; then
752 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
753 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100754
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100755 # ARM Compiler 6 - Target ARMv7-A
756 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200757
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100758 # ARM Compiler 6 - Target ARMv7-M
759 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher51aaa992017-07-23 13:42:36 +0200760
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100761 # ARM Compiler 6 - Target ARMv8-A - AArch32
762 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher51aaa992017-07-23 13:42:36 +0200763
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100764 # ARM Compiler 6 - Target ARMv8-M
765 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher51aaa992017-07-23 13:42:36 +0200766
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100767 # ARM Compiler 6 - Target ARMv8-A - AArch64
768 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
769fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100770
Gilles Peskine2a458da2017-05-12 15:26:58 +0200771msg "build: allow SHA1 in certificates by default"
772cleanup
773cp "$CONFIG_H" "$CONFIG_BAK"
774scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100775make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200776msg "test: allow SHA1 in certificates by default"
777make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100778if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200779
Hanno Beckerd485c312018-01-05 13:03:53 +0000780msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000781cleanup
782cp "$CONFIG_H" "$CONFIG_BAK"
783scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000784CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
785make
Hanno Beckere963efa2018-01-03 10:03:43 +0000786
787msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
788make test
789
Simon Butcher002bc622016-11-17 09:27:45 +0000790msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100791cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100792make 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 +0000793
Simon Butcher002bc622016-11-17 09:27:45 +0000794# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100795make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
796make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000797
Simon Butcher002bc622016-11-17 09:27:45 +0000798msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100799make 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
800make 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
801make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100802
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000803# MemSan currently only available on Linux 64 bits
804if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000805
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100806 msg "build: MSan (clang)" # ~ 1 min 20s
807 cleanup
808 cp "$CONFIG_H" "$CONFIG_BAK"
809 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
810 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
811 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200812
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100813 msg "test: main suites (MSan)" # ~ 10s
814 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100815
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100816 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100817 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100818
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100819 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100820
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100821 if [ "$MEMORY" -gt 0 ]; then
822 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100823 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100824 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100825
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000826else # no MemSan
827
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100828 msg "build: Release (clang)"
829 cleanup
830 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
831 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000832
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100833 msg "test: main suites valgrind (Release)"
834 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000835
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100836 # Optional part(s)
837 # Currently broken, programs don't seem to receive signals
838 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000839
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100840 if [ "$MEMORY" -gt 0 ]; then
841 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100842 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100843 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000844
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100845 if [ "$MEMORY" -gt 1 ]; then
846 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100847 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100848 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000849
850fi # MemSan
851
Andres AGdc192212016-08-31 17:33:13 +0100852msg "build: cmake 'out-of-source' build"
853cleanup
854MBEDTLS_ROOT_DIR="$PWD"
855mkdir "$OUT_OF_SOURCE_DIR"
856cd "$OUT_OF_SOURCE_DIR"
857cmake "$MBEDTLS_ROOT_DIR"
858make
859
860msg "test: cmake 'out-of-source' build"
861make test
862cd "$MBEDTLS_ROOT_DIR"
863rm -rf "$OUT_OF_SOURCE_DIR"
864
Gilles Peskine192c72f2017-12-21 15:59:21 +0100865
866
867################################################################
868#### Termination
869################################################################
870
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100871msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100872cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100873
874final_report