Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 3 | # all.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 4 | # |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 5 | # This file is part of mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 6 | # |
Gilles Peskine | d7602c2 | 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 | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 15 | # Purpose |
Gilles Peskine | d7602c2 | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 16 | # ------- |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 17 | # |
| 18 | # To run all tests possible or available on the platform. |
| 19 | # |
Gilles Peskine | d7602c2 | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 20 | # Notes for users |
| 21 | # --------------- |
| 22 | # |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +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 | d7602c2 | 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. |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 30 | # |
Gilles Peskine | d7602c2 | 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 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
| 41 | # interoperability tests. If they don't support SSLv3 then a legacy |
| 42 | # version of these tools must be present as well (search for LEGACY |
| 43 | # below). |
| 44 | # See the invocation of check_tools below for details. |
| 45 | # |
| 46 | # This script must be invoked from the toplevel directory of a git |
| 47 | # working copy of Mbed TLS. |
| 48 | # |
| 49 | # Note that the output is not saved. You may want to run |
| 50 | # script -c tests/scripts/all.sh |
| 51 | # or |
| 52 | # tests/scripts/all.sh >all.log 2>&1 |
| 53 | # |
| 54 | # Notes for maintainers |
| 55 | # --------------------- |
| 56 | # |
| 57 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 58 | # have to be exact, but in general you should add slower tests towards |
| 59 | # the end and fast checks near the beginning. |
| 60 | # |
| 61 | # Sanity checks have the following form: |
| 62 | # 1. msg "short description of what is about to be done" |
| 63 | # 2. run sanity check (failure stops the script) |
| 64 | # |
| 65 | # Build or build-and-test steps have the following form: |
| 66 | # 1. msg "short description of what is about to be done" |
| 67 | # 2. cleanup |
| 68 | # 3. preparation (config.pl, cmake, ...) (failure stops the script) |
| 69 | # 4. make |
| 70 | # 5. Run tests if relevant. All tests must be prefixed with |
| 71 | # if_build_successful for the sake of --keep-going. |
| 72 | |
| 73 | |
| 74 | |
| 75 | ################################################################ |
| 76 | #### Initialization and command line parsing |
| 77 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 78 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 79 | # Abort on errors (and uninitialised variables) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 80 | set -eu |
| 81 | |
| 82 | if [ -d library -a -d include -a -d tests ]; then :; else |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 83 | err_msg "Must be run from mbed TLS root" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 84 | exit 1 |
| 85 | fi |
| 86 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 87 | CONFIG_H='include/mbedtls/config.h' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 88 | CONFIG_BAK="$CONFIG_H.bak" |
| 89 | |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 90 | MEMORY=0 |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 91 | FORCE=0 |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 92 | KEEP_GOING=0 |
Gilles Peskine | b9344e3 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 93 | RUN_ARMCC=1 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 94 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 95 | # Default commands, can be overriden by the environment |
| 96 | : ${OPENSSL:="openssl"} |
| 97 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 98 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 99 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 100 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 101 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 102 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 103 | |
| 104 | usage() |
| 105 | { |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 106 | cat <<EOF |
| 107 | Usage: $0 [OPTION]... |
| 108 | -h|--help Print this help. |
| 109 | |
| 110 | General options: |
| 111 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 112 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 113 | -m|--memory Additional optional memory tests. |
Gilles Peskine | b9344e3 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 114 | --armcc Run ARM Compiler builds (on by default). |
| 115 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 243bb4c | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 116 | --no-force Refuse to overwrite modified files (default). |
| 117 | --no-keep-going Stop at the first error (default). |
| 118 | --no-memory No additional memory tests (default). |
Gilles Peskine | 32d9293 | 2018-03-21 10:14:05 +0100 | [diff] [blame] | 119 | --no-yotta Ignored for compatibility with other Mbed TLS versions. |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 120 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 243bb4c | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 121 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 122 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 123 | -s|--seed Integer seed value to use for this test run. |
| 124 | |
| 125 | Tool path options: |
Gilles Peskine | 37c88db | 2018-03-21 11:44:52 +0100 | [diff] [blame] | 126 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 127 | --armc6-bin-dir=<ARMC6_bin_dir_path> Ignored for compatibility with other Mbed TLS versions. |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 128 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 129 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 130 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 131 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 132 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 133 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3. |
| 134 | EOF |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 135 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 136 | |
| 137 | # remove built files as well as the cmake cache/config |
| 138 | cleanup() |
| 139 | { |
Gilles Peskine | 00de2fd | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 140 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 141 | cd "$MBEDTLS_ROOT_DIR" |
| 142 | fi |
| 143 | |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 144 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 145 | |
Gilles Peskine | 341ea25 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 146 | # Remove CMake artefacts |
| 147 | find . -name .git -prune -o -name yotta -prune -o \ |
| 148 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 149 | \( -iname cmake_install.cmake -o \ |
| 150 | -iname CTestTestfile.cmake -o \ |
| 151 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 152 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 153 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 154 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 155 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 156 | |
| 157 | if [ -f "$CONFIG_BAK" ]; then |
| 158 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 159 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 160 | } |
| 161 | |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 162 | # Executed on exit. May be redefined depending on command line options. |
| 163 | final_report () { |
| 164 | : |
| 165 | } |
| 166 | |
| 167 | fatal_signal () { |
| 168 | cleanup |
| 169 | final_report $1 |
| 170 | trap - $1 |
| 171 | kill -$1 $$ |
| 172 | } |
| 173 | |
| 174 | trap 'fatal_signal HUP' HUP |
| 175 | trap 'fatal_signal INT' INT |
| 176 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 177 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 178 | msg() |
| 179 | { |
| 180 | echo "" |
| 181 | echo "******************************************************************" |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 182 | echo "* $1 " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 183 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 184 | echo "******************************************************************" |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 185 | current_section=$1 |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 186 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 187 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 188 | err_msg() |
| 189 | { |
| 190 | echo "$1" >&2 |
| 191 | } |
| 192 | |
| 193 | check_tools() |
| 194 | { |
| 195 | for TOOL in "$@"; do |
Andres AG | 63cc716 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 196 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 197 | err_msg "$TOOL not found!" |
| 198 | exit 1 |
| 199 | fi |
| 200 | done |
| 201 | } |
| 202 | |
| 203 | while [ $# -gt 0 ]; do |
| 204 | case "$1" in |
Gilles Peskine | 7efa8cf | 2018-03-21 10:04:49 +0100 | [diff] [blame] | 205 | --armcc) RUN_ARMCC=1;; |
Gilles Peskine | 37c88db | 2018-03-21 11:44:52 +0100 | [diff] [blame] | 206 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 207 | --armc6-bin-dir) shift;; # Ignore for compatibility with later Mbed TLS versions |
Gilles Peskine | 7efa8cf | 2018-03-21 10:04:49 +0100 | [diff] [blame] | 208 | --force|-f) FORCE=1;; |
| 209 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 210 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 211 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 212 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 213 | --help|-h) usage; exit;; |
| 214 | --keep-going|-k) KEEP_GOING=1;; |
| 215 | --memory|-m) MEMORY=1;; |
| 216 | --no-armcc) RUN_ARMCC=0;; |
Gilles Peskine | 243bb4c | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 217 | --no-force) FORCE=0;; |
| 218 | --no-keep-going) KEEP_GOING=0;; |
| 219 | --no-memory) MEMORY=0;; |
Gilles Peskine | 32d9293 | 2018-03-21 10:14:05 +0100 | [diff] [blame] | 220 | --no-yotta) :;; # No Yotta support anyway, so just ignore --no-yotta |
Gilles Peskine | 7efa8cf | 2018-03-21 10:04:49 +0100 | [diff] [blame] | 221 | --openssl) shift; OPENSSL="$1";; |
| 222 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 223 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
Gilles Peskine | 243bb4c | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 224 | --random-seed) unset SEED;; |
| 225 | --release-test|-r) SEED=1;; |
Gilles Peskine | 7efa8cf | 2018-03-21 10:04:49 +0100 | [diff] [blame] | 226 | --seed|-s) shift; SEED="$1";; |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 227 | *) |
| 228 | echo >&2 "Unknown option: $1" |
| 229 | echo >&2 "Run $0 --help for usage." |
| 230 | exit 120 |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 231 | ;; |
| 232 | esac |
| 233 | shift |
| 234 | done |
| 235 | |
| 236 | if [ $FORCE -eq 1 ]; then |
| 237 | rm -rf yotta/module "$OUT_OF_SOURCE_DIR" |
| 238 | git checkout-index -f -q $CONFIG_H |
| 239 | cleanup |
| 240 | else |
| 241 | |
| 242 | if [ -d yotta/module ]; then |
| 243 | err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'" |
| 244 | echo "You can either delete your work and retry, or force the test to overwrite the" |
| 245 | echo "test by rerunning the script as: $0 --force" |
| 246 | exit 1 |
| 247 | fi |
| 248 | |
| 249 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 250 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 251 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 252 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 253 | exit 1 |
| 254 | fi |
| 255 | |
| 256 | if ! git diff-files --quiet include/mbedtls/config.h; then |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 257 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 258 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 259 | echo "script as: $0 --force" |
| 260 | exit 1 |
| 261 | fi |
| 262 | fi |
| 263 | |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 264 | build_status=0 |
| 265 | if [ $KEEP_GOING -eq 1 ]; then |
| 266 | failure_summary= |
| 267 | failure_count=0 |
| 268 | start_red= |
| 269 | end_color= |
| 270 | if [ -t 1 ]; then |
Gilles Peskine | 92deeaa | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 271 | case "${TERM:-}" in |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 272 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 273 | start_red=$(printf '\033[31m') |
| 274 | end_color=$(printf '\033[0m') |
| 275 | ;; |
| 276 | esac |
| 277 | fi |
| 278 | record_status () { |
| 279 | if "$@"; then |
| 280 | last_status=0 |
| 281 | else |
| 282 | last_status=$? |
| 283 | text="$current_section: $* -> $last_status" |
| 284 | failure_summary="$failure_summary |
| 285 | $text" |
| 286 | failure_count=$((failure_count + 1)) |
| 287 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 288 | fi |
| 289 | } |
| 290 | make () { |
| 291 | case "$*" in |
| 292 | *test|*check) |
| 293 | if [ $build_status -eq 0 ]; then |
| 294 | record_status command make "$@" |
| 295 | else |
| 296 | echo "(skipped because the build failed)" |
| 297 | fi |
| 298 | ;; |
| 299 | *) |
| 300 | record_status command make "$@" |
| 301 | build_status=$last_status |
| 302 | ;; |
| 303 | esac |
| 304 | } |
| 305 | final_report () { |
| 306 | if [ $failure_count -gt 0 ]; then |
| 307 | echo |
| 308 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 309 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 310 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 7ef1f5b | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 311 | exit 1 |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 312 | elif [ -z "${1-}" ]; then |
| 313 | echo "SUCCESS :)" |
| 314 | fi |
| 315 | if [ -n "${1-}" ]; then |
| 316 | echo "Killed by SIG$1." |
| 317 | fi |
| 318 | } |
| 319 | else |
| 320 | record_status () { |
| 321 | "$@" |
| 322 | } |
| 323 | fi |
| 324 | if_build_succeeded () { |
| 325 | if [ $build_status -eq 0 ]; then |
| 326 | record_status "$@" |
| 327 | fi |
| 328 | } |
| 329 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 330 | msg "info: $0 configuration" |
| 331 | echo "MEMORY: $MEMORY" |
| 332 | echo "FORCE: $FORCE" |
| 333 | echo "SEED: ${SEED-"UNSET"}" |
| 334 | echo "OPENSSL: $OPENSSL" |
| 335 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 336 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 337 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 338 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 339 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
Gilles Peskine | 37c88db | 2018-03-21 11:44:52 +0100 | [diff] [blame] | 340 | echo "ARMC5_BIN_DIR: ${ARMC5_BIN_DIR:-UNSET}" |
| 341 | |
| 342 | if [ -n "${ARMC5_BIN_DIR-}" ]; then |
| 343 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 344 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
| 345 | else |
| 346 | ARMC5_CC=armcc |
| 347 | ARMC5_AR=armar |
| 348 | fi |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 349 | |
| 350 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh |
| 351 | # we just export the variables they require |
| 352 | export OPENSSL_CMD="$OPENSSL" |
| 353 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 354 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 355 | |
| 356 | # Avoid passing --seed flag in every call to ssl-opt.sh |
Gilles Peskine | 243bb4c | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 357 | if [ -n "${SEED-}" ]; then |
| 358 | export SEED |
| 359 | fi |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 360 | |
| 361 | # Make sure the tools we need are available. |
| 362 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 363 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \ |
Gilles Peskine | b9344e3 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 364 | "arm-none-eabi-gcc" |
| 365 | if [ $RUN_ARMCC -ne 0 ]; then |
Gilles Peskine | 37c88db | 2018-03-21 11:44:52 +0100 | [diff] [blame] | 366 | check_tools "$ARMC5_CC" "$ARMC5_AR" |
Gilles Peskine | b9344e3 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 367 | fi |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 368 | |
Gilles Peskine | d7602c2 | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 369 | |
| 370 | |
| 371 | ################################################################ |
| 372 | #### Basic checks |
| 373 | ################################################################ |
| 374 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 375 | # |
| 376 | # Test Suites to be executed |
| 377 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 378 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 379 | # 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] | 380 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 381 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 382 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 383 | # |
| 384 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 385 | |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 386 | msg "test: recursion.pl" # < 1s |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 387 | tests/scripts/recursion.pl library/*.c |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 388 | |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 389 | msg "test: freshness of generated source files" # < 1s |
| 390 | tests/scripts/check-generated-files.sh |
| 391 | |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 392 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 393 | tests/scripts/check-doxy-blocks.pl |
| 394 | |
Darryl Green | f8277f9 | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 395 | msg "test: check-files.py" # < 1s |
| 396 | cleanup |
| 397 | tests/scripts/check-files.py |
| 398 | |
Manuel Pégourié-Gonnard | a687baf | 2015-04-09 11:09:03 +0200 | [diff] [blame] | 399 | msg "test/build: declared and exported names" # < 3s |
| 400 | cleanup |
| 401 | tests/scripts/check-names.sh |
| 402 | |
Gilles Peskine | d7602c2 | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 403 | |
| 404 | |
| 405 | ################################################################ |
| 406 | #### Build and test many configurations and targets |
| 407 | ################################################################ |
| 408 | |
Simon Butcher | 7315635 | 2015-11-04 00:36:30 +0000 | [diff] [blame] | 409 | # Yotta not supported in 2.1 branch |
| 410 | #msg "build: create and build yotta module" # ~ 30s |
| 411 | #cleanup |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 412 | #record_status tests/scripts/yotta-build.sh |
Manuel Pégourié-Gonnard | 77d56bb | 2015-07-28 15:00:37 +0200 | [diff] [blame] | 413 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 414 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 415 | cleanup |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 416 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 417 | make |
| 418 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 419 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 420 | make test |
| 421 | programs/test/selftest |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 422 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 423 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 424 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 425 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 426 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
Gilles Peskine | a193169 | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 427 | record_status tests/scripts/test-ref-configs.pl |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 428 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 429 | msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min |
| 430 | make |
| 431 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 432 | msg "test: compat.sh (ASan build)" # ~ 6 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 433 | if_build_succeeded tests/compat.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 434 | |
Hanno Becker | 797c084 | 2017-10-19 15:49:21 +0100 | [diff] [blame] | 435 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
| 436 | cleanup |
| 437 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 438 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 439 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 440 | make |
| 441 | |
| 442 | msg "test: ssl-opt.sh, MFL-related tests" |
| 443 | tests/ssl-opt.sh -f "Max fragment length" |
| 444 | |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 445 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
| 446 | cleanup |
| 447 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 448 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 449 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 450 | make |
| 451 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 452 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 453 | make test |
| 454 | programs/test/selftest |
| 455 | |
| 456 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 457 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 458 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 459 | |
| 460 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 461 | if_build_succeeded tests/ssl-opt.sh |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 462 | |
Hanno Becker | 4f9973e | 2017-10-24 11:56:28 +0100 | [diff] [blame] | 463 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
| 464 | cleanup |
| 465 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 466 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 467 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 468 | make |
| 469 | |
| 470 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 471 | make test |
| 472 | |
| 473 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 474 | if_build_succeeded tests/ssl-opt.sh |
Hanno Becker | 4f9973e | 2017-10-24 11:56:28 +0100 | [diff] [blame] | 475 | |
Hanno Becker | 9293592 | 2017-11-06 15:07:09 +0000 | [diff] [blame] | 476 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
| 477 | cleanup |
| 478 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 479 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 480 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 481 | make |
| 482 | |
| 483 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 484 | make test |
| 485 | |
| 486 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 487 | tests/ssl-opt.sh -f RSA |
| 488 | |
| 489 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 490 | tests/compat.sh -t RSA |
| 491 | |
| 492 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 493 | msg "build: cmake, full config, clang" # ~ 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 494 | cleanup |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 495 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 496 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 497 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
Manuel Pégourié-Gonnard | ac92a48 | 2017-06-20 10:49:24 +0200 | [diff] [blame] | 498 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 499 | make |
| 500 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 501 | msg "test: main suites (full config)" # ~ 5s |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 502 | make test |
| 503 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 504 | msg "test: ssl-opt.sh default (full config)" # ~ 1s |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 505 | if_build_succeeded tests/ssl-opt.sh -f Default |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 506 | |
Manuel Pégourié-Gonnard | ea0920f | 2015-03-24 09:50:15 +0100 | [diff] [blame] | 507 | msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 508 | 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] | 509 | |
Gilles Peskine | 31ed29d | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 510 | msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s |
| 511 | cleanup |
| 512 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 513 | scripts/config.pl full |
Gilles Peskine | 29af5f3 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 514 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 31ed29d | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 515 | # Build with -O -Wextra to catch a maximum of issues. |
| 516 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 517 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
| 518 | |
| 519 | msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s |
| 520 | # No cleanup, just tweak the configuration and rebuild |
| 521 | make clean |
| 522 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 29af5f3 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 523 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
Gilles Peskine | 31ed29d | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 524 | # Build with -O -Wextra to catch a maximum of issues. |
| 525 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 526 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
Gilles Peskine | 29af5f3 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 527 | |
Manuel Pégourié-Gonnard | 134ca18 | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 528 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 529 | cleanup |
Gilles Peskine | a193169 | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 530 | record_status tests/scripts/curves.pl |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 531 | |
Manuel Pégourié-Gonnard | 57176e5 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 532 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
| 533 | cleanup |
Gilles Peskine | a193169 | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 534 | record_status tests/scripts/depends-hashes.pl |
Manuel Pégourié-Gonnard | 57176e5 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 535 | |
Manuel Pégourié-Gonnard | f2fd546 | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 536 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
| 537 | cleanup |
Gilles Peskine | a193169 | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 538 | record_status tests/scripts/depends-pkalgs.pl |
Manuel Pégourié-Gonnard | f2fd546 | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 539 | |
Manuel Pégourié-Gonnard | 134ca18 | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 540 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
| 541 | cleanup |
Gilles Peskine | a193169 | 2018-03-22 22:26:03 +0100 | [diff] [blame] | 542 | record_status tests/scripts/key-exchanges.pl |
Manuel Pégourié-Gonnard | 134ca18 | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 543 | |
Manuel Pégourié-Gonnard | 61fe8b0 | 2015-03-13 14:33:16 +0000 | [diff] [blame] | 544 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 545 | cleanup |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 546 | make CC=gcc CFLAGS='-Werror -Os' |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 547 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 548 | # this is meant to cath missing #define mbedtls_printf etc |
Manuel Pégourié-Gonnard | 981732b | 2015-02-17 15:46:45 +0000 | [diff] [blame] | 549 | # disable fsio to catch some more missing #include <stdio.h> |
Manuel Pégourié-Gonnard | 757ca00 | 2015-03-23 15:24:07 +0100 | [diff] [blame] | 550 | msg "build: full config except platform/fsio, make, gcc" # ~ 30s |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 551 | cleanup |
| 552 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 553 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 554 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 555 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
Manuel Pégourié-Gonnard | 3d4755b | 2015-06-03 14:03:17 +0100 | [diff] [blame] | 556 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 557 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 558 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 559 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 560 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 561 | scripts/config.pl unset MBEDTLS_FS_IO |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 562 | make CC=gcc CFLAGS='-Werror -O0' |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 563 | |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 564 | # catch compile bugs in _uninit functions |
| 565 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
| 566 | cleanup |
| 567 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 568 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 7ee5ddd | 2015-06-03 10:33:55 +0100 | [diff] [blame] | 569 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 570 | make CC=gcc CFLAGS='-Werror -O0' |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 571 | |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 572 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
| 573 | cleanup |
| 574 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 575 | scripts/config.pl full |
| 576 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 577 | make CC=gcc CFLAGS='-Werror -O0' |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 578 | |
| 579 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
| 580 | cleanup |
| 581 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 582 | scripts/config.pl full |
| 583 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 584 | make CC=gcc CFLAGS='-Werror -O0' |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 585 | |
Manuel Pégourié-Gonnard | f78e4de | 2015-05-29 10:52:14 +0200 | [diff] [blame] | 586 | msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 587 | cleanup |
| 588 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 589 | scripts/config.pl full |
Manuel Pégourié-Gonnard | f78e4de | 2015-05-29 10:52:14 +0200 | [diff] [blame] | 590 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 591 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 592 | make CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' lib |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 593 | |
Hanno Becker | 864e998 | 2018-10-11 11:15:14 +0100 | [diff] [blame^] | 594 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 595 | cleanup |
| 596 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 597 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 598 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 599 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 600 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 601 | make |
| 602 | |
| 603 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 604 | make test |
| 605 | |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 606 | if uname -a | grep -F Linux >/dev/null; then |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 607 | msg "build/test: make shared" # ~ 40s |
| 608 | cleanup |
| 609 | make SHARED=1 all check |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 610 | fi |
| 611 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 612 | if uname -a | grep -F x86_64 >/dev/null; then |
Simon Butcher | 698cb34 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 613 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 614 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 615 | cleanup |
Simon Butcher | f218c0c | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 616 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 617 | scripts/config.pl full |
Simon Butcher | 698cb34 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 618 | make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' |
Andres Amaya Garcia | 401441b | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 619 | |
Simon Butcher | 698cb34 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 620 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 621 | make test |
| 622 | |
| 623 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 624 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
| 625 | cleanup |
| 626 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 627 | scripts/config.pl full |
| 628 | make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' |
| 629 | |
| 630 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | 401441b | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 631 | make test |
| 632 | |
| 633 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
| 634 | cleanup |
Simon Butcher | f218c0c | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 635 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 636 | scripts/config.pl full |
Andres Amaya Garcia | 401441b | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 637 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' |
| 638 | |
| 639 | msg "test: 64-bit ILP32, make, gcc" |
| 640 | make test |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 641 | fi # x86_64 |
| 642 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 643 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
| 644 | cleanup |
| 645 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 646 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 647 | scripts/config.pl unset MBEDTLS_NET_C |
| 648 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 649 | scripts/config.pl unset MBEDTLS_FS_IO |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 650 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 651 | # following things are not in the default config |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 652 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 653 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 654 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 655 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 656 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 657 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror lib |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 658 | |
Gilles Peskine | b9344e3 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 659 | if [ $RUN_ARMCC -ne 0 ]; then |
| 660 | msg "build: armcc, make" |
| 661 | cleanup |
| 662 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 663 | scripts/config.pl full |
| 664 | scripts/config.pl unset MBEDTLS_NET_C |
| 665 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 666 | scripts/config.pl unset MBEDTLS_FS_IO |
| 667 | scripts/config.pl unset MBEDTLS_HAVE_TIME |
| 668 | scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE |
| 669 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
| 670 | # following things are not in the default config |
| 671 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 672 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 673 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 674 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 675 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 676 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Gilles Peskine | 37c88db | 2018-03-21 11:44:52 +0100 | [diff] [blame] | 677 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= lib |
Gilles Peskine | b9344e3 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 678 | fi |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 679 | |
Gilles Peskine | b49351d | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 680 | msg "build: allow SHA1 in certificates by default" |
| 681 | cleanup |
| 682 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 683 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 684 | make CFLAGS='-Werror -Wall -Wextra' |
Gilles Peskine | b49351d | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 685 | msg "test: allow SHA1 in certificates by default" |
| 686 | make test |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 687 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
Gilles Peskine | b49351d | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 688 | |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 689 | if which i686-w64-mingw32-gcc >/dev/null; then |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 690 | msg "build: cross-mingw64, make" # ~ 30s |
| 691 | cleanup |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 692 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 |
| 693 | make WINDOWS_BUILD=1 clean |
| 694 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 |
| 695 | make WINDOWS_BUILD=1 clean |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 696 | fi |
| 697 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 698 | # MemSan currently only available on Linux 64 bits |
| 699 | if uname -a | grep 'Linux.*x86_64' >/dev/null; then |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 700 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 701 | msg "build: MSan (clang)" # ~ 1 min 20s |
| 702 | cleanup |
| 703 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 704 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 705 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 706 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 707 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 708 | msg "test: main suites (MSan)" # ~ 10s |
| 709 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 710 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 711 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 712 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 713 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 714 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 715 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 716 | if [ "$MEMORY" -gt 0 ]; then |
| 717 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 718 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 719 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 720 | |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 721 | else # no MemSan |
| 722 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 723 | msg "build: Release (clang)" |
| 724 | cleanup |
| 725 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 726 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 727 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 728 | msg "test: main suites valgrind (Release)" |
| 729 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 730 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 731 | # Optional part(s) |
| 732 | # Currently broken, programs don't seem to receive signals |
| 733 | # under valgrind on OS X |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 734 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 735 | if [ "$MEMORY" -gt 0 ]; then |
| 736 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 737 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 738 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 739 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 740 | if [ "$MEMORY" -gt 1 ]; then |
| 741 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 742 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 743 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 744 | |
| 745 | fi # MemSan |
| 746 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 747 | msg "build: cmake 'out-of-source' build" |
| 748 | cleanup |
| 749 | MBEDTLS_ROOT_DIR="$PWD" |
| 750 | mkdir "$OUT_OF_SOURCE_DIR" |
| 751 | cd "$OUT_OF_SOURCE_DIR" |
| 752 | cmake "$MBEDTLS_ROOT_DIR" |
| 753 | make |
| 754 | |
| 755 | msg "test: cmake 'out-of-source' build" |
| 756 | make test |
Gilles Peskine | aebcfbb | 2018-03-21 12:17:20 +0100 | [diff] [blame] | 757 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 758 | # Also ensure that there are no error messages such as |
| 759 | # "No such file or directory", which would indicate that some required |
| 760 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 761 | # may exit with status 0 but emit errors). |
| 762 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 763 | if [ -s ssl-opt.err ]; then |
| 764 | cat ssl-opt.err >&2 |
| 765 | record_status [ ! -s ssl-opt.err ] |
| 766 | rm ssl-opt.err |
| 767 | fi |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 768 | cd "$MBEDTLS_ROOT_DIR" |
| 769 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 00de2fd | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 770 | unset MBEDTLS_ROOT_DIR |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 771 | |
Gilles Peskine | d7602c2 | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 772 | |
| 773 | |
| 774 | ################################################################ |
| 775 | #### Termination |
| 776 | ################################################################ |
| 777 | |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 778 | msg "Done, cleaning up" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 779 | cleanup |
Gilles Peskine | a8bf986 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 780 | |
| 781 | final_report |