blob: 6dba7a51ebdeea26a8c615cb25752217b55ddafb [file] [log] [blame]
Andres AG31f9b5b2016-10-04 17:14:38 +01001#! /usr/bin/env sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002
Simon Butcher3ea7f522016-03-07 23:22:10 +00003# all.sh
4#
SimonB2e23c822016-04-16 21:54:39 +01005# This file is part of mbed TLS (https://tls.mbed.org)
6#
Gilles Peskine192c72f2017-12-21 15:59:21 +01007# Copyright (c) 2014-2017, ARM Limited, All Rights Reserved
8
9
10
11################################################################
12#### Documentation
13################################################################
14
Simon Butcher3ea7f522016-03-07 23:22:10 +000015# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010016# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000017#
SimonB2e23c822016-04-16 21:54:39 +010018# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010019#
Gilles Peskine192c72f2017-12-21 15:59:21 +010020# Notes for users
21# ---------------
22#
SimonB2e23c822016-04-16 21:54:39 +010023# Warning: the test is destructive. It includes various build modes and
24# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010025# configuration. The following files must be committed into git:
26# * include/mbedtls/config.h
27# * Makefile, library/Makefile, programs/Makefile, tests/Makefile
28# After running this script, the CMake cache will be lost and CMake
29# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010030#
Gilles Peskine192c72f2017-12-21 15:59:21 +010031# The script assumes the presence of a number of tools:
32# * Basic Unix tools (Windows users note: a Unix-style find must be before
33# the Windows find in the PATH)
34# * Perl
35# * GNU Make
36# * CMake
37# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040038# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010039# * arm-gcc and mingw-gcc
40# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine192c72f2017-12-21 15:59:21 +010041# * OpenSSL and GnuTLS command line tools, recent enough for the
42# interoperability tests. If they don't support SSLv3 then a legacy
43# version of these tools must be present as well (search for LEGACY
44# below).
45# See the invocation of check_tools below for details.
46#
47# This script must be invoked from the toplevel directory of a git
48# working copy of Mbed TLS.
49#
50# Note that the output is not saved. You may want to run
51# script -c tests/scripts/all.sh
52# or
53# tests/scripts/all.sh >all.log 2>&1
54#
55# Notes for maintainers
56# ---------------------
57#
58# The tests are roughly in order from fastest to slowest. This doesn't
59# have to be exact, but in general you should add slower tests towards
60# the end and fast checks near the beginning.
61#
62# Sanity checks have the following form:
63# 1. msg "short description of what is about to be done"
64# 2. run sanity check (failure stops the script)
65#
66# Build or build-and-test steps have the following form:
67# 1. msg "short description of what is about to be done"
68# 2. cleanup
69# 3. preparation (config.pl, cmake, ...) (failure stops the script)
70# 4. make
71# 5. Run tests if relevant. All tests must be prefixed with
72# if_build_successful for the sake of --keep-going.
73
74
75
76################################################################
77#### Initialization and command line parsing
78################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010079
SimonB2e23c822016-04-16 21:54:39 +010080# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010081set -eu
82
Andres AG38495a32016-07-12 16:54:33 +010083if [ "$( uname )" != "Linux" ]; then
84 echo "This script only works in Linux" >&2
85 exit 1
86elif [ -d library -a -d include -a -d tests ]; then :; else
87 echo "Must be run from mbed TLS root" >&2
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088 exit 1
89fi
90
Jaeden Ameroed93bdc2018-11-02 16:57:24 +000091if ! [ -f crypto/Makefile ]; then
92 echo "Please initialize the crypto submodule" >&2
93 exit 1
94fi
95
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000096CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020097CONFIG_BAK="$CONFIG_H.bak"
98
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010099MEMORY=0
SimonB2e23c822016-04-16 21:54:39 +0100100FORCE=0
Gilles Peskine7c652162017-12-11 00:01:40 +0100101KEEP_GOING=0
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100102RUN_ARMCC=1
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100103
Andres AGd9eba4b2016-08-26 14:42:14 +0100104# Default commands, can be overriden by the environment
105: ${OPENSSL:="openssl"}
106: ${OPENSSL_LEGACY:="$OPENSSL"}
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100107: ${OPENSSL_NEXT:="$OPENSSL"}
Andres AGd9eba4b2016-08-26 14:42:14 +0100108: ${GNUTLS_CLI:="gnutls-cli"}
109: ${GNUTLS_SERV:="gnutls-serv"}
110: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
111: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +0100112: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +0100113: ${ARMC5_BIN_DIR:=/usr/bin}
114: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +0100115
Andres AG38495a32016-07-12 16:54:33 +0100116# if MAKEFLAGS is not set add the -j option to speed up invocations of make
117if [ -n "${MAKEFLAGS+set}" ]; then
118 export MAKEFLAGS="-j"
119fi
120
Simon Butcher41eeccf2016-09-07 00:07:09 +0100121usage()
SimonB2e23c822016-04-16 21:54:39 +0100122{
Gilles Peskine709346a2017-12-10 23:43:39 +0100123 cat <<EOF
124Usage: $0 [OPTION]...
125 -h|--help Print this help.
126
127General options:
128 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100129 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100130 -m|--memory Additional optional memory tests.
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100131 --armcc Run ARM Compiler builds (on by default).
132 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100133 --no-force Refuse to overwrite modified files (default).
134 --no-keep-going Stop at the first error (default).
135 --no-memory No additional memory tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100136 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine38d81652018-03-21 08:40:26 +0100137 --random-seed Use a random seed value for randomized tests (default).
Gilles Peskine709346a2017-12-10 23:43:39 +0100138 -r|--release-test Run this script in release mode. This fixes the seed value to 1.
139 -s|--seed Integer seed value to use for this test run.
140
141Tool path options:
142 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
143 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
144 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
145 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
146 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
147 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
148 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
149 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100150 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100151EOF
SimonB2e23c822016-04-16 21:54:39 +0100152}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100153
154# remove built files as well as the cmake cache/config
155cleanup()
156{
Gilles Peskinea71d64c2018-03-21 12:16:57 +0100157 if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
158 cd "$MBEDTLS_ROOT_DIR"
159 fi
160
Gilles Peskine7c652162017-12-11 00:01:40 +0100161 command make clean
Jaeden Ameroed93bdc2018-11-02 16:57:24 +0000162 cd crypto
163 command make clean
164 cd ..
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200165
Gilles Peskine31b07e22018-03-21 12:15:06 +0100166 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000167 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100168 -iname CMakeFiles -exec rm -rf {} \+ -o \
169 \( -iname cmake_install.cmake -o \
170 -iname CTestTestfile.cmake -o \
171 -iname CMakeCache.txt \) -exec rm {} \+
172 # Recover files overwritten by in-tree CMake builds
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000173 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +0200174 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
175 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Jaeden Ameroed93bdc2018-11-02 16:57:24 +0000176 cd crypto
177 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
178 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
179 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
180 cd ..
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200181
182 if [ -f "$CONFIG_BAK" ]; then
183 mv "$CONFIG_BAK" "$CONFIG_H"
184 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100185}
186
Gilles Peskine7c652162017-12-11 00:01:40 +0100187# Executed on exit. May be redefined depending on command line options.
188final_report () {
189 :
190}
191
192fatal_signal () {
193 cleanup
194 final_report $1
195 trap - $1
196 kill -$1 $$
197}
198
199trap 'fatal_signal HUP' HUP
200trap 'fatal_signal INT' INT
201trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200202
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100203msg()
204{
205 echo ""
206 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100207 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000208 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100209 echo "******************************************************************"
Gilles Peskine7c652162017-12-11 00:01:40 +0100210 current_section=$1
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100211}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100212
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100213if [ $RUN_ARMCC -ne 0 ]; then
214 armc6_build_test()
215 {
216 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100217
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100218 msg "build: ARM Compiler 6 ($FLAGS), make"
219 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
220 WARNING_CFLAGS='-xc -std=c99' make lib
221 make clean
222 }
223fi
Andres AGa5cd9732016-10-17 15:23:10 +0100224
Andres AGd9eba4b2016-08-26 14:42:14 +0100225err_msg()
226{
227 echo "$1" >&2
228}
229
230check_tools()
231{
232 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000233 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100234 err_msg "$TOOL not found!"
235 exit 1
236 fi
237 done
238}
239
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400240check_headers_in_cpp () {
241 ls include/mbedtls >headers.txt
242 <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
243 sort |
244 diff headers.txt -
245 rm headers.txt
246}
247
SimonB2e23c822016-04-16 21:54:39 +0100248while [ $# -gt 0 ]; do
249 case "$1" in
Gilles Peskine8a244c92018-03-21 08:39:32 +0100250 --armcc) RUN_ARMCC=1;;
251 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
252 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
253 --force|-f) FORCE=1;;
254 --gnutls-cli) shift; GNUTLS_CLI="$1";;
255 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
256 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
257 --gnutls-serv) shift; GNUTLS_SERV="$1";;
258 --help|-h) usage; exit;;
259 --keep-going|-k) KEEP_GOING=1;;
260 --memory|-m) MEMORY=1;;
261 --no-armcc) RUN_ARMCC=0;;
Gilles Peskine38d81652018-03-21 08:40:26 +0100262 --no-force) FORCE=0;;
263 --no-keep-going) KEEP_GOING=0;;
264 --no-memory) MEMORY=0;;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100265 --openssl) shift; OPENSSL="$1";;
266 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
Manuel Pégourié-Gonnarda3712be2018-05-22 15:58:50 +0200267 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100268 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Gilles Peskine38d81652018-03-21 08:40:26 +0100269 --random-seed) unset SEED;;
270 --release-test|-r) SEED=1;;
Gilles Peskine8a244c92018-03-21 08:39:32 +0100271 --seed|-s) shift; SEED="$1";;
Gilles Peskine709346a2017-12-10 23:43:39 +0100272 *)
273 echo >&2 "Unknown option: $1"
274 echo >&2 "Run $0 --help for usage."
275 exit 120
SimonB2e23c822016-04-16 21:54:39 +0100276 ;;
277 esac
278 shift
279done
280
281if [ $FORCE -eq 1 ]; then
SimonB2e23c822016-04-16 21:54:39 +0100282 git checkout-index -f -q $CONFIG_H
283 cleanup
284else
285
Andres AGdc192212016-08-31 17:33:13 +0100286 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
287 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
288 echo "You can either delete this directory manually, or force the test by rerunning"
289 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
290 exit 1
291 fi
292
SimonB2e23c822016-04-16 21:54:39 +0100293 if ! git diff-files --quiet include/mbedtls/config.h; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100294 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100295 echo "You can either delete or preserve your work, or force the test by rerunning the"
296 echo "script as: $0 --force"
297 exit 1
298 fi
299fi
300
Gilles Peskine7c652162017-12-11 00:01:40 +0100301build_status=0
302if [ $KEEP_GOING -eq 1 ]; then
303 failure_summary=
304 failure_count=0
305 start_red=
306 end_color=
307 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100308 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100309 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
310 start_red=$(printf '\033[31m')
311 end_color=$(printf '\033[0m')
312 ;;
313 esac
314 fi
315 record_status () {
316 if "$@"; then
317 last_status=0
318 else
319 last_status=$?
320 text="$current_section: $* -> $last_status"
321 failure_summary="$failure_summary
322$text"
323 failure_count=$((failure_count + 1))
324 echo "${start_red}^^^^$text^^^^${end_color}"
325 fi
326 }
327 make () {
328 case "$*" in
329 *test|*check)
330 if [ $build_status -eq 0 ]; then
331 record_status command make "$@"
332 else
333 echo "(skipped because the build failed)"
334 fi
335 ;;
336 *)
337 record_status command make "$@"
338 build_status=$last_status
339 ;;
340 esac
341 }
342 final_report () {
343 if [ $failure_count -gt 0 ]; then
344 echo
345 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
346 echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
347 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Jaeden Amero7c1258d2018-07-20 16:42:14 +0100348 exit 1
Gilles Peskine7c652162017-12-11 00:01:40 +0100349 elif [ -z "${1-}" ]; then
350 echo "SUCCESS :)"
351 fi
352 if [ -n "${1-}" ]; then
353 echo "Killed by SIG$1."
354 fi
355 }
356else
357 record_status () {
358 "$@"
359 }
360fi
361if_build_succeeded () {
362 if [ $build_status -eq 0 ]; then
363 record_status "$@"
364 fi
365}
366
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200367# to be used instead of ! for commands run with
368# record_status or if_build_succeeded
369not() {
370 ! "$@"
371}
372
Andres AGd9eba4b2016-08-26 14:42:14 +0100373msg "info: $0 configuration"
374echo "MEMORY: $MEMORY"
375echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100376echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100377echo "OPENSSL: $OPENSSL"
378echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100379echo "OPENSSL_NEXT: $OPENSSL_NEXT"
Andres AGd9eba4b2016-08-26 14:42:14 +0100380echo "GNUTLS_CLI: $GNUTLS_CLI"
381echo "GNUTLS_SERV: $GNUTLS_SERV"
382echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
383echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100384echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
385echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
386
387ARMC5_CC="$ARMC5_BIN_DIR/armcc"
388ARMC5_AR="$ARMC5_BIN_DIR/armar"
389ARMC6_CC="$ARMC6_BIN_DIR/armclang"
390ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100391
Andres AGb2fdd042016-09-22 14:17:46 +0100392# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
393# we just export the variables they require
394export OPENSSL_CMD="$OPENSSL"
395export GNUTLS_CLI="$GNUTLS_CLI"
396export GNUTLS_SERV="$GNUTLS_SERV"
397
Andres AG7770ea82016-10-10 15:46:20 +0100398# Avoid passing --seed flag in every call to ssl-opt.sh
Gilles Peskine38d81652018-03-21 08:40:26 +0100399if [ -n "${SEED-}" ]; then
400 export SEED
401fi
Andres AG7770ea82016-10-10 15:46:20 +0100402
Andres AGd9eba4b2016-08-26 14:42:14 +0100403# Make sure the tools we need are available.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100404check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
405 "$GNUTLS_CLI" "$GNUTLS_SERV" \
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100406 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Andres Amaya Garciaddebc492017-10-24 22:16:34 +0100407 "arm-none-eabi-gcc" "i686-w64-mingw32-gcc" "gdb"
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100408if [ $RUN_ARMCC -ne 0 ]; then
409 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
410fi
Andres AGd9eba4b2016-08-26 14:42:14 +0100411
Gilles Peskine192c72f2017-12-21 15:59:21 +0100412
413
414################################################################
415#### Basic checks
416################################################################
SimonB2e23c822016-04-16 21:54:39 +0100417
418#
419# Test Suites to be executed
420#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200421# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100422# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200423# and/or are more likely to fail than others (eg I use Clang most of the
424# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200425# 2. Minimize total running time, by avoiding useless rebuilds
426#
427# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100428
Janos Follathb72c6782016-07-19 14:54:17 +0100429msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100430OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
431 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100432 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
Gilles Peskine26232962018-03-21 08:35:07 +0100433 ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100434
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100435msg "test: recursion.pl" # < 1s
Gilles Peskine487cdf52018-09-26 15:54:40 +0200436record_status tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100437
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000438msg "test: freshness of generated source files" # < 1s
Gilles Peskine487cdf52018-09-26 15:54:40 +0200439record_status tests/scripts/check-generated-files.sh
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000440
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200441msg "test: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskine487cdf52018-09-26 15:54:40 +0200442record_status tests/scripts/check-doxy-blocks.pl
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200443
Darryl Greena07039c2018-03-13 16:48:16 +0000444msg "test: check-files.py" # < 1s
445cleanup
Gilles Peskine487cdf52018-09-26 15:54:40 +0200446record_status tests/scripts/check-files.py
Darryl Greena07039c2018-03-13 16:48:16 +0000447
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200448msg "test/build: declared and exported names" # < 3s
449cleanup
Gilles Peskine487cdf52018-09-26 15:54:40 +0200450record_status tests/scripts/check-names.sh
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200451
Andres AGd9eba4b2016-08-26 14:42:14 +0100452msg "test: doxygen warnings" # ~ 3s
453cleanup
Gilles Peskine487cdf52018-09-26 15:54:40 +0200454record_status tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100455
Gilles Peskine192c72f2017-12-21 15:59:21 +0100456
457
458################################################################
459#### Build and test many configurations and targets
460################################################################
461
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100462msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100463cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100464CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100465make
466
Simon Butcher8e3afc72016-09-15 17:13:08 +0100467msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100468make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200469
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100470msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100471if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200472
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100473msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Gilles Peskine396fac12018-03-22 22:26:03 +0100474record_status tests/scripts/test-ref-configs.pl
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200475
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200476msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
477make
478
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100479msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100480if_build_succeeded tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200481
Simon Butcher3ea7f522016-03-07 23:22:10 +0000482msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
483cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000484cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000485scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
486CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
487make
488
Simon Butcher8e3afc72016-09-15 17:13:08 +0100489msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000490make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000491
492msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100493if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
494if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000495
496msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100497if_build_succeeded tests/ssl-opt.sh
Simon Butcher3ea7f522016-03-07 23:22:10 +0000498
Hanno Becker134c2ab2017-10-12 15:29:50 +0100499msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
500cleanup
501cp "$CONFIG_H" "$CONFIG_BAK"
502scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
503CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
504make
505
506msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
507make test
508
509msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100510if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100511
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100512msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
513cleanup
514cp "$CONFIG_H" "$CONFIG_BAK"
515scripts/config.pl set MBEDTLS_RSA_NO_CRT
516CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
517make
518
519msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
520make test
521
522msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinebd90a8c2018-09-27 10:12:17 +0200523if_build_succeeded tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100524
525msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
Gilles Peskinebd90a8c2018-09-27 10:12:17 +0200526if_build_succeeded tests/compat.sh -t RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +0100527
Angus Grattonc4dd0732018-04-11 16:28:39 +1000528msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
529cleanup
530cp "$CONFIG_H" "$CONFIG_BAK"
531scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
532scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
533CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
534make
535
536msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
537if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet"
538
539msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
540cleanup
541cp "$CONFIG_H" "$CONFIG_BAK"
542scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096
543scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
544CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
545make
546
547msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
548if_build_succeeded tests/ssl-opt.sh -f "Max fragment"
549
Hanno Becker2f5aa4c2018-08-24 14:43:44 +0100550msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
551cleanup
552cp "$CONFIG_H" "$CONFIG_BAK"
553scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
554CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
555make
556
557msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
558if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
559
560msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
561cleanup
562cp "$CONFIG_H" "$CONFIG_BAK"
563scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240
564CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
565make
566
567msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
568if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
569
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200570msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200571cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100572cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200573scripts/config.pl full
574scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Simon Butcherf95c1762016-11-10 17:25:58 +0000575CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200576make
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100577
578msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnard602544e2017-06-20 10:49:24 +0200579make test
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200580
Jaeden Amerod9c71da2018-06-15 20:31:26 +0100581msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
582if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200583
584msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Gilles Peskine7c652162017-12-11 00:01:40 +0100585if_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 +0200586
Manuel Pégourié-Gonnard9fece7e2018-06-18 11:38:22 +0200587msg "test: compat.sh ARIA + ChachaPoly"
588if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100589
Jaeden Ameroed93bdc2018-11-02 16:57:24 +0000590# USE_CRYPTO_SUBMODULE: check that the build works with CMake
591msg "build: cmake, full config + USE_CRYPTO_SUBMODULE, gcc+debug"
592cleanup
593cp "$CONFIG_H" "$CONFIG_BAK"
594scripts/config.pl full # enables md4 and submodule doesn't enable md4
595scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
596CC=gcc cmake -D USE_CRYPTO_SUBMODULE=1 -D CMAKE_BUILD_TYPE=Debug .
597make
598msg "test: top-level libmbedcrypto wasn't built (USE_CRYPTO_SUBMODULE, cmake)"
599if_build_succeeded not test -f library/libmbedcrypto.a
600msg "test: libmbedcrypto symbols are from crypto files (USE_CRYPTO_SUBMODULE, cmake)"
601if_build_succeeded objdump -g crypto/library/libmbedcrypto.a | grep -E 'crypto/library$' > /dev/null
602msg "test: libmbedcrypto uses top-level config (USE_CRYPTO_SUBMODULE, cmake)"
603if_build_succeeded objdump -g crypto/library/libmbedcrypto.a | grep 'md4.c' > /dev/null
604msg "test: main suites (USE_CRYPTO_SUBMODULE, cmake)"
605make test
606msg "test: ssl-opt.sh (USE_CRYPTO_SUBMODULE, cmake)"
607if_build_succeeded tests/ssl-opt.sh
608
609# USE_CRYPTO_SUBMODULE: check that the build works with make
610msg "build: make, full config + USE_CRYPTO_SUBMODULE, gcc+debug"
611cleanup
612cp "$CONFIG_H" "$CONFIG_BAK"
613scripts/config.pl full # enables md4 and submodule doesn't enable md4
614scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
615make CC=gcc CFLAGS='-g' USE_CRYPTO_SUBMODULE=1
616msg "test: top-level libmbedcrypto wasn't built (USE_CRYPTO_SUBMODULE, make)"
617if_build_succeeded not test -f library/libmbedcrypto.a
618msg "test: libmbedcrypto symbols are from crypto files (USE_CRYPTO_SUBMODULE, make)"
619if_build_succeeded objdump -g crypto/library/libmbedcrypto.a | grep -E 'crypto/library$' > /dev/null
620msg "test: libmbedcrypto uses top-level config (USE_CRYPTO_SUBMODULE, make)"
621if_build_succeeded objdump -g crypto/library/libmbedcrypto.a | grep 'md4.c' > /dev/null
622msg "test: main suites (USE_CRYPTO_SUBMODULE, make)"
623make CC=gcc USE_CRYPTO_SUBMODULE=1 test
624msg "test: ssl-opt.sh (USE_CRYPTO_SUBMODULE, make)"
625if_build_succeeded tests/ssl-opt.sh
626
Jaeden Ameroacaabe72018-11-07 11:52:52 +0000627# Don't USE_CRYPTO_SUBMODULE: check that the submodule is not used with make
628msg "build: make, full config - USE_CRYPTO_SUBMODULE, gcc+debug"
629cleanup
630cp "$CONFIG_H" "$CONFIG_BAK"
631scripts/config.pl full
632make CC=gcc CFLAGS='-g'
633msg "test: submodule libmbedcrypto wasn't built (USE_CRYPTO_SUBMODULE, make)"
634if_build_succeeded not test -f crypto/library/libmbedcrypto.a
635msg "test: libmbedcrypto symbols are from library files (USE_CRYPTO_SUBMODULE, make)"
636if_build_succeeded objdump -g library/libmbedcrypto.a | grep -E 'library$' | not grep 'crypto' > /dev/null
637
638# Don't USE_CRYPTO_SUBMODULE: check that the submodule is not used with CMake
639msg "build: cmake, full config - USE_CRYPTO_SUBMODULE, gcc+debug"
640cleanup
641cp "$CONFIG_H" "$CONFIG_BAK"
642scripts/config.pl full
643CC=gcc cmake -D CMAKE_BUILD_TYPE=Debug .
644make
645msg "test: submodule libmbedcrypto wasn't built (USE_CRYPTO_SUBMODULE, cmake)"
646if_build_succeeded not test -f crypto/library/libmbedcrypto.a
647msg "test: libmbedcrypto symbols are from library files (USE_CRYPTO_SUBMODULE, cmake)"
648if_build_succeeded objdump -g library/libmbedcrypto.a | grep -E 'library$' | not grep 'crypto' > /dev/null
649
Hanno Becker6e021972018-11-19 15:16:12 +0000650# MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
651msg "build: cmake, full config + MBEDTLS_USE_PSA_CRYPTO, ASan"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100652cleanup
653cp "$CONFIG_H" "$CONFIG_BAK"
654scripts/config.pl full
655scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
656scripts/config.pl set MBEDTLS_PSA_CRYPTO_C
657scripts/config.pl set MBEDTLS_USE_PSA_CRYPTO
658CC=gcc cmake -D USE_CRYPTO_SUBMODULE -D CMAKE_BUILD_TYPE:String=Asan .
659make
660
Hanno Becker6e021972018-11-19 15:16:12 +0000661msg "test: main suites (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100662make test
663
Hanno Becker6e021972018-11-19 15:16:12 +0000664msg "test: ssl-opt.sh (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100665if_build_succeeded tests/ssl-opt.sh
666
Hanno Becker6e021972018-11-19 15:16:12 +0000667msg "test: compat.sh default (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100668if_build_succeeded tests/compat.sh
669
Hanno Becker6e021972018-11-19 15:16:12 +0000670msg "test: compat.sh ssl3 (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100671if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
672
Hanno Becker6e021972018-11-19 15:16:12 +0000673msg "test: compat.sh RC4, DES & NULL (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100674if_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'
675
Hanno Becker6e021972018-11-19 15:16:12 +0000676msg "test: compat.sh ARIA + ChachaPoly (MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +0100677if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
678
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100679msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
680cleanup
681cp "$CONFIG_H" "$CONFIG_BAK"
682scripts/config.pl full
Gilles Peskine0afe6242018-02-21 19:28:12 +0100683scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100684# Build with -O -Wextra to catch a maximum of issues.
685make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs
686make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
687
688msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s
689# No cleanup, just tweak the configuration and rebuild
690make clean
691scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
Gilles Peskine0afe6242018-02-21 19:28:12 +0100692scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED
Gilles Peskineb4ef45b2018-03-01 22:23:50 +0100693# Build with -O -Wextra to catch a maximum of issues.
694make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs
695make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests
Gilles Peskine0afe6242018-02-21 19:28:12 +0100696
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200697msg "test/build: curves.pl (gcc)" # ~ 4 min
698cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100699record_status tests/scripts/curves.pl
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200700
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200701msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min
702cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100703record_status tests/scripts/depends-hashes.pl
Manuel Pégourié-Gonnard1fe6bb92017-06-06 11:36:16 +0200704
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200705msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min
706cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100707record_status tests/scripts/depends-pkalgs.pl
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +0200708
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200709msg "test/build: key-exchanges (gcc)" # ~ 1 min
710cleanup
Gilles Peskine396fac12018-03-22 22:26:03 +0100711record_status tests/scripts/key-exchanges.pl
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200712
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000713msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100714cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100715make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100716
Andrzej Kurek991f9fe2018-07-02 09:08:21 -0400717msg "test: verify header list in cpp_dummy_build.cpp"
718record_status check_headers_in_cpp
719
720msg "build: Unix make, incremental g++"
721make TEST_CPP=1
722
Simon Butcherf95c1762016-11-10 17:25:58 +0000723# Full configuration build, without platform support, file IO and net sockets.
724# This should catch missing mbedtls_printf definitions, and by disabling file
725# IO, it should catch missing '#include <stdio.h>'
726msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000727cleanup
728cp "$CONFIG_H" "$CONFIG_BAK"
729scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200730scripts/config.pl unset MBEDTLS_PLATFORM_C
Simon Butcherf95c1762016-11-10 17:25:58 +0000731scripts/config.pl unset MBEDTLS_NET_C
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200732scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100733scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
734scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
735scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100736scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100737scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100738scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200739scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
740scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchercb587002017-01-06 16:14:44 +0000741# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
742# to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine7c652162017-12-11 00:01:40 +0100743make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
744make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000745
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100746# catch compile bugs in _uninit functions
747msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
748cleanup
749cp "$CONFIG_H" "$CONFIG_BAK"
750scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100751scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100752scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine7c652162017-12-11 00:01:40 +0100753make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100754
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200755msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
756cleanup
757cp "$CONFIG_H" "$CONFIG_BAK"
758scripts/config.pl full
759scripts/config.pl unset MBEDTLS_SSL_SRV_C
Gilles Peskine7c652162017-12-11 00:01:40 +0100760make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200761
762msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
763cleanup
764cp "$CONFIG_H" "$CONFIG_BAK"
765scripts/config.pl full
766scripts/config.pl unset MBEDTLS_SSL_CLI_C
Hanno Beckerd485c312018-01-05 13:03:53 +0000767make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200768
Simon Butcherf95c1762016-11-10 17:25:58 +0000769# Note, C99 compliance can also be tested with the sockets support disabled,
770# as that requires a POSIX platform (which isn't the same as C99).
Andres AG788aa4a2016-09-14 14:32:09 +0100771msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200772cleanup
773cp "$CONFIG_H" "$CONFIG_BAK"
774scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200775scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
776scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine7c652162017-12-11 00:01:40 +0100777make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200778
Angus Grattonc4dd0732018-04-11 16:28:39 +1000779# Run max fragment length tests with MFL disabled
Hanno Becker5175ac62017-09-18 15:36:25 +0100780msg "build: default config except MFL extension (ASan build)" # ~ 30s
781cleanup
782cp "$CONFIG_H" "$CONFIG_BAK"
783scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
784CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
785make
786
787msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskine7c652162017-12-11 00:01:40 +0100788if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000789
Angus Grattonc4dd0732018-04-11 16:28:39 +1000790msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
791cleanup
792cp "$CONFIG_H" "$CONFIG_BAK"
793scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
794scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
795scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
796CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
797make
798
799msg "test: MFL tests (disabled MFL extension case) & large packet tests"
800if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
801
Simon Butcherab5df402016-06-11 02:31:21 +0100802msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100803cleanup
804cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100805scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100806scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
807scripts/config.pl set MBEDTLS_ENTROPY_C
808scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
809scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
810scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100811CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100812make
813
Simon Butcher8e3afc72016-09-15 17:13:08 +0100814msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100815make test
Janos Follath06c54002016-06-09 13:57:40 +0100816
Hanno Beckere5fecec2018-10-11 11:02:52 +0100817msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
818cleanup
819cp "$CONFIG_H" "$CONFIG_BAK"
820scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
821scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
822scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free
823CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
824make
825
826msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
827make test
828
Hanno Becker83ebf782017-07-07 12:29:15 +0100829msg "build: default config with AES_FEWER_TABLES enabled"
830cleanup
831cp "$CONFIG_H" "$CONFIG_BAK"
832scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100833make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100834
835msg "test: AES_FEWER_TABLES"
836make test
837
838msg "build: default config with AES_ROM_TABLES enabled"
839cleanup
840cp "$CONFIG_H" "$CONFIG_BAK"
841scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100842make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100843
844msg "test: AES_ROM_TABLES"
845make test
846
847msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
848cleanup
849cp "$CONFIG_H" "$CONFIG_BAK"
850scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
851scripts/config.pl set MBEDTLS_AES_ROM_TABLES
Hanno Becker98a67862018-03-27 17:10:09 +0100852make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +0100853
854msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
855make test
856
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200857if uname -a | grep -F Linux >/dev/null; then
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100858 msg "build/test: make shared" # ~ 40s
859 cleanup
860 make SHARED=1 all check
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200861fi
862
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000863if uname -a | grep -F x86_64 >/dev/null; then
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100864 # Build once with -O0, to compile out the i386 specific inline assembly
865 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine7ad603e2017-12-10 23:22:20 +0100866 cleanup
Simon Butcher7a6da6e2018-06-27 21:52:54 +0100867 cp "$CONFIG_H" "$CONFIG_BAK"
868 scripts/config.pl full
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100869 make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100870
Simon Butcher8e6a22a2018-07-20 21:27:33 +0100871 msg "test: i386, make, gcc -O0 (ASan build)"
872 make test
873
874 # Build again with -O1, to compile in the i386 specific inline assembly
875 msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
876 cleanup
877 cp "$CONFIG_H" "$CONFIG_BAK"
878 scripts/config.pl full
879 make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
880
881 msg "test: i386, make, gcc -O1 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100882 make test
883
884 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
885 cleanup
Simon Butcher7a6da6e2018-06-27 21:52:54 +0100886 cp "$CONFIG_H" "$CONFIG_BAK"
887 scripts/config.pl full
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +0100888 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
889
890 msg "test: 64-bit ILP32, make, gcc"
891 make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000892fi # x86_64
893
Gilles Peskine14c3c062018-01-29 21:25:12 +0100894msg "build: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100895cleanup
896cp "$CONFIG_H" "$CONFIG_BAK"
897scripts/config.pl unset MBEDTLS_HAVE_ASM
898scripts/config.pl unset MBEDTLS_AESNI_C
899scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100900make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100901
Gilles Peskine14c3c062018-01-29 21:25:12 +0100902msg "test: gcc, force 32-bit bignum limbs"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +0100903make test
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100904
Gilles Peskine14c3c062018-01-29 21:25:12 +0100905msg "build: gcc, force 64-bit bignum limbs"
Andres Amaya Garciafe843a32017-07-20 13:21:34 +0100906cleanup
907cp "$CONFIG_H" "$CONFIG_BAK"
908scripts/config.pl unset MBEDTLS_HAVE_ASM
909scripts/config.pl unset MBEDTLS_AESNI_C
910scripts/config.pl unset MBEDTLS_PADLOCK_C
Gilles Peskine14c3c062018-01-29 21:25:12 +0100911make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
912
913msg "test: gcc, force 64-bit bignum limbs"
914make test
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000915
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200916
917msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
918cleanup
919cp "$CONFIG_H" "$CONFIG_BAK"
920scripts/config.pl full
921scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
922scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
923make CFLAGS='-Werror -O1'
924
925msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
926make test
927
928
929msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
930cleanup
931cp "$CONFIG_H" "$CONFIG_BAK"
932scripts/config.pl full
933scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
934scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
935make CFLAGS='-Werror -O1'
936
937msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
938make test
939
940
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000941msg "build: arm-none-eabi-gcc, make" # ~ 10s
942cleanup
943cp "$CONFIG_H" "$CONFIG_BAK"
944scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200945scripts/config.pl unset MBEDTLS_NET_C
946scripts/config.pl unset MBEDTLS_TIMING_C
947scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100948scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000949scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000950# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200951scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
952scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
953scripts/config.pl unset MBEDTLS_THREADING_C
954scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
955scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskine7c652162017-12-11 00:01:40 +0100956make 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 +0000957
Gilles Peskineed942f82017-06-08 15:19:20 +0200958msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
959cleanup
Simon Butcher940737f2017-07-23 13:42:36 +0200960cp "$CONFIG_H" "$CONFIG_BAK"
Andres Amaya Garcia05931972017-07-20 13:27:35 +0100961scripts/config.pl full
962scripts/config.pl unset MBEDTLS_NET_C
963scripts/config.pl unset MBEDTLS_TIMING_C
964scripts/config.pl unset MBEDTLS_FS_IO
965scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
966scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
967# following things are not in the default config
968scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
969scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
970scripts/config.pl unset MBEDTLS_THREADING_C
971scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
972scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Gilles Peskineed942f82017-06-08 15:19:20 +0200973scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine7c652162017-12-11 00:01:40 +0100974make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
Gilles Peskineed942f82017-06-08 15:19:20 +0200975echo "Checking that software 64-bit division is not required"
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +0200976if_build_succeeded not grep __aeabi_uldiv library/*.o
977
978msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
979cleanup
980cp "$CONFIG_H" "$CONFIG_BAK"
981scripts/config.pl full
982scripts/config.pl unset MBEDTLS_NET_C
983scripts/config.pl unset MBEDTLS_TIMING_C
984scripts/config.pl unset MBEDTLS_FS_IO
985scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
986scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
987# following things are not in the default config
988scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
989scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
990scripts/config.pl unset MBEDTLS_THREADING_C
991scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
992scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
993scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
994make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib
995echo "Checking that software 64-bit multiplication is not required"
996if_build_succeeded not grep __aeabi_lmul library/*.o
Gilles Peskineed942f82017-06-08 15:19:20 +0200997
Andres AG87bb5772016-09-27 15:05:15 +0100998msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100999cleanup
1000cp "$CONFIG_H" "$CONFIG_BAK"
1001scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001002scripts/config.pl unset MBEDTLS_NET_C
1003scripts/config.pl unset MBEDTLS_TIMING_C
1004scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +01001005scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001006scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +02001007scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +00001008scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01001009# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001010scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
1011scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
1012scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
1013scripts/config.pl unset MBEDTLS_THREADING_C
1014scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
1015scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +03001016scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +01001017
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001018if [ $RUN_ARMCC -ne 0 ]; then
1019 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
1020 make clean
Andres AG87bb5772016-09-27 15:05:15 +01001021
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001022 # ARM Compiler 6 - Target ARMv7-A
1023 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02001024
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001025 # ARM Compiler 6 - Target ARMv7-M
1026 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02001027
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001028 # ARM Compiler 6 - Target ARMv8-A - AArch32
1029 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02001030
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001031 # ARM Compiler 6 - Target ARMv8-M
1032 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02001033
Gilles Peskinebca6ab92017-12-19 18:24:31 +01001034 # ARM Compiler 6 - Target ARMv8-A - AArch64
1035 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
1036fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01001037
Gilles Peskine2a458da2017-05-12 15:26:58 +02001038msg "build: allow SHA1 in certificates by default"
1039cleanup
1040cp "$CONFIG_H" "$CONFIG_BAK"
1041scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine7c652162017-12-11 00:01:40 +01001042make CFLAGS='-Werror -Wall -Wextra'
Gilles Peskine2a458da2017-05-12 15:26:58 +02001043msg "test: allow SHA1 in certificates by default"
1044make test
Gilles Peskine7c652162017-12-11 00:01:40 +01001045if_build_succeeded tests/ssl-opt.sh -f SHA-1
Gilles Peskine2a458da2017-05-12 15:26:58 +02001046
Hanno Beckerd485c312018-01-05 13:03:53 +00001047msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
Hanno Beckere963efa2018-01-03 10:03:43 +00001048cleanup
1049cp "$CONFIG_H" "$CONFIG_BAK"
1050scripts/config.pl set MBEDTLS_RSA_NO_CRT
Hanno Beckerd485c312018-01-05 13:03:53 +00001051CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1052make
Hanno Beckere963efa2018-01-03 10:03:43 +00001053
1054msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
1055make test
Simon Butcher002bc622016-11-17 09:27:45 +00001056
1057msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
1058cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +01001059make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Manuel Pégourié-Gonnard52fa38a2015-06-23 14:29:58 +02001060
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +02001061# note Make tests only builds the tests, but doesn't run them
Gilles Peskine7c652162017-12-11 00:01:40 +01001062make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
1063make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +01001064
1065msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Gilles Peskine7c652162017-12-11 00:01:40 +01001066make 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
1067make 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
1068make WINDOWS_BUILD=1 clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +01001069
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00001070# MemSan currently only available on Linux 64 bits
1071if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001072
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001073 msg "build: MSan (clang)" # ~ 1 min 20s
1074 cleanup
1075 cp "$CONFIG_H" "$CONFIG_BAK"
1076 scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
1077 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1078 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02001079
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001080 msg "test: main suites (MSan)" # ~ 10s
1081 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001082
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001083 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskine7c652162017-12-11 00:01:40 +01001084 if_build_succeeded tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001085
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001086 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001087
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001088 if [ "$MEMORY" -gt 0 ]; then
1089 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskine7c652162017-12-11 00:01:40 +01001090 if_build_succeeded tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001091 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001092
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001093else # no MemSan
1094
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001095 msg "build: Release (clang)"
1096 cleanup
1097 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
1098 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001099
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001100 msg "test: main suites valgrind (Release)"
1101 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001102
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001103 # Optional part(s)
1104 # Currently broken, programs don't seem to receive signals
1105 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001106
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001107 if [ "$MEMORY" -gt 0 ]; then
1108 msg "test: ssl-opt.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001109 if_build_succeeded tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001110 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001111
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001112 if [ "$MEMORY" -gt 1 ]; then
1113 msg "test: compat.sh --memcheck (Release)"
Gilles Peskine7c652162017-12-11 00:01:40 +01001114 if_build_succeeded tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01001115 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00001116
1117fi # MemSan
1118
Andres AGdc192212016-08-31 17:33:13 +01001119msg "build: cmake 'out-of-source' build"
1120cleanup
1121MBEDTLS_ROOT_DIR="$PWD"
1122mkdir "$OUT_OF_SOURCE_DIR"
1123cd "$OUT_OF_SOURCE_DIR"
1124cmake "$MBEDTLS_ROOT_DIR"
1125make
1126
1127msg "test: cmake 'out-of-source' build"
1128make test
Gilles Peskine0114ffc2018-03-21 12:17:20 +01001129# Test an SSL option that requires an auxiliary script in test/scripts/.
1130# Also ensure that there are no error messages such as
1131# "No such file or directory", which would indicate that some required
1132# file is missing (ssl-opt.sh tolerates the absence of some files so
1133# may exit with status 0 but emit errors).
1134if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
1135if [ -s ssl-opt.err ]; then
1136 cat ssl-opt.err >&2
1137 record_status [ ! -s ssl-opt.err ]
1138 rm ssl-opt.err
1139fi
Andres AGdc192212016-08-31 17:33:13 +01001140cd "$MBEDTLS_ROOT_DIR"
1141rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskinea71d64c2018-03-21 12:16:57 +01001142unset MBEDTLS_ROOT_DIR
Andres AGdc192212016-08-31 17:33:13 +01001143
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001144# Test that the function mbedtls_platform_zeroize() is not optimized away by
1145# different combinations of compilers and optimization flags by using an
1146# auxiliary GDB script. Unfortunately, GDB does not return error values to the
1147# system in all cases that the script fails, so we must manually search the
1148# output to check whether the pass string is present and no failure strings
1149# were printed.
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001150for optimization_flag in -O2 -O3 -Ofast -Os; do
1151 for compiler in clang gcc; do
Andres Amaya Garcia708c5cb2018-04-24 08:33:31 -05001152 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001153 cleanup
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001154 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Andres Amaya Garcia79947662018-06-20 09:34:54 +01001155 if_build_succeeded gdb -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
Andres Amaya Garcia79947662018-06-20 09:34:54 +01001156 if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log
1157 if_build_succeeded not grep -i "error" test_zeroize.log
Andres Amaya Garcia9b04e192018-06-12 20:16:03 +01001158 rm -f test_zeroize.log
Andres Amaya Garcia29673812017-10-25 10:35:51 +01001159 done
1160done
Andres Amaya Garciad0d7bf62017-10-25 09:01:31 +01001161
Mohammad Azim Khanee6529e2018-07-06 00:50:34 +01001162msg "Lint: Python scripts"
Gilles Peskine487cdf52018-09-26 15:54:40 +02001163record_status tests/scripts/check-python-files.sh
Gilles Peskine192c72f2017-12-21 15:59:21 +01001164
Mohammad Azim Khanee6529e2018-07-06 00:50:34 +01001165msg "uint test: generate_test_code.py"
Gilles Peskine487cdf52018-09-26 15:54:40 +02001166record_status ./tests/scripts/test_generate_test_code.py
Gilles Peskine192c72f2017-12-21 15:59:21 +01001167
1168################################################################
1169#### Termination
1170################################################################
1171
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01001172msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001173cleanup
1174
Gilles Peskine7c652162017-12-11 00:01:40 +01001175final_report