blob: 133d9867740e42d7d807ddd11b8254ed8ca3ed4b [file] [log] [blame]
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001#!/bin/sh
2
Simon Butcher123fb022016-10-15 22:18:05 +01003# all.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01004#
Simon Butcher123fb022016-10-15 22:18:05 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01006#
Simon Butcher123fb022016-10-15 22:18:05 +01007# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# To run all tests possible or available on the platform.
12#
13# 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.
17#
18# 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
Simon Butcher123fb022016-10-15 22:18:05 +010022# Abort on errors (and uninitialised variables)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010023set -eu
24
25if [ -d library -a -d include -a -d tests ]; then :; else
Simon Butcher123fb022016-10-15 22:18:05 +010026 err_msg "Must be run from mbed TLS root"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010027 exit 1
28fi
29
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020030CONFIG_H='include/polarssl/config.h'
31CONFIG_BAK="$CONFIG_H.bak"
32
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010033MEMORY=0
Simon Butcher123fb022016-10-15 22:18:05 +010034FORCE=0
35RELEASE=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010036
Simon Butcher123fb022016-10-15 22:18:05 +010037# Default commands, can be overriden by the environment
38: ${OPENSSL:="openssl"}
39: ${OPENSSL_LEGACY:="$OPENSSL"}
40: ${GNUTLS_CLI:="gnutls-cli"}
41: ${GNUTLS_SERV:="gnutls-serv"}
42: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
43: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
44: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
45
46usage()
47{
48 printf "Usage: $0\n"
49 printf " -h|--help\t\tPrint this help.\n"
50 printf " -m|--memory\t\tAdditional optional memory tests.\n"
51 printf " -f|--force\t\tForce the tests to overwrite any modified files.\n"
52 printf " -s|--seed\t\tInteger seed value to use for this test run.\n"
53 printf " -r|--release-test\t\tRun this script in release mode. This fixes the seed value to 1.\n"
54 printf " --out-of-source-dir=<path>\t\tDirectory used for CMake out-of-source build tests."
55 printf " --openssl=<OpenSSL_path>\t\tPath to OpenSSL executable to use for most tests.\n"
56 printf " --openssl-legacy=<OpenSSL_path>\t\tPath to OpenSSL executable to use for legacy tests e.g. SSLv3.\n"
57 printf " --gnutls-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for most tests.\n"
58 printf " --gnutls-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for most tests.\n"
59 printf " --gnutls-legacy-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for legacy tests.\n"
60 printf " --gnutls-legacy-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for legacy tests.\n"
61}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010062
63# remove built files as well as the cmake cache/config
64cleanup()
65{
66 make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020067
Manuel Pégourié-Gonnard76c99a02014-12-11 10:33:43 +010068 find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard897a5952014-03-25 13:23:04 +010069 rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020070 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
71 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020072
73 if [ -f "$CONFIG_BAK" ]; then
74 mv "$CONFIG_BAK" "$CONFIG_H"
75 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010076}
77
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020078trap cleanup INT TERM HUP
79
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010080msg()
81{
82 echo ""
83 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +010084 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +000085 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010086 echo "******************************************************************"
87}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088
Simon Butcher123fb022016-10-15 22:18:05 +010089err_msg()
90{
91 echo "$1" >&2
92}
93
94check_tools()
95{
96 for TOOL in "$@"; do
97 if ! `hash "$TOOL" >/dev/null 2>&1`; then
98 err_msg "$TOOL not found!"
99 exit 1
100 fi
101 done
102}
103
104while [ $# -gt 0 ]; do
105 case "$1" in
106 --memory|-m*)
107 MEMORY=${1#-m}
108 ;;
109 --force|-f)
110 FORCE=1
111 ;;
112 --seed|-s)
113 shift
114 SEED="$1"
115 ;;
116 --release-test|-r)
117 RELEASE=1
118 ;;
119 --out-of-source-dir)
120 shift
121 OUT_OF_SOURCE_DIR="$1"
122 ;;
123 --openssl)
124 shift
125 OPENSSL="$1"
126 ;;
127 --openssl-legacy)
128 shift
129 OPENSSL_LEGACY="$1"
130 ;;
131 --gnutls-cli)
132 shift
133 GNUTLS_CLI="$1"
134 ;;
135 --gnutls-serv)
136 shift
137 GNUTLS_SERV="$1"
138 ;;
139 --gnutls-legacy-cli)
140 shift
141 GNUTLS_LEGACY_CLI="$1"
142 ;;
143 --gnutls-legacy-serv)
144 shift
145 GNUTLS_LEGACY_SERV="$1"
146 ;;
147 --help|-h|*)
148 usage
149 exit 1
150 ;;
151 esac
152 shift
153done
154
155if [ $FORCE -eq 1 ]; then
156 git checkout-index -f -q $CONFIG_H
157 cleanup
158else
159
160 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
161 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
162 echo "You can either delete this directory manually, or force the test by rerunning"
163 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
164 exit 1
165 fi
166
167 if ! git diff-files --quiet include/polarssl/config.h; then
168 echo $?
169 err_msg "Warning - the configuration file 'include/polarssl/config.h' has been edited. "
170 echo "You can either delete or preserve your work, or force the test by rerunning the"
171 echo "script as: $0 --force"
172 exit 1
173 fi
174fi
175
176if [ $RELEASE -eq 1 ]; then
177 # Fix the seed value to 1 to ensure that the tests are deterministic.
178 SEED=1
179fi
180
181msg "info: $0 configuration"
182echo "MEMORY: $MEMORY"
183echo "FORCE: $FORCE"
184echo "SEED: ${SEED-"UNSET"}"
185echo "OPENSSL: $OPENSSL"
186echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
187echo "GNUTLS_CLI: $GNUTLS_CLI"
188echo "GNUTLS_SERV: $GNUTLS_SERV"
189echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
190echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
191
192# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
193# we just export the variables they require
194export OPENSSL_CMD="$OPENSSL"
195export GNUTLS_CLI="$GNUTLS_CLI"
196export GNUTLS_SERV="$GNUTLS_SERV"
197
198# Avoid passing --seed flag in every call to ssl-opt.sh
199[ ! -z ${SEED+set} ] && export SEED
200
201# Make sure the tools we need are available.
202check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
203 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
204 "arm-none-eabi-gcc" "armcc"
205
206#
207# Test Suites to be executed
208#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200209# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100210# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200211# and/or are more likely to fail than others (eg I use Clang most of the
212# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200213# 2. Minimize total running time, by avoiding useless rebuilds
214#
215# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100216
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100217msg "test: recursion.pl" # < 1s
218scripts/recursion.pl library/*.c
219
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000220msg "test: freshness of generated source files" # < 1s
221tests/scripts/check-generated-files.sh
222
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100223msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100224cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100225CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100226make
227
Simon Butcher123fb022016-10-15 22:18:05 +0100228msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100229make test
230programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200231
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100232msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Simon Butcher123fb022016-10-15 22:18:05 +0100233tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200234
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100235msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200236tests/scripts/test-ref-configs.pl
237
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200238msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
239make
240
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100241msg "test: compat.sh (ASan build)" # ~ 6 min
Simon Butcher123fb022016-10-15 22:18:05 +0100242tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200243
Janos Follath4dfecab2016-03-14 13:40:43 +0000244msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
245cleanup
246cp "$CONFIG_H" "$CONFIG_BAK"
247scripts/config.pl set POLARSSL_SSL_PROTO_SSL3
248CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
249make
250
Simon Butcher123fb022016-10-15 22:18:05 +0100251msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Janos Follath4dfecab2016-03-14 13:40:43 +0000252make test
253programs/test/selftest
254
255msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Simon Butcher123fb022016-10-15 22:18:05 +0100256tests/compat.sh -m 'tls1 tls1_1 tls1_2'
257OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Janos Follath4dfecab2016-03-14 13:40:43 +0000258
259msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Simon Butcher123fb022016-10-15 22:18:05 +0100260tests/ssl-opt.sh
Janos Follath4dfecab2016-03-14 13:40:43 +0000261
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100262msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100263cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200264cp "$CONFIG_H" "$CONFIG_BAK"
265scripts/config.pl full
266scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard4d9e36a2015-09-02 10:10:32 +0200267scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
268scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100269CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100270make
271
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100272msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200273make test
274
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100275msg "test: ssl-opt.sh default (full config)" # ~ 1s
Simon Butcher123fb022016-10-15 22:18:05 +0100276tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200277
Simon Butcher123fb022016-10-15 22:18:05 +0100278msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
279OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|3DES-EDE-CBC\|DES-CBC3'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200280
Simon Butcher123fb022016-10-15 22:18:05 +0100281
282msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100283cleanup
284cmake -D CMAKE_BUILD_TYPE:String=Debug .
285tests/scripts/curves.pl
286
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000287msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100288cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000289CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100290
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000291# this is meant to cath missing #define polarssl_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000292# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100293msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000294cleanup
295cp "$CONFIG_H" "$CONFIG_BAK"
296scripts/config.pl full
297scripts/config.pl unset POLARSSL_PLATFORM_C
Manuel Pégourié-Gonnard6ca40762015-02-13 15:57:35 +0000298scripts/config.pl unset POLARSSL_PLATFORM_MEMORY
Manuel Pégourié-Gonnard721e6bb2015-06-03 13:38:20 +0100299scripts/config.pl unset POLARSSL_PLATFORM_PRINTF_ALT
300scripts/config.pl unset POLARSSL_PLATFORM_FPRINTF_ALT
301scripts/config.pl unset POLARSSL_PLATFORM_SNPRINTF_ALT
302scripts/config.pl unset POLARSSL_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000303scripts/config.pl unset POLARSSL_MEMORY_C
304scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000305scripts/config.pl unset POLARSSL_FS_IO
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200306scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
307scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000308CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000309
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100310# catch compile bugs in _uninit functions
311msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
312cleanup
313cp "$CONFIG_H" "$CONFIG_BAK"
314scripts/config.pl full
315scripts/config.pl set POLARSSL_PLATFORM_NO_STD_FUNCTIONS
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200316scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
317scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100318CC=gcc CFLAGS='-Werror -O0' make
319
Simon Butcher123fb022016-10-15 22:18:05 +0100320msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
321cleanup
322cp "$CONFIG_H" "$CONFIG_BAK"
323scripts/config.pl full
324scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
325scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
326scripts/config.pl unset POLARSSL_SSL_SRV_C
327CC=gcc CFLAGS='-Werror -O0' make
328
329msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
330cleanup
331cp "$CONFIG_H" "$CONFIG_BAK"
332scripts/config.pl full
333scripts/config.pl unset POLARSSL_SSL_CLI_C
334scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
335scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
336CC=gcc CFLAGS='-Werror -O0' make
337
Manuel Pégourié-Gonnard1b1254f2015-08-10 11:56:06 +0200338if uname -a | grep -F Linux >/dev/null; then
339msg "build/test: make shared" # ~ 40s
340cleanup
341make SHARED=1 all check
342fi
343
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000344if uname -a | grep -F x86_64 >/dev/null; then
345msg "build: i386, make, gcc" # ~ 30s
346cleanup
347CC=gcc CFLAGS='-Werror -m32' make
348fi # x86_64
349
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000350msg "build: arm-none-eabi-gcc, make" # ~ 10s
351cleanup
352cp "$CONFIG_H" "$CONFIG_BAK"
353scripts/config.pl full
354scripts/config.pl unset POLARSSL_NET_C
355scripts/config.pl unset POLARSSL_TIMING_C
356scripts/config.pl unset POLARSSL_FS_IO
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200357scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
358scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Simon Butcher123fb022016-10-15 22:18:05 +0100359scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000360# following things are not in the default config
361scripts/config.pl unset POLARSSL_HAVEGE_C # depends on timing.c
362scripts/config.pl unset POLARSSL_THREADING_PTHREAD
363scripts/config.pl unset POLARSSL_THREADING_C
364scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # execinfo.h
365scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher123fb022016-10-15 22:18:05 +0100366CC=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 +0000367
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100368msg "build: armcc, make"
369cleanup
370cp "$CONFIG_H" "$CONFIG_BAK"
371scripts/config.pl full
372scripts/config.pl unset POLARSSL_NET_C
373scripts/config.pl unset POLARSSL_TIMING_C
374scripts/config.pl unset POLARSSL_FS_IO
375scripts/config.pl unset POLARSSL_HAVE_TIME
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200376scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
377scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Simon Butcher123fb022016-10-15 22:18:05 +0100378scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100379# following things are not in the default config
Manuel Pégourié-Gonnardf1002f82015-03-25 16:44:26 +0100380scripts/config.pl unset POLARSSL_DEPRECATED_WARNING
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100381scripts/config.pl unset POLARSSL_HAVEGE_C # depends on timing.c
382scripts/config.pl unset POLARSSL_THREADING_PTHREAD
383scripts/config.pl unset POLARSSL_THREADING_C
384scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # execinfo.h
385scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher123fb022016-10-15 22:18:05 +0100386CC=armcc AR=armar WARNING_CFLAGS= make lib
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100387
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100388if which i686-w64-mingw32-gcc >/dev/null; then
389msg "build: cross-mingw64, make" # ~ 30s
390cleanup
Manuel Pégourié-Gonnard1b1254f2015-08-10 11:56:06 +0200391CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 make
392WINDOWS_BUILD=1 make clean
393CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
394WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100395fi
396
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000397# MemSan currently only available on Linux 64 bits
398if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000399
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100400msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100401cleanup
402cp "$CONFIG_H" "$CONFIG_BAK"
403scripts/config.pl unset POLARSSL_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard1e77a962015-01-26 14:11:51 +0100404scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY # memsan vs getrandom()
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100405CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
406make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200407
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100408msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100409make test
410
411msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Simon Butcher123fb022016-10-15 22:18:05 +0100412tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100413
414# Optional part(s)
415
416if [ "$MEMORY" -gt 0 ]; then
417 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Simon Butcher123fb022016-10-15 22:18:05 +0100418 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200419fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100420
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000421else # no MemSan
422
423msg "build: Release (clang)"
424cleanup
425CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
426make
427
428msg "test: main suites valgrind (Release)"
429make test
430
431# Optional part(s)
432# Currently broken, programs don't seem to receive signals
433# under valgrind on OS X
434
435if [ "$MEMORY" -gt 0 ]; then
436 msg "test: ssl-opt.sh --memcheck (Release)"
Simon Butcher123fb022016-10-15 22:18:05 +0100437 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000438fi
439
440if [ "$MEMORY" -gt 1 ]; then
441 msg "test: compat.sh --memcheck (Release)"
Simon Butcher123fb022016-10-15 22:18:05 +0100442 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000443fi
444
445fi # MemSan
446
Simon Butcher123fb022016-10-15 22:18:05 +0100447msg "build: cmake 'out-of-source' build"
448cleanup
449MBEDTLS_ROOT_DIR="$PWD"
450mkdir "$OUT_OF_SOURCE_DIR"
451cd "$OUT_OF_SOURCE_DIR"
452cmake "$MBEDTLS_ROOT_DIR"
453make
454
455msg "test: cmake 'out-of-source' build"
456make test
457cd "$MBEDTLS_ROOT_DIR"
458rm -rf "$OUT_OF_SOURCE_DIR"
459
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100460msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100461cleanup
462