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