blob: 497a261c4b995178ed3afc8a0bebadedc3dd61b8 [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
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100331 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100332 *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 Peskine396fac12018-03-22 22:26:03 +0100495record_status 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
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100532
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100533msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
534cleanup
535cp "$CONFIG_H" "$CONFIG_BAK"
536scripts/config.pl set MBEDTLS_RSA_NO_CRT
537CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
538make
539
540msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
541make test
542
543msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
544tests/ssl-opt.sh -f RSA
545
546msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
547tests/compat.sh -t RSA
548
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200549msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200550cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100551cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200552scripts/config.pl full
553scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000554CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200555make
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100556
557msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200558make test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200559
560msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100561if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200562
563msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100564if_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 +0200565
566msg "test/build: curves.pl (gcc)" # ~ 4 min
567cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100568record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200569
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200570msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
571cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100572record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200573
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200574msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
575cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100576record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200577
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200578msg "test/build: key-exchanges (gcc)" # ~ 1 min
579cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100580record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200581
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000582msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100583cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100584make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100585
Simon Butcherf95c1762016-11-10 17:25:58 +0000586# Full configuration build, without platform support, file IO and net sockets.
587# This should catch missing mbedtls_printf definitions, and by disabling file
588# IO, it should catch missing '#include <stdio.h>'
589msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000590cleanup
591cp "$CONFIG_H" "$CONFIG_BAK"
592scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200593scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000594scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200595scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100596scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
597scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
598scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100599scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100600scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100601scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200602scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
603scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000604# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
605# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100606make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
607make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000608
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100609# catch compile bugs in _uninit functions
610msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
611cleanup
612cp "$CONFIG_H" "$CONFIG_BAK"
613scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100614scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100615scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100616make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100617
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200618msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
619cleanup
620cp "$CONFIG_H" "$CONFIG_BAK"
621scripts/config.pl full
622scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100623make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200624
625msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
626cleanup
627cp "$CONFIG_H" "$CONFIG_BAK"
628scripts/config.pl full
629scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000630make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200631
Simon Butcherf95c1762016-11-10 17:25:58 +0000632# Note, C99 compliance can also be tested with the sockets support disabled,
633# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100634msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200635cleanup
636cp "$CONFIG_H" "$CONFIG_BAK"
637scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200638scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
639scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100640make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200641
Hanno Becker5175ac62017-09-18 15:36:25 +0100642msg "build: default config except MFL extension (ASan build)" # ~ 30s
643cleanup
644cp "$CONFIG_H" "$CONFIG_BAK"
645scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
646CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
647make
648
649msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100650if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000651
Simon Butcherab5df402016-06-11 02:31:21 +0100652msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100653cleanup
654cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100655scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100656scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
657scripts/config.pl set MBEDTLS_ENTROPY_C
658scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
659scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
660scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100661CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100662make
663
Simon Butcher8e3afc72016-09-15 17:13:08 +0100664msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100665make test
Janos Follath06c54002016-06-09 13:57:40 +0100666
Hanno Becker83ebf782017-07-07 12:29:15 +0100667msg "build: default config with AES_FEWER_TABLES enabled"
668cleanup
669cp "$CONFIG_H" "$CONFIG_BAK"
670scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100671make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100672
673msg "test: AES_FEWER_TABLES"
674make test
675
676msg "build: default config with AES_ROM_TABLES enabled"
677cleanup
678cp "$CONFIG_H" "$CONFIG_BAK"
679scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100680make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100681
682msg "test: AES_ROM_TABLES"
683make test
684
685msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
686cleanup
687cp "$CONFIG_H" "$CONFIG_BAK"
688scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
689scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100690make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100691
692msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
693make test
694
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200695if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100696 msg "build/test: make shared" # ~ 40s
697 cleanup
698 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200699fi
700
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000701if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100702 msg "build: i386, make, gcc" # ~ 30s
703 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100704 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100705
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100706 msg "test: i386, make, gcc"
707 make test
708
709 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
710 cleanup
711 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
712
713 msg "test: 64-bit ILP32, make, gcc"
714 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000715fi # x86_64
716
Gilles Peskine14c3c062018-01-29 21:25:12 +0100717msg "build: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100718cleanup
719cp "$CONFIG_H" "$CONFIG_BAK"
720scripts/config.pl unset MBEDTLS_HAVE_ASM
721scripts/config.pl unset MBEDTLS_AESNI_C
722scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100723make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100724
Gilles Peskine14c3c062018-01-29 21:25:12 +0100725msg "test: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100726make test
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100727
Gilles Peskine14c3c062018-01-29 21:25:12 +0100728msg "build: gcc, force 64-bit bignum limbs"
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100729cleanup
730cp "$CONFIG_H" "$CONFIG_BAK"
731scripts/config.pl unset MBEDTLS_HAVE_ASM
732scripts/config.pl unset MBEDTLS_AESNI_C
733scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100734make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
735
736msg "test: gcc, force 64-bit bignum limbs"
737make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000738
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000739msg "build: arm-none-eabi-gcc, make" # ~ 10s
740cleanup
741cp "$CONFIG_H" "$CONFIG_BAK"
742scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200743scripts/config.pl unset MBEDTLS_NET_C
744scripts/config.pl unset MBEDTLS_TIMING_C
745scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100746scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000747scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000748# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200749scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
750scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
751scripts/config.pl unset MBEDTLS_THREADING_C
752scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
753scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100754make 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 +0000755
Gilles Peskineed942f82017-06-08 15:19:20 +0200756msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
757cleanup
Simon Butcher940737f2017-07-23 13:42:36 +0200758cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia05931972017-07-20 13:27:35 +0100759scripts/config.pl full
760scripts/config.pl unset MBEDTLS_NET_C
761scripts/config.pl unset MBEDTLS_TIMING_C
762scripts/config.pl unset MBEDTLS_FS_IO
763scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
764scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
765# following things are not in the default config
766scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
767scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
768scripts/config.pl unset MBEDTLS_THREADING_C
769scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
770scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineed942f82017-06-08 15:19:20 +0200771scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100772make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskineed942f82017-06-08 15:19:20 +0200773echo "Checking that software 64-bit division is not required"
774! grep __aeabi_uldiv library/*.o
775
Andres AG87bb5772016-09-27 15:05:15 +0100776msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100777cleanup
778cp "$CONFIG_H" "$CONFIG_BAK"
779scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200780scripts/config.pl unset MBEDTLS_NET_C
781scripts/config.pl unset MBEDTLS_TIMING_C
782scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100783scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200784scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200785scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000786scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100787# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200788scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
789scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
790scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
791scripts/config.pl unset MBEDTLS_THREADING_C
792scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
793scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300794scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100795
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100796if [ $RUN_ARMCC -ne 0 ]; then
797 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
798 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100799
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100800 # ARM Compiler 6 - Target ARMv7-A
801 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +0200802
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100803 # ARM Compiler 6 - Target ARMv7-M
804 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +0200805
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100806 # ARM Compiler 6 - Target ARMv8-A - AArch32
807 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +0200808
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100809 # ARM Compiler 6 - Target ARMv8-M
810 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +0200811
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100812 # ARM Compiler 6 - Target ARMv8-A - AArch64
813 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
814fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100815
Gilles Peskine2a458da2017-05-12 15:26:58 +0200816msg "build: allow SHA1 in certificates by default"
817cleanup
818cp "$CONFIG_H" "$CONFIG_BAK"
819scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100820make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200821msg "test: allow SHA1 in certificates by default"
822make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100823if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200824
Hanno Beckerd485c312018-01-05 13:03:53 +0000825msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +0000826cleanup
827cp "$CONFIG_H" "$CONFIG_BAK"
828scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +0000829CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
830make
Hanno Beckere963efa2018-01-03 10:03:43 +0000831
832msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
833make test
Simon Butcher002bc622016-11-17 09:27:45 +0000834
835msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
836cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100837make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Manuel Pégourié-Gonnard52fa38a2015-06-23 14:29:58 +0200838
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200839# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100840make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
841make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100842
843msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100844make 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
845make 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
846make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100847
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000848# MemSan currently only available on Linux 64 bits
849if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000850
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100851 msg "build: MSan (clang)" # ~ 1 min 20s
852 cleanup
853 cp "$CONFIG_H" "$CONFIG_BAK"
854 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
855 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
856 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200857
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100858 msg "test: main suites (MSan)" # ~ 10s
859 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100860
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100861 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100862 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100863
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100864 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100865
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100866 if [ "$MEMORY" -gt 0 ]; then
867 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100868 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100869 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100870
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000871else # no MemSan
872
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100873 msg "build: Release (clang)"
874 cleanup
875 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
876 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000877
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100878 msg "test: main suites valgrind (Release)"
879 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000880
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100881 # Optional part(s)
882 # Currently broken, programs don't seem to receive signals
883 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000884
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100885 if [ "$MEMORY" -gt 0 ]; then
886 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100887 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100888 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000889
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100890 if [ "$MEMORY" -gt 1 ]; then
891 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100892 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100893 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000894
895fi # MemSan
896
Andres AGdc192212016-08-31 17:33:13 +0100897msg "build: cmake 'out-of-source' build"
898cleanup
899MBEDTLS_ROOT_DIR="$PWD"
900mkdir "$OUT_OF_SOURCE_DIR"
901cd "$OUT_OF_SOURCE_DIR"
902cmake "$MBEDTLS_ROOT_DIR"
903make
904
905msg "test: cmake 'out-of-source' build"
906make test
907cd "$MBEDTLS_ROOT_DIR"
908rm -rf "$OUT_OF_SOURCE_DIR"
909
Gilles Peskine192c72f2017-12-21 15:59:21 +0100910
911
912################################################################
913#### Termination
914################################################################
915
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100916msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100917cleanup
918
Gilles Peskine7c652162017-12-11 00:01:40 +0100919final_report