blob: 0a5c234c5f1db75090c77542e32848ddc66bb6af [file] [log] [blame]
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001#!/bin/sh
2
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 AGd9eba4b2016-08-26 14:42:14 +0100101err_msg()
102{
103 echo "$1" >&2
104}
105
106check_tools()
107{
108 for TOOL in "$@"; do
109 if ! `hash "$TOOL" >/dev/null 2>&1`; then
110 err_msg "$TOOL not found!"
111 exit 1
112 fi
113 done
114}
115
SimonB2e23c822016-04-16 21:54:39 +0100116while [ $# -gt 0 ]; do
117 case "$1" in
118 --memory|-m*)
119 MEMORY=${1#-m}
120 ;;
SimonB2e23c822016-04-16 21:54:39 +0100121 --force|-f)
122 FORCE=1
123 ;;
Andres AG7770ea82016-10-10 15:46:20 +0100124 --seed|-s)
125 shift
126 SEED="$1"
127 ;;
128 --release-test|-r)
129 RELEASE=1
130 ;;
Andres AGdc192212016-08-31 17:33:13 +0100131 --out-of-source-dir)
132 shift
133 OUT_OF_SOURCE_DIR="$1"
134 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100135 --openssl)
136 shift
137 OPENSSL="$1"
138 ;;
139 --openssl-legacy)
140 shift
141 OPENSSL_LEGACY="$1"
142 ;;
143 --gnutls-cli)
144 shift
145 GNUTLS_CLI="$1"
146 ;;
147 --gnutls-serv)
148 shift
149 GNUTLS_SERV="$1"
150 ;;
151 --gnutls-legacy-cli)
152 shift
153 GNUTLS_LEGACY_CLI="$1"
154 ;;
155 --gnutls-legacy-serv)
156 shift
157 GNUTLS_LEGACY_SERV="$1"
158 ;;
Andres AG87bb5772016-09-27 15:05:15 +0100159 --armc5-bin-dir)
160 shift
161 ARMC5_BIN_DIR="$1"
162 ;;
163 --armc6-bin-dir)
164 shift
165 ARMC6_BIN_DIR="$1"
166 ;;
SimonB2e23c822016-04-16 21:54:39 +0100167 --help|-h|*)
Andres AGd9eba4b2016-08-26 14:42:14 +0100168 usage
SimonB2e23c822016-04-16 21:54:39 +0100169 exit 1
170 ;;
171 esac
172 shift
173done
174
175if [ $FORCE -eq 1 ]; then
Andres AGdc192212016-08-31 17:33:13 +0100176 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
SimonB2e23c822016-04-16 21:54:39 +0100177 git checkout-index -f -q $CONFIG_H
178 cleanup
179else
180
181 if [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100182 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100183 echo "You can either delete your work and retry, or force the test to overwrite the"
184 echo "test by rerunning the script as: $0 --force"
185 exit 1
186 fi
187
Andres AGdc192212016-08-31 17:33:13 +0100188 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
189 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
190 echo "You can either delete this directory manually, or force the test by rerunning"
191 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
192 exit 1
193 fi
194
SimonB2e23c822016-04-16 21:54:39 +0100195 if ! git diff-files --quiet include/mbedtls/config.h; then
196 echo $?
Andres AGd9eba4b2016-08-26 14:42:14 +0100197 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100198 echo "You can either delete or preserve your work, or force the test by rerunning the"
199 echo "script as: $0 --force"
200 exit 1
201 fi
202fi
203
Andres AG7770ea82016-10-10 15:46:20 +0100204if [ $RELEASE -eq 1 ]; then
205 # Fix the seed value to 1 to ensure that the tests are deterministic.
206 SEED=1
207fi
208
Andres AGd9eba4b2016-08-26 14:42:14 +0100209msg "info: $0 configuration"
210echo "MEMORY: $MEMORY"
211echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100212echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100213echo "OPENSSL: $OPENSSL"
214echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
215echo "GNUTLS_CLI: $GNUTLS_CLI"
216echo "GNUTLS_SERV: $GNUTLS_SERV"
217echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
218echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
Andres AG87bb5772016-09-27 15:05:15 +0100219echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
220echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
221
222ARMC5_CC="$ARMC5_BIN_DIR/armcc"
223ARMC5_AR="$ARMC5_BIN_DIR/armar"
224ARMC6_CC="$ARMC6_BIN_DIR/armclang"
225ARMC6_AR="$ARMC6_BIN_DIR/armar"
Andres AGd9eba4b2016-08-26 14:42:14 +0100226
Andres AGb2fdd042016-09-22 14:17:46 +0100227# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
228# we just export the variables they require
229export OPENSSL_CMD="$OPENSSL"
230export GNUTLS_CLI="$GNUTLS_CLI"
231export GNUTLS_SERV="$GNUTLS_SERV"
232
Andres AG7770ea82016-10-10 15:46:20 +0100233# Avoid passing --seed flag in every call to ssl-opt.sh
234[ ! -z ${SEED+set} ] && export SEED
235
Andres AGd9eba4b2016-08-26 14:42:14 +0100236# Make sure the tools we need are available.
237check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
238 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
Andres AG87bb5772016-09-27 15:05:15 +0100239 "arm-none-eabi-gcc" "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
Andres AGd9eba4b2016-08-26 14:42:14 +0100240
SimonB2e23c822016-04-16 21:54:39 +0100241#
242# Test Suites to be executed
243#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200244# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100245# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200246# and/or are more likely to fail than others (eg I use Clang most of the
247# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200248# 2. Minimize total running time, by avoiding useless rebuilds
249#
250# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100251
Janos Follathb72c6782016-07-19 14:54:17 +0100252msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100253OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
254 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
Andres AG87bb5772016-09-27 15:05:15 +0100255 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
256 ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100257
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100258msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200259tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100260
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000261msg "test: freshness of generated source files" # < 1s
262tests/scripts/check-generated-files.sh
263
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200264msg "test: doxygen markup outside doxygen blocks" # < 1s
265tests/scripts/check-doxy-blocks.pl
266
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200267msg "test/build: declared and exported names" # < 3s
268cleanup
269tests/scripts/check-names.sh
270
Andres AGd9eba4b2016-08-26 14:42:14 +0100271msg "test: doxygen warnings" # ~ 3s
272cleanup
273tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100274
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200275msg "build: create and build yotta module" # ~ 30s
276cleanup
277tests/scripts/yotta-build.sh
278
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100279msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100280cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100281CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100282make
283
Simon Butcher8e3afc72016-09-15 17:13:08 +0100284msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100285make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200286
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100287msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100288tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200289
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100290msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200291tests/scripts/test-ref-configs.pl
292
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200293msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
294make
295
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100296msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100297tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200298
Simon Butcher3ea7f522016-03-07 23:22:10 +0000299msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
300cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000301cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000302scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
303CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
304make
305
Simon Butcher8e3afc72016-09-15 17:13:08 +0100306msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000307make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000308
309msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100310tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
311OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000312
313msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
314tests/ssl-opt.sh
315
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100316msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100317cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100318cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200319scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200320scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100321CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100322make
323
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100324msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200325make test
326
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100327msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100328tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200329
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100330msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100331OPENSSL_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 +0200332
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200333msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100334cleanup
335cmake -D CMAKE_BUILD_TYPE:String=Debug .
336tests/scripts/curves.pl
337
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200338msg "test/build: key-exchanges (gcc)" # ~ 1 min
339cleanup
340cmake -D CMAKE_BUILD_TYPE:String=Check .
341tests/scripts/key-exchanges.pl
342
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000343msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100344cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000345CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100346
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200347# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000348# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100349msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000350cleanup
351cp "$CONFIG_H" "$CONFIG_BAK"
352scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200353scripts/config.pl unset MBEDTLS_PLATFORM_C
354scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100355scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
356scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
357scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100358scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100359scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100360scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200361scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
362scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000363CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000364
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100365# catch compile bugs in _uninit functions
366msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
367cleanup
368cp "$CONFIG_H" "$CONFIG_BAK"
369scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100370scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100371scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100372CC=gcc CFLAGS='-Werror -O0' make
373
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200374msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
375cleanup
376cp "$CONFIG_H" "$CONFIG_BAK"
377scripts/config.pl full
378scripts/config.pl unset MBEDTLS_SSL_SRV_C
379CC=gcc CFLAGS='-Werror -O0' make
380
381msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
382cleanup
383cp "$CONFIG_H" "$CONFIG_BAK"
384scripts/config.pl full
385scripts/config.pl unset MBEDTLS_SSL_CLI_C
386CC=gcc CFLAGS='-Werror -O0' make
387
Andres AG788aa4a2016-09-14 14:32:09 +0100388msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200389cleanup
390cp "$CONFIG_H" "$CONFIG_BAK"
391scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200392scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
393scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Manuel Pégourié-Gonnard71859362015-06-02 16:39:22 +0100394CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200395
Simon Butcherab5df402016-06-11 02:31:21 +0100396msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100397cleanup
398cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100399scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100400scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
401scripts/config.pl set MBEDTLS_ENTROPY_C
402scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
403scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
404scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100405CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100406make
407
Simon Butcher8e3afc72016-09-15 17:13:08 +0100408msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100409make test
Janos Follath06c54002016-06-09 13:57:40 +0100410
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200411if uname -a | grep -F Linux >/dev/null; then
412msg "build/test: make shared" # ~ 40s
413cleanup
414make SHARED=1 all check
415fi
416
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000417if uname -a | grep -F x86_64 >/dev/null; then
418msg "build: i386, make, gcc" # ~ 30s
419cleanup
420CC=gcc CFLAGS='-Werror -m32' make
421fi # x86_64
422
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000423msg "build: arm-none-eabi-gcc, make" # ~ 10s
424cleanup
425cp "$CONFIG_H" "$CONFIG_BAK"
426scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200427scripts/config.pl unset MBEDTLS_NET_C
428scripts/config.pl unset MBEDTLS_TIMING_C
429scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100430scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000431scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000432# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200433scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
434scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
435scripts/config.pl unset MBEDTLS_THREADING_C
436scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
437scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200438CC=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 +0000439
Andres AG87bb5772016-09-27 15:05:15 +0100440msg "build: ARM Compiler 5, make"
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100441cleanup
442cp "$CONFIG_H" "$CONFIG_BAK"
443scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200444scripts/config.pl unset MBEDTLS_NET_C
445scripts/config.pl unset MBEDTLS_TIMING_C
446scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100447scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200448scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200449scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000450scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100451# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200452scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
453scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
454scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
455scripts/config.pl unset MBEDTLS_THREADING_C
456scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
457scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300458scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Andres AG87bb5772016-09-27 15:05:15 +0100459
460CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= make lib
461make clean
462
463msg "build: ARM Compiler 6 (arm-arm-none-eabi), make"
464ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" \
465 CFLAGS="--target=arm-arm-none-eabi" WARNING_CFLAGS= make lib
466make clean
467
468msg "build: ARM Compiler 6 (aarch64-arm-none-eabi), make"
469ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" \
470 CFLAGS="--target=aarch64-arm-none-eabi" WARNING_CFLAGS= make lib
471make clean
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100472
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100473if which i686-w64-mingw32-gcc >/dev/null; then
474msg "build: cross-mingw64, make" # ~ 30s
475cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200476CC=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 +0200477WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200478CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
479WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100480fi
481
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000482# MemSan currently only available on Linux 64 bits
483if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000484
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100485msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100486cleanup
487cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200488scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100489CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
490make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200491
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100492msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100493make test
494
495msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100496tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100497
498# Optional part(s)
499
500if [ "$MEMORY" -gt 0 ]; then
501 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100502 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200503fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100504
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000505else # no MemSan
506
507msg "build: Release (clang)"
508cleanup
509CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
510make
511
512msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200513make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000514
515# Optional part(s)
516# Currently broken, programs don't seem to receive signals
517# under valgrind on OS X
518
519if [ "$MEMORY" -gt 0 ]; then
520 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100521 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000522fi
523
524if [ "$MEMORY" -gt 1 ]; then
525 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100526 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000527fi
528
529fi # MemSan
530
Andres AGdc192212016-08-31 17:33:13 +0100531msg "build: cmake 'out-of-source' build"
532cleanup
533MBEDTLS_ROOT_DIR="$PWD"
534mkdir "$OUT_OF_SOURCE_DIR"
535cd "$OUT_OF_SOURCE_DIR"
536cmake "$MBEDTLS_ROOT_DIR"
537make
538
539msg "test: cmake 'out-of-source' build"
540make test
541cd "$MBEDTLS_ROOT_DIR"
542rm -rf "$OUT_OF_SOURCE_DIR"
543
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100544msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100545cleanup
546