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