blob: ae991f13dddff8797d8a8ddc09a47b76c6be6090 [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#
Simon Butcher3ea7f522016-03-07 23:22:10 +00007# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
SimonB2e23c822016-04-16 21:54:39 +010011# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010012#
SimonB2e23c822016-04-16 21:54:39 +010013# Warning: the test is destructive. It includes various build modes and
14# configurations, and can and will arbitrarily change the current CMake
15# configuration. After this script has been run, the CMake cache will be lost
16# and CMake will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010017#
SimonB2e23c822016-04-16 21:54:39 +010018# The script assumes the presence of gcc and clang (recent enough for using
19# ASan with gcc and MemSan with clang, or valgrind) are available, as well as
20# cmake and a "good" find.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010021
SimonB2e23c822016-04-16 21:54:39 +010022# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010023set -eu
24
Andres AG38495a32016-07-12 16:54:33 +010025if [ "$( uname )" != "Linux" ]; then
26 echo "This script only works in Linux" >&2
27 exit 1
28elif [ -d library -a -d include -a -d tests ]; then :; else
29 echo "Must be run from mbed TLS root" >&2
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010030 exit 1
31fi
32
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000033CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020034CONFIG_BAK="$CONFIG_H.bak"
35
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010036MEMORY=0
SimonB2e23c822016-04-16 21:54:39 +010037FORCE=0
Gilles Peskine7c652162017-12-11 00:01:40 +010038KEEP_GOING=0
Andres AG7770ea82016-10-10 15:46:20 +010039RELEASE=0
Gilles Peskineda519252017-11-30 13:22:04 +010040YOTTA=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010041
Andres AGd9eba4b2016-08-26 14:42:14 +010042# Default commands, can be overriden by the environment
43: ${OPENSSL:="openssl"}
44: ${OPENSSL_LEGACY:="$OPENSSL"}
45: ${GNUTLS_CLI:="gnutls-cli"}
46: ${GNUTLS_SERV:="gnutls-serv"}
47: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
48: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +010049: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +010050: ${ARMC5_BIN_DIR:=/usr/bin}
51: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +010052
Andres AG38495a32016-07-12 16:54:33 +010053# if MAKEFLAGS is not set add the -j option to speed up invocations of make
54if [ -n "${MAKEFLAGS+set}" ]; then
55 export MAKEFLAGS="-j"
56fi
57
Simon Butcher41eeccf2016-09-07 00:07:09 +010058usage()
SimonB2e23c822016-04-16 21:54:39 +010059{
Gilles Peskine709346a2017-12-10 23:43:39 +010060 cat <<EOF
61Usage: $0 [OPTION]...
62 -h|--help Print this help.
63
64General options:
65 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +010066 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +010067 -m|--memory Additional optional memory tests.
Gilles Peskine2a22a802017-12-21 15:19:00 +010068 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +010069 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
70 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
71 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +010072 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +010073
74Tool path options:
75 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
76 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
77 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
78 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
79 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
80 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
81 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
82 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
83EOF
SimonB2e23c822016-04-16 21:54:39 +010084}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010085
86# remove built files as well as the cmake cache/config
87cleanup()
88{
Gilles Peskine7c652162017-12-11 00:01:40 +010089 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020090
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020091 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000092 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020093 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
94 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020095
96 if [ -f "$CONFIG_BAK" ]; then
97 mv "$CONFIG_BAK" "$CONFIG_H"
98 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010099}
100
Gilles Peskine7c652162017-12-11 00:01:40 +0100101# Executed on exit. May be redefined depending on command line options.
102final_report () {
103 :
104}
105
106fatal_signal () {
107 cleanup
108 final_report $1
109 trap - $1
110 kill -$1 $$
111}
112
113trap 'fatal_signal HUP' HUP
114trap 'fatal_signal INT' INT
115trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200116
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100117msg()
118{
119 echo ""
120 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100121 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000122 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100123 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100124 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100125}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100126
Andres AGa5cd9732016-10-17 15:23:10 +0100127armc6_build_test()
128{
129 FLAGS="$1"
130
131 msg "build: ARM Compiler 6 ($FLAGS), make"
132 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
Simon Butchercb587002017-01-06 16:14:44 +0000133 WARNING_CFLAGS='-xc -std=c99' make lib
Andres AGa5cd9732016-10-17 15:23:10 +0100134 make clean
135}
136
Andres AGd9eba4b2016-08-26 14:42:14 +0100137err_msg()
138{
139 echo "$1" >&2
140}
141
142check_tools()
143{
144 for TOOL in "$@"; do
145 if ! `hash "$TOOL" >/dev/null 2>&1`; then
146 err_msg "$TOOL not found!"
147 exit 1
148 fi
149 done
150}
151
SimonB2e23c822016-04-16 21:54:39 +0100152while [ $# -gt 0 ]; do
153 case "$1" in
Gilles Peskine709346a2017-12-10 23:43:39 +0100154 --armc5-bin-dir)
155 shift
156 ARMC5_BIN_DIR="$1"
157 ;;
158 --armc6-bin-dir)
159 shift
160 ARMC6_BIN_DIR="$1"
SimonB2e23c822016-04-16 21:54:39 +0100161 ;;
SimonB2e23c822016-04-16 21:54:39 +0100162 --force|-f)
163 FORCE=1
164 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100165 --gnutls-cli)
166 shift
167 GNUTLS_CLI="$1"
168 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100169 --gnutls-legacy-cli)
170 shift
171 GNUTLS_LEGACY_CLI="$1"
172 ;;
173 --gnutls-legacy-serv)
174 shift
175 GNUTLS_LEGACY_SERV="$1"
176 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100177 --gnutls-serv)
Andres AG87bb5772016-09-27 15:05:15 +0100178 shift
Gilles Peskine709346a2017-12-10 23:43:39 +0100179 GNUTLS_SERV="$1"
Andres AG87bb5772016-09-27 15:05:15 +0100180 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100181 --help|-h)
Andres AGd9eba4b2016-08-26 14:42:14 +0100182 usage
Gilles Peskine709346a2017-12-10 23:43:39 +0100183 exit
184 ;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100185 --keep-going|-k)
186 KEEP_GOING=1
187 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100188 --memory|-m)
189 MEMORY=1
190 ;;
191 --no-yotta)
192 YOTTA=0
193 ;;
194 --openssl)
195 shift
196 OPENSSL="$1"
197 ;;
198 --openssl-legacy)
199 shift
200 OPENSSL_LEGACY="$1"
201 ;;
202 --out-of-source-dir)
203 shift
204 OUT_OF_SOURCE_DIR="$1"
205 ;;
206 --release-test|-r)
207 RELEASE=1
208 ;;
209 --seed|-s)
210 shift
211 SEED="$1"
212 ;;
Gilles Peskine2a22a802017-12-21 15:19:00 +0100213 --yotta)
214 YOTTA=1
215 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100216 *)
217 echo >&2 "Unknown option: $1"
218 echo >&2 "Run $0 --help for usage."
219 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100220 ;;
221 esac
222 shift
223done
224
225if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100226 if [ $YOTTA -eq 1 ]; then
227 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
228 fi
SimonB2e23c822016-04-16 21:54:39 +0100229 git checkout-index -f -q $CONFIG_H
230 cleanup
231else
232
Gilles Peskine2a22a802017-12-21 15:19:00 +0100233 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100234 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100235 echo "You can either delete your work and retry, or force the test to overwrite the"
236 echo "test by rerunning the script as: $0 --force"
237 exit 1
238 fi
239
Andres AGdc192212016-08-31 17:33:13 +0100240 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
241 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
242 echo "You can either delete this directory manually, or force the test by rerunning"
243 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
244 exit 1
245 fi
246
SimonB2e23c822016-04-16 21:54:39 +0100247 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100248 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100249 echo "You can either delete or preserve your work, or force the test by rerunning the"
250 echo "script as: $0 --force"
251 exit 1
252 fi
253fi
254
Gilles Peskine7c652162017-12-11 00:01:40 +0100255build_status=0
256if [ $KEEP_GOING -eq 1 ]; then
257 failure_summary=
258 failure_count=0
259 start_red=
260 end_color=
261 if [ -t 1 ]; then
262 case "$TERM" in
263 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
264 start_red=$(printf '\033[31m')
265 end_color=$(printf '\033[0m')
266 ;;
267 esac
268 fi
269 record_status () {
270 if "$@"; then
271 last_status=0
272 else
273 last_status=$?
274 text="$current_section: $* -> $last_status"
275 failure_summary="$failure_summary
276$text"
277 failure_count=$((failure_count + 1))
278 echo "${start_red}^^^^$text^^^^${end_color}"
279 fi
280 }
281 make () {
282 case "$*" in
283 *test|*check)
284 if [ $build_status -eq 0 ]; then
285 record_status command make "$@"
286 else
287 echo "(skipped because the build failed)"
288 fi
289 ;;
290 *)
291 record_status command make "$@"
292 build_status=$last_status
293 ;;
294 esac
295 }
296 final_report () {
297 if [ $failure_count -gt 0 ]; then
298 echo
299 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
300 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
301 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
302 elif [ -z "${1-}" ]; then
303 echo "SUCCESS :)"
304 fi
305 if [ -n "${1-}" ]; then
306 echo "Killed by SIG$1."
307 fi
308 }
309else
310 record_status () {
311 "$@"
312 }
313fi
314if_build_succeeded () {
315 if [ $build_status -eq 0 ]; then
316 record_status "$@"
317 fi
318}
319
Andres AG7770ea82016-10-10 15:46:20 +0100320if [ $RELEASE -eq 1 ]; then
321 # Fix the seed value to 1 to ensure that the tests are deterministic.
322 SEED=1
323fi
324
Andres AGd9eba4b2016-08-26 14:42:14 +0100325msg "info: $0 configuration"
326echo "MEMORY: $MEMORY"
327echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100328echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100329echo "OPENSSL: $OPENSSL"
330echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
331echo "GNUTLS_CLI: $GNUTLS_CLI"
332echo "GNUTLS_SERV: $GNUTLS_SERV"
333echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
334echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100335echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
336echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
337
338ARMC5_CC="$ARMC5_BIN_DIR/armcc"
339ARMC5_AR="$ARMC5_BIN_DIR/armar"
340ARMC6_CC="$ARMC6_BIN_DIR/armclang"
341ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100342
Andres AGb2fdd042016-09-22 14:17:46 +0100343# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
344# we just export the variables they require
345export OPENSSL_CMD="$OPENSSL"
346export GNUTLS_CLI="$GNUTLS_CLI"
347export GNUTLS_SERV="$GNUTLS_SERV"
348
Andres AG7770ea82016-10-10 15:46:20 +0100349# Avoid passing --seed flag in every call to ssl-opt.sh
350[ ! -z ${SEED+set} ] && export SEED
351
Andres AGd9eba4b2016-08-26 14:42:14 +0100352# Make sure the tools we need are available.
353check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100354 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
355 "arm-none-eabi-gcc" "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR" \
356 "i686-w64-mingw32-gcc"
Andres AGd9eba4b2016-08-26 14:42:14 +0100357
SimonB2e23c822016-04-16 21:54:39 +0100358#
359# Test Suites to be executed
360#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200361# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100362# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200363# and/or are more likely to fail than others (eg I use Clang most of the
364# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200365# 2. Minimize total running time, by avoiding useless rebuilds
366#
367# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100368
Janos Follathb72c6782016-07-19 14:54:17 +0100369msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100370OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
371 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100372 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
373 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100374
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100375msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200376tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100377
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000378msg "test: freshness of generated source files" # < 1s
379tests/scripts/check-generated-files.sh
380
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200381msg "test: doxygen markup outside doxygen blocks" # < 1s
382tests/scripts/check-doxy-blocks.pl
383
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200384msg "test/build: declared and exported names" # < 3s
385cleanup
386tests/scripts/check-names.sh
387
Andres AGd9eba4b2016-08-26 14:42:14 +0100388msg "test: doxygen warnings" # ~ 3s
389cleanup
390tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100391
Gilles Peskineda519252017-11-30 13:22:04 +0100392if [ $YOTTA -ne 0 ]; then
393 # Note - use of yotta is deprecated, and yotta also requires armcc to be
394 # on the path, and uses whatever version of armcc it finds there.
395 msg "build: create and build yotta module" # ~ 30s
396 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100397 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100398fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200399
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100400msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100401cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100402CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100403make
404
Simon Butcher8e3afc72016-09-15 17:13:08 +0100405msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100406make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200407
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100408msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100409if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200410
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100411msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100412if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200413
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200414msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
415make
416
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100417msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100418if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200419
Simon Butcher3ea7f522016-03-07 23:22:10 +0000420msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
421cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000422cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000423scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
424CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
425make
426
Simon Butcher8e3afc72016-09-15 17:13:08 +0100427msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000428make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000429
430msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100431if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
432if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000433
434msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100435if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000436
Hanno Becker134c2ab2017-10-12 15:29:50 +0100437msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
438cleanup
439cp "$CONFIG_H" "$CONFIG_BAK"
440scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
441CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
442make
443
444msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
445make test
446
447msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100448if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100449
Simon Butcherf95c1762016-11-10 17:25:58 +0000450msg "build: cmake, full config, clang, C99" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100451cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100452cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200453scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200454scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000455CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Gilles Peskine7c652162017-12-11 00:01:40 +0100456make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100457
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100458msg "test: main suites (full config)" # ~ 5s
Gilles Peskine7c652162017-12-11 00:01:40 +0100459make CFLAGS='-Werror -Wall -Wextra' test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200460
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100461msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100462if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200463
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100464msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100465if_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 +0200466
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200467msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100468cleanup
469cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskine7c652162017-12-11 00:01:40 +0100470if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100471
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200472msg "test/build: key-exchanges (gcc)" # ~ 1 min
473cleanup
474cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine7c652162017-12-11 00:01:40 +0100475if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200476
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000477msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100478cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100479make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100480
Simon Butcherf95c1762016-11-10 17:25:58 +0000481# Full configuration build, without platform support, file IO and net sockets.
482# This should catch missing mbedtls_printf definitions, and by disabling file
483# IO, it should catch missing '#include <stdio.h>'
484msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000485cleanup
486cp "$CONFIG_H" "$CONFIG_BAK"
487scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200488scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000489scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200490scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100491scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
492scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
493scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100494scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100495scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100496scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200497scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
498scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000499# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
500# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100501make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
502make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000503
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100504# catch compile bugs in _uninit functions
505msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
506cleanup
507cp "$CONFIG_H" "$CONFIG_BAK"
508scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100509scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100510scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100511make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100512
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200513msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
514cleanup
515cp "$CONFIG_H" "$CONFIG_BAK"
516scripts/config.pl full
517scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100518make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200519
520msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
521cleanup
522cp "$CONFIG_H" "$CONFIG_BAK"
523scripts/config.pl full
524scripts/config.pl unset MBEDTLS_SSL_CLI_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100525make CC=gcc CFLAGS='-Werror -Wall -Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200526
Simon Butcherf95c1762016-11-10 17:25:58 +0000527# Note, C99 compliance can also be tested with the sockets support disabled,
528# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100529msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200530cleanup
531cp "$CONFIG_H" "$CONFIG_BAK"
532scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200533scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
534scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100535make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200536
Hanno Becker5175ac62017-09-18 15:36:25 +0100537msg "build: default config except MFL extension (ASan build)" # ~ 30s
538cleanup
539cp "$CONFIG_H" "$CONFIG_BAK"
540scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
541CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
542make
543
544msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100545if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100546
Simon Butcherab5df402016-06-11 02:31:21 +0100547msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100548cleanup
549cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100550scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100551scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
552scripts/config.pl set MBEDTLS_ENTROPY_C
553scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
554scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
555scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100556CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100557make
558
Simon Butcher8e3afc72016-09-15 17:13:08 +0100559msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100560make test
Janos Follath06c54002016-06-09 13:57:40 +0100561
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200562if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100563 msg "build/test: make shared" # ~ 40s
564 cleanup
565 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200566fi
567
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000568if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100569 msg "build: i386, make, gcc" # ~ 30s
570 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100571 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garcia5e873fb2017-05-04 11:35:51 +0100572
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100573 msg "build: gcc, force 32-bit compilation"
574 cleanup
575 cp "$CONFIG_H" "$CONFIG_BAK"
576 scripts/config.pl unset MBEDTLS_HAVE_ASM
577 scripts/config.pl unset MBEDTLS_AESNI_C
578 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100579 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia5e873fb2017-05-04 11:35:51 +0100580
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100581 msg "build: gcc, force 64-bit compilation"
582 cleanup
583 cp "$CONFIG_H" "$CONFIG_BAK"
584 scripts/config.pl unset MBEDTLS_HAVE_ASM
585 scripts/config.pl unset MBEDTLS_AESNI_C
586 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100587 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Andres Amaya Garcia99467832017-07-20 13:21:34 +0100588
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100589 msg "test: gcc, force 64-bit compilation"
590 make test
Andres Amaya Garcia99467832017-07-20 13:21:34 +0100591
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100592 msg "build: gcc, force 64-bit compilation"
593 cleanup
594 cp "$CONFIG_H" "$CONFIG_BAK"
595 scripts/config.pl unset MBEDTLS_HAVE_ASM
596 scripts/config.pl unset MBEDTLS_AESNI_C
597 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100598 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000599fi # x86_64
600
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000601msg "build: arm-none-eabi-gcc, make" # ~ 10s
602cleanup
603cp "$CONFIG_H" "$CONFIG_BAK"
604scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200605scripts/config.pl unset MBEDTLS_NET_C
606scripts/config.pl unset MBEDTLS_TIMING_C
607scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100608scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000609scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000610# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200611scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
612scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
613scripts/config.pl unset MBEDTLS_THREADING_C
614scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
615scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100616make 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 +0000617
Gilles Peskineb1a977f2017-06-08 15:19:20 +0200618msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
619cleanup
Simon Butcher2c4d5582017-07-23 13:42:36 +0200620cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia465db7e2017-07-20 13:27:35 +0100621scripts/config.pl full
622scripts/config.pl unset MBEDTLS_NET_C
623scripts/config.pl unset MBEDTLS_TIMING_C
624scripts/config.pl unset MBEDTLS_FS_IO
625scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
626scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
627# following things are not in the default config
628scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
629scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
630scripts/config.pl unset MBEDTLS_THREADING_C
631scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
632scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineb1a977f2017-06-08 15:19:20 +0200633scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100634make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskineb1a977f2017-06-08 15:19:20 +0200635echo "Checking that software 64-bit division is not required"
636! grep __aeabi_uldiv library/*.o
637
Andres AG87bb5772016-09-27 15:05:15 +0100638msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100639cleanup
640cp "$CONFIG_H" "$CONFIG_BAK"
641scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200642scripts/config.pl unset MBEDTLS_NET_C
643scripts/config.pl unset MBEDTLS_TIMING_C
644scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100645scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200646scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200647scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000648scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100649# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200650scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
651scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
652scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
653scripts/config.pl unset MBEDTLS_THREADING_C
654scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
655scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300656scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100657
Gilles Peskine7c652162017-12-11 00:01:40 +0100658make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Andres AG87bb5772016-09-27 15:05:15 +0100659make clean
660
Simon Butcher2c4d5582017-07-23 13:42:36 +0200661# ARM Compiler 6 - Target ARMv7-A
Andres AGa5cd9732016-10-17 15:23:10 +0100662armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200663
664# ARM Compiler 6 - Target ARMv7-M
Andres AGa5cd9732016-10-17 15:23:10 +0100665armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200666
667# ARM Compiler 6 - Target ARMv8-A - AArch32
Andres AGa5cd9732016-10-17 15:23:10 +0100668armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200669
670# ARM Compiler 6 - Target ARMv8-M
Andres AGa5cd9732016-10-17 15:23:10 +0100671armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200672
673# ARM Compiler 6 - Target ARMv8-A - AArch64
674armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100675
Gilles Peskine2a458da2017-05-12 15:26:58 +0200676msg "build: allow SHA1 in certificates by default"
677cleanup
678cp "$CONFIG_H" "$CONFIG_BAK"
679scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100680make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200681msg "test: allow SHA1 in certificates by default"
682make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100683if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200684
Simon Butcher002bc622016-11-17 09:27:45 +0000685msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100686cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100687make 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 +0000688
Simon Butcher002bc622016-11-17 09:27:45 +0000689# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100690make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
691make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000692
Simon Butcher002bc622016-11-17 09:27:45 +0000693msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100694make 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
695make 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
696make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100697
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000698# MemSan currently only available on Linux 64 bits
699if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000700
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100701 msg "build: MSan (clang)" # ~ 1 min 20s
702 cleanup
703 cp "$CONFIG_H" "$CONFIG_BAK"
704 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
705 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
706 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200707
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100708 msg "test: main suites (MSan)" # ~ 10s
709 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100710
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100711 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100712 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100713
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100714 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100715
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100716 if [ "$MEMORY" -gt 0 ]; then
717 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100718 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100719 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100720
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000721else # no MemSan
722
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100723 msg "build: Release (clang)"
724 cleanup
725 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
726 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000727
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100728 msg "test: main suites valgrind (Release)"
729 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000730
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100731 # Optional part(s)
732 # Currently broken, programs don't seem to receive signals
733 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000734
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100735 if [ "$MEMORY" -gt 0 ]; then
736 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100737 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100738 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000739
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100740 if [ "$MEMORY" -gt 1 ]; then
741 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100742 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100743 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000744
745fi # MemSan
746
Andres AGdc192212016-08-31 17:33:13 +0100747msg "build: cmake 'out-of-source' build"
748cleanup
749MBEDTLS_ROOT_DIR="$PWD"
750mkdir "$OUT_OF_SOURCE_DIR"
751cd "$OUT_OF_SOURCE_DIR"
752cmake "$MBEDTLS_ROOT_DIR"
753make
754
755msg "test: cmake 'out-of-source' build"
756make test
757cd "$MBEDTLS_ROOT_DIR"
758rm -rf "$OUT_OF_SOURCE_DIR"
759
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100760msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100761cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100762
763final_report