blob: d76e6f805bbca77c03ef39483248b46f73c3b13f [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
Gilles Peskine57db6ff2019-01-08 22:04:31 +010083pre_check_environment () {
84 if [ "$( uname )" != "Linux" ]; then
85 echo "This script only works in Linux" >&2
86 exit 1
87 elif [ -d library -a -d include -a -d tests ]; then :; else
88 echo "Must be run from mbed TLS root" >&2
89 exit 1
90 fi
91}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010092
Gilles Peskine57db6ff2019-01-08 22:04:31 +010093pre_initialize_variables () {
94 CONFIG_H='include/mbedtls/config.h'
95 CONFIG_BAK="$CONFIG_H.bak"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020096
Gilles Peskine57db6ff2019-01-08 22:04:31 +010097 MEMORY=0
98 FORCE=0
99 KEEP_GOING=0
100 RUN_ARMCC=1
101 YOTTA=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100102
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100103 # Default commands, can be overriden by the environment
104 : ${OPENSSL:="openssl"}
105 : ${OPENSSL_LEGACY:="$OPENSSL"}
106 : ${GNUTLS_CLI:="gnutls-cli"}
107 : ${GNUTLS_SERV:="gnutls-serv"}
108 : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
109 : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
110 : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
111 : ${ARMC5_BIN_DIR:=/usr/bin}
112 : ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +0100113
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100114 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
115 if [ -n "${MAKEFLAGS+set}" ]; then
116 export MAKEFLAGS="-j"
117 fi
118}
Andres AG38495a32016-07-12 16:54:33 +0100119
Simon Butcher41eeccf2016-09-07 00:07:09 +0100120usage()
SimonB2e23c822016-04-16 21:54:39 +0100121{
Gilles Peskine709346a2017-12-10 23:43:39 +0100122 cat <<EOF
123Usage: $0 [OPTION]...
124 -h|--help Print this help.
125
126General options:
127 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100128 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100129 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100130 --armcc Run ARM Compiler builds (on by default).
131 --no-armcc Skip ARM Compiler builds.
Gilles Peskine19ceb712018-03-21 08:40:26 +0100132 --no-force Refuse to overwrite modified files (default).
133 --no-keep-going Stop at the first error (default).
134 --no-memory No additional memory tests (default).
Gilles Peskine2a22a802017-12-21 15:19:00 +0100135 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +0100136 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine19ceb712018-03-21 08:40:26 +0100137 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100138 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
139 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +0100140 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100141
142Tool path options:
143 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
144 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
145 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
146 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
147 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
148 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
149 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
150 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
151EOF
SimonB2e23c822016-04-16 21:54:39 +0100152}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100153
154# remove built files as well as the cmake cache/config
155cleanup()
156{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100157 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
158 cd "$MBEDTLS_ROOT_DIR"
159 fi
160
Gilles Peskine7c652162017-12-11 00:01:40 +0100161 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200162
Gilles Peskine31b07e22018-03-21 12:15:06 +0100163 # Remove CMake artefacts
164 find . -name .git -prune -o -name yotta -prune -o \
165 -iname CMakeFiles -exec rm -rf {} \+ -o \
166 \( -iname cmake_install.cmake -o \
167 -iname CTestTestfile.cmake -o \
168 -iname CMakeCache.txt \) -exec rm {} \+
169 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000170 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200171 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
172 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200173
174 if [ -f "$CONFIG_BAK" ]; then
175 mv "$CONFIG_BAK" "$CONFIG_H"
176 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100177}
178
Gilles Peskine7c652162017-12-11 00:01:40 +0100179# Executed on exit. May be redefined depending on command line options.
180final_report () {
181 :
182}
183
184fatal_signal () {
185 cleanup
186 final_report $1
187 trap - $1
188 kill -$1 $$
189}
190
191trap 'fatal_signal HUP' HUP
192trap 'fatal_signal INT' INT
193trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200194
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100195msg()
196{
197 echo ""
198 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100199 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000200 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100201 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100202 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100203}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100204
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100205armc6_build_test()
206{
207 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100208
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100209 msg "build: ARM Compiler 6 ($FLAGS), make"
210 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
211 WARNING_CFLAGS='-xc -std=c99' make lib
212 make clean
213}
Andres AGa5cd9732016-10-17 15:23:10 +0100214
Andres AGd9eba4b2016-08-26 14:42:14 +0100215err_msg()
216{
217 echo "$1" >&2
218}
219
220check_tools()
221{
222 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000223 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100224 err_msg "$TOOL not found!"
225 exit 1
226 fi
227 done
228}
229
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100230pre_parse_command_line () {
231 while [ $# -gt 0 ]; do
232 case "$1" in
233 --armcc) RUN_ARMCC=1;;
234 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
235 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
236 --force|-f) FORCE=1;;
237 --gnutls-cli) shift; GNUTLS_CLI="$1";;
238 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
239 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
240 --gnutls-serv) shift; GNUTLS_SERV="$1";;
241 --help|-h) usage; exit;;
242 --keep-going|-k) KEEP_GOING=1;;
243 --memory|-m) MEMORY=1;;
244 --no-armcc) RUN_ARMCC=0;;
245 --no-force) FORCE=0;;
246 --no-keep-going) KEEP_GOING=0;;
247 --no-memory) MEMORY=0;;
248 --no-yotta) YOTTA=0;;
249 --openssl) shift; OPENSSL="$1";;
250 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
251 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
252 --random-seed) unset SEED;;
253 --release-test|-r) SEED=1;;
254 --seed|-s) shift; SEED="$1";;
255 --yotta) YOTTA=1;;
256 *)
257 echo >&2 "Unknown option: $1"
258 echo >&2 "Run $0 --help for usage."
259 exit 120
260 ;;
261 esac
262 shift
263 done
264}
SimonB2e23c822016-04-16 21:54:39 +0100265
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100266pre_check_git () {
267 if [ $FORCE -eq 1 ]; then
268 if [ $YOTTA -eq 1 ]; then
269 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
270 fi
271 git checkout-index -f -q $CONFIG_H
272 cleanup
273 else
274
275 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
276 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
277 echo "You can either delete your work and retry, or force the test to overwrite the"
278 echo "test by rerunning the script as: $0 --force"
279 exit 1
280 fi
281
282 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
283 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
284 echo "You can either delete this directory manually, or force the test by rerunning"
285 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
286 exit 1
287 fi
288
289 if ! git diff-files --quiet include/mbedtls/config.h; then
290 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
291 echo "You can either delete or preserve your work, or force the test by rerunning the"
292 echo "script as: $0 --force"
293 exit 1
294 fi
Gilles Peskineda519252017-11-30 13:22:04 +0100295 fi
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100296}
SimonB2e23c822016-04-16 21:54:39 +0100297
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100298pre_setup_keep_going () {
Gilles Peskine7c652162017-12-11 00:01:40 +0100299 failure_summary=
300 failure_count=0
301 start_red=
302 end_color=
303 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100304 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100305 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
306 start_red=$(printf '\033[31m')
307 end_color=$(printf '\033[0m')
308 ;;
309 esac
310 fi
311 record_status () {
312 if "$@"; then
313 last_status=0
314 else
315 last_status=$?
316 text="$current_section: $* -> $last_status"
317 failure_summary="$failure_summary
318$text"
319 failure_count=$((failure_count + 1))
320 echo "${start_red}^^^^$text^^^^${end_color}"
321 fi
322 }
323 make () {
324 case "$*" in
325 *test|*check)
326 if [ $build_status -eq 0 ]; then
327 record_status command make "$@"
328 else
329 echo "(skipped because the build failed)"
330 fi
331 ;;
332 *)
333 record_status command make "$@"
334 build_status=$last_status
335 ;;
336 esac
337 }
338 final_report () {
339 if [ $failure_count -gt 0 ]; then
340 echo
341 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
342 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
343 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero5113bde2018-07-20 16:42:14 +0100344 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100345 elif [ -z "${1-}" ]; then
346 echo "SUCCESS :)"
347 fi
348 if [ -n "${1-}" ]; then
349 echo "Killed by SIG$1."
350 fi
351 }
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100352}
353
Gilles Peskine7c652162017-12-11 00:01:40 +0100354if_build_succeeded () {
355 if [ $build_status -eq 0 ]; then
356 record_status "$@"
357 fi
358}
359
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100360pre_print_configuration () {
361 msg "info: $0 configuration"
362 echo "MEMORY: $MEMORY"
363 echo "FORCE: $FORCE"
364 echo "SEED: ${SEED-"UNSET"}"
365 echo "OPENSSL: $OPENSSL"
366 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
367 echo "GNUTLS_CLI: $GNUTLS_CLI"
368 echo "GNUTLS_SERV: $GNUTLS_SERV"
369 echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
370 echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
371 echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
372 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
373}
Andres AG7770ea82016-10-10 15:46:20 +0100374
Andres AGd9eba4b2016-08-26 14:42:14 +0100375# Make sure the tools we need are available.
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100376pre_check_tools () {
377 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
378 ARMC5_AR="$ARMC5_BIN_DIR/armar"
379 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
380 ARMC6_AR="$ARMC6_BIN_DIR/armar"
381
382 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
383 # we just export the variables they require
384 export OPENSSL_CMD="$OPENSSL"
385 export GNUTLS_CLI="$GNUTLS_CLI"
386 export GNUTLS_SERV="$GNUTLS_SERV"
387
388 # Avoid passing --seed flag in every call to ssl-opt.sh
389 if [ -n "${SEED-}" ]; then
390 export SEED
391 fi
392
393 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
394 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
395 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
396 if [ $RUN_ARMCC -ne 0 ]; then
397 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
398 fi
399
400 msg "info: output_env.sh"
401 OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
402 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
403 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
404 ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
405}
Andres AGd9eba4b2016-08-26 14:42:14 +0100406
Gilles Peskine192c72f2017-12-21 15:59:21 +0100407
408
409################################################################
410#### Basic checks
411################################################################
SimonB2e23c822016-04-16 21:54:39 +0100412
413#
414# Test Suites to be executed
415#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200416# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100417# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200418# and/or are more likely to fail than others (eg I use Clang most of the
419# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200420# 2. Minimize total running time, by avoiding useless rebuilds
421#
422# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100423
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100424run_all_the_tests () {
Janos Follathb72c6782016-07-19 14:54:17 +0100425
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100426 msg "test: recursion.pl" # < 1s
427 record_status tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100428
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100429 msg "test: freshness of generated source files" # < 1s
430 record_status tests/scripts/check-generated-files.sh
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000431
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100432 msg "test: doxygen markup outside doxygen blocks" # < 1s
433 record_status tests/scripts/check-doxy-blocks.pl
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200434
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100435 msg "test: check-files.py" # < 1s
Gilles Peskineda519252017-11-30 13:22:04 +0100436 cleanup
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100437 record_status tests/scripts/check-files.py
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200438
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100439 msg "test/build: declared and exported names" # < 3s
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100440 cleanup
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100441 record_status tests/scripts/check-names.sh
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200442
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100443 msg "test: doxygen warnings" # ~ 3s
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100444 cleanup
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100445 record_status tests/scripts/doxygen.sh
Andres Amaya Garciadd29c2f2017-05-04 11:35:51 +0100446
Simon Butcher948f2642018-07-20 21:27:33 +0100447
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100448
449 ################################################################
450 #### Build and test many configurations and targets
451 ################################################################
452
453 if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
454 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
455 # path, and uses whatever version of armcc it finds there.
456 msg "build: create and build yotta module" # ~ 30s
457 cleanup
458 record_status tests/scripts/yotta-build.sh
459 fi
460
461 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Simon Butcher948f2642018-07-20 21:27:33 +0100462 cleanup
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100463 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100464 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200465
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100466 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100467 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100468
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100469 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100470 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100471
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100472 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
473 record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100474
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100475 msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100476 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000477
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100478 msg "test: compat.sh (ASan build)" # ~ 6 min
479 if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000480
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100481 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
482 cleanup
483 cp "$CONFIG_H" "$CONFIG_BAK"
484 scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
485 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
486 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000487
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100488 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
489 make test
490
491 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
492 if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
493 if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
494
495 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
496 if_build_succeeded tests/ssl-opt.sh
497
498 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
499 cleanup
500 cp "$CONFIG_H" "$CONFIG_BAK"
501 scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
502 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
503 make
504
505 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
506 make test
507
508 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
509 if_build_succeeded tests/ssl-opt.sh
510
511 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
512 cleanup
513 cp "$CONFIG_H" "$CONFIG_BAK"
514 scripts/config.pl set MBEDTLS_RSA_NO_CRT
515 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
516 make
517
518 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
519 make test
520
521 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
522 if_build_succeeded tests/ssl-opt.sh -f RSA
523
524 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
525 if_build_succeeded tests/compat.sh -t RSA
526
527 msg "build: cmake, full config, clang" # ~ 50s
528 cleanup
529 cp "$CONFIG_H" "$CONFIG_BAK"
530 scripts/config.pl full
531 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
532 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
533 make
534
535 msg "test: main suites (full config)" # ~ 5s
536 make test
537
538 msg "test: ssl-opt.sh default (full config)" # ~ 1s
539 if_build_succeeded tests/ssl-opt.sh -f Default
540
541 msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
542 if_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'
543
544 msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
545 cleanup
546 cp "$CONFIG_H" "$CONFIG_BAK"
547 scripts/config.pl full
548 scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
549 # Build with -O -Wextra to catch a maximum of issues.
550 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs
551 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
552
553 msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s
554 # No cleanup, just tweak the configuration and rebuild
555 make clean
556 scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
557 scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED
558 # Build with -O -Wextra to catch a maximum of issues.
559 make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs
560 make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
561
562 msg "test/build: curves.pl (gcc)" # ~ 4 min
563 cleanup
564 record_status tests/scripts/curves.pl
565
566 msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
567 cleanup
568 record_status tests/scripts/depends-hashes.pl
569
570 msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
571 cleanup
572 record_status tests/scripts/depends-pkalgs.pl
573
574 msg "test/build: key-exchanges (gcc)" # ~ 1 min
575 cleanup
576 record_status tests/scripts/key-exchanges.pl
577
578 msg "build: Unix make, -Os (gcc)" # ~ 30s
579 cleanup
580 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
581
582 # Full configuration build, without platform support, file IO and net sockets.
583 # This should catch missing mbedtls_printf definitions, and by disabling file
584 # IO, it should catch missing '#include <stdio.h>'
585 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
586 cleanup
587 cp "$CONFIG_H" "$CONFIG_BAK"
588 scripts/config.pl full
589 scripts/config.pl unset MBEDTLS_PLATFORM_C
590 scripts/config.pl unset MBEDTLS_NET_C
591 scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
592 scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
593 scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
594 scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
595 scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
596 scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
597 scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
598 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
599 scripts/config.pl unset MBEDTLS_FS_IO
600 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
601 # to re-enable platform integration features otherwise disabled in C99 builds
602 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
603 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
604
605 # catch compile bugs in _uninit functions
606 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
607 cleanup
608 cp "$CONFIG_H" "$CONFIG_BAK"
609 scripts/config.pl full
610 scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
611 scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
612 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
613
614 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
615 cleanup
616 cp "$CONFIG_H" "$CONFIG_BAK"
617 scripts/config.pl full
618 scripts/config.pl unset MBEDTLS_SSL_SRV_C
619 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
620
621 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
622 cleanup
623 cp "$CONFIG_H" "$CONFIG_BAK"
624 scripts/config.pl full
625 scripts/config.pl unset MBEDTLS_SSL_CLI_C
626 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
627
628 # Note, C99 compliance can also be tested with the sockets support disabled,
629 # as that requires a POSIX platform (which isn't the same as C99).
630 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
631 cleanup
632 cp "$CONFIG_H" "$CONFIG_BAK"
633 scripts/config.pl full
634 scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
635 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
636 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
637
638 msg "build: default config except MFL extension (ASan build)" # ~ 30s
639 cleanup
640 cp "$CONFIG_H" "$CONFIG_BAK"
641 scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
642 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
643 make
644
645 msg "test: ssl-opt.sh, MFL-related tests"
646 if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
647
648 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
649 cleanup
650 cp "$CONFIG_H" "$CONFIG_BAK"
651 scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
652 scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
653 scripts/config.pl set MBEDTLS_ENTROPY_C
654 scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
655 scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
656 scripts/config.pl unset MBEDTLS_HAVEGE_C
657 CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
658 make
659
660 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
661 make test
662
663 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
664 cleanup
665 cp "$CONFIG_H" "$CONFIG_BAK"
666 scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
667 scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
668 scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free
669 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
670 make
671
672 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
673 make test
674
675 if uname -a | grep -F Linux >/dev/null; then
676 msg "build/test: make shared" # ~ 40s
677 cleanup
678 make SHARED=1 all check
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100679 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000680
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100681 if uname -a | grep -F x86_64 >/dev/null; then
682 # Build once with -O0, to compile out the i386 specific inline assembly
683 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
684 cleanup
685 cp "$CONFIG_H" "$CONFIG_BAK"
686 scripts/config.pl full
687 make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
688
689 msg "test: i386, make, gcc -O0 (ASan build)"
690 make test
691
692 # Build again with -O1, to compile in the i386 specific inline assembly
693 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
694 cleanup
695 cp "$CONFIG_H" "$CONFIG_BAK"
696 scripts/config.pl full
697 make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
698
699 msg "test: i386, make, gcc -O1 (ASan build)"
700 make test
701
702 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
703 cleanup
704 cp "$CONFIG_H" "$CONFIG_BAK"
705 scripts/config.pl full
706 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
707
708 msg "test: 64-bit ILP32, make, gcc"
709 make test
710 fi # x86_64
711
712 msg "build: gcc, force 32-bit bignum limbs"
713 cleanup
714 cp "$CONFIG_H" "$CONFIG_BAK"
715 scripts/config.pl unset MBEDTLS_HAVE_ASM
716 scripts/config.pl unset MBEDTLS_AESNI_C
717 scripts/config.pl unset MBEDTLS_PADLOCK_C
718 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
719
720 msg "test: gcc, force 32-bit bignum limbs"
721 make test
722
723 msg "build: gcc, force 64-bit bignum limbs"
724 cleanup
725 cp "$CONFIG_H" "$CONFIG_BAK"
726 scripts/config.pl unset MBEDTLS_HAVE_ASM
727 scripts/config.pl unset MBEDTLS_AESNI_C
728 scripts/config.pl unset MBEDTLS_PADLOCK_C
729 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
730
731 msg "test: gcc, force 64-bit bignum limbs"
732 make test
733
734 msg "build: arm-none-eabi-gcc, make" # ~ 10s
735 cleanup
736 cp "$CONFIG_H" "$CONFIG_BAK"
737 scripts/config.pl full
738 scripts/config.pl unset MBEDTLS_NET_C
739 scripts/config.pl unset MBEDTLS_TIMING_C
740 scripts/config.pl unset MBEDTLS_FS_IO
741 scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
742 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
743 # following things are not in the default config
744 scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
745 scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
746 scripts/config.pl unset MBEDTLS_THREADING_C
747 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
748 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
749 make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
750
751 msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
752 cleanup
753 cp "$CONFIG_H" "$CONFIG_BAK"
754 scripts/config.pl full
755 scripts/config.pl unset MBEDTLS_NET_C
756 scripts/config.pl unset MBEDTLS_TIMING_C
757 scripts/config.pl unset MBEDTLS_FS_IO
758 scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
759 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
760 # following things are not in the default config
761 scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
762 scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
763 scripts/config.pl unset MBEDTLS_THREADING_C
764 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
765 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
766 scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
767 make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
768 echo "Checking that software 64-bit division is not required"
769 ! grep __aeabi_uldiv library/*.o
770
771 msg "build: ARM Compiler 5, make"
772 cleanup
773 cp "$CONFIG_H" "$CONFIG_BAK"
774 scripts/config.pl full
775 scripts/config.pl unset MBEDTLS_NET_C
776 scripts/config.pl unset MBEDTLS_TIMING_C
777 scripts/config.pl unset MBEDTLS_FS_IO
778 scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
779 scripts/config.pl unset MBEDTLS_HAVE_TIME
780 scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
781 scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
782 # following things are not in the default config
783 scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
784 scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
785 scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
786 scripts/config.pl unset MBEDTLS_THREADING_C
787 scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
788 scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
789 scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
790
791 if [ $RUN_ARMCC -ne 0 ]; then
792 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
793 make clean
794
795 # ARM Compiler 6 - Target ARMv7-A
796 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
797
798 # ARM Compiler 6 - Target ARMv7-M
799 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
800
801 # ARM Compiler 6 - Target ARMv8-A - AArch32
802 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
803
804 # ARM Compiler 6 - Target ARMv8-M
805 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
806
807 # ARM Compiler 6 - Target ARMv8-A - AArch64
808 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100809 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000810
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100811 msg "build: allow SHA1 in certificates by default"
812 cleanup
813 cp "$CONFIG_H" "$CONFIG_BAK"
814 scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
815 make CFLAGS='-Werror -Wall -Wextra'
816 msg "test: allow SHA1 in certificates by default"
817 make test
818 if_build_succeeded tests/ssl-opt.sh -f SHA-1
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000819
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100820 msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
821 cleanup
822 cp "$CONFIG_H" "$CONFIG_BAK"
823 scripts/config.pl set MBEDTLS_RSA_NO_CRT
824 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
825 make
Andres AGdc192212016-08-31 17:33:13 +0100826
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100827 msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
828 make test
829
830 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
831 cleanup
832 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
833
834 # note Make tests only builds the tests, but doesn't run them
835 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
836 make WINDOWS_BUILD=1 clean
837
838 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
839 make 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
840 make 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
841 make WINDOWS_BUILD=1 clean
842
843 # MemSan currently only available on Linux 64 bits
844 if uname -a | grep 'Linux.*x86_64' >/dev/null; then
845
846 msg "build: MSan (clang)" # ~ 1 min 20s
847 cleanup
848 cp "$CONFIG_H" "$CONFIG_BAK"
849 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
850 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
851 make
852
853 msg "test: main suites (MSan)" # ~ 10s
854 make test
855
856 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
857 if_build_succeeded tests/ssl-opt.sh
858
859 # Optional part(s)
860
861 if [ "$MEMORY" -gt 0 ]; then
862 msg "test: compat.sh (MSan)" # ~ 6 min 20s
863 if_build_succeeded tests/compat.sh
864 fi
865
866 else # no MemSan
867
868 msg "build: Release (clang)"
869 cleanup
870 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
871 make
872
873 msg "test: main suites valgrind (Release)"
874 make memcheck
875
876 # Optional part(s)
877 # Currently broken, programs don't seem to receive signals
878 # under valgrind on OS X
879
880 if [ "$MEMORY" -gt 0 ]; then
881 msg "test: ssl-opt.sh --memcheck (Release)"
882 if_build_succeeded tests/ssl-opt.sh --memcheck
883 fi
884
885 if [ "$MEMORY" -gt 1 ]; then
886 msg "test: compat.sh --memcheck (Release)"
887 if_build_succeeded tests/compat.sh --memcheck
888 fi
889
890 fi # MemSan
891
892 msg "build: cmake 'out-of-source' build"
893 cleanup
894 MBEDTLS_ROOT_DIR="$PWD"
895 mkdir "$OUT_OF_SOURCE_DIR"
896 cd "$OUT_OF_SOURCE_DIR"
897 cmake "$MBEDTLS_ROOT_DIR"
898 make
899
900 msg "test: cmake 'out-of-source' build"
901 make test
902 # Test an SSL option that requires an auxiliary script in test/scripts/.
903 # Also ensure that there are no error messages such as
904 # "No such file or directory", which would indicate that some required
905 # file is missing (ssl-opt.sh tolerates the absence of some files so
906 # may exit with status 0 but emit errors).
907 if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
908 if [ -s ssl-opt.err ]; then
909 cat ssl-opt.err >&2
910 record_status [ ! -s ssl-opt.err ]
911 rm ssl-opt.err
912 fi
913 cd "$MBEDTLS_ROOT_DIR"
914 rm -rf "$OUT_OF_SOURCE_DIR"
915 unset MBEDTLS_ROOT_DIR
916}
Andres AGdc192212016-08-31 17:33:13 +0100917
Gilles Peskine192c72f2017-12-21 15:59:21 +0100918
919
920################################################################
921#### Termination
922################################################################
923
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100924post_report () {
925 msg "Done, cleaning up"
926 cleanup
927
928 final_report
929}
930
931
932
933################################################################
934#### Run all the things
935################################################################
936
937# Preliminary setup
938pre_check_environment
939pre_initialize_variables
940pre_parse_command_line "$@"
941
942pre_check_git
943build_status=0
944if [ $KEEP_GOING -eq 1 ]; then
945 pre_setup_keep_going
946else
947 record_status () {
948 "$@"
949 }
950fi
951pre_print_configuration
952pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100953cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100954
Gilles Peskine57db6ff2019-01-08 22:04:31 +0100955run_all_the_tests
956
957# We're done.
958post_report