blob: c9c790c8090c0345900f68b446440c23ec7a7ab1 [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 Peskinebca6ab92017-12-19 18:24:31 +010040RUN_ARMCC=1
Gilles Peskineda519252017-11-30 13:22:04 +010041YOTTA=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010042
Andres AGd9eba4b2016-08-26 14:42:14 +010043# Default commands, can be overriden by the environment
44: ${OPENSSL:="openssl"}
45: ${OPENSSL_LEGACY:="$OPENSSL"}
46: ${GNUTLS_CLI:="gnutls-cli"}
47: ${GNUTLS_SERV:="gnutls-serv"}
48: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
49: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +010050: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +010051: ${ARMC5_BIN_DIR:=/usr/bin}
52: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +010053
Andres AG38495a32016-07-12 16:54:33 +010054# if MAKEFLAGS is not set add the -j option to speed up invocations of make
55if [ -n "${MAKEFLAGS+set}" ]; then
56 export MAKEFLAGS="-j"
57fi
58
Simon Butcher41eeccf2016-09-07 00:07:09 +010059usage()
SimonB2e23c822016-04-16 21:54:39 +010060{
Gilles Peskine709346a2017-12-10 23:43:39 +010061 cat <<EOF
62Usage: $0 [OPTION]...
63 -h|--help Print this help.
64
65General options:
66 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +010067 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +010068 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +010069 --armcc Run ARM Compiler builds (on by default).
70 --no-armcc Skip ARM Compiler builds.
Gilles Peskine2a22a802017-12-21 15:19:00 +010071 --no-yotta Skip yotta module build.
Gilles Peskine709346a2017-12-10 23:43:39 +010072 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
73 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
74 -s|--seed Integer seed value to use for this test run.
Gilles Peskine2a22a802017-12-21 15:19:00 +010075 --yotta Build yotta module (on by default).
Gilles Peskine709346a2017-12-10 23:43:39 +010076
77Tool path options:
78 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
79 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
80 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
81 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
82 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
83 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
84 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
85 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
86EOF
SimonB2e23c822016-04-16 21:54:39 +010087}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088
89# remove built files as well as the cmake cache/config
90cleanup()
91{
Gilles Peskine7c652162017-12-11 00:01:40 +010092 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020093
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020094 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000095 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020096 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
97 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020098
99 if [ -f "$CONFIG_BAK" ]; then
100 mv "$CONFIG_BAK" "$CONFIG_H"
101 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100102}
103
Gilles Peskine7c652162017-12-11 00:01:40 +0100104# Executed on exit. May be redefined depending on command line options.
105final_report () {
106 :
107}
108
109fatal_signal () {
110 cleanup
111 final_report $1
112 trap - $1
113 kill -$1 $$
114}
115
116trap 'fatal_signal HUP' HUP
117trap 'fatal_signal INT' INT
118trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200119
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100120msg()
121{
122 echo ""
123 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100124 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000125 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100126 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100127 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100128}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100129
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100130if [ $RUN_ARMCC -ne 0 ]; then
131 armc6_build_test()
132 {
133 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100134
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100135 msg "build: ARM Compiler 6 ($FLAGS), make"
136 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
137 WARNING_CFLAGS='-xc -std=c99' make lib
138 make clean
139 }
140fi
Andres AGa5cd9732016-10-17 15:23:10 +0100141
Andres AGd9eba4b2016-08-26 14:42:14 +0100142err_msg()
143{
144 echo "$1" >&2
145}
146
147check_tools()
148{
149 for TOOL in "$@"; do
150 if ! `hash "$TOOL" >/dev/null 2>&1`; then
151 err_msg "$TOOL not found!"
152 exit 1
153 fi
154 done
155}
156
SimonB2e23c822016-04-16 21:54:39 +0100157while [ $# -gt 0 ]; do
158 case "$1" in
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100159 --armcc)
160 RUN_ARMCC=1
161 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100162 --armc5-bin-dir)
163 shift
164 ARMC5_BIN_DIR="$1"
165 ;;
166 --armc6-bin-dir)
167 shift
168 ARMC6_BIN_DIR="$1"
SimonB2e23c822016-04-16 21:54:39 +0100169 ;;
SimonB2e23c822016-04-16 21:54:39 +0100170 --force|-f)
171 FORCE=1
172 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100173 --gnutls-cli)
174 shift
175 GNUTLS_CLI="$1"
176 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100177 --gnutls-legacy-cli)
178 shift
179 GNUTLS_LEGACY_CLI="$1"
180 ;;
181 --gnutls-legacy-serv)
182 shift
183 GNUTLS_LEGACY_SERV="$1"
184 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100185 --gnutls-serv)
Andres AG87bb5772016-09-27 15:05:15 +0100186 shift
Gilles Peskine709346a2017-12-10 23:43:39 +0100187 GNUTLS_SERV="$1"
Andres AG87bb5772016-09-27 15:05:15 +0100188 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100189 --help|-h)
Andres AGd9eba4b2016-08-26 14:42:14 +0100190 usage
Gilles Peskine709346a2017-12-10 23:43:39 +0100191 exit
192 ;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100193 --keep-going|-k)
194 KEEP_GOING=1
195 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100196 --memory|-m)
197 MEMORY=1
198 ;;
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100199 --no-armcc)
200 RUN_ARMCC=0
201 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100202 --no-yotta)
203 YOTTA=0
204 ;;
205 --openssl)
206 shift
207 OPENSSL="$1"
208 ;;
209 --openssl-legacy)
210 shift
211 OPENSSL_LEGACY="$1"
212 ;;
213 --out-of-source-dir)
214 shift
215 OUT_OF_SOURCE_DIR="$1"
216 ;;
217 --release-test|-r)
218 RELEASE=1
219 ;;
220 --seed|-s)
221 shift
222 SEED="$1"
223 ;;
Gilles Peskine2a22a802017-12-21 15:19:00 +0100224 --yotta)
225 YOTTA=1
226 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100227 *)
228 echo >&2 "Unknown option: $1"
229 echo >&2 "Run $0 --help for usage."
230 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100231 ;;
232 esac
233 shift
234done
235
236if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100237 if [ $YOTTA -eq 1 ]; then
238 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
239 fi
SimonB2e23c822016-04-16 21:54:39 +0100240 git checkout-index -f -q $CONFIG_H
241 cleanup
242else
243
Gilles Peskine2a22a802017-12-21 15:19:00 +0100244 if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100245 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100246 echo "You can either delete your work and retry, or force the test to overwrite the"
247 echo "test by rerunning the script as: $0 --force"
248 exit 1
249 fi
250
Andres AGdc192212016-08-31 17:33:13 +0100251 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
252 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
253 echo "You can either delete this directory manually, or force the test by rerunning"
254 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
255 exit 1
256 fi
257
SimonB2e23c822016-04-16 21:54:39 +0100258 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100259 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100260 echo "You can either delete or preserve your work, or force the test by rerunning the"
261 echo "script as: $0 --force"
262 exit 1
263 fi
264fi
265
Gilles Peskine7c652162017-12-11 00:01:40 +0100266build_status=0
267if [ $KEEP_GOING -eq 1 ]; then
268 failure_summary=
269 failure_count=0
270 start_red=
271 end_color=
272 if [ -t 1 ]; then
273 case "$TERM" in
274 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
275 start_red=$(printf '\033[31m')
276 end_color=$(printf '\033[0m')
277 ;;
278 esac
279 fi
280 record_status () {
281 if "$@"; then
282 last_status=0
283 else
284 last_status=$?
285 text="$current_section: $* -> $last_status"
286 failure_summary="$failure_summary
287$text"
288 failure_count=$((failure_count + 1))
289 echo "${start_red}^^^^$text^^^^${end_color}"
290 fi
291 }
292 make () {
293 case "$*" in
294 *test|*check)
295 if [ $build_status -eq 0 ]; then
296 record_status command make "$@"
297 else
298 echo "(skipped because the build failed)"
299 fi
300 ;;
301 *)
302 record_status command make "$@"
303 build_status=$last_status
304 ;;
305 esac
306 }
307 final_report () {
308 if [ $failure_count -gt 0 ]; then
309 echo
310 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
311 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
312 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
313 elif [ -z "${1-}" ]; then
314 echo "SUCCESS :)"
315 fi
316 if [ -n "${1-}" ]; then
317 echo "Killed by SIG$1."
318 fi
319 }
320else
321 record_status () {
322 "$@"
323 }
324fi
325if_build_succeeded () {
326 if [ $build_status -eq 0 ]; then
327 record_status "$@"
328 fi
329}
330
Andres AG7770ea82016-10-10 15:46:20 +0100331if [ $RELEASE -eq 1 ]; then
332 # Fix the seed value to 1 to ensure that the tests are deterministic.
333 SEED=1
334fi
335
Andres AGd9eba4b2016-08-26 14:42:14 +0100336msg "info: $0 configuration"
337echo "MEMORY: $MEMORY"
338echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100339echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100340echo "OPENSSL: $OPENSSL"
341echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
342echo "GNUTLS_CLI: $GNUTLS_CLI"
343echo "GNUTLS_SERV: $GNUTLS_SERV"
344echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
345echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100346echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
347echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
348
349ARMC5_CC="$ARMC5_BIN_DIR/armcc"
350ARMC5_AR="$ARMC5_BIN_DIR/armar"
351ARMC6_CC="$ARMC6_BIN_DIR/armclang"
352ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100353
Andres AGb2fdd042016-09-22 14:17:46 +0100354# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
355# we just export the variables they require
356export OPENSSL_CMD="$OPENSSL"
357export GNUTLS_CLI="$GNUTLS_CLI"
358export GNUTLS_SERV="$GNUTLS_SERV"
359
Andres AG7770ea82016-10-10 15:46:20 +0100360# Avoid passing --seed flag in every call to ssl-opt.sh
361[ ! -z ${SEED+set} ] && export SEED
362
Andres AGd9eba4b2016-08-26 14:42:14 +0100363# Make sure the tools we need are available.
364check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100365 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100366 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
367if [ $RUN_ARMCC -ne 0 ]; then
368 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
369fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100370
SimonB2e23c822016-04-16 21:54:39 +0100371#
372# Test Suites to be executed
373#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200374# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100375# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200376# and/or are more likely to fail than others (eg I use Clang most of the
377# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200378# 2. Minimize total running time, by avoiding useless rebuilds
379#
380# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100381
Janos Follathb72c6782016-07-19 14:54:17 +0100382msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100383OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
384 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100385 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
386 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100387
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100388msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200389tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100390
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000391msg "test: freshness of generated source files" # < 1s
392tests/scripts/check-generated-files.sh
393
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200394msg "test: doxygen markup outside doxygen blocks" # < 1s
395tests/scripts/check-doxy-blocks.pl
396
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200397msg "test/build: declared and exported names" # < 3s
398cleanup
399tests/scripts/check-names.sh
400
Andres AGd9eba4b2016-08-26 14:42:14 +0100401msg "test: doxygen warnings" # ~ 3s
402cleanup
403tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100404
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100405if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
406 # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
407 # path, and uses whatever version of armcc it finds there.
Gilles Peskineda519252017-11-30 13:22:04 +0100408 msg "build: create and build yotta module" # ~ 30s
409 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100410 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100411fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200412
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100413msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100414cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100415CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100416make
417
Simon Butcher8e3afc72016-09-15 17:13:08 +0100418msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100419make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200420
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100421msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100422if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200423
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100424msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100425if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200426
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200427msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
428make
429
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100430msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100431if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200432
Simon Butcher3ea7f522016-03-07 23:22:10 +0000433msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
434cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000435cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000436scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
437CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
438make
439
Simon Butcher8e3afc72016-09-15 17:13:08 +0100440msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000441make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000442
443msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100444if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
445if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000446
447msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100448if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000449
Hanno Becker134c2ab2017-10-12 15:29:50 +0100450msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
451cleanup
452cp "$CONFIG_H" "$CONFIG_BAK"
453scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
454CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
455make
456
457msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
458make test
459
460msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100461if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100462
Simon Butcherf95c1762016-11-10 17:25:58 +0000463msg "build: cmake, full config, clang, C99" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100464cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100465cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200466scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200467scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000468CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Gilles Peskine7c652162017-12-11 00:01:40 +0100469make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100470
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100471msg "test: main suites (full config)" # ~ 5s
Gilles Peskine7c652162017-12-11 00:01:40 +0100472make CFLAGS='-Werror -Wall -Wextra' test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200473
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100474msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100475if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200476
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100477msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100478if_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 +0200479
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200480msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100481cleanup
482cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskine7c652162017-12-11 00:01:40 +0100483if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100484
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200485msg "test/build: key-exchanges (gcc)" # ~ 1 min
486cleanup
487cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine7c652162017-12-11 00:01:40 +0100488if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200489
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000490msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100491cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100492make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100493
Simon Butcherf95c1762016-11-10 17:25:58 +0000494# Full configuration build, without platform support, file IO and net sockets.
495# This should catch missing mbedtls_printf definitions, and by disabling file
496# IO, it should catch missing '#include <stdio.h>'
497msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000498cleanup
499cp "$CONFIG_H" "$CONFIG_BAK"
500scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200501scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000502scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200503scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100504scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
505scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
506scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100507scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100508scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100509scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200510scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
511scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000512# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
513# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100514make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
515make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000516
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100517# catch compile bugs in _uninit functions
518msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
519cleanup
520cp "$CONFIG_H" "$CONFIG_BAK"
521scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100522scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100523scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100524make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100525
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200526msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
527cleanup
528cp "$CONFIG_H" "$CONFIG_BAK"
529scripts/config.pl full
530scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100531make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200532
533msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
534cleanup
535cp "$CONFIG_H" "$CONFIG_BAK"
536scripts/config.pl full
537scripts/config.pl unset MBEDTLS_SSL_CLI_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100538make CC=gcc CFLAGS='-Werror -Wall -Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200539
Simon Butcherf95c1762016-11-10 17:25:58 +0000540# Note, C99 compliance can also be tested with the sockets support disabled,
541# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100542msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200543cleanup
544cp "$CONFIG_H" "$CONFIG_BAK"
545scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200546scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
547scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100548make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200549
Hanno Becker5175ac62017-09-18 15:36:25 +0100550msg "build: default config except MFL extension (ASan build)" # ~ 30s
551cleanup
552cp "$CONFIG_H" "$CONFIG_BAK"
553scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
554CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
555make
556
557msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100558if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100559
Simon Butcherab5df402016-06-11 02:31:21 +0100560msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100561cleanup
562cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100563scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100564scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
565scripts/config.pl set MBEDTLS_ENTROPY_C
566scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
567scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
568scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100569CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100570make
571
Simon Butcher8e3afc72016-09-15 17:13:08 +0100572msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100573make test
Janos Follath06c54002016-06-09 13:57:40 +0100574
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200575if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100576 msg "build/test: make shared" # ~ 40s
577 cleanup
578 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200579fi
580
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000581if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100582 msg "build: i386, make, gcc" # ~ 30s
583 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100584 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garcia5e873fb2017-05-04 11:35:51 +0100585
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100586 msg "build: gcc, force 32-bit compilation"
587 cleanup
588 cp "$CONFIG_H" "$CONFIG_BAK"
589 scripts/config.pl unset MBEDTLS_HAVE_ASM
590 scripts/config.pl unset MBEDTLS_AESNI_C
591 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100592 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia5e873fb2017-05-04 11:35:51 +0100593
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100594 msg "build: gcc, force 64-bit compilation"
595 cleanup
596 cp "$CONFIG_H" "$CONFIG_BAK"
597 scripts/config.pl unset MBEDTLS_HAVE_ASM
598 scripts/config.pl unset MBEDTLS_AESNI_C
599 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100600 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Andres Amaya Garcia99467832017-07-20 13:21:34 +0100601
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100602 msg "test: gcc, force 64-bit compilation"
603 make test
Andres Amaya Garcia99467832017-07-20 13:21:34 +0100604
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100605 msg "build: gcc, force 64-bit compilation"
606 cleanup
607 cp "$CONFIG_H" "$CONFIG_BAK"
608 scripts/config.pl unset MBEDTLS_HAVE_ASM
609 scripts/config.pl unset MBEDTLS_AESNI_C
610 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100611 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000612fi # x86_64
613
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000614msg "build: arm-none-eabi-gcc, make" # ~ 10s
615cleanup
616cp "$CONFIG_H" "$CONFIG_BAK"
617scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200618scripts/config.pl unset MBEDTLS_NET_C
619scripts/config.pl unset MBEDTLS_TIMING_C
620scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100621scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000622scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000623# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200624scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
625scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
626scripts/config.pl unset MBEDTLS_THREADING_C
627scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
628scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100629make 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 +0000630
Gilles Peskineb1a977f2017-06-08 15:19:20 +0200631msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
632cleanup
Simon Butcher2c4d5582017-07-23 13:42:36 +0200633cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia465db7e2017-07-20 13:27:35 +0100634scripts/config.pl full
635scripts/config.pl unset MBEDTLS_NET_C
636scripts/config.pl unset MBEDTLS_TIMING_C
637scripts/config.pl unset MBEDTLS_FS_IO
638scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
639scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
640# following things are not in the default config
641scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
642scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
643scripts/config.pl unset MBEDTLS_THREADING_C
644scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
645scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineb1a977f2017-06-08 15:19:20 +0200646scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100647make 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 +0200648echo "Checking that software 64-bit division is not required"
649! grep __aeabi_uldiv library/*.o
650
Andres AG87bb5772016-09-27 15:05:15 +0100651msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100652cleanup
653cp "$CONFIG_H" "$CONFIG_BAK"
654scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200655scripts/config.pl unset MBEDTLS_NET_C
656scripts/config.pl unset MBEDTLS_TIMING_C
657scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100658scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200659scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200660scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000661scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100662# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200663scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
664scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
665scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
666scripts/config.pl unset MBEDTLS_THREADING_C
667scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
668scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300669scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100670
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100671if [ $RUN_ARMCC -ne 0 ]; then
672 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
673 make clean
Andres AG87bb5772016-09-27 15:05:15 +0100674
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100675 # ARM Compiler 6 - Target ARMv7-A
676 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200677
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100678 # ARM Compiler 6 - Target ARMv7-M
679 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200680
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100681 # ARM Compiler 6 - Target ARMv8-A - AArch32
682 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200683
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100684 # ARM Compiler 6 - Target ARMv8-M
685 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200686
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100687 # ARM Compiler 6 - Target ARMv8-A - AArch64
688 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
689fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100690
Gilles Peskine2a458da2017-05-12 15:26:58 +0200691msg "build: allow SHA1 in certificates by default"
692cleanup
693cp "$CONFIG_H" "$CONFIG_BAK"
694scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100695make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200696msg "test: allow SHA1 in certificates by default"
697make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100698if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200699
Simon Butcher002bc622016-11-17 09:27:45 +0000700msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100701cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100702make 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 +0000703
Simon Butcher002bc622016-11-17 09:27:45 +0000704# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100705make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
706make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000707
Simon Butcher002bc622016-11-17 09:27:45 +0000708msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +0100709make 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
710make 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
711make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100712
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000713# MemSan currently only available on Linux 64 bits
714if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000715
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100716 msg "build: MSan (clang)" # ~ 1 min 20s
717 cleanup
718 cp "$CONFIG_H" "$CONFIG_BAK"
719 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
720 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
721 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200722
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100723 msg "test: main suites (MSan)" # ~ 10s
724 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100725
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100726 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100727 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100728
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100729 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100730
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100731 if [ "$MEMORY" -gt 0 ]; then
732 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100733 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100734 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100735
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000736else # no MemSan
737
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100738 msg "build: Release (clang)"
739 cleanup
740 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
741 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000742
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100743 msg "test: main suites valgrind (Release)"
744 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000745
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100746 # Optional part(s)
747 # Currently broken, programs don't seem to receive signals
748 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000749
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100750 if [ "$MEMORY" -gt 0 ]; then
751 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100752 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100753 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000754
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100755 if [ "$MEMORY" -gt 1 ]; then
756 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100757 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100758 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000759
760fi # MemSan
761
Andres AGdc192212016-08-31 17:33:13 +0100762msg "build: cmake 'out-of-source' build"
763cleanup
764MBEDTLS_ROOT_DIR="$PWD"
765mkdir "$OUT_OF_SOURCE_DIR"
766cd "$OUT_OF_SOURCE_DIR"
767cmake "$MBEDTLS_ROOT_DIR"
768make
769
770msg "test: cmake 'out-of-source' build"
771make test
772cd "$MBEDTLS_ROOT_DIR"
773rm -rf "$OUT_OF_SOURCE_DIR"
774
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100775msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100776cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100777
778final_report