Andres AG | 31f9b5b | 2016-10-04 17:14:38 +0100 | [diff] [blame] | 1 | #! /usr/bin/env sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 3 | # all.sh |
| 4 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 5 | # This file is part of mbed TLS (https://tls.mbed.org) |
| 6 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 7 | # Copyright (c) 2014-2017, ARM Limited, All Rights Reserved |
| 8 | |
| 9 | |
| 10 | |
| 11 | ################################################################ |
| 12 | #### Documentation |
| 13 | ################################################################ |
| 14 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 15 | # Purpose |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 16 | # ------- |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 17 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 18 | # To run all tests possible or available on the platform. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 19 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 20 | # Notes for users |
| 21 | # --------------- |
| 22 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 23 | # Warning: the test is destructive. It includes various build modes and |
| 24 | # configurations, and can and will arbitrarily change the current CMake |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 25 | # configuration. The following files must be committed into git: |
| 26 | # * include/mbedtls/config.h |
| 27 | # * Makefile, library/Makefile, programs/Makefile, tests/Makefile |
| 28 | # After running this script, the CMake cache will be lost and CMake |
| 29 | # will no longer be initialised. |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 30 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 31 | # The script assumes the presence of a number of tools: |
| 32 | # * Basic Unix tools (Windows users note: a Unix-style find must be before |
| 33 | # the Windows find in the PATH) |
| 34 | # * Perl |
| 35 | # * GNU Make |
| 36 | # * CMake |
| 37 | # * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind) |
| 38 | # * arm-gcc and mingw-gcc |
| 39 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
| 40 | # * Yotta build dependencies, unless invoked with --no-yotta |
| 41 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
| 42 | # interoperability tests. If they don't support SSLv3 then a legacy |
| 43 | # version of these tools must be present as well (search for LEGACY |
| 44 | # below). |
| 45 | # See the invocation of check_tools below for details. |
| 46 | # |
| 47 | # This script must be invoked from the toplevel directory of a git |
| 48 | # working copy of Mbed TLS. |
| 49 | # |
| 50 | # Note that the output is not saved. You may want to run |
| 51 | # script -c tests/scripts/all.sh |
| 52 | # or |
| 53 | # tests/scripts/all.sh >all.log 2>&1 |
| 54 | # |
| 55 | # Notes for maintainers |
| 56 | # --------------------- |
| 57 | # |
| 58 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 59 | # have to be exact, but in general you should add slower tests towards |
| 60 | # the end and fast checks near the beginning. |
| 61 | # |
| 62 | # Sanity checks have the following form: |
| 63 | # 1. msg "short description of what is about to be done" |
| 64 | # 2. run sanity check (failure stops the script) |
| 65 | # |
| 66 | # Build or build-and-test steps have the following form: |
| 67 | # 1. msg "short description of what is about to be done" |
| 68 | # 2. cleanup |
| 69 | # 3. preparation (config.pl, cmake, ...) (failure stops the script) |
| 70 | # 4. make |
| 71 | # 5. Run tests if relevant. All tests must be prefixed with |
| 72 | # if_build_successful for the sake of --keep-going. |
| 73 | |
| 74 | |
| 75 | |
| 76 | ################################################################ |
| 77 | #### Initialization and command line parsing |
| 78 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 79 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 80 | # Abort on errors (and uninitialised variables) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 81 | set -eu |
| 82 | |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 83 | if [ "$( uname )" != "Linux" ]; then |
| 84 | echo "This script only works in Linux" >&2 |
| 85 | exit 1 |
| 86 | elif [ -d library -a -d include -a -d tests ]; then :; else |
| 87 | echo "Must be run from mbed TLS root" >&2 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 88 | exit 1 |
| 89 | fi |
| 90 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 91 | CONFIG_H='include/mbedtls/config.h' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 92 | CONFIG_BAK="$CONFIG_H.bak" |
| 93 | |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 94 | MEMORY=0 |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 95 | FORCE=0 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 96 | KEEP_GOING=0 |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 97 | RUN_ARMCC=1 |
Gilles Peskine | da51925 | 2017-11-30 13:22:04 +0100 | [diff] [blame] | 98 | YOTTA=1 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 99 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 100 | # Default commands, can be overriden by the environment |
| 101 | : ${OPENSSL:="openssl"} |
| 102 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 103 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 104 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 105 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 106 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 107 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 108 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 109 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 110 | |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 111 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
| 112 | if [ -n "${MAKEFLAGS+set}" ]; then |
| 113 | export MAKEFLAGS="-j" |
| 114 | fi |
| 115 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 116 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 117 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 118 | cat <<EOF |
| 119 | Usage: $0 [OPTION]... |
| 120 | -h|--help Print this help. |
| 121 | |
| 122 | General options: |
| 123 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 124 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 125 | -m|--memory Additional optional memory tests. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 126 | --armcc Run ARM Compiler builds (on by default). |
| 127 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 128 | --no-force Refuse to overwrite modified files (default). |
| 129 | --no-keep-going Stop at the first error (default). |
| 130 | --no-memory No additional memory tests (default). |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 131 | --no-yotta Skip yotta module build. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 132 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 133 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 134 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 135 | -s|--seed Integer seed value to use for this test run. |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 136 | --yotta Build yotta module (on by default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 137 | |
| 138 | Tool path options: |
| 139 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 140 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 141 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 142 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 143 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 144 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 145 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 146 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3. |
| 147 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 148 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 149 | |
| 150 | # remove built files as well as the cmake cache/config |
| 151 | cleanup() |
| 152 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 153 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 154 | cd "$MBEDTLS_ROOT_DIR" |
| 155 | fi |
| 156 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 157 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 158 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 159 | # Remove CMake artefacts |
| 160 | find . -name .git -prune -o -name yotta -prune -o \ |
| 161 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 162 | \( -iname cmake_install.cmake -o \ |
| 163 | -iname CTestTestfile.cmake -o \ |
| 164 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 165 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 166 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 167 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 168 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 169 | |
| 170 | if [ -f "$CONFIG_BAK" ]; then |
| 171 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 172 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 173 | } |
| 174 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 175 | # Executed on exit. May be redefined depending on command line options. |
| 176 | final_report () { |
| 177 | : |
| 178 | } |
| 179 | |
| 180 | fatal_signal () { |
| 181 | cleanup |
| 182 | final_report $1 |
| 183 | trap - $1 |
| 184 | kill -$1 $$ |
| 185 | } |
| 186 | |
| 187 | trap 'fatal_signal HUP' HUP |
| 188 | trap 'fatal_signal INT' INT |
| 189 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 190 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 191 | msg() |
| 192 | { |
| 193 | echo "" |
| 194 | echo "******************************************************************" |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 195 | echo "* $1 " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 196 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 197 | echo "******************************************************************" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 198 | current_section=$1 |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 199 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 200 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 201 | if [ $RUN_ARMCC -ne 0 ]; then |
| 202 | armc6_build_test() |
| 203 | { |
| 204 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 205 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 206 | msg "build: ARM Compiler 6 ($FLAGS), make" |
| 207 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 208 | WARNING_CFLAGS='-xc -std=c99' make lib |
| 209 | make clean |
| 210 | } |
| 211 | fi |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 212 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 213 | err_msg() |
| 214 | { |
| 215 | echo "$1" >&2 |
| 216 | } |
| 217 | |
| 218 | check_tools() |
| 219 | { |
| 220 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 221 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 222 | err_msg "$TOOL not found!" |
| 223 | exit 1 |
| 224 | fi |
| 225 | done |
| 226 | } |
| 227 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 228 | while [ $# -gt 0 ]; do |
| 229 | case "$1" in |
Gilles Peskine | 54933e9 | 2018-03-21 08:39:32 +0100 | [diff] [blame] | 230 | --armcc) RUN_ARMCC=1;; |
| 231 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 232 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
| 233 | --force|-f) FORCE=1;; |
| 234 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 235 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 236 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 237 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 238 | --help|-h) usage; exit;; |
| 239 | --keep-going|-k) KEEP_GOING=1;; |
| 240 | --memory|-m) MEMORY=1;; |
| 241 | --no-armcc) RUN_ARMCC=0;; |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 242 | --no-force) FORCE=0;; |
| 243 | --no-keep-going) KEEP_GOING=0;; |
| 244 | --no-memory) MEMORY=0;; |
Gilles Peskine | 54933e9 | 2018-03-21 08:39:32 +0100 | [diff] [blame] | 245 | --no-yotta) YOTTA=0;; |
| 246 | --openssl) shift; OPENSSL="$1";; |
| 247 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 248 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 249 | --random-seed) unset SEED;; |
| 250 | --release-test|-r) SEED=1;; |
Gilles Peskine | 54933e9 | 2018-03-21 08:39:32 +0100 | [diff] [blame] | 251 | --seed|-s) shift; SEED="$1";; |
| 252 | --yotta) YOTTA=1;; |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 253 | *) |
| 254 | echo >&2 "Unknown option: $1" |
| 255 | echo >&2 "Run $0 --help for usage." |
| 256 | exit 120 |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 257 | ;; |
| 258 | esac |
| 259 | shift |
| 260 | done |
| 261 | |
| 262 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | da51925 | 2017-11-30 13:22:04 +0100 | [diff] [blame] | 263 | if [ $YOTTA -eq 1 ]; then |
| 264 | rm -rf yotta/module "$OUT_OF_SOURCE_DIR" |
| 265 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 266 | git checkout-index -f -q $CONFIG_H |
| 267 | cleanup |
| 268 | else |
| 269 | |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 270 | if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 271 | err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'" |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 272 | echo "You can either delete your work and retry, or force the test to overwrite the" |
| 273 | echo "test by rerunning the script as: $0 --force" |
| 274 | exit 1 |
| 275 | fi |
| 276 | |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 277 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 278 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 279 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 280 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 281 | exit 1 |
| 282 | fi |
| 283 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 284 | if ! git diff-files --quiet include/mbedtls/config.h; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 285 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 286 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 287 | echo "script as: $0 --force" |
| 288 | exit 1 |
| 289 | fi |
| 290 | fi |
| 291 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 292 | build_status=0 |
| 293 | if [ $KEEP_GOING -eq 1 ]; then |
| 294 | failure_summary= |
| 295 | failure_count=0 |
| 296 | start_red= |
| 297 | end_color= |
| 298 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 299 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 300 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 301 | start_red=$(printf '\033[31m') |
| 302 | end_color=$(printf '\033[0m') |
| 303 | ;; |
| 304 | esac |
| 305 | fi |
| 306 | record_status () { |
| 307 | if "$@"; then |
| 308 | last_status=0 |
| 309 | else |
| 310 | last_status=$? |
| 311 | text="$current_section: $* -> $last_status" |
| 312 | failure_summary="$failure_summary |
| 313 | $text" |
| 314 | failure_count=$((failure_count + 1)) |
| 315 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 316 | fi |
| 317 | } |
| 318 | make () { |
| 319 | case "$*" in |
| 320 | *test|*check) |
| 321 | if [ $build_status -eq 0 ]; then |
| 322 | record_status command make "$@" |
| 323 | else |
| 324 | echo "(skipped because the build failed)" |
| 325 | fi |
| 326 | ;; |
| 327 | *) |
| 328 | record_status command make "$@" |
| 329 | build_status=$last_status |
| 330 | ;; |
| 331 | esac |
| 332 | } |
| 333 | final_report () { |
| 334 | if [ $failure_count -gt 0 ]; then |
| 335 | echo |
| 336 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 337 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 338 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 5113bde | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 339 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 340 | elif [ -z "${1-}" ]; then |
| 341 | echo "SUCCESS :)" |
| 342 | fi |
| 343 | if [ -n "${1-}" ]; then |
| 344 | echo "Killed by SIG$1." |
| 345 | fi |
| 346 | } |
| 347 | else |
| 348 | record_status () { |
| 349 | "$@" |
| 350 | } |
| 351 | fi |
| 352 | if_build_succeeded () { |
| 353 | if [ $build_status -eq 0 ]; then |
| 354 | record_status "$@" |
| 355 | fi |
| 356 | } |
| 357 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 358 | msg "info: $0 configuration" |
| 359 | echo "MEMORY: $MEMORY" |
| 360 | echo "FORCE: $FORCE" |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 361 | echo "SEED: ${SEED-"UNSET"}" |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 362 | echo "OPENSSL: $OPENSSL" |
| 363 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 364 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 365 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 366 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 367 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 368 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 369 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 370 | |
| 371 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 372 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
| 373 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 374 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 375 | |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 376 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh |
| 377 | # we just export the variables they require |
| 378 | export OPENSSL_CMD="$OPENSSL" |
| 379 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 380 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 381 | |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 382 | # Avoid passing --seed flag in every call to ssl-opt.sh |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 383 | if [ -n "${SEED-}" ]; then |
| 384 | export SEED |
| 385 | fi |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 386 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 387 | # Make sure the tools we need are available. |
| 388 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 389 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \ |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 390 | "arm-none-eabi-gcc" "i686-w64-mingw32-gcc" |
| 391 | if [ $RUN_ARMCC -ne 0 ]; then |
| 392 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR" |
| 393 | fi |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 394 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 395 | |
| 396 | |
| 397 | ################################################################ |
| 398 | #### Basic checks |
| 399 | ################################################################ |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 400 | |
| 401 | # |
| 402 | # Test Suites to be executed |
| 403 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 404 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 405 | # 1. Catch possible problems early, by running first tests that run quickly |
Manuel Pégourié-Gonnard | 61bc57a | 2014-08-14 11:29:06 +0200 | [diff] [blame] | 406 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 407 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 408 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 409 | # |
| 410 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 411 | |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 412 | msg "info: output_env.sh" |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 413 | OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \ |
| 414 | GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \ |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 415 | GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \ |
Gilles Peskine | 53038eb | 2018-03-21 08:35:07 +0100 | [diff] [blame] | 416 | ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 417 | |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 418 | msg "test: recursion.pl" # < 1s |
Gilles Peskine | 732826d | 2018-09-26 15:54:40 +0200 | [diff] [blame] | 419 | record_status tests/scripts/recursion.pl library/*.c |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 420 | |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 421 | msg "test: freshness of generated source files" # < 1s |
Gilles Peskine | 732826d | 2018-09-26 15:54:40 +0200 | [diff] [blame] | 422 | record_status tests/scripts/check-generated-files.sh |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 423 | |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 424 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
Gilles Peskine | 732826d | 2018-09-26 15:54:40 +0200 | [diff] [blame] | 425 | record_status tests/scripts/check-doxy-blocks.pl |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 426 | |
Darryl Green | bd38c3b | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 427 | msg "test: check-files.py" # < 1s |
| 428 | cleanup |
Gilles Peskine | 732826d | 2018-09-26 15:54:40 +0200 | [diff] [blame] | 429 | record_status tests/scripts/check-files.py |
Darryl Green | bd38c3b | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 430 | |
Manuel Pégourié-Gonnard | a687baf | 2015-04-09 11:09:03 +0200 | [diff] [blame] | 431 | msg "test/build: declared and exported names" # < 3s |
| 432 | cleanup |
Gilles Peskine | 732826d | 2018-09-26 15:54:40 +0200 | [diff] [blame] | 433 | record_status tests/scripts/check-names.sh |
Manuel Pégourié-Gonnard | a687baf | 2015-04-09 11:09:03 +0200 | [diff] [blame] | 434 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 435 | msg "test: doxygen warnings" # ~ 3s |
| 436 | cleanup |
Gilles Peskine | 732826d | 2018-09-26 15:54:40 +0200 | [diff] [blame] | 437 | record_status tests/scripts/doxygen.sh |
Manuel Pégourié-Gonnard | 1d552e7 | 2016-01-04 16:49:09 +0100 | [diff] [blame] | 438 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 439 | |
| 440 | |
| 441 | ################################################################ |
| 442 | #### Build and test many configurations and targets |
| 443 | ################################################################ |
| 444 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 445 | if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then |
| 446 | # Note - use of yotta is deprecated, and yotta also requires armcc to be on the |
| 447 | # path, and uses whatever version of armcc it finds there. |
Gilles Peskine | da51925 | 2017-11-30 13:22:04 +0100 | [diff] [blame] | 448 | msg "build: create and build yotta module" # ~ 30s |
| 449 | cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 450 | record_status tests/scripts/yotta-build.sh |
Gilles Peskine | da51925 | 2017-11-30 13:22:04 +0100 | [diff] [blame] | 451 | fi |
Manuel Pégourié-Gonnard | 77d56bb | 2015-07-28 15:00:37 +0200 | [diff] [blame] | 452 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 453 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 454 | cleanup |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 455 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 456 | make |
| 457 | |
Simon Butcher | 8e3afc7 | 2016-09-15 17:13:08 +0100 | [diff] [blame] | 458 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 459 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 460 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 461 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 462 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 463 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 464 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
Gilles Peskine | 763da6e | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 465 | record_status tests/scripts/test-ref-configs.pl |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 466 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 467 | msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min |
| 468 | make |
| 469 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 470 | msg "test: compat.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 471 | if_build_succeeded tests/compat.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 472 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 473 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
| 474 | cleanup |
Simon Butcher | f413b6f | 2016-03-14 22:32:42 +0000 | [diff] [blame] | 475 | cp "$CONFIG_H" "$CONFIG_BAK" |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 476 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 477 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 478 | make |
| 479 | |
Simon Butcher | 8e3afc7 | 2016-09-15 17:13:08 +0100 | [diff] [blame] | 480 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 481 | make test |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 482 | |
| 483 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 484 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 485 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 486 | |
| 487 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 488 | if_build_succeeded tests/ssl-opt.sh |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 489 | |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 490 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
| 491 | cleanup |
| 492 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 493 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 494 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 495 | make |
| 496 | |
| 497 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 498 | make test |
| 499 | |
| 500 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 501 | if_build_succeeded tests/ssl-opt.sh |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 502 | |
Hanno Becker | 69d45cc | 2018-03-09 10:46:23 +0000 | [diff] [blame] | 503 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
| 504 | cleanup |
| 505 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 506 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 507 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 508 | make |
| 509 | |
| 510 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 511 | make test |
| 512 | |
| 513 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | b46c59e | 2018-09-27 10:12:58 +0200 | [diff] [blame] | 514 | if_build_succeeded tests/ssl-opt.sh -f RSA |
Hanno Becker | 69d45cc | 2018-03-09 10:46:23 +0000 | [diff] [blame] | 515 | |
| 516 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
Gilles Peskine | b46c59e | 2018-09-27 10:12:58 +0200 | [diff] [blame] | 517 | if_build_succeeded tests/compat.sh -t RSA |
Hanno Becker | 69d45cc | 2018-03-09 10:46:23 +0000 | [diff] [blame] | 518 | |
Manuel Pégourié-Gonnard | 4d9e7cb | 2017-06-20 10:49:24 +0200 | [diff] [blame] | 519 | msg "build: cmake, full config, clang" # ~ 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 520 | cleanup |
Janos Follath | 35d48cb | 2016-04-22 14:45:00 +0100 | [diff] [blame] | 521 | cp "$CONFIG_H" "$CONFIG_BAK" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 522 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 523 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
Simon Butcher | f95c176 | 2016-11-10 17:25:58 +0000 | [diff] [blame] | 524 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
Manuel Pégourié-Gonnard | 4d9e7cb | 2017-06-20 10:49:24 +0200 | [diff] [blame] | 525 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 526 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 527 | msg "test: main suites (full config)" # ~ 5s |
Manuel Pégourié-Gonnard | 4d9e7cb | 2017-06-20 10:49:24 +0200 | [diff] [blame] | 528 | make test |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 529 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 530 | msg "test: ssl-opt.sh default (full config)" # ~ 1s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 531 | if_build_succeeded tests/ssl-opt.sh -f Default |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 532 | |
Manuel Pégourié-Gonnard | ea0920f | 2015-03-24 09:50:15 +0100 | [diff] [blame] | 533 | msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 534 | if_build_succeeded env OPENSSL_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é-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 535 | |
Gilles Peskine | b4ef45b | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 536 | msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s |
| 537 | cleanup |
| 538 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 539 | scripts/config.pl full |
Gilles Peskine | 0afe624 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 540 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | b4ef45b | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 541 | # Build with -O -Wextra to catch a maximum of issues. |
| 542 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 543 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
| 544 | |
| 545 | msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s |
| 546 | # No cleanup, just tweak the configuration and rebuild |
| 547 | make clean |
| 548 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 0afe624 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 549 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
Gilles Peskine | b4ef45b | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 550 | # Build with -O -Wextra to catch a maximum of issues. |
| 551 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 552 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
Gilles Peskine | 0afe624 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 553 | |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 554 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 555 | cleanup |
Gilles Peskine | 763da6e | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 556 | record_status tests/scripts/curves.pl |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 557 | |
Manuel Pégourié-Gonnard | 483a776 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 558 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
| 559 | cleanup |
Gilles Peskine | 763da6e | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 560 | record_status tests/scripts/depends-hashes.pl |
Manuel Pégourié-Gonnard | 483a776 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 561 | |
Manuel Pégourié-Gonnard | 1ddd682 | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 562 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
| 563 | cleanup |
Gilles Peskine | 763da6e | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 564 | record_status tests/scripts/depends-pkalgs.pl |
Manuel Pégourié-Gonnard | 1ddd682 | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 565 | |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 566 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
| 567 | cleanup |
Gilles Peskine | 763da6e | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 568 | record_status tests/scripts/key-exchanges.pl |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 569 | |
Manuel Pégourié-Gonnard | 61fe8b0 | 2015-03-13 14:33:16 +0000 | [diff] [blame] | 570 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 571 | cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 572 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 573 | |
Simon Butcher | f95c176 | 2016-11-10 17:25:58 +0000 | [diff] [blame] | 574 | # Full configuration build, without platform support, file IO and net sockets. |
| 575 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 576 | # IO, it should catch missing '#include <stdio.h>' |
| 577 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 578 | cleanup |
| 579 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 580 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 581 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
Simon Butcher | f95c176 | 2016-11-10 17:25:58 +0000 | [diff] [blame] | 582 | scripts/config.pl unset MBEDTLS_NET_C |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 583 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
Manuel Pégourié-Gonnard | 3d4755b | 2015-06-03 14:03:17 +0100 | [diff] [blame] | 584 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 585 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 586 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
Simon Butcher | b928343 | 2016-07-13 11:02:41 +0100 | [diff] [blame] | 587 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
Manuel Pégourié-Gonnard | 3d4755b | 2015-06-03 14:03:17 +0100 | [diff] [blame] | 588 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
Simon Butcher | 284b4c9 | 2016-06-26 13:10:00 +0100 | [diff] [blame] | 589 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 590 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 591 | scripts/config.pl unset MBEDTLS_FS_IO |
Simon Butcher | cb58700 | 2017-01-06 16:14:44 +0000 | [diff] [blame] | 592 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 593 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 594 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs |
| 595 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 596 | |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 597 | # catch compile bugs in _uninit functions |
| 598 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
| 599 | cleanup |
| 600 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 601 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 7ee5ddd | 2015-06-03 10:33:55 +0100 | [diff] [blame] | 602 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
Simon Butcher | eebf1b9 | 2016-06-27 01:42:39 +0100 | [diff] [blame] | 603 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 604 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 605 | |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 606 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
| 607 | cleanup |
| 608 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 609 | scripts/config.pl full |
| 610 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 611 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 612 | |
| 613 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
| 614 | cleanup |
| 615 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 616 | scripts/config.pl full |
| 617 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
Hanno Becker | d485c31 | 2018-01-05 13:03:53 +0000 | [diff] [blame] | 618 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 619 | |
Simon Butcher | f95c176 | 2016-11-10 17:25:58 +0000 | [diff] [blame] | 620 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 621 | # as that requires a POSIX platform (which isn't the same as C99). |
Andres AG | 788aa4a | 2016-09-14 14:32:09 +0100 | [diff] [blame] | 622 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 623 | cleanup |
| 624 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 625 | scripts/config.pl full |
Manuel Pégourié-Gonnard | f78e4de | 2015-05-29 10:52:14 +0200 | [diff] [blame] | 626 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 627 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 628 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 629 | |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 630 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
| 631 | cleanup |
| 632 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 633 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 634 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 635 | make |
| 636 | |
| 637 | msg "test: ssl-opt.sh, MFL-related tests" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 638 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 639 | |
Simon Butcher | ab5df40 | 2016-06-11 02:31:21 +0100 | [diff] [blame] | 640 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 641 | cleanup |
| 642 | cp "$CONFIG_H" "$CONFIG_BAK" |
Simon Butcher | ab5df40 | 2016-06-11 02:31:21 +0100 | [diff] [blame] | 643 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 644 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 645 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 646 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 647 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 648 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Simon Butcher | eebf1b9 | 2016-06-27 01:42:39 +0100 | [diff] [blame] | 649 | CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" . |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 650 | make |
| 651 | |
Simon Butcher | 8e3afc7 | 2016-09-15 17:13:08 +0100 | [diff] [blame] | 652 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 653 | make test |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 654 | |
Hanno Becker | 72311b4 | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 655 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 656 | cleanup |
| 657 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 658 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 659 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 660 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 661 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 662 | make |
| 663 | |
| 664 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 665 | make test |
| 666 | |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 667 | if uname -a | grep -F Linux >/dev/null; then |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 668 | msg "build/test: make shared" # ~ 40s |
| 669 | cleanup |
| 670 | make SHARED=1 all check |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 671 | fi |
| 672 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 673 | if uname -a | grep -F x86_64 >/dev/null; then |
Simon Butcher | 948f264 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 674 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 675 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 676 | cleanup |
Simon Butcher | 7c6b841 | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 677 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 678 | scripts/config.pl full |
Simon Butcher | 948f264 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 679 | make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' |
Andres Amaya Garcia | dd29c2f | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 680 | |
Simon Butcher | 948f264 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 681 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 682 | make test |
| 683 | |
| 684 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 685 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
| 686 | cleanup |
| 687 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 688 | scripts/config.pl full |
| 689 | make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' |
| 690 | |
| 691 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 692 | make test |
| 693 | |
| 694 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
| 695 | cleanup |
Simon Butcher | 7c6b841 | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 696 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 697 | scripts/config.pl full |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 698 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' |
| 699 | |
| 700 | msg "test: 64-bit ILP32, make, gcc" |
| 701 | make test |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 702 | fi # x86_64 |
| 703 | |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 704 | msg "build: gcc, force 32-bit bignum limbs" |
| 705 | cleanup |
| 706 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 707 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 708 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 709 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 710 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
| 711 | |
| 712 | msg "test: gcc, force 32-bit bignum limbs" |
| 713 | make test |
| 714 | |
| 715 | msg "build: gcc, force 64-bit bignum limbs" |
| 716 | cleanup |
| 717 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 718 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 719 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 720 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 721 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
| 722 | |
| 723 | msg "test: gcc, force 64-bit bignum limbs" |
| 724 | make test |
| 725 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 726 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
| 727 | cleanup |
| 728 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 729 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 730 | scripts/config.pl unset MBEDTLS_NET_C |
| 731 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 732 | scripts/config.pl unset MBEDTLS_FS_IO |
Simon Butcher | eebf1b9 | 2016-06-27 01:42:39 +0100 | [diff] [blame] | 733 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Simon Butcher | bc6a486 | 2016-03-07 17:35:59 +0000 | [diff] [blame] | 734 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 735 | # following things are not in the default config |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 736 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 737 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 738 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 739 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 740 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 741 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 742 | |
Gilles Peskine | 9a9adcd | 2017-06-08 15:19:20 +0200 | [diff] [blame] | 743 | msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
| 744 | cleanup |
Simon Butcher | 51aaa99 | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 745 | cp "$CONFIG_H" "$CONFIG_BAK" |
Andres Amaya Garcia | 6fb6586 | 2017-07-20 13:27:35 +0100 | [diff] [blame] | 746 | scripts/config.pl full |
| 747 | scripts/config.pl unset MBEDTLS_NET_C |
| 748 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 749 | scripts/config.pl unset MBEDTLS_FS_IO |
| 750 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 751 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
| 752 | # following things are not in the default config |
| 753 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 754 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 755 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 756 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 757 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Gilles Peskine | 9a9adcd | 2017-06-08 15:19:20 +0200 | [diff] [blame] | 758 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 759 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
Gilles Peskine | 9a9adcd | 2017-06-08 15:19:20 +0200 | [diff] [blame] | 760 | echo "Checking that software 64-bit division is not required" |
| 761 | ! grep __aeabi_uldiv library/*.o |
| 762 | |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 763 | msg "build: ARM Compiler 5, make" |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 764 | cleanup |
| 765 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 766 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 767 | scripts/config.pl unset MBEDTLS_NET_C |
| 768 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 769 | scripts/config.pl unset MBEDTLS_FS_IO |
Simon Butcher | 1c71965 | 2016-06-27 19:02:12 +0100 | [diff] [blame] | 770 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 771 | scripts/config.pl unset MBEDTLS_HAVE_TIME |
Manuel Pégourié-Gonnard | bbc60db | 2015-06-22 14:31:50 +0200 | [diff] [blame] | 772 | scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE |
Simon Butcher | bc6a486 | 2016-03-07 17:35:59 +0000 | [diff] [blame] | 773 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 774 | # following things are not in the default config |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 775 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 776 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 777 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 778 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 779 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 780 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Simon Butcher | 4df5eaf | 2016-08-24 22:58:31 +0300 | [diff] [blame] | 781 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 782 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 783 | if [ $RUN_ARMCC -ne 0 ]; then |
| 784 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 785 | make clean |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 786 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 787 | # ARM Compiler 6 - Target ARMv7-A |
| 788 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Simon Butcher | 51aaa99 | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 789 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 790 | # ARM Compiler 6 - Target ARMv7-M |
| 791 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Simon Butcher | 51aaa99 | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 792 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 793 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 794 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Simon Butcher | 51aaa99 | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 795 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 796 | # ARM Compiler 6 - Target ARMv8-M |
| 797 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 51aaa99 | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 798 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 799 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 800 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
| 801 | fi |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 802 | |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 803 | msg "build: allow SHA1 in certificates by default" |
| 804 | cleanup |
| 805 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 806 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 807 | make CFLAGS='-Werror -Wall -Wextra' |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 808 | msg "test: allow SHA1 in certificates by default" |
| 809 | make test |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 810 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 811 | |
Hanno Becker | d485c31 | 2018-01-05 13:03:53 +0000 | [diff] [blame] | 812 | msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 813 | cleanup |
| 814 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 815 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
Hanno Becker | d485c31 | 2018-01-05 13:03:53 +0000 | [diff] [blame] | 816 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 817 | make |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 818 | |
| 819 | msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)" |
| 820 | make test |
| 821 | |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 822 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 823 | cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 824 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs |
Simon Butcher | 91aef33 | 2016-11-17 09:20:50 +0000 | [diff] [blame] | 825 | |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 826 | # note Make tests only builds the tests, but doesn't run them |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 827 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
| 828 | make WINDOWS_BUILD=1 clean |
Simon Butcher | f95c176 | 2016-11-10 17:25:58 +0000 | [diff] [blame] | 829 | |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 830 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 831 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs |
| 832 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests |
| 833 | make WINDOWS_BUILD=1 clean |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 834 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 835 | # MemSan currently only available on Linux 64 bits |
| 836 | if uname -a | grep 'Linux.*x86_64' >/dev/null; then |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 837 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 838 | msg "build: MSan (clang)" # ~ 1 min 20s |
| 839 | cleanup |
| 840 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 841 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 842 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 843 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 844 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 845 | msg "test: main suites (MSan)" # ~ 10s |
| 846 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 847 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 848 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 849 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 850 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 851 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 852 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 853 | if [ "$MEMORY" -gt 0 ]; then |
| 854 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 855 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 856 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 857 | |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 858 | else # no MemSan |
| 859 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 860 | msg "build: Release (clang)" |
| 861 | cleanup |
| 862 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 863 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 864 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 865 | msg "test: main suites valgrind (Release)" |
| 866 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 867 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 868 | # Optional part(s) |
| 869 | # Currently broken, programs don't seem to receive signals |
| 870 | # under valgrind on OS X |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 871 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 872 | if [ "$MEMORY" -gt 0 ]; then |
| 873 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 874 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 875 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 876 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 877 | if [ "$MEMORY" -gt 1 ]; then |
| 878 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 879 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 880 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 881 | |
| 882 | fi # MemSan |
| 883 | |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 884 | msg "build: cmake 'out-of-source' build" |
| 885 | cleanup |
| 886 | MBEDTLS_ROOT_DIR="$PWD" |
| 887 | mkdir "$OUT_OF_SOURCE_DIR" |
| 888 | cd "$OUT_OF_SOURCE_DIR" |
| 889 | cmake "$MBEDTLS_ROOT_DIR" |
| 890 | make |
| 891 | |
| 892 | msg "test: cmake 'out-of-source' build" |
| 893 | make test |
Gilles Peskine | 0114ffc | 2018-03-21 12:17:20 +0100 | [diff] [blame] | 894 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 895 | # Also ensure that there are no error messages such as |
| 896 | # "No such file or directory", which would indicate that some required |
| 897 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 898 | # may exit with status 0 but emit errors). |
| 899 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 900 | if [ -s ssl-opt.err ]; then |
| 901 | cat ssl-opt.err >&2 |
| 902 | record_status [ ! -s ssl-opt.err ] |
| 903 | rm ssl-opt.err |
| 904 | fi |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 905 | cd "$MBEDTLS_ROOT_DIR" |
| 906 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 907 | unset MBEDTLS_ROOT_DIR |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 908 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 909 | |
| 910 | |
| 911 | ################################################################ |
| 912 | #### Termination |
| 913 | ################################################################ |
| 914 | |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 915 | msg "Done, cleaning up" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 916 | cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 917 | |
| 918 | final_report |