blob: 5060f10d8fdb10254880461d8308b8deff9d25fa [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
Andres AGdc192212016-08-31 17:33:13 +010037: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
38
SimonB2e23c822016-04-16 21:54:39 +010039usage()
40{
41 echo "Usage: $0"
42 echo -e " -h|--help\t\tPrint this help."
43 echo -e " -m|--memory\t\tAdditional optional memory tests."
44 echo -e " -s|--short\t\tSubset of tests."
45 echo -e " -f|--force\t\tForce the tests to overwrite any modified files."
Andres AGdc192212016-08-31 17:33:13 +010046 echo -e " --out-of-source-dir\t\tDirectory used for CMake out-of-source build tests."
SimonB2e23c822016-04-16 21:54:39 +010047}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010048
49# remove built files as well as the cmake cache/config
50cleanup()
51{
52 make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020053
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020054 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000055 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020056 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
57 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020058
59 if [ -f "$CONFIG_BAK" ]; then
60 mv "$CONFIG_BAK" "$CONFIG_H"
61 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010062}
63
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020064trap cleanup INT TERM HUP
65
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010066msg()
67{
68 echo ""
69 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +010070 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +000071 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010072 echo "******************************************************************"
73}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010074
SimonB2e23c822016-04-16 21:54:39 +010075while [ $# -gt 0 ]; do
76 case "$1" in
77 --memory|-m*)
78 MEMORY=${1#-m}
79 ;;
80 --short|-s)
81 SHORT=1
82 ;;
83 --force|-f)
84 FORCE=1
85 ;;
Andres AGdc192212016-08-31 17:33:13 +010086 --out-of-source-dir)
87 shift
88 OUT_OF_SOURCE_DIR="$1"
89 ;;
SimonB2e23c822016-04-16 21:54:39 +010090 --help|-h|*)
91 usage()
92 exit 1
93 ;;
94 esac
95 shift
96done
97
98if [ $FORCE -eq 1 ]; then
Andres AGdc192212016-08-31 17:33:13 +010099 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
SimonB2e23c822016-04-16 21:54:39 +0100100 git checkout-index -f -q $CONFIG_H
101 cleanup
102else
103
104 if [ -d yotta/module ]; then
105 echo "Warning - there is an existing yotta module in the directory 'yotta/module'" >&2
106 echo "You can either delete your work and retry, or force the test to overwrite the"
107 echo "test by rerunning the script as: $0 --force"
108 exit 1
109 fi
110
Andres AGdc192212016-08-31 17:33:13 +0100111 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
112 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
113 echo "You can either delete this directory manually, or force the test by rerunning"
114 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
115 exit 1
116 fi
117
SimonB2e23c822016-04-16 21:54:39 +0100118 if ! git diff-files --quiet include/mbedtls/config.h; then
119 echo $?
120 echo "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " >&2
121 echo "You can either delete or preserve your work, or force the test by rerunning the"
122 echo "script as: $0 --force"
123 exit 1
124 fi
125fi
126
127#
128# Test Suites to be executed
129#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200130# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100131# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200132# and/or are more likely to fail than others (eg I use Clang most of the
133# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200134# 2. Minimize total running time, by avoiding useless rebuilds
135#
136# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100137
Janos Follathb72c6782016-07-19 14:54:17 +0100138msg "info: output_env.sh"
139scripts/output_env.sh
140
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100141msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200142tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100143
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000144msg "test: freshness of generated source files" # < 1s
145tests/scripts/check-generated-files.sh
146
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200147msg "test: doxygen markup outside doxygen blocks" # < 1s
148tests/scripts/check-doxy-blocks.pl
149
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200150msg "test/build: declared and exported names" # < 3s
151cleanup
152tests/scripts/check-names.sh
153
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100154if which doxygen >/dev/null; then
155 msg "test: doxygen warnings" # ~ 3s
156 cleanup
157 tests/scripts/doxygen.sh
158fi
159
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200160msg "build: create and build yotta module" # ~ 30s
161cleanup
162tests/scripts/yotta-build.sh
163
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100164msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100165cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100166CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100167make
168
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100169msg "test: main suites and selftest (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100170make test
171programs/test/selftest
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200172
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100173msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100174tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200175
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100176msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200177tests/scripts/test-ref-configs.pl
178
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100179# Most frequent issues are likely to be caught at this point
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100180if [ $SHORT -eq 1 ]; then
181 msg "Done, cleaning up"
182 cleanup
183 exit 0
184fi
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200185
186msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
187make
188
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100189msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100190tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200191
Simon Butcher3ea7f522016-03-07 23:22:10 +0000192msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
193cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000194cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000195scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
196CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
197make
198
199msg "test: SSLv3 - main suites and selftest (ASan build)" # ~ 50s
200make test
201programs/test/selftest
202
203msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
204tests/compat.sh -m 'ssl3 tls1 tls1_1 tls1_2 dtls1 dtls1_2'
205
206msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
207tests/ssl-opt.sh
208
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100209msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100210cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100211cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200212scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200213scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100214CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100215make
216
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100217msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200218make test
219
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100220msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100221tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200222
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100223msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100224tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200225
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200226msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100227cleanup
228cmake -D CMAKE_BUILD_TYPE:String=Debug .
229tests/scripts/curves.pl
230
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200231msg "test/build: key-exchanges (gcc)" # ~ 1 min
232cleanup
233cmake -D CMAKE_BUILD_TYPE:String=Check .
234tests/scripts/key-exchanges.pl
235
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000236msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100237cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000238CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100239
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200240# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000241# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100242msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000243cleanup
244cp "$CONFIG_H" "$CONFIG_BAK"
245scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200246scripts/config.pl unset MBEDTLS_PLATFORM_C
247scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100248scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
249scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
250scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100251scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100252scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100253scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
255scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000256CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000257
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100258# catch compile bugs in _uninit functions
259msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
260cleanup
261cp "$CONFIG_H" "$CONFIG_BAK"
262scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100263scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100264scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100265CC=gcc CFLAGS='-Werror -O0' make
266
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +0200267msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
268cleanup
269cp "$CONFIG_H" "$CONFIG_BAK"
270scripts/config.pl full
271scripts/config.pl unset MBEDTLS_SSL_SRV_C
272CC=gcc CFLAGS='-Werror -O0' make
273
274msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
275cleanup
276cp "$CONFIG_H" "$CONFIG_BAK"
277scripts/config.pl full
278scripts/config.pl unset MBEDTLS_SSL_CLI_C
279CC=gcc CFLAGS='-Werror -O0' make
280
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200281msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200282cleanup
283cp "$CONFIG_H" "$CONFIG_BAK"
284scripts/config.pl full
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200285scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
286scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Manuel Pégourié-Gonnard71859362015-06-02 16:39:22 +0100287CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +0200288
Simon Butcherab5df402016-06-11 02:31:21 +0100289msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100290cleanup
291cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100292scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100293scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
294scripts/config.pl set MBEDTLS_ENTROPY_C
295scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
296scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
297scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100298CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100299make
300
Simon Butcherab5df402016-06-11 02:31:21 +0100301msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites and selftest (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100302make test
303programs/test/selftest
304
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200305if uname -a | grep -F Linux >/dev/null; then
306msg "build/test: make shared" # ~ 40s
307cleanup
308make SHARED=1 all check
309fi
310
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000311if uname -a | grep -F x86_64 >/dev/null; then
312msg "build: i386, make, gcc" # ~ 30s
313cleanup
314CC=gcc CFLAGS='-Werror -m32' make
315fi # x86_64
316
317if which arm-none-eabi-gcc >/dev/null; then
318msg "build: arm-none-eabi-gcc, make" # ~ 10s
319cleanup
320cp "$CONFIG_H" "$CONFIG_BAK"
321scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200322scripts/config.pl unset MBEDTLS_NET_C
323scripts/config.pl unset MBEDTLS_TIMING_C
324scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100325scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000326scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000327# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200328scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
329scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
330scripts/config.pl unset MBEDTLS_THREADING_C
331scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
332scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200333CC=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 +0000334fi # arm-gcc
335
Manuel Pégourié-Gonnard6dc26512015-06-25 10:48:24 +0200336if which armcc >/dev/null && armcc --help >/dev/null 2>&1; then
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100337msg "build: armcc, make"
338cleanup
339cp "$CONFIG_H" "$CONFIG_BAK"
340scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200341scripts/config.pl unset MBEDTLS_NET_C
342scripts/config.pl unset MBEDTLS_TIMING_C
343scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100344scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200345scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200346scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000347scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100348# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200349scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
350scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
351scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
352scripts/config.pl unset MBEDTLS_THREADING_C
353scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
354scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300355scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Simon Butchera4ed19c2016-08-24 22:37:43 +0300356CC=armcc AR=armar WARNING_CFLAGS= make lib
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100357fi # armcc
358
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100359if which i686-w64-mingw32-gcc >/dev/null; then
360msg "build: cross-mingw64, make" # ~ 30s
361cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200362CC=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 +0200363WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200364CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
365WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100366fi
367
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000368# MemSan currently only available on Linux 64 bits
369if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000370
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100371msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100372cleanup
373cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200374scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100375CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
376make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200377
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100378msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100379make test
380
381msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100382tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100383
384# Optional part(s)
385
386if [ "$MEMORY" -gt 0 ]; then
387 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100388 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200389fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100390
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000391else # no MemSan
392
393msg "build: Release (clang)"
394cleanup
395CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
396make
397
398msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200399make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000400
401# Optional part(s)
402# Currently broken, programs don't seem to receive signals
403# under valgrind on OS X
404
405if [ "$MEMORY" -gt 0 ]; then
406 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100407 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000408fi
409
410if [ "$MEMORY" -gt 1 ]; then
411 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100412 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000413fi
414
415fi # MemSan
416
Andres AGdc192212016-08-31 17:33:13 +0100417msg "build: cmake 'out-of-source' build"
418cleanup
419MBEDTLS_ROOT_DIR="$PWD"
420mkdir "$OUT_OF_SOURCE_DIR"
421cd "$OUT_OF_SOURCE_DIR"
422cmake "$MBEDTLS_ROOT_DIR"
423make
424
425msg "test: cmake 'out-of-source' build"
426make test
427cd "$MBEDTLS_ROOT_DIR"
428rm -rf "$OUT_OF_SOURCE_DIR"
429
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100430msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100431cleanup
432