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