blob: 5fe9fd87766b130abbde54e01715a7f076d19cf6 [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
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200285msg "build: create and build yotta module" # ~ 30s
286cleanup
287tests/scripts/yotta-build.sh
288
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100289msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100290cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100291CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100292make
293
Simon Butcher8e3afc72016-09-15 17:13:08 +0100294msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100295make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200296
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100297msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100298tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200299
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100300msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200301tests/scripts/test-ref-configs.pl
302
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200303msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
304make
305
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100306msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100307tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200308
Simon Butcher3ea7f522016-03-07 23:22:10 +0000309msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
310cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000311cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000312scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
313CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
314make
315
Simon Butcher8e3afc72016-09-15 17:13:08 +0100316msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000317make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000318
319msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100320tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
321OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000322
323msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
324tests/ssl-opt.sh
325
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100326msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100327cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100328cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200329scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200330scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100331CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100332make
333
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100334msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200335make test
336
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100337msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100338tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200339
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100340msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100341OPENSSL_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 +0200342
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200343msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100344cleanup
345cmake -D CMAKE_BUILD_TYPE:String=Debug .
346tests/scripts/curves.pl
347
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200348msg "test/build: key-exchanges (gcc)" # ~ 1 min
349cleanup
350cmake -D CMAKE_BUILD_TYPE:String=Check .
351tests/scripts/key-exchanges.pl
352
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000353msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100354cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000355CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100356
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200357# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000358# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100359msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000360cleanup
361cp "$CONFIG_H" "$CONFIG_BAK"
362scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200363scripts/config.pl unset MBEDTLS_PLATFORM_C
364scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100365scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
366scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
367scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100368scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100369scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100370scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200371scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
372scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000373CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000374
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100375# catch compile bugs in _uninit functions
376msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
377cleanup
378cp "$CONFIG_H" "$CONFIG_BAK"
379scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100380scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100381scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100382CC=gcc CFLAGS='-Werror -O0' make
383
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200384msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
385cleanup
386cp "$CONFIG_H" "$CONFIG_BAK"
387scripts/config.pl full
388scripts/config.pl unset MBEDTLS_SSL_SRV_C
389CC=gcc CFLAGS='-Werror -O0' make
390
391msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
392cleanup
393cp "$CONFIG_H" "$CONFIG_BAK"
394scripts/config.pl full
395scripts/config.pl unset MBEDTLS_SSL_CLI_C
396CC=gcc CFLAGS='-Werror -O0' make
397
Andres AG788aa4a2016-09-14 14:32:09 +0100398msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200399cleanup
400cp "$CONFIG_H" "$CONFIG_BAK"
401scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200402scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
403scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Manuel Pégourié-Gonnard71859362015-06-02 16:39:22 +0100404CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200405
Simon Butcherab5df402016-06-11 02:31:21 +0100406msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100407cleanup
408cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100409scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100410scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
411scripts/config.pl set MBEDTLS_ENTROPY_C
412scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
413scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
414scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100415CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100416make
417
Simon Butcher8e3afc72016-09-15 17:13:08 +0100418msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100419make test
Janos Follath06c54002016-06-09 13:57:40 +0100420
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200421if uname -a | grep -F Linux >/dev/null; then
422msg "build/test: make shared" # ~ 40s
423cleanup
424make SHARED=1 all check
425fi
426
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000427if uname -a | grep -F x86_64 >/dev/null; then
428msg "build: i386, make, gcc" # ~ 30s
429cleanup
430CC=gcc CFLAGS='-Werror -m32' make
431fi # x86_64
432
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000433msg "build: arm-none-eabi-gcc, make" # ~ 10s
434cleanup
435cp "$CONFIG_H" "$CONFIG_BAK"
436scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200437scripts/config.pl unset MBEDTLS_NET_C
438scripts/config.pl unset MBEDTLS_TIMING_C
439scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100440scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000441scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000442# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200443scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
444scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
445scripts/config.pl unset MBEDTLS_THREADING_C
446scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
447scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200448CC=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 +0000449
Andres AG87bb5772016-09-27 15:05:15 +0100450msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100451cleanup
452cp "$CONFIG_H" "$CONFIG_BAK"
453scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200454scripts/config.pl unset MBEDTLS_NET_C
455scripts/config.pl unset MBEDTLS_TIMING_C
456scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100457scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200458scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200459scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000460scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100461# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200462scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
463scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
464scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
465scripts/config.pl unset MBEDTLS_THREADING_C
466scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
467scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300468scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100469
470CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= make lib
471make clean
472
Andres AGa5cd9732016-10-17 15:23:10 +0100473armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
474armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
475armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
476armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
477armc6_build_test "--target=aarch64-arm-none-eabi"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100478
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100479if which i686-w64-mingw32-gcc >/dev/null; then
480msg "build: cross-mingw64, make" # ~ 30s
481cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200482CC=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 +0200483WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200484CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
485WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100486fi
487
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000488# MemSan currently only available on Linux 64 bits
489if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000490
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100491msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100492cleanup
493cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200494scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100495CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
496make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200497
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100498msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100499make test
500
501msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100502tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100503
504# Optional part(s)
505
506if [ "$MEMORY" -gt 0 ]; then
507 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100508 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200509fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100510
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000511else # no MemSan
512
513msg "build: Release (clang)"
514cleanup
515CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
516make
517
518msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200519make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000520
521# Optional part(s)
522# Currently broken, programs don't seem to receive signals
523# under valgrind on OS X
524
525if [ "$MEMORY" -gt 0 ]; then
526 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100527 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000528fi
529
530if [ "$MEMORY" -gt 1 ]; then
531 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100532 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000533fi
534
535fi # MemSan
536
Andres AGdc192212016-08-31 17:33:13 +0100537msg "build: cmake 'out-of-source' build"
538cleanup
539MBEDTLS_ROOT_DIR="$PWD"
540mkdir "$OUT_OF_SOURCE_DIR"
541cd "$OUT_OF_SOURCE_DIR"
542cmake "$MBEDTLS_ROOT_DIR"
543make
544
545msg "test: cmake 'out-of-source' build"
546make test
547cd "$MBEDTLS_ROOT_DIR"
548rm -rf "$OUT_OF_SOURCE_DIR"
549
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100550msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100551cleanup
552