blob: a3782118f583b7f5a3ae8044b991a6075eb05433 [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" \
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100203 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
204 "arm-none-eabi-gcc" "armcc"
Simon Butcher123fb022016-10-15 22:18:05 +0100205
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
Hanno Beckerbe812f62017-10-25 09:49:13 +0100262msg "build: Default + POLARSSL_SSL_DISABLE_RENEGOTIATION (ASan build)" # ~ 6 min
263cleanup
264cp "$CONFIG_H" "$CONFIG_BAK"
265scripts/config.pl set POLARSSL_SSL_DISABLE_RENEGOTIATION
266CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
267make
268
269msg "test: POLARSSL_SSL_DISABLE_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
270make test
271
272msg "test: POLARSSL_SSL_DISABLE_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
273tests/ssl-opt.sh
274
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100275msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100276cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200277cp "$CONFIG_H" "$CONFIG_BAK"
278scripts/config.pl full
279scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard4d9e36a2015-09-02 10:10:32 +0200280scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
281scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100282CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100283make
284
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100285msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200286make test
287
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100288msg "test: ssl-opt.sh default (full config)" # ~ 1s
Simon Butcher123fb022016-10-15 22:18:05 +0100289tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200290
Simon Butcher123fb022016-10-15 22:18:05 +0100291msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
292OPENSSL_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 +0200293
Simon Butcher123fb022016-10-15 22:18:05 +0100294
295msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100296cleanup
297cmake -D CMAKE_BUILD_TYPE:String=Debug .
298tests/scripts/curves.pl
299
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000300msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100301cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000302CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100303
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000304# this is meant to cath missing #define polarssl_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000305# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100306msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000307cleanup
308cp "$CONFIG_H" "$CONFIG_BAK"
309scripts/config.pl full
310scripts/config.pl unset POLARSSL_PLATFORM_C
Manuel Pégourié-Gonnard6ca40762015-02-13 15:57:35 +0000311scripts/config.pl unset POLARSSL_PLATFORM_MEMORY
Manuel Pégourié-Gonnard721e6bb2015-06-03 13:38:20 +0100312scripts/config.pl unset POLARSSL_PLATFORM_PRINTF_ALT
313scripts/config.pl unset POLARSSL_PLATFORM_FPRINTF_ALT
314scripts/config.pl unset POLARSSL_PLATFORM_SNPRINTF_ALT
315scripts/config.pl unset POLARSSL_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000316scripts/config.pl unset POLARSSL_MEMORY_C
317scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000318scripts/config.pl unset POLARSSL_FS_IO
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200319scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
320scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000321CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000322
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100323# catch compile bugs in _uninit functions
324msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
325cleanup
326cp "$CONFIG_H" "$CONFIG_BAK"
327scripts/config.pl full
328scripts/config.pl set POLARSSL_PLATFORM_NO_STD_FUNCTIONS
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200329scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
330scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100331CC=gcc CFLAGS='-Werror -O0' make
332
Simon Butcher123fb022016-10-15 22:18:05 +0100333msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
334cleanup
335cp "$CONFIG_H" "$CONFIG_BAK"
336scripts/config.pl full
337scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
338scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
339scripts/config.pl unset POLARSSL_SSL_SRV_C
340CC=gcc CFLAGS='-Werror -O0' make
341
342msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
343cleanup
344cp "$CONFIG_H" "$CONFIG_BAK"
345scripts/config.pl full
346scripts/config.pl unset POLARSSL_SSL_CLI_C
347scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
348scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
349CC=gcc CFLAGS='-Werror -O0' make
350
Manuel Pégourié-Gonnard1b1254f2015-08-10 11:56:06 +0200351if uname -a | grep -F Linux >/dev/null; then
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100352 msg "build/test: make shared" # ~ 40s
353 cleanup
354 make SHARED=1 all check
Manuel Pégourié-Gonnard1b1254f2015-08-10 11:56:06 +0200355fi
356
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000357if uname -a | grep -F x86_64 >/dev/null; then
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100358 msg "build: i386, make, gcc" # ~ 30s
359 cleanup
360 CC=gcc CFLAGS='-Werror -m32' make
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000361fi # x86_64
362
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000363msg "build: arm-none-eabi-gcc, make" # ~ 10s
364cleanup
365cp "$CONFIG_H" "$CONFIG_BAK"
366scripts/config.pl full
367scripts/config.pl unset POLARSSL_NET_C
368scripts/config.pl unset POLARSSL_TIMING_C
369scripts/config.pl unset POLARSSL_FS_IO
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200370scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
371scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Simon Butcher123fb022016-10-15 22:18:05 +0100372scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000373# following things are not in the default config
374scripts/config.pl unset POLARSSL_HAVEGE_C # depends on timing.c
375scripts/config.pl unset POLARSSL_THREADING_PTHREAD
376scripts/config.pl unset POLARSSL_THREADING_C
377scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # execinfo.h
378scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher123fb022016-10-15 22:18:05 +0100379CC=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 +0000380
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100381msg "build: armcc, make"
382cleanup
383cp "$CONFIG_H" "$CONFIG_BAK"
384scripts/config.pl full
385scripts/config.pl unset POLARSSL_NET_C
386scripts/config.pl unset POLARSSL_TIMING_C
387scripts/config.pl unset POLARSSL_FS_IO
388scripts/config.pl unset POLARSSL_HAVE_TIME
Manuel Pégourié-Gonnardb0282ea2015-09-02 12:12:44 +0200389scripts/config.pl unset POLARSSL_ERROR_STRERROR_BC # deprecated
390scripts/config.pl unset POLARSSL_PBKDF2_C # deprecated
Simon Butcher123fb022016-10-15 22:18:05 +0100391scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100392# following things are not in the default config
Manuel Pégourié-Gonnardf1002f82015-03-25 16:44:26 +0100393scripts/config.pl unset POLARSSL_DEPRECATED_WARNING
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100394scripts/config.pl unset POLARSSL_HAVEGE_C # depends on timing.c
395scripts/config.pl unset POLARSSL_THREADING_PTHREAD
396scripts/config.pl unset POLARSSL_THREADING_C
397scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # execinfo.h
398scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher123fb022016-10-15 22:18:05 +0100399CC=armcc AR=armar WARNING_CFLAGS= make lib
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100400
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100401if which i686-w64-mingw32-gcc >/dev/null; then
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100402 msg "build: cross-mingw64, make" # ~ 30s
403 cleanup
404 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 make
405 WINDOWS_BUILD=1 make clean
406 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
407 WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100408fi
409
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000410# MemSan currently only available on Linux 64 bits
411if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000412
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100413 msg "build: MSan (clang)" # ~ 1 min 20s
414 cleanup
415 cp "$CONFIG_H" "$CONFIG_BAK"
416 scripts/config.pl unset POLARSSL_AESNI_C # memsan doesn't grok asm
417 scripts/config.pl set POLARSSL_NO_PLATFORM_ENTROPY # memsan vs getrandom()
418 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
419 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200420
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100421 msg "test: main suites (MSan)" # ~ 10s
422 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100423
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100424 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
425 tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100426
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100427 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100428
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100429 if [ "$MEMORY" -gt 0 ]; then
430 msg "test: compat.sh (MSan)" # ~ 6 min 20s
431 tests/compat.sh
432 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100433
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000434else # no MemSan
435
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100436 msg "build: Release (clang)"
437 cleanup
438 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
439 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000440
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100441 msg "test: main suites valgrind (Release)"
442 make test
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000443
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100444 # Optional part(s)
445 # Currently broken, programs don't seem to receive signals
446 # under valgrind on OS X
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000447
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100448 if [ "$MEMORY" -gt 0 ]; then
449 msg "test: ssl-opt.sh --memcheck (Release)"
450 tests/ssl-opt.sh --memcheck
451 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000452
Gilles Peskinefb18b6c2017-12-20 14:00:06 +0100453 if [ "$MEMORY" -gt 1 ]; then
454 msg "test: compat.sh --memcheck (Release)"
455 tests/compat.sh --memcheck
456 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000457
458fi # MemSan
459
Simon Butcher123fb022016-10-15 22:18:05 +0100460msg "build: cmake 'out-of-source' build"
461cleanup
462MBEDTLS_ROOT_DIR="$PWD"
463mkdir "$OUT_OF_SOURCE_DIR"
464cd "$OUT_OF_SOURCE_DIR"
465cmake "$MBEDTLS_ROOT_DIR"
466make
467
468msg "test: cmake 'out-of-source' build"
469make test
470cd "$MBEDTLS_ROOT_DIR"
471rm -rf "$OUT_OF_SOURCE_DIR"
472
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100473msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100474cleanup
475