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