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