blob: 6dbe54458ed000b2264f5d553a5ab9988b0a4420 [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
Andres AG7770ea82016-10-10 15:46:20 +010038RELEASE=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010039
Andres AGd9eba4b2016-08-26 14:42:14 +010040# Default commands, can be overriden by the environment
41: ${OPENSSL:="openssl"}
42: ${OPENSSL_LEGACY:="$OPENSSL"}
43: ${GNUTLS_CLI:="gnutls-cli"}
44: ${GNUTLS_SERV:="gnutls-serv"}
45: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
46: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +010047: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
Andres AG87bb5772016-09-27 15:05:15 +010048: ${ARMC5_BIN_DIR:=/usr/bin}
49: ${ARMC6_BIN_DIR:=/usr/bin}
Andres AGdc192212016-08-31 17:33:13 +010050
Andres AG38495a32016-07-12 16:54:33 +010051# if MAKEFLAGS is not set add the -j option to speed up invocations of make
52if [ -n "${MAKEFLAGS+set}" ]; then
53 export MAKEFLAGS="-j"
54fi
55
Simon Butcher41eeccf2016-09-07 00:07:09 +010056usage()
SimonB2e23c822016-04-16 21:54:39 +010057{
Andres AGd9eba4b2016-08-26 14:42:14 +010058 printf "Usage: $0\n"
59 printf " -h|--help\t\tPrint this help.\n"
60 printf " -m|--memory\t\tAdditional optional memory tests.\n"
61 printf " -f|--force\t\tForce the tests to overwrite any modified files.\n"
Andres AG7770ea82016-10-10 15:46:20 +010062 printf " -s|--seed\t\tInteger seed value to use for this test run.\n"
63 printf " -r|--release-test\t\tRun this script in release mode. This fixes the seed value to 1.\n"
Simon Butcher41eeccf2016-09-07 00:07:09 +010064 printf " --out-of-source-dir=<path>\t\tDirectory used for CMake out-of-source build tests."
Andres AGd9eba4b2016-08-26 14:42:14 +010065 printf " --openssl=<OpenSSL_path>\t\tPath to OpenSSL executable to use for most tests.\n"
66 printf " --openssl-legacy=<OpenSSL_path>\t\tPath to OpenSSL executable to use for legacy tests e.g. SSLv3.\n"
67 printf " --gnutls-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for most tests.\n"
68 printf " --gnutls-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for most tests.\n"
69 printf " --gnutls-legacy-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for legacy tests.\n"
70 printf " --gnutls-legacy-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for legacy tests.\n"
Andres AG87bb5772016-09-27 15:05:15 +010071 printf " --armc5-bin-dir=<ARMC5_bin_dir_path>\t\tPath to the ARM Compiler 5 bin directory.\n"
72 printf " --armc6-bin-dir=<ARMC6_bin_dir_path>\t\tPath to the ARM Compiler 6 bin directory.\n"
SimonB2e23c822016-04-16 21:54:39 +010073}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010074
75# remove built files as well as the cmake cache/config
76cleanup()
77{
78 make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020079
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020080 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000081 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020082 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
83 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020084
85 if [ -f "$CONFIG_BAK" ]; then
86 mv "$CONFIG_BAK" "$CONFIG_H"
87 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088}
89
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020090trap cleanup INT TERM HUP
91
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010092msg()
93{
94 echo ""
95 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +010096 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +000097 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010098 echo "******************************************************************"
99}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100100
Andres AGa5cd9732016-10-17 15:23:10 +0100101armc6_build_test()
102{
103 FLAGS="$1"
104
105 msg "build: ARM Compiler 6 ($FLAGS), make"
106 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
107 WARNING_CFLAGS= make lib
108 make clean
109}
110
Andres AGd9eba4b2016-08-26 14:42:14 +0100111err_msg()
112{
113 echo "$1" >&2
114}
115
116check_tools()
117{
118 for TOOL in "$@"; do
119 if ! `hash "$TOOL" >/dev/null 2>&1`; then
120 err_msg "$TOOL not found!"
121 exit 1
122 fi
123 done
124}
125
SimonB2e23c822016-04-16 21:54:39 +0100126while [ $# -gt 0 ]; do
127 case "$1" in
128 --memory|-m*)
129 MEMORY=${1#-m}
130 ;;
SimonB2e23c822016-04-16 21:54:39 +0100131 --force|-f)
132 FORCE=1
133 ;;
Andres AG7770ea82016-10-10 15:46:20 +0100134 --seed|-s)
135 shift
136 SEED="$1"
137 ;;
138 --release-test|-r)
139 RELEASE=1
140 ;;
Andres AGdc192212016-08-31 17:33:13 +0100141 --out-of-source-dir)
142 shift
143 OUT_OF_SOURCE_DIR="$1"
144 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100145 --openssl)
146 shift
147 OPENSSL="$1"
148 ;;
149 --openssl-legacy)
150 shift
151 OPENSSL_LEGACY="$1"
152 ;;
153 --gnutls-cli)
154 shift
155 GNUTLS_CLI="$1"
156 ;;
157 --gnutls-serv)
158 shift
159 GNUTLS_SERV="$1"
160 ;;
161 --gnutls-legacy-cli)
162 shift
163 GNUTLS_LEGACY_CLI="$1"
164 ;;
165 --gnutls-legacy-serv)
166 shift
167 GNUTLS_LEGACY_SERV="$1"
168 ;;
Andres AG87bb5772016-09-27 15:05:15 +0100169 --armc5-bin-dir)
170 shift
171 ARMC5_BIN_DIR="$1"
172 ;;
173 --armc6-bin-dir)
174 shift
175 ARMC6_BIN_DIR="$1"
176 ;;
SimonB2e23c822016-04-16 21:54:39 +0100177 --help|-h|*)
Andres AGd9eba4b2016-08-26 14:42:14 +0100178 usage
SimonB2e23c822016-04-16 21:54:39 +0100179 exit 1
180 ;;
181 esac
182 shift
183done
184
185if [ $FORCE -eq 1 ]; then
Andres AGdc192212016-08-31 17:33:13 +0100186 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
SimonB2e23c822016-04-16 21:54:39 +0100187 git checkout-index -f -q $CONFIG_H
188 cleanup
189else
190
191 if [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100192 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100193 echo "You can either delete your work and retry, or force the test to overwrite the"
194 echo "test by rerunning the script as: $0 --force"
195 exit 1
196 fi
197
Andres AGdc192212016-08-31 17:33:13 +0100198 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
199 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
200 echo "You can either delete this directory manually, or force the test by rerunning"
201 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
202 exit 1
203 fi
204
SimonB2e23c822016-04-16 21:54:39 +0100205 if ! git diff-files --quiet include/mbedtls/config.h; then
206 echo $?
Andres AGd9eba4b2016-08-26 14:42:14 +0100207 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100208 echo "You can either delete or preserve your work, or force the test by rerunning the"
209 echo "script as: $0 --force"
210 exit 1
211 fi
212fi
213
Andres AG7770ea82016-10-10 15:46:20 +0100214if [ $RELEASE -eq 1 ]; then
215 # Fix the seed value to 1 to ensure that the tests are deterministic.
216 SEED=1
217fi
218
Andres AGd9eba4b2016-08-26 14:42:14 +0100219msg "info: $0 configuration"
220echo "MEMORY: $MEMORY"
221echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100222echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100223echo "OPENSSL: $OPENSSL"
224echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
225echo "GNUTLS_CLI: $GNUTLS_CLI"
226echo "GNUTLS_SERV: $GNUTLS_SERV"
227echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
228echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100229echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
230echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
231
232ARMC5_CC="$ARMC5_BIN_DIR/armcc"
233ARMC5_AR="$ARMC5_BIN_DIR/armar"
234ARMC6_CC="$ARMC6_BIN_DIR/armclang"
235ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100236
Andres AGb2fdd042016-09-22 14:17:46 +0100237# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
238# we just export the variables they require
239export OPENSSL_CMD="$OPENSSL"
240export GNUTLS_CLI="$GNUTLS_CLI"
241export GNUTLS_SERV="$GNUTLS_SERV"
242
Andres AG7770ea82016-10-10 15:46:20 +0100243# Avoid passing --seed flag in every call to ssl-opt.sh
244[ ! -z ${SEED+set} ] && export SEED
245
Andres AGd9eba4b2016-08-26 14:42:14 +0100246# Make sure the tools we need are available.
247check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
248 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Andres AG87bb5772016-09-27 15:05:15 +0100249 "arm-none-eabi-gcc" "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
Andres AGd9eba4b2016-08-26 14:42:14 +0100250
SimonB2e23c822016-04-16 21:54:39 +0100251#
252# Test Suites to be executed
253#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200254# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100255# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200256# and/or are more likely to fail than others (eg I use Clang most of the
257# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200258# 2. Minimize total running time, by avoiding useless rebuilds
259#
260# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100261
Janos Follathb72c6782016-07-19 14:54:17 +0100262msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100263OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
264 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100265 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
266 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100267
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100268msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200269tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100270
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000271msg "test: freshness of generated source files" # < 1s
272tests/scripts/check-generated-files.sh
273
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200274msg "test: doxygen markup outside doxygen blocks" # < 1s
275tests/scripts/check-doxy-blocks.pl
276
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200277msg "test/build: declared and exported names" # < 3s
278cleanup
279tests/scripts/check-names.sh
280
Andres AGd9eba4b2016-08-26 14:42:14 +0100281msg "test: doxygen warnings" # ~ 3s
282cleanup
283tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100284
Simon Butcher49f00bd2017-01-05 16:20:56 +0000285# Note - use of yotta is deprecated, and yotta also requires armcc to be on the
286# path, and uses whatever version of armcc it finds there.
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200287msg "build: create and build yotta module" # ~ 30s
288cleanup
289tests/scripts/yotta-build.sh
290
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100291msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100292cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100293CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100294make
295
Simon Butcher8e3afc72016-09-15 17:13:08 +0100296msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100297make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200298
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100299msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100300tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200301
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100302msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200303tests/scripts/test-ref-configs.pl
304
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200305msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
306make
307
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100308msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100309tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200310
Simon Butcher3ea7f522016-03-07 23:22:10 +0000311msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
312cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000313cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000314scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
315CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
316make
317
Simon Butcher8e3afc72016-09-15 17:13:08 +0100318msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000319make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000320
321msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100322tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
323OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000324
325msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
326tests/ssl-opt.sh
327
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100328msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100329cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100330cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200331scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200332scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100333CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100334make
335
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100336msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200337make test
338
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100339msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100340tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200341
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100342msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100343OPENSSL_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 +0200344
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200345msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100346cleanup
347cmake -D CMAKE_BUILD_TYPE:String=Debug .
348tests/scripts/curves.pl
349
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200350msg "test/build: key-exchanges (gcc)" # ~ 1 min
351cleanup
352cmake -D CMAKE_BUILD_TYPE:String=Check .
353tests/scripts/key-exchanges.pl
354
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000355msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100356cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000357CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100358
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200359# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000360# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100361msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000362cleanup
363cp "$CONFIG_H" "$CONFIG_BAK"
364scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200365scripts/config.pl unset MBEDTLS_PLATFORM_C
366scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100367scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
368scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
369scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100370scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100371scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100372scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200373scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
374scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000375CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000376
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100377# catch compile bugs in _uninit functions
378msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
379cleanup
380cp "$CONFIG_H" "$CONFIG_BAK"
381scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100382scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100383scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100384CC=gcc CFLAGS='-Werror -O0' make
385
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200386msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
387cleanup
388cp "$CONFIG_H" "$CONFIG_BAK"
389scripts/config.pl full
390scripts/config.pl unset MBEDTLS_SSL_SRV_C
391CC=gcc CFLAGS='-Werror -O0' make
392
393msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
394cleanup
395cp "$CONFIG_H" "$CONFIG_BAK"
396scripts/config.pl full
397scripts/config.pl unset MBEDTLS_SSL_CLI_C
398CC=gcc CFLAGS='-Werror -O0' make
399
Andres AG788aa4a2016-09-14 14:32:09 +0100400msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200401cleanup
402cp "$CONFIG_H" "$CONFIG_BAK"
403scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200404scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
405scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Manuel Pégourié-Gonnard71859362015-06-02 16:39:22 +0100406CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200407
Simon Butcherab5df402016-06-11 02:31:21 +0100408msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100409cleanup
410cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100411scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100412scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
413scripts/config.pl set MBEDTLS_ENTROPY_C
414scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
415scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
416scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100417CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100418make
419
Simon Butcher8e3afc72016-09-15 17:13:08 +0100420msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100421make test
Janos Follath06c54002016-06-09 13:57:40 +0100422
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200423if uname -a | grep -F Linux >/dev/null; then
424msg "build/test: make shared" # ~ 40s
425cleanup
426make SHARED=1 all check
427fi
428
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000429if uname -a | grep -F x86_64 >/dev/null; then
430msg "build: i386, make, gcc" # ~ 30s
431cleanup
432CC=gcc CFLAGS='-Werror -m32' make
433fi # x86_64
434
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000435msg "build: arm-none-eabi-gcc, make" # ~ 10s
436cleanup
437cp "$CONFIG_H" "$CONFIG_BAK"
438scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200439scripts/config.pl unset MBEDTLS_NET_C
440scripts/config.pl unset MBEDTLS_TIMING_C
441scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100442scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000443scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000444# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200445scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
446scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
447scripts/config.pl unset MBEDTLS_THREADING_C
448scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
449scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200450CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror make lib
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000451
Andres AG87bb5772016-09-27 15:05:15 +0100452msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100453cleanup
454cp "$CONFIG_H" "$CONFIG_BAK"
455scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200456scripts/config.pl unset MBEDTLS_NET_C
457scripts/config.pl unset MBEDTLS_TIMING_C
458scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100459scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200460scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200461scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000462scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100463# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200464scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
465scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
466scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
467scripts/config.pl unset MBEDTLS_THREADING_C
468scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
469scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300470scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100471
472CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= make lib
473make clean
474
Andres AGa5cd9732016-10-17 15:23:10 +0100475armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
476armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
477armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
478armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
479armc6_build_test "--target=aarch64-arm-none-eabi"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100480
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100481if which i686-w64-mingw32-gcc >/dev/null; then
482msg "build: cross-mingw64, make" # ~ 30s
483cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200484CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 make
Manuel Pégourié-Gonnard52fa38a2015-06-23 14:29:58 +0200485WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200486CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
487WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100488fi
489
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000490# MemSan currently only available on Linux 64 bits
491if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000492
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100493msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100494cleanup
495cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200496scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100497CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
498make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200499
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100500msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100501make test
502
503msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100504tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100505
506# Optional part(s)
507
508if [ "$MEMORY" -gt 0 ]; then
509 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100510 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200511fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100512
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000513else # no MemSan
514
515msg "build: Release (clang)"
516cleanup
517CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
518make
519
520msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200521make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000522
523# Optional part(s)
524# Currently broken, programs don't seem to receive signals
525# under valgrind on OS X
526
527if [ "$MEMORY" -gt 0 ]; then
528 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100529 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000530fi
531
532if [ "$MEMORY" -gt 1 ]; then
533 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100534 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000535fi
536
537fi # MemSan
538
Andres AGdc192212016-08-31 17:33:13 +0100539msg "build: cmake 'out-of-source' build"
540cleanup
541MBEDTLS_ROOT_DIR="$PWD"
542mkdir "$OUT_OF_SOURCE_DIR"
543cd "$OUT_OF_SOURCE_DIR"
544cmake "$MBEDTLS_ROOT_DIR"
545make
546
547msg "test: cmake 'out-of-source' build"
548make test
549cd "$MBEDTLS_ROOT_DIR"
550rm -rf "$OUT_OF_SOURCE_DIR"
551
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100552msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100553cleanup
554