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