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