blob: d73c9262d133cc498a5c042d7ba19fc41d82de43 [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
Andres AG38495a32016-07-12 16:54:33 +010025if [ "$( uname )" != "Linux" ]; then
26 echo "This script only works in Linux" >&2
27 exit 1
28elif [ -d library -a -d include -a -d tests ]; then :; else
29 echo "Must be run from mbed TLS root" >&2
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010030 exit 1
31fi
32
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000033CONFIG_H='include/mbedtls/config.h'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020034CONFIG_BAK="$CONFIG_H.bak"
35
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010036MEMORY=0
SimonB2e23c822016-04-16 21:54:39 +010037FORCE=0
Andres AG7770ea82016-10-10 15:46:20 +010038RELEASE=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010039
Andres AGd9eba4b2016-08-26 14:42:14 +010040# Default commands, can be overriden by the environment
41: ${OPENSSL:="openssl"}
42: ${OPENSSL_LEGACY:="$OPENSSL"}
43: ${GNUTLS_CLI:="gnutls-cli"}
44: ${GNUTLS_SERV:="gnutls-serv"}
45: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
46: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
Andres AGdc192212016-08-31 17:33:13 +010047: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
48
Andres AG38495a32016-07-12 16:54:33 +010049# if MAKEFLAGS is not set add the -j option to speed up invocations of make
50if [ -n "${MAKEFLAGS+set}" ]; then
51 export MAKEFLAGS="-j"
52fi
53
Simon Butcher41eeccf2016-09-07 00:07:09 +010054usage()
SimonB2e23c822016-04-16 21:54:39 +010055{
Andres AGd9eba4b2016-08-26 14:42:14 +010056 printf "Usage: $0\n"
57 printf " -h|--help\t\tPrint this help.\n"
58 printf " -m|--memory\t\tAdditional optional memory tests.\n"
59 printf " -f|--force\t\tForce the tests to overwrite any modified files.\n"
Andres AG7770ea82016-10-10 15:46:20 +010060 printf " -s|--seed\t\tInteger seed value to use for this test run.\n"
61 printf " -r|--release-test\t\tRun this script in release mode. This fixes the seed value to 1.\n"
Simon Butcher41eeccf2016-09-07 00:07:09 +010062 printf " --out-of-source-dir=<path>\t\tDirectory used for CMake out-of-source build tests."
Andres AGd9eba4b2016-08-26 14:42:14 +010063 printf " --openssl=<OpenSSL_path>\t\tPath to OpenSSL executable to use for most tests.\n"
64 printf " --openssl-legacy=<OpenSSL_path>\t\tPath to OpenSSL executable to use for legacy tests e.g. SSLv3.\n"
65 printf " --gnutls-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for most tests.\n"
66 printf " --gnutls-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for most tests.\n"
67 printf " --gnutls-legacy-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for legacy tests.\n"
68 printf " --gnutls-legacy-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for legacy tests.\n"
SimonB2e23c822016-04-16 21:54:39 +010069}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010070
71# remove built files as well as the cmake cache/config
72cleanup()
73{
74 make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020075
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +020076 find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000077 rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020078 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
79 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020080
81 if [ -f "$CONFIG_BAK" ]; then
82 mv "$CONFIG_BAK" "$CONFIG_H"
83 fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010084}
85
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +020086trap cleanup INT TERM HUP
87
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010088msg()
89{
90 echo ""
91 echo "******************************************************************"
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +010092 echo "* $1 "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +000093 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010094 echo "******************************************************************"
95}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010096
Andres AGd9eba4b2016-08-26 14:42:14 +010097err_msg()
98{
99 echo "$1" >&2
100}
101
102check_tools()
103{
104 for TOOL in "$@"; do
105 if ! `hash "$TOOL" >/dev/null 2>&1`; then
106 err_msg "$TOOL not found!"
107 exit 1
108 fi
109 done
110}
111
SimonB2e23c822016-04-16 21:54:39 +0100112while [ $# -gt 0 ]; do
113 case "$1" in
114 --memory|-m*)
115 MEMORY=${1#-m}
116 ;;
SimonB2e23c822016-04-16 21:54:39 +0100117 --force|-f)
118 FORCE=1
119 ;;
Andres AG7770ea82016-10-10 15:46:20 +0100120 --seed|-s)
121 shift
122 SEED="$1"
123 ;;
124 --release-test|-r)
125 RELEASE=1
126 ;;
Andres AGdc192212016-08-31 17:33:13 +0100127 --out-of-source-dir)
128 shift
129 OUT_OF_SOURCE_DIR="$1"
130 ;;
Andres AGd9eba4b2016-08-26 14:42:14 +0100131 --openssl)
132 shift
133 OPENSSL="$1"
134 ;;
135 --openssl-legacy)
136 shift
137 OPENSSL_LEGACY="$1"
138 ;;
139 --gnutls-cli)
140 shift
141 GNUTLS_CLI="$1"
142 ;;
143 --gnutls-serv)
144 shift
145 GNUTLS_SERV="$1"
146 ;;
147 --gnutls-legacy-cli)
148 shift
149 GNUTLS_LEGACY_CLI="$1"
150 ;;
151 --gnutls-legacy-serv)
152 shift
153 GNUTLS_LEGACY_SERV="$1"
154 ;;
SimonB2e23c822016-04-16 21:54:39 +0100155 --help|-h|*)
Andres AGd9eba4b2016-08-26 14:42:14 +0100156 usage
SimonB2e23c822016-04-16 21:54:39 +0100157 exit 1
158 ;;
159 esac
160 shift
161done
162
163if [ $FORCE -eq 1 ]; then
Andres AGdc192212016-08-31 17:33:13 +0100164 rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
SimonB2e23c822016-04-16 21:54:39 +0100165 git checkout-index -f -q $CONFIG_H
166 cleanup
167else
168
169 if [ -d yotta/module ]; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100170 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
SimonB2e23c822016-04-16 21:54:39 +0100171 echo "You can either delete your work and retry, or force the test to overwrite the"
172 echo "test by rerunning the script as: $0 --force"
173 exit 1
174 fi
175
Andres AGdc192212016-08-31 17:33:13 +0100176 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
177 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
178 echo "You can either delete this directory manually, or force the test by rerunning"
179 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
180 exit 1
181 fi
182
SimonB2e23c822016-04-16 21:54:39 +0100183 if ! git diff-files --quiet include/mbedtls/config.h; then
184 echo $?
Andres AGd9eba4b2016-08-26 14:42:14 +0100185 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
SimonB2e23c822016-04-16 21:54:39 +0100186 echo "You can either delete or preserve your work, or force the test by rerunning the"
187 echo "script as: $0 --force"
188 exit 1
189 fi
190fi
191
Andres AG7770ea82016-10-10 15:46:20 +0100192if [ $RELEASE -eq 1 ]; then
193 # Fix the seed value to 1 to ensure that the tests are deterministic.
194 SEED=1
195fi
196
Andres AGd9eba4b2016-08-26 14:42:14 +0100197msg "info: $0 configuration"
198echo "MEMORY: $MEMORY"
199echo "FORCE: $FORCE"
Andres AG7770ea82016-10-10 15:46:20 +0100200echo "SEED: ${SEED-"UNSET"}"
Andres AGd9eba4b2016-08-26 14:42:14 +0100201echo "OPENSSL: $OPENSSL"
202echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
203echo "GNUTLS_CLI: $GNUTLS_CLI"
204echo "GNUTLS_SERV: $GNUTLS_SERV"
205echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
206echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
207
Andres AGb2fdd042016-09-22 14:17:46 +0100208# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
209# we just export the variables they require
210export OPENSSL_CMD="$OPENSSL"
211export GNUTLS_CLI="$GNUTLS_CLI"
212export GNUTLS_SERV="$GNUTLS_SERV"
213
Andres AG7770ea82016-10-10 15:46:20 +0100214# Avoid passing --seed flag in every call to ssl-opt.sh
215[ ! -z ${SEED+set} ] && export SEED
216
Andres AGd9eba4b2016-08-26 14:42:14 +0100217# Make sure the tools we need are available.
218check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
219 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
220 "arm-none-eabi-gcc" "armcc"
221
SimonB2e23c822016-04-16 21:54:39 +0100222#
223# Test Suites to be executed
224#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200225# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100226# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard61bc57a2014-08-14 11:29:06 +0200227# and/or are more likely to fail than others (eg I use Clang most of the
228# time, so start with a GCC build).
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200229# 2. Minimize total running time, by avoiding useless rebuilds
230#
231# Indicative running times are given for reference.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100232
Janos Follathb72c6782016-07-19 14:54:17 +0100233msg "info: output_env.sh"
Andres AGd9eba4b2016-08-26 14:42:14 +0100234OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
235 GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
236 GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" scripts/output_env.sh
Janos Follathb72c6782016-07-19 14:54:17 +0100237
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100238msg "test: recursion.pl" # < 1s
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200239tests/scripts/recursion.pl library/*.c
Manuel Pégourié-Gonnardea29d152014-11-20 17:32:33 +0100240
Manuel Pégourié-Gonnardb3b8e432015-02-13 14:52:19 +0000241msg "test: freshness of generated source files" # < 1s
242tests/scripts/check-generated-files.sh
243
Manuel Pégourié-Gonnardd09a6b52015-04-09 17:19:23 +0200244msg "test: doxygen markup outside doxygen blocks" # < 1s
245tests/scripts/check-doxy-blocks.pl
246
Manuel Pégourié-Gonnarda687baf2015-04-09 11:09:03 +0200247msg "test/build: declared and exported names" # < 3s
248cleanup
249tests/scripts/check-names.sh
250
Andres AGd9eba4b2016-08-26 14:42:14 +0100251msg "test: doxygen warnings" # ~ 3s
252cleanup
253tests/scripts/doxygen.sh
Manuel Pégourié-Gonnard1d552e72016-01-04 16:49:09 +0100254
Manuel Pégourié-Gonnard77d56bb2015-07-28 15:00:37 +0200255msg "build: create and build yotta module" # ~ 30s
256cleanup
257tests/scripts/yotta-build.sh
258
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100259msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100260cleanup
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100261CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100262make
263
Simon Butcher8e3afc72016-09-15 17:13:08 +0100264msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100265make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200266
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100267msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100268tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200269
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100270msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200271tests/scripts/test-ref-configs.pl
272
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200273msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
274make
275
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100276msg "test: compat.sh (ASan build)" # ~ 6 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100277tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200278
Simon Butcher3ea7f522016-03-07 23:22:10 +0000279msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
280cleanup
Simon Butcherf413b6f2016-03-14 22:32:42 +0000281cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcher3ea7f522016-03-07 23:22:10 +0000282scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
283CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
284make
285
Simon Butcher8e3afc72016-09-15 17:13:08 +0100286msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
Simon Butcher3ea7f522016-03-07 23:22:10 +0000287make test
Simon Butcher3ea7f522016-03-07 23:22:10 +0000288
289msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100290tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
291OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +0000292
293msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
294tests/ssl-opt.sh
295
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100296msg "build: cmake, full config, clang" # ~ 50s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100297cleanup
Janos Follath35d48cb2016-04-22 14:45:00 +0100298cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200299scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200300scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100301CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100302make
303
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100304msg "test: main suites (full config)" # ~ 5s
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200305make test
306
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100307msg "test: ssl-opt.sh default (full config)" # ~ 1s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100308tests/ssl-opt.sh -f Default
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200309
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100310msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
Andres AGd9eba4b2016-08-26 14:42:14 +0100311OPENSSL_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 +0200312
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200313msg "test/build: curves.pl (gcc)" # ~ 4 min
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +0100314cleanup
315cmake -D CMAKE_BUILD_TYPE:String=Debug .
316tests/scripts/curves.pl
317
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +0200318msg "test/build: key-exchanges (gcc)" # ~ 1 min
319cleanup
320cmake -D CMAKE_BUILD_TYPE:String=Check .
321tests/scripts/key-exchanges.pl
322
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000323msg "build: Unix make, -Os (gcc)" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100324cleanup
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000325CC=gcc CFLAGS='-Werror -Os' make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100326
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200327# this is meant to cath missing #define mbedtls_printf etc
Manuel Pégourié-Gonnard981732b2015-02-17 15:46:45 +0000328# disable fsio to catch some more missing #include <stdio.h>
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +0100329msg "build: full config except platform/fsio, make, gcc" # ~ 30s
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000330cleanup
331cp "$CONFIG_H" "$CONFIG_BAK"
332scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200333scripts/config.pl unset MBEDTLS_PLATFORM_C
334scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100335scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
336scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
337scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Simon Butcherb9283432016-07-13 11:02:41 +0100338scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
Manuel Pégourié-Gonnard3d4755b2015-06-03 14:03:17 +0100339scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
Simon Butcher284b4c92016-06-26 13:10:00 +0100340scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200341scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
342scripts/config.pl unset MBEDTLS_FS_IO
Manuel Pégourié-Gonnard61fe8b02015-03-13 14:33:16 +0000343CC=gcc CFLAGS='-Werror -O0' make
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +0000344
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +0100345# catch compile bugs in _uninit functions
346msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
347cleanup
348cp "$CONFIG_H" "$CONFIG_BAK"
349scripts/config.pl full
Manuel Pégourié-Gonnard7ee5ddd2015-06-03 10:33:55 +0100350scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Simon Butchereebf1b92016-06-27 01:42:39 +0100351scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
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
Andres AG788aa4a2016-09-14 14:32:09 +0100368msg "build: full config except net_sockets.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
Simon Butcherab5df402016-06-11 02:31:21 +0100376msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100377cleanup
378cp "$CONFIG_H" "$CONFIG_BAK"
Simon Butcherab5df402016-06-11 02:31:21 +0100379scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
Janos Follath06c54002016-06-09 13:57:40 +0100380scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
381scripts/config.pl set MBEDTLS_ENTROPY_C
382scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
383scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT
384scripts/config.pl unset MBEDTLS_HAVEGE_C
Simon Butchereebf1b92016-06-27 01:42:39 +0100385CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" .
Janos Follath06c54002016-06-09 13:57:40 +0100386make
387
Simon Butcher8e3afc72016-09-15 17:13:08 +0100388msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
Janos Follath06c54002016-06-09 13:57:40 +0100389make test
Janos Follath06c54002016-06-09 13:57:40 +0100390
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +0200391if uname -a | grep -F Linux >/dev/null; then
392msg "build/test: make shared" # ~ 40s
393cleanup
394make SHARED=1 all check
395fi
396
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000397if uname -a | grep -F x86_64 >/dev/null; then
398msg "build: i386, make, gcc" # ~ 30s
399cleanup
400CC=gcc CFLAGS='-Werror -m32' make
401fi # x86_64
402
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000403msg "build: arm-none-eabi-gcc, make" # ~ 10s
404cleanup
405cp "$CONFIG_H" "$CONFIG_BAK"
406scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200407scripts/config.pl unset MBEDTLS_NET_C
408scripts/config.pl unset MBEDTLS_TIMING_C
409scripts/config.pl unset MBEDTLS_FS_IO
Simon Butchereebf1b92016-06-27 01:42:39 +0100410scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Simon Butcherbc6a4862016-03-07 17:35:59 +0000411scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000412# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200413scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
414scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
415scripts/config.pl unset MBEDTLS_THREADING_C
416scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
417scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200418CC=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 +0000419
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100420msg "build: armcc, make"
421cleanup
422cp "$CONFIG_H" "$CONFIG_BAK"
423scripts/config.pl full
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200424scripts/config.pl unset MBEDTLS_NET_C
425scripts/config.pl unset MBEDTLS_TIMING_C
426scripts/config.pl unset MBEDTLS_FS_IO
Simon Butcher1c719652016-06-27 19:02:12 +0100427scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200428scripts/config.pl unset MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardbbc60db2015-06-22 14:31:50 +0200429scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE
Simon Butcherbc6a4862016-03-07 17:35:59 +0000430scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100431# following things are not in the default config
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200432scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING
433scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
434scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
435scripts/config.pl unset MBEDTLS_THREADING_C
436scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
437scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
Simon Butcher4df5eaf2016-08-24 22:58:31 +0300438scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
Simon Butchera4ed19c2016-08-24 22:37:43 +0300439CC=armcc AR=armar WARNING_CFLAGS= make lib
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +0100440
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100441if which i686-w64-mingw32-gcc >/dev/null; then
442msg "build: cross-mingw64, make" # ~ 30s
443cleanup
Manuel Pégourié-Gonnarde058ea22015-06-25 09:04:13 +0200444CC=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 +0200445WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnarde33316c2015-08-07 13:17:23 +0200446CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
447WINDOWS_BUILD=1 make clean
Manuel Pégourié-Gonnard6448bce2015-02-16 17:18:36 +0100448fi
449
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +0000450# MemSan currently only available on Linux 64 bits
451if uname -a | grep 'Linux.*x86_64' >/dev/null; then
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000452
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100453msg "build: MSan (clang)" # ~ 1 min 20s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100454cleanup
455cp "$CONFIG_H" "$CONFIG_BAK"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200456scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100457CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
458make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200459
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100460msg "test: main suites (MSan)" # ~ 10s
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100461make test
462
463msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100464tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100465
466# Optional part(s)
467
468if [ "$MEMORY" -gt 0 ]; then
469 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100470 tests/compat.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200471fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100472
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000473else # no MemSan
474
475msg "build: Release (clang)"
476cleanup
477CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
478make
479
480msg "test: main suites valgrind (Release)"
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +0200481make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000482
483# Optional part(s)
484# Currently broken, programs don't seem to receive signals
485# under valgrind on OS X
486
487if [ "$MEMORY" -gt 0 ]; then
488 msg "test: ssl-opt.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100489 tests/ssl-opt.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000490fi
491
492if [ "$MEMORY" -gt 1 ]; then
493 msg "test: compat.sh --memcheck (Release)"
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100494 tests/compat.sh --memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000495fi
496
497fi # MemSan
498
Andres AGdc192212016-08-31 17:33:13 +0100499msg "build: cmake 'out-of-source' build"
500cleanup
501MBEDTLS_ROOT_DIR="$PWD"
502mkdir "$OUT_OF_SOURCE_DIR"
503cd "$OUT_OF_SOURCE_DIR"
504cmake "$MBEDTLS_ROOT_DIR"
505make
506
507msg "test: cmake 'out-of-source' build"
508make test
509cd "$MBEDTLS_ROOT_DIR"
510rm -rf "$OUT_OF_SOURCE_DIR"
511
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100512msg "Done, cleaning up"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100513cleanup
514