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