blob: 526239768a766ebd68241dfd394c108e20128439 [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
25if [ -d library -a -d include -a -d tests ]; then :; else
Manuel Pégourié-Gonnarde4f6edc2015-01-22 16:43:54 +000026 echo "Must be run from mbed TLS root" >&2
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
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +010034SHORT=0
SimonB2e23c822016-04-16 21:54:39 +010035FORCE=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010036
SimonB2e23c822016-04-16 21:54:39 +010037usage()
38{
39 echo "Usage: $0"
40 echo -e " -h|--help\t\tPrint this help."
41 echo -e " -m|--memory\t\tAdditional optional memory tests."
42 echo -e " -s|--short\t\tSubset of tests."
43 echo -e " -f|--force\t\tForce the tests to overwrite any modified files."
44}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010045
46# remove built files as well as the cmake cache/config
47cleanup()
48{
49 make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020050
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020051 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000052 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020053 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
54 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020055
56 if [ -f "$CONFIG_BAK" ]; then
57 mv "$CONFIG_BAK" "$CONFIG_H"
58 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010059}
60
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020061trap cleanup INT TERM HUP
62
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010063msg()
64{
65 echo ""
66 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +010067 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +000068 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010069 echo "******************************************************************"
70}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010071
SimonB2e23c822016-04-16 21:54:39 +010072while [ $# -gt 0 ]; do
73 case "$1" in
74 --memory|-m*)
75 MEMORY=${1#-m}
76 ;;
77 --short|-s)
78 SHORT=1
79 ;;
80 --force|-f)
81 FORCE=1
82 ;;
83 --help|-h|*)
84 usage()
85 exit 1
86 ;;
87 esac
88 shift
89done
90
91if [ $FORCE -eq 1 ]; then
92 rm -rf yotta/module
93 git checkout-index -f -q $CONFIG_H
94 cleanup
95else
96
97 if [ -d yotta/module ]; then
98 echo "Warning - there is an existing yotta module in the directory 'yotta/module'" >&2
99 echo "You can either delete your work and retry, or force the test to overwrite the"
100 echo "test by rerunning the script as: $0 --force"
101 exit 1
102 fi
103
104 if ! git diff-files --quiet include/mbedtls/config.h; then
105 echo $?
106 echo "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " >&2
107 echo "You can either delete or preserve your work, or force the test by rerunning the"
108 echo "script as: $0 --force"
109 exit 1
110 fi
111fi
112
113#
114# Test Suites to be executed
115#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200116# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100117# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200118# and/or are more likely to fail than others (eg I use Clang most of the
119# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200120# 2. Minimize total running time, by avoiding useless rebuilds
121#
122# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100123
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100124msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200125tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100126
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000127msg "test: freshness of generated source files" # < 1s
128tests/scripts/check-generated-files.sh
129
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200130msg "test: doxygen markup outside doxygen blocks" # < 1s
131tests/scripts/check-doxy-blocks.pl
132
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200133msg "test/build: declared and exported names" # < 3s
134cleanup
135tests/scripts/check-names.sh
136
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100137if which doxygen >/dev/null; then
138 msg "test: doxygen warnings" # ~ 3s
139 cleanup
140 tests/scripts/doxygen.sh
141fi
142
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200143msg "build: create and build yotta module" # ~ 30s
144cleanup
145tests/scripts/yotta-build.sh
146
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100147msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100148cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100149CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100150make
151
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100152msg "test: main suites and selftest (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100153make test
154programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200155
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100156msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100157tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200158
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100159msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200160tests/scripts/test-ref-configs.pl
161
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100162# Most frequent issues are likely to be caught at this point
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100163if [ $SHORT -eq 1 ]; then
164 msg "Done, cleaning up"
165 cleanup
166 exit 0
167fi
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200168
169msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
170make
171
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100172msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100173tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200174
Simon Butcher3ea7f522016-03-07 23:22:10 +0000175msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
176cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000177cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000178scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
179CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
180make
181
182msg "test: SSLv3 - main suites and selftest (ASan build)" # ~ 50s
183make test
184programs/test/selftest
185
186msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
187tests/compat.sh -m 'ssl3 tls1 tls1_1 tls1_2 dtls1 dtls1_2'
188
189msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
190tests/ssl-opt.sh
191
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100192msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100193cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100194cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200195scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200196scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100197CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100198make
199
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100200msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200201make test
202
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100203msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100204tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200205
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100206msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100207tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200208
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200209msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100210cleanup
211cmake -D CMAKE_BUILD_TYPE:String=Debug .
212tests/scripts/curves.pl
213
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200214msg "test/build: key-exchanges (gcc)" # ~ 1 min
215cleanup
216cmake -D CMAKE_BUILD_TYPE:String=Check .
217tests/scripts/key-exchanges.pl
218
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000219msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100220cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000221CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100222
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200223# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000224# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100225msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000226cleanup
227cp "$CONFIG_H" "$CONFIG_BAK"
228scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200229scripts/config.pl unset MBEDTLS_PLATFORM_C
230scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100231scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
232scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
233scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
234scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100235scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200236scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
237scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000238CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000239
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100240# catch compile bugs in _uninit functions
241msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
242cleanup
243cp "$CONFIG_H" "$CONFIG_BAK"
244scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100245scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100246scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100247CC=gcc CFLAGS='-Werror -O0' make
248
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200249msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
250cleanup
251cp "$CONFIG_H" "$CONFIG_BAK"
252scripts/config.pl full
253scripts/config.pl unset MBEDTLS_SSL_SRV_C
254CC=gcc CFLAGS='-Werror -O0' make
255
256msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
257cleanup
258cp "$CONFIG_H" "$CONFIG_BAK"
259scripts/config.pl full
260scripts/config.pl unset MBEDTLS_SSL_CLI_C
261CC=gcc CFLAGS='-Werror -O0' make
262
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200263msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200264cleanup
265cp "$CONFIG_H" "$CONFIG_BAK"
266scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200267scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
268scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Manuel Pégourié-Gonnard71859362015-06-02 16:39:22 +0100269CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200270
Simon Butcherab5df402016-06-11 02:31:21 +0100271msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100272cleanup
273cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100274scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100275scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
276scripts/config.pl set MBEDTLS_ENTROPY_C
277scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
278scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
279scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100280CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100281make
282
Simon Butcherab5df402016-06-11 02:31:21 +0100283msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites and selftest (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100284make test
285programs/test/selftest
286
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200287if uname -a | grep -F Linux >/dev/null; then
288msg "build/test: make shared" # ~ 40s
289cleanup
290make SHARED=1 all check
291fi
292
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000293if uname -a | grep -F x86_64 >/dev/null; then
294msg "build: i386, make, gcc" # ~ 30s
295cleanup
296CC=gcc CFLAGS='-Werror -m32' make
297fi # x86_64
298
299if which arm-none-eabi-gcc >/dev/null; then
300msg "build: arm-none-eabi-gcc, make" # ~ 10s
301cleanup
302cp "$CONFIG_H" "$CONFIG_BAK"
303scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200304scripts/config.pl unset MBEDTLS_NET_C
305scripts/config.pl unset MBEDTLS_TIMING_C
306scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100307scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000308scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000309# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
311scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
312scripts/config.pl unset MBEDTLS_THREADING_C
313scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
314scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200315CC=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 +0000316fi # arm-gcc
317
Manuel Pégourié-Gonnard6dc26512015-06-25 10:48:24 +0200318if which armcc >/dev/null && armcc --help >/dev/null 2>&1; then
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100319msg "build: armcc, make"
320cleanup
321cp "$CONFIG_H" "$CONFIG_BAK"
322scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200323scripts/config.pl unset MBEDTLS_NET_C
324scripts/config.pl unset MBEDTLS_TIMING_C
325scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100326scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200327scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200328scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000329scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100330# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200331scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
332scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
333scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
334scripts/config.pl unset MBEDTLS_THREADING_C
335scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
336scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnard35519012016-01-07 13:06:51 +0100337CC=armcc AR=armar WARNING_CFLAGS= make lib 2> armcc.stderr
Manuel Pégourié-Gonnard129e4132015-03-13 17:29:18 +0100338if [ -s armcc.stderr ]; then
339 cat armcc.stderr
340 exit 1;
341fi
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100342rm armcc.stderr
343fi # armcc
344
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100345if which i686-w64-mingw32-gcc >/dev/null; then
346msg "build: cross-mingw64, make" # ~ 30s
347cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200348CC=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 +0200349WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200350CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
351WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100352fi
353
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000354# MemSan currently only available on Linux 64 bits
355if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000356
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100357msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100358cleanup
359cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200360scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100361CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
362make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200363
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100364msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100365make test
366
367msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100368tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100369
370# Optional part(s)
371
372if [ "$MEMORY" -gt 0 ]; then
373 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100374 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200375fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100376
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000377else # no MemSan
378
379msg "build: Release (clang)"
380cleanup
381CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
382make
383
384msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200385make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000386
387# Optional part(s)
388# Currently broken, programs don't seem to receive signals
389# under valgrind on OS X
390
391if [ "$MEMORY" -gt 0 ]; then
392 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100393 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000394fi
395
396if [ "$MEMORY" -gt 1 ]; then
397 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100398 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000399fi
400
401fi # MemSan
402
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100403msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100404cleanup
405