blob: 923932f215febaaae3b443db2a4b82edfe199cd4 [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.
68 --no-yotta Skip yotta build.
69 --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.
72
73Tool path options:
74 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
75 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
76 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
77 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
78 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
79 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
80 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
81 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
82EOF
SimonB2e23c822016-04-16 21:54:39 +010083}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010084
85# remove built files as well as the cmake cache/config
86cleanup()
87{
Gilles Peskine7c652162017-12-11 00:01:40 +010088 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020089
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020090 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000091 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020092 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
93 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020094
95 if [ -f "$CONFIG_BAK" ]; then
96 mv "$CONFIG_BAK" "$CONFIG_H"
97 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010098}
99
Gilles Peskine7c652162017-12-11 00:01:40 +0100100# Executed on exit. May be redefined depending on command line options.
101final_report () {
102 :
103}
104
105fatal_signal () {
106 cleanup
107 final_report $1
108 trap - $1
109 kill -$1 $$
110}
111
112trap 'fatal_signal HUP' HUP
113trap 'fatal_signal INT' INT
114trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200115
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100116msg()
117{
118 echo ""
119 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100120 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000121 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100122 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100123 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100124}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100125
Andres AGa5cd9732016-10-17 15:23:10 +0100126armc6_build_test()
127{
128 FLAGS="$1"
129
130 msg "build: ARM Compiler 6 ($FLAGS), make"
131 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
Simon Butchercb587002017-01-06 16:14:44 +0000132 WARNING_CFLAGS='-xc -std=c99' make lib
Andres AGa5cd9732016-10-17 15:23:10 +0100133 make clean
134}
135
Andres AGd9eba4b2016-08-26 14:42:14 +0100136err_msg()
137{
138 echo "$1" >&2
139}
140
141check_tools()
142{
143 for TOOL in "$@"; do
144 if ! `hash "$TOOL" >/dev/null 2>&1`; then
145 err_msg "$TOOL not found!"
146 exit 1
147 fi
148 done
149}
150
SimonB2e23c822016-04-16 21:54:39 +0100151while [ $# -gt 0 ]; do
152 case "$1" in
Gilles Peskine709346a2017-12-10 23:43:39 +0100153 --armc5-bin-dir)
154 shift
155 ARMC5_BIN_DIR="$1"
156 ;;
157 --armc6-bin-dir)
158 shift
159 ARMC6_BIN_DIR="$1"
SimonB2e23c822016-04-16 21:54:39 +0100160 ;;
SimonB2e23c822016-04-16 21:54:39 +0100161 --force|-f)
162 FORCE=1
163 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100164 --gnutls-cli)
165 shift
166 GNUTLS_CLI="$1"
167 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100168 --gnutls-legacy-cli)
169 shift
170 GNUTLS_LEGACY_CLI="$1"
171 ;;
172 --gnutls-legacy-serv)
173 shift
174 GNUTLS_LEGACY_SERV="$1"
175 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100176 --gnutls-serv)
Andres AG87bb5772016-09-27 15:05:15 +0100177 shift
Gilles Peskine709346a2017-12-10 23:43:39 +0100178 GNUTLS_SERV="$1"
Andres AG87bb5772016-09-27 15:05:15 +0100179 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100180 --help|-h)
Andres AGd9eba4b2016-08-26 14:42:14 +0100181 usage
Gilles Peskine709346a2017-12-10 23:43:39 +0100182 exit
183 ;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100184 --keep-going|-k)
185 KEEP_GOING=1
186 ;;
Gilles Peskine709346a2017-12-10 23:43:39 +0100187 --memory|-m)
188 MEMORY=1
189 ;;
190 --no-yotta)
191 YOTTA=0
192 ;;
193 --openssl)
194 shift
195 OPENSSL="$1"
196 ;;
197 --openssl-legacy)
198 shift
199 OPENSSL_LEGACY="$1"
200 ;;
201 --out-of-source-dir)
202 shift
203 OUT_OF_SOURCE_DIR="$1"
204 ;;
205 --release-test|-r)
206 RELEASE=1
207 ;;
208 --seed|-s)
209 shift
210 SEED="$1"
211 ;;
212 *)
213 echo >&2 "Unknown option: $1"
214 echo >&2 "Run $0 --help for usage."
215 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100216 ;;
217 esac
218 shift
219done
220
221if [ $FORCE -eq 1 ]; then
Gilles Peskineda519252017-11-30 13:22:04 +0100222 if [ $YOTTA -eq 1 ]; then
223 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
224 fi
SimonB2e23c822016-04-16 21:54:39 +0100225 git checkout-index -f -q $CONFIG_H
226 cleanup
227else
228
Gilles Peskineda519252017-11-30 13:22:04 +0100229 if [ $YOTTA -eq 1 ] && [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100230 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100231 echo "You can either delete your work and retry, or force the test to overwrite the"
232 echo "test by rerunning the script as: $0 --force"
233 exit 1
234 fi
235
Andres AGdc192212016-08-31 17:33:13 +0100236 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
237 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
238 echo "You can either delete this directory manually, or force the test by rerunning"
239 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
240 exit 1
241 fi
242
SimonB2e23c822016-04-16 21:54:39 +0100243 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100244 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100245 echo "You can either delete or preserve your work, or force the test by rerunning the"
246 echo "script as: $0 --force"
247 exit 1
248 fi
249fi
250
Gilles Peskine7c652162017-12-11 00:01:40 +0100251build_status=0
252if [ $KEEP_GOING -eq 1 ]; then
253 failure_summary=
254 failure_count=0
255 start_red=
256 end_color=
257 if [ -t 1 ]; then
258 case "$TERM" in
259 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
260 start_red=$(printf '\033[31m')
261 end_color=$(printf '\033[0m')
262 ;;
263 esac
264 fi
265 record_status () {
266 if "$@"; then
267 last_status=0
268 else
269 last_status=$?
270 text="$current_section: $* -> $last_status"
271 failure_summary="$failure_summary
272$text"
273 failure_count=$((failure_count + 1))
274 echo "${start_red}^^^^$text^^^^${end_color}"
275 fi
276 }
277 make () {
278 case "$*" in
279 *test|*check)
280 if [ $build_status -eq 0 ]; then
281 record_status command make "$@"
282 else
283 echo "(skipped because the build failed)"
284 fi
285 ;;
286 *)
287 record_status command make "$@"
288 build_status=$last_status
289 ;;
290 esac
291 }
292 final_report () {
293 if [ $failure_count -gt 0 ]; then
294 echo
295 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
296 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
297 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
298 elif [ -z "${1-}" ]; then
299 echo "SUCCESS :)"
300 fi
301 if [ -n "${1-}" ]; then
302 echo "Killed by SIG$1."
303 fi
304 }
305else
306 record_status () {
307 "$@"
308 }
309fi
310if_build_succeeded () {
311 if [ $build_status -eq 0 ]; then
312 record_status "$@"
313 fi
314}
315
Andres AG7770ea82016-10-10 15:46:20 +0100316if [ $RELEASE -eq 1 ]; then
317 # Fix the seed value to 1 to ensure that the tests are deterministic.
318 SEED=1
319fi
320
Andres AGd9eba4b2016-08-26 14:42:14 +0100321msg "info: $0 configuration"
322echo "MEMORY: $MEMORY"
323echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100324echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100325echo "OPENSSL: $OPENSSL"
326echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
327echo "GNUTLS_CLI: $GNUTLS_CLI"
328echo "GNUTLS_SERV: $GNUTLS_SERV"
329echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
330echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100331echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
332echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
333
334ARMC5_CC="$ARMC5_BIN_DIR/armcc"
335ARMC5_AR="$ARMC5_BIN_DIR/armar"
336ARMC6_CC="$ARMC6_BIN_DIR/armclang"
337ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100338
Andres AGb2fdd042016-09-22 14:17:46 +0100339# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
340# we just export the variables they require
341export OPENSSL_CMD="$OPENSSL"
342export GNUTLS_CLI="$GNUTLS_CLI"
343export GNUTLS_SERV="$GNUTLS_SERV"
344
Andres AG7770ea82016-10-10 15:46:20 +0100345# Avoid passing --seed flag in every call to ssl-opt.sh
346[ ! -z ${SEED+set} ] && export SEED
347
Andres AGd9eba4b2016-08-26 14:42:14 +0100348# Make sure the tools we need are available.
349check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100350 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
351 "arm-none-eabi-gcc" "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR" \
352 "i686-w64-mingw32-gcc"
Andres AGd9eba4b2016-08-26 14:42:14 +0100353
SimonB2e23c822016-04-16 21:54:39 +0100354#
355# Test Suites to be executed
356#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200357# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100358# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200359# and/or are more likely to fail than others (eg I use Clang most of the
360# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200361# 2. Minimize total running time, by avoiding useless rebuilds
362#
363# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100364
Janos Follathb72c6782016-07-19 14:54:17 +0100365msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100366OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
367 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100368 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
369 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100370
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100371msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200372tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100373
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000374msg "test: freshness of generated source files" # < 1s
375tests/scripts/check-generated-files.sh
376
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200377msg "test: doxygen markup outside doxygen blocks" # < 1s
378tests/scripts/check-doxy-blocks.pl
379
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200380msg "test/build: declared and exported names" # < 3s
381cleanup
382tests/scripts/check-names.sh
383
Andres AGd9eba4b2016-08-26 14:42:14 +0100384msg "test: doxygen warnings" # ~ 3s
385cleanup
386tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100387
Gilles Peskineda519252017-11-30 13:22:04 +0100388if [ $YOTTA -ne 0 ]; then
389 # Note - use of yotta is deprecated, and yotta also requires armcc to be
390 # on the path, and uses whatever version of armcc it finds there.
391 msg "build: create and build yotta module" # ~ 30s
392 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100393 record_status tests/scripts/yotta-build.sh
Gilles Peskineda519252017-11-30 13:22:04 +0100394fi
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200395
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100396msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100397cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100398CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100399make
400
Simon Butcher8e3afc72016-09-15 17:13:08 +0100401msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100402make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200403
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100404msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100405if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200406
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100407msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100408if_build_succeeded tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200409
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200410msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
411make
412
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100413msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100414if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200415
Simon Butcher3ea7f522016-03-07 23:22:10 +0000416msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
417cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000418cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000419scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
420CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
421make
422
Simon Butcher8e3afc72016-09-15 17:13:08 +0100423msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000424make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000425
426msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100427if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
428if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000429
430msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100431if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000432
Hanno Becker134c2ab2017-10-12 15:29:50 +0100433msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
434cleanup
435cp "$CONFIG_H" "$CONFIG_BAK"
436scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
437CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
438make
439
440msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
441make test
442
443msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100444if_build_succeeded tests/ssl-opt.sh
Hanno Becker134c2ab2017-10-12 15:29:50 +0100445
Simon Butcherf95c1762016-11-10 17:25:58 +0000446msg "build: cmake, full config, clang, C99" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100447cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100448cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200449scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200450scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000451CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Gilles Peskine7c652162017-12-11 00:01:40 +0100452make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100453
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100454msg "test: main suites (full config)" # ~ 5s
Gilles Peskine7c652162017-12-11 00:01:40 +0100455make CFLAGS='-Werror -Wall -Wextra' test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200456
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100457msg "test: ssl-opt.sh default (full config)" # ~ 1s
Gilles Peskine7c652162017-12-11 00:01:40 +0100458if_build_succeeded tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200459
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100460msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100461if_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 +0200462
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200463msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100464cleanup
465cmake -D CMAKE_BUILD_TYPE:String=Debug .
Gilles Peskine7c652162017-12-11 00:01:40 +0100466if_build_succeeded tests/scripts/curves.pl
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100467
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200468msg "test/build: key-exchanges (gcc)" # ~ 1 min
469cleanup
470cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine7c652162017-12-11 00:01:40 +0100471if_build_succeeded tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200472
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000473msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100474cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100475make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100476
Simon Butcherf95c1762016-11-10 17:25:58 +0000477# Full configuration build, without platform support, file IO and net sockets.
478# This should catch missing mbedtls_printf definitions, and by disabling file
479# IO, it should catch missing '#include <stdio.h>'
480msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000481cleanup
482cp "$CONFIG_H" "$CONFIG_BAK"
483scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200484scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000485scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200486scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100487scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
488scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
489scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100490scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100491scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100492scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200493scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
494scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000495# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
496# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100497make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
498make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000499
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100500# catch compile bugs in _uninit functions
501msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
502cleanup
503cp "$CONFIG_H" "$CONFIG_BAK"
504scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100505scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100506scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100507make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100508
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200509msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
510cleanup
511cp "$CONFIG_H" "$CONFIG_BAK"
512scripts/config.pl full
513scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100514make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200515
516msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
517cleanup
518cp "$CONFIG_H" "$CONFIG_BAK"
519scripts/config.pl full
520scripts/config.pl unset MBEDTLS_SSL_CLI_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100521make CC=gcc CFLAGS='-Werror -Wall -Werror -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200522
Simon Butcherf95c1762016-11-10 17:25:58 +0000523# Note, C99 compliance can also be tested with the sockets support disabled,
524# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100525msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200526cleanup
527cp "$CONFIG_H" "$CONFIG_BAK"
528scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200529scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
530scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100531make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200532
Hanno Becker5175ac62017-09-18 15:36:25 +0100533msg "build: default config except MFL extension (ASan build)" # ~ 30s
534cleanup
535cp "$CONFIG_H" "$CONFIG_BAK"
536scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
537CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
538make
539
540msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100541if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Hanno Becker5175ac62017-09-18 15:36:25 +0100542
Simon Butcherab5df402016-06-11 02:31:21 +0100543msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100544cleanup
545cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100546scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100547scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
548scripts/config.pl set MBEDTLS_ENTROPY_C
549scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
550scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
551scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100552CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100553make
554
Simon Butcher8e3afc72016-09-15 17:13:08 +0100555msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100556make test
Janos Follath06c54002016-06-09 13:57:40 +0100557
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200558if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100559 msg "build/test: make shared" # ~ 40s
560 cleanup
561 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200562fi
563
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000564if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100565 msg "build: i386, make, gcc" # ~ 30s
566 cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100567 make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
Andres Amaya Garcia5e873fb2017-05-04 11:35:51 +0100568
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100569 msg "build: gcc, force 32-bit compilation"
570 cleanup
571 cp "$CONFIG_H" "$CONFIG_BAK"
572 scripts/config.pl unset MBEDTLS_HAVE_ASM
573 scripts/config.pl unset MBEDTLS_AESNI_C
574 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100575 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia5e873fb2017-05-04 11:35:51 +0100576
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100577 msg "build: gcc, force 64-bit compilation"
578 cleanup
579 cp "$CONFIG_H" "$CONFIG_BAK"
580 scripts/config.pl unset MBEDTLS_HAVE_ASM
581 scripts/config.pl unset MBEDTLS_AESNI_C
582 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100583 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Andres Amaya Garcia99467832017-07-20 13:21:34 +0100584
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100585 msg "test: gcc, force 64-bit compilation"
586 make test
Andres Amaya Garcia99467832017-07-20 13:21:34 +0100587
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100588 msg "build: gcc, force 64-bit compilation"
589 cleanup
590 cp "$CONFIG_H" "$CONFIG_BAK"
591 scripts/config.pl unset MBEDTLS_HAVE_ASM
592 scripts/config.pl unset MBEDTLS_AESNI_C
593 scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100594 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000595fi # x86_64
596
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000597msg "build: arm-none-eabi-gcc, make" # ~ 10s
598cleanup
599cp "$CONFIG_H" "$CONFIG_BAK"
600scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200601scripts/config.pl unset MBEDTLS_NET_C
602scripts/config.pl unset MBEDTLS_TIMING_C
603scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100604scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000605scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000606# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200607scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
608scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
609scripts/config.pl unset MBEDTLS_THREADING_C
610scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
611scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100612make 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 +0000613
Gilles Peskineb1a977f2017-06-08 15:19:20 +0200614msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
615cleanup
Simon Butcher2c4d5582017-07-23 13:42:36 +0200616cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia465db7e2017-07-20 13:27:35 +0100617scripts/config.pl full
618scripts/config.pl unset MBEDTLS_NET_C
619scripts/config.pl unset MBEDTLS_TIMING_C
620scripts/config.pl unset MBEDTLS_FS_IO
621scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
622scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
623# following things are not in the default config
624scripts/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 Peskineb1a977f2017-06-08 15:19:20 +0200629scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100630make 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 +0200631echo "Checking that software 64-bit division is not required"
632! grep __aeabi_uldiv library/*.o
633
Andres AG87bb5772016-09-27 15:05:15 +0100634msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100635cleanup
636cp "$CONFIG_H" "$CONFIG_BAK"
637scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200638scripts/config.pl unset MBEDTLS_NET_C
639scripts/config.pl unset MBEDTLS_TIMING_C
640scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100641scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200642scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200643scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000644scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100645# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200646scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
647scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
648scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
649scripts/config.pl unset MBEDTLS_THREADING_C
650scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
651scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300652scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100653
Gilles Peskine7c652162017-12-11 00:01:40 +0100654make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Andres AG87bb5772016-09-27 15:05:15 +0100655make clean
656
Simon Butcher2c4d5582017-07-23 13:42:36 +0200657# ARM Compiler 6 - Target ARMv7-A
Andres AGa5cd9732016-10-17 15:23:10 +0100658armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200659
660# ARM Compiler 6 - Target ARMv7-M
Andres AGa5cd9732016-10-17 15:23:10 +0100661armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200662
663# ARM Compiler 6 - Target ARMv8-A - AArch32
Andres AGa5cd9732016-10-17 15:23:10 +0100664armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200665
666# ARM Compiler 6 - Target ARMv8-M
Andres AGa5cd9732016-10-17 15:23:10 +0100667armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher2c4d5582017-07-23 13:42:36 +0200668
669# ARM Compiler 6 - Target ARMv8-A - AArch64
670armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100671
Gilles Peskine2a458da2017-05-12 15:26:58 +0200672msg "build: allow SHA1 in certificates by default"
673cleanup
674cp "$CONFIG_H" "$CONFIG_BAK"
675scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +0100676make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +0200677msg "test: allow SHA1 in certificates by default"
678make test
Gilles Peskine7c652162017-12-11 00:01:40 +0100679if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +0200680
Simon Butcher002bc622016-11-17 09:27:45 +0000681msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100682cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100683make 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 +0000684
Simon Butcher002bc622016-11-17 09:27:45 +0000685# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +0100686make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
687make WINDOWS_BUILD=1 clean
Simon Butcherf95c1762016-11-10 17:25:58 +0000688
Simon Butcher002bc622016-11-17 09:27:45 +0000689msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
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 -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
691make 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
692make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100693
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000694# MemSan currently only available on Linux 64 bits
695if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000696
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100697 msg "build: MSan (clang)" # ~ 1 min 20s
698 cleanup
699 cp "$CONFIG_H" "$CONFIG_BAK"
700 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
701 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
702 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200703
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100704 msg "test: main suites (MSan)" # ~ 10s
705 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100706
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100707 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100708 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100709
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100710 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100711
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100712 if [ "$MEMORY" -gt 0 ]; then
713 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +0100714 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100715 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100716
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000717else # no MemSan
718
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100719 msg "build: Release (clang)"
720 cleanup
721 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
722 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000723
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100724 msg "test: main suites valgrind (Release)"
725 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000726
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100727 # Optional part(s)
728 # Currently broken, programs don't seem to receive signals
729 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000730
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100731 if [ "$MEMORY" -gt 0 ]; then
732 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100733 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100734 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000735
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100736 if [ "$MEMORY" -gt 1 ]; then
737 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +0100738 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100739 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000740
741fi # MemSan
742
Andres AGdc192212016-08-31 17:33:13 +0100743msg "build: cmake 'out-of-source' build"
744cleanup
745MBEDTLS_ROOT_DIR="$PWD"
746mkdir "$OUT_OF_SOURCE_DIR"
747cd "$OUT_OF_SOURCE_DIR"
748cmake "$MBEDTLS_ROOT_DIR"
749make
750
751msg "test: cmake 'out-of-source' build"
752make test
753cd "$MBEDTLS_ROOT_DIR"
754rm -rf "$OUT_OF_SOURCE_DIR"
755
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100756msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100757cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100758
759final_report