blob: cacb7caf09c795794d284500f596d5efaa02591c [file] [log] [blame]
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001#!/bin/sh
2
Simon Butcherd7f19022016-10-14 09:49:48 +01003# all.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01004#
Simon Butcherd7f19022016-10-14 09:49:48 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01006#
Simon Butcherd7f19022016-10-14 09:49:48 +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 Butcherd7f19022016-10-14 09:49:48 +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 Butcherd7f19022016-10-14 09:49:48 +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é-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020031CONFIG_BAK="$CONFIG_H.bak"
32
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010033MEMORY=0
Simon Butcherd7f19022016-10-14 09:49:48 +010034FORCE=0
35RELEASE=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010036
Simon Butcherd7f19022016-10-14 09:49:48 +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é-Gonnard77d56bb2015-07-28 15:00:37 +020068 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000069 rm -f include/Makefile include/mbedtls/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 Butcherd7f19022016-10-14 09:49:48 +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 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
157 git checkout-index -f -q $CONFIG_H
158 cleanup
159else
160
161 if [ -d yotta/module ]; then
162 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
163 echo "You can either delete your work and retry, or force the test to overwrite the"
164 echo "test by rerunning the script as: $0 --force"
165 exit 1
166 fi
167
168 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
169 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
170 echo "You can either delete this directory manually, or force the test by rerunning"
171 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
172 exit 1
173 fi
174
175 if ! git diff-files --quiet include/mbedtls/config.h; then
176 echo $?
177 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
178 echo "You can either delete or preserve your work, or force the test by rerunning the"
179 echo "script as: $0 --force"
180 exit 1
181 fi
182fi
183
184if [ $RELEASE -eq 1 ]; then
185 # Fix the seed value to 1 to ensure that the tests are deterministic.
186 SEED=1
187fi
188
189msg "info: $0 configuration"
190echo "MEMORY: $MEMORY"
191echo "FORCE: $FORCE"
192echo "SEED: ${SEED-"UNSET"}"
193echo "OPENSSL: $OPENSSL"
194echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
195echo "GNUTLS_CLI: $GNUTLS_CLI"
196echo "GNUTLS_SERV: $GNUTLS_SERV"
197echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
198echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
199
200# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
201# we just export the variables they require
202export OPENSSL_CMD="$OPENSSL"
203export GNUTLS_CLI="$GNUTLS_CLI"
204export GNUTLS_SERV="$GNUTLS_SERV"
205
206# Avoid passing --seed flag in every call to ssl-opt.sh
207[ ! -z ${SEED+set} ] && export SEED
208
209# Make sure the tools we need are available.
210check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
211 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
212 "arm-none-eabi-gcc" "armcc"
213
214#
215# Test Suites to be executed
216#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200217# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100218# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200219# and/or are more likely to fail than others (eg I use Clang most of the
220# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200221# 2. Minimize total running time, by avoiding useless rebuilds
222#
223# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100224
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100225msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200226tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100227
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000228msg "test: freshness of generated source files" # < 1s
229tests/scripts/check-generated-files.sh
230
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200231msg "test: doxygen markup outside doxygen blocks" # < 1s
232tests/scripts/check-doxy-blocks.pl
233
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200234msg "test/build: declared and exported names" # < 3s
235cleanup
236tests/scripts/check-names.sh
237
Simon Butcher73156352015-11-04 00:36:30 +0000238# Yotta not supported in 2.1 branch
239#msg "build: create and build yotta module" # ~ 30s
240#cleanup
241#tests/scripts/yotta-build.sh
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200242
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100243msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100244cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100245CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100246make
247
Simon Butcherd7f19022016-10-14 09:49:48 +0100248msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100249make test
250programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200251
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100252msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100253tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200254
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100255msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200256tests/scripts/test-ref-configs.pl
257
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200258msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
259make
260
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100261msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100262tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200263
Simon Butcher02b8d482016-03-15 20:39:52 +0000264msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
265cleanup
266cp "$CONFIG_H" "$CONFIG_BAK"
267scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
268CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
269make
270
Simon Butcherd7f19022016-10-14 09:49:48 +0100271msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher02b8d482016-03-15 20:39:52 +0000272make test
273programs/test/selftest
274
275msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Simon Butcherd7f19022016-10-14 09:49:48 +0100276tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
277OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher02b8d482016-03-15 20:39:52 +0000278
279msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
280tests/ssl-opt.sh
281
Hanno Becker92935922017-11-06 15:07:09 +0000282msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
283cleanup
284cp "$CONFIG_H" "$CONFIG_BAK"
285scripts/config.pl set MBEDTLS_RSA_NO_CRT
286CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
287make
288
289msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
290make test
291
292msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
293tests/ssl-opt.sh -f RSA
294
295msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
296tests/compat.sh -t RSA
297
298
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100299msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100300cleanup
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200301cp "$CONFIG_H" "$CONFIG_BAK"
302scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200303scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100304CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100305make
306
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100307msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200308make test
309
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100310msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100311tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200312
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100313msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Simon Butcherd7f19022016-10-14 09:49:48 +0100314OPENSSL_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 +0200315
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200316msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100317cleanup
318cmake -D CMAKE_BUILD_TYPE:String=Debug .
319tests/scripts/curves.pl
320
Manuel Pégourié-Gonnard134ca182015-10-23 09:04:45 +0200321msg "test/build: key-exchanges (gcc)" # ~ 1 min
322cleanup
323cmake -D CMAKE_BUILD_TYPE:String=Check .
324tests/scripts/key-exchanges.pl
325
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000326msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100327cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000328CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100329
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200330# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000331# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100332msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000333cleanup
334cp "$CONFIG_H" "$CONFIG_BAK"
335scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200336scripts/config.pl unset MBEDTLS_PLATFORM_C
337scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100338scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
339scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
340scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
341scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200342scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
343scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000344CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000345
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100346# catch compile bugs in _uninit functions
347msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
348cleanup
349cp "$CONFIG_H" "$CONFIG_BAK"
350scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100351scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100352CC=gcc CFLAGS='-Werror -O0' make
353
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200354msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
355cleanup
356cp "$CONFIG_H" "$CONFIG_BAK"
357scripts/config.pl full
358scripts/config.pl unset MBEDTLS_SSL_SRV_C
359CC=gcc CFLAGS='-Werror -O0' make
360
361msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
362cleanup
363cp "$CONFIG_H" "$CONFIG_BAK"
364scripts/config.pl full
365scripts/config.pl unset MBEDTLS_SSL_CLI_C
366CC=gcc CFLAGS='-Werror -O0' make
367
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200368msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200369cleanup
370cp "$CONFIG_H" "$CONFIG_BAK"
371scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200372scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
373scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Manuel Pégourié-Gonnard71859362015-06-02 16:39:22 +0100374CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200375
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200376if uname -a | grep -F Linux >/dev/null; then
377msg "build/test: make shared" # ~ 40s
378cleanup
379make SHARED=1 all check
380fi
381
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000382if uname -a | grep -F x86_64 >/dev/null; then
383msg "build: i386, make, gcc" # ~ 30s
384cleanup
385CC=gcc CFLAGS='-Werror -m32' make
386fi # x86_64
387
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000388msg "build: arm-none-eabi-gcc, make" # ~ 10s
389cleanup
390cp "$CONFIG_H" "$CONFIG_BAK"
391scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200392scripts/config.pl unset MBEDTLS_NET_C
393scripts/config.pl unset MBEDTLS_TIMING_C
394scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcherd7f19022016-10-14 09:49:48 +0100395scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000396# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200397scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
398scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
399scripts/config.pl unset MBEDTLS_THREADING_C
400scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
401scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200402CC=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 +0000403
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100404msg "build: armcc, make"
405cleanup
406cp "$CONFIG_H" "$CONFIG_BAK"
407scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200408scripts/config.pl unset MBEDTLS_NET_C
409scripts/config.pl unset MBEDTLS_TIMING_C
410scripts/config.pl unset MBEDTLS_FS_IO
411scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200412scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherd7f19022016-10-14 09:49:48 +0100413scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100414# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200415scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
416scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
417scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
418scripts/config.pl unset MBEDTLS_THREADING_C
419scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
420scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcherd7f19022016-10-14 09:49:48 +0100421CC=armcc AR=armar WARNING_CFLAGS= make lib
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100422
Gilles Peskineb49351d2017-05-12 15:26:58 +0200423msg "build: allow SHA1 in certificates by default"
424cleanup
425cp "$CONFIG_H" "$CONFIG_BAK"
426scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
427CFLAGS='-Werror -Wall -Wextra' make
428msg "test: allow SHA1 in certificates by default"
429make test
430tests/ssl-opt.sh -f SHA-1
431
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100432if which i686-w64-mingw32-gcc >/dev/null; then
433msg "build: cross-mingw64, make" # ~ 30s
434cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200435CC=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 +0200436WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200437CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
438WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100439fi
440
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000441# MemSan currently only available on Linux 64 bits
442if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000443
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100444msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100445cleanup
446cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200447scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100448CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
449make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200450
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100451msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100452make test
453
454msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100455tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100456
457# Optional part(s)
458
459if [ "$MEMORY" -gt 0 ]; then
460 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100461 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200462fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100463
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000464else # no MemSan
465
466msg "build: Release (clang)"
467cleanup
468CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
469make
470
471msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200472make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000473
474# Optional part(s)
475# Currently broken, programs don't seem to receive signals
476# under valgrind on OS X
477
478if [ "$MEMORY" -gt 0 ]; then
479 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100480 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000481fi
482
483if [ "$MEMORY" -gt 1 ]; then
484 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100485 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000486fi
487
488fi # MemSan
489
Simon Butcherd7f19022016-10-14 09:49:48 +0100490msg "build: cmake 'out-of-source' build"
491cleanup
492MBEDTLS_ROOT_DIR="$PWD"
493mkdir "$OUT_OF_SOURCE_DIR"
494cd "$OUT_OF_SOURCE_DIR"
495cmake "$MBEDTLS_ROOT_DIR"
496make
497
498msg "test: cmake 'out-of-source' build"
499make test
500cd "$MBEDTLS_ROOT_DIR"
501rm -rf "$OUT_OF_SOURCE_DIR"
502
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100503msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100504cleanup
505