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 | |
Antonin Décimo | 8fd9156 | 2019-01-23 15:24:37 +0100 | [diff] [blame] | 124 | # Default commands, can be overridden by the environment |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 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 | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 157 | # Test whether the component $1 is included in the command line patterns. |
| 158 | is_component_included() |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 159 | { |
| 160 | set -f |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 161 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 162 | set +f |
| 163 | case ${1#component_} in $pattern) return 0;; esac |
| 164 | done |
| 165 | set +f |
| 166 | return 1 |
| 167 | } |
| 168 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 169 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 170 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 171 | cat <<EOF |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 172 | Usage: $0 [OPTION]... [COMPONENT]... |
| 173 | Run mbedtls release validation tests. |
| 174 | By default, run all tests. With one or more COMPONENT, run only those. |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 175 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 176 | |
| 177 | Examples: |
| 178 | $0 "check_*" |
| 179 | Run all sanity checks. |
| 180 | $0 --no-armcc --except test_memsan |
| 181 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 182 | |
| 183 | Special options: |
| 184 | -h|--help Print this help and exit. |
Gilles Peskine | b3241cb | 2019-01-08 23:44:07 +0100 | [diff] [blame] | 185 | --list-all-components List all available test components and exit. |
| 186 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 187 | |
| 188 | General options: |
| 189 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 190 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 191 | -m|--memory Additional optional memory tests. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 192 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 193 | --except Exclude the COMPONENTs listed on the command line, |
| 194 | instead of running only those. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 195 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 196 | --no-force Refuse to overwrite modified files (default). |
| 197 | --no-keep-going Stop at the first error (default). |
| 198 | --no-memory No additional memory tests (default). |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 199 | --no-yotta Skip yotta module build. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 200 | --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] | 201 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 202 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 203 | -s|--seed Integer seed value to use for this test run. |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 204 | --yotta Build yotta module (on by default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 205 | |
| 206 | Tool path options: |
| 207 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 208 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 209 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 210 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 211 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 212 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 213 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 214 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3. |
| 215 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 216 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 217 | |
| 218 | # remove built files as well as the cmake cache/config |
| 219 | cleanup() |
| 220 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 221 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 222 | cd "$MBEDTLS_ROOT_DIR" |
| 223 | fi |
| 224 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 225 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 226 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 227 | # Remove CMake artefacts |
| 228 | find . -name .git -prune -o -name yotta -prune -o \ |
| 229 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 230 | \( -iname cmake_install.cmake -o \ |
| 231 | -iname CTestTestfile.cmake -o \ |
| 232 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 233 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 234 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 235 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 236 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 237 | |
| 238 | if [ -f "$CONFIG_BAK" ]; then |
| 239 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 240 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 241 | } |
| 242 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 243 | # Executed on exit. May be redefined depending on command line options. |
| 244 | final_report () { |
| 245 | : |
| 246 | } |
| 247 | |
| 248 | fatal_signal () { |
| 249 | cleanup |
| 250 | final_report $1 |
| 251 | trap - $1 |
| 252 | kill -$1 $$ |
| 253 | } |
| 254 | |
| 255 | trap 'fatal_signal HUP' HUP |
| 256 | trap 'fatal_signal INT' INT |
| 257 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 258 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 259 | msg() |
| 260 | { |
Gilles Peskine | 11ddca6 | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 261 | if [ -n "${current_component:-}" ]; then |
| 262 | current_section="${current_component#component_}: $1" |
| 263 | else |
| 264 | current_section="$1" |
| 265 | fi |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 266 | echo "" |
| 267 | echo "******************************************************************" |
Gilles Peskine | 11ddca6 | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 268 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 269 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 270 | echo "******************************************************************" |
| 271 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 272 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 273 | armc6_build_test() |
| 274 | { |
| 275 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 276 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 277 | msg "build: ARM Compiler 6 ($FLAGS), make" |
| 278 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 279 | WARNING_CFLAGS='-xc -std=c99' make lib |
| 280 | make clean |
| 281 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 282 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 283 | err_msg() |
| 284 | { |
| 285 | echo "$1" >&2 |
| 286 | } |
| 287 | |
| 288 | check_tools() |
| 289 | { |
| 290 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 291 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 292 | err_msg "$TOOL not found!" |
| 293 | exit 1 |
| 294 | fi |
| 295 | done |
| 296 | } |
| 297 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 298 | pre_parse_command_line () { |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 299 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 300 | all_except=0 |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 301 | no_armcc= |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 302 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 303 | while [ $# -gt 0 ]; do |
| 304 | case "$1" in |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 305 | --armcc) no_armcc=;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 306 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 307 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 308 | --except) all_except=1;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 309 | --force|-f) FORCE=1;; |
| 310 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 311 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 312 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 313 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 314 | --help|-h) usage; exit;; |
| 315 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | b3241cb | 2019-01-08 23:44:07 +0100 | [diff] [blame] | 316 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 317 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 318 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 319 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 320 | --no-force) FORCE=0;; |
| 321 | --no-keep-going) KEEP_GOING=0;; |
| 322 | --no-memory) MEMORY=0;; |
| 323 | --no-yotta) YOTTA=0;; |
| 324 | --openssl) shift; OPENSSL="$1";; |
| 325 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 326 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
| 327 | --random-seed) unset SEED;; |
| 328 | --release-test|-r) SEED=1;; |
| 329 | --seed|-s) shift; SEED="$1";; |
| 330 | --yotta) YOTTA=1;; |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 331 | -*) |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 332 | echo >&2 "Unknown option: $1" |
| 333 | echo >&2 "Run $0 --help for usage." |
| 334 | exit 120 |
| 335 | ;; |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 336 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 337 | esac |
| 338 | shift |
| 339 | done |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 340 | |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 341 | # With no list of components, run everything. |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 342 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 343 | all_except=1 |
| 344 | fi |
| 345 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 346 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 347 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 348 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 349 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
| 350 | # --no-armcc also disables yotta. |
| 351 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_yotta*" |
| 352 | fi |
| 353 | |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 354 | # Build the list of components to run. |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 355 | RUN_COMPONENTS= |
| 356 | for component in $SUPPORTED_COMPONENTS; do |
| 357 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 358 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 359 | fi |
| 360 | done |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 361 | |
| 362 | unset all_except |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 363 | unset no_armcc |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 364 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 365 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 366 | pre_check_git () { |
| 367 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | c780095 | 2019-01-09 23:14:09 +0100 | [diff] [blame] | 368 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 369 | if [ $YOTTA -eq 1 ]; then |
Gilles Peskine | c780095 | 2019-01-09 23:14:09 +0100 | [diff] [blame] | 370 | rm -rf yotta/module |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 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 | |
Gilles Peskine | c9663b1 | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 390 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 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 | 30bc385 | 2019-01-09 23:25:25 +0100 | [diff] [blame] | 461 | # to be used instead of ! for commands run with |
| 462 | # record_status or if_build_succeeded |
| 463 | not() { |
| 464 | ! "$@" |
| 465 | } |
| 466 | |
| 467 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 468 | pre_print_configuration () { |
| 469 | msg "info: $0 configuration" |
| 470 | echo "MEMORY: $MEMORY" |
| 471 | echo "FORCE: $FORCE" |
| 472 | echo "SEED: ${SEED-"UNSET"}" |
| 473 | echo "OPENSSL: $OPENSSL" |
| 474 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 475 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 476 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 477 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 478 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 479 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 480 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 481 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 482 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 483 | # Make sure the tools we need are available. |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 484 | pre_check_tools () { |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 485 | # Build the list of variables to pass to output_env.sh. |
| 486 | set env |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 487 | |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 488 | case " $RUN_COMPONENTS " in |
| 489 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 490 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 491 | # is a good enough approximation in practice. |
| 492 | *" test_"*) |
| 493 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 494 | # and ssl-opt.sh, we just export the variables they require. |
| 495 | export OPENSSL_CMD="$OPENSSL" |
| 496 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 497 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 498 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 499 | if [ -n "${SEED-}" ]; then |
| 500 | export SEED |
| 501 | fi |
| 502 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 503 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 504 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 505 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
| 506 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" \ |
| 507 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 508 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 509 | ;; |
| 510 | esac |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 511 | |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 512 | case " $RUN_COMPONENTS " in |
| 513 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 514 | esac |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 515 | |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 516 | case " $RUN_COMPONENTS " in |
| 517 | *_arm_none_eabi_gcc[_\ ]*) check_tools "arm-none-eabi-gcc";; |
| 518 | esac |
| 519 | |
| 520 | case " $RUN_COMPONENTS " in |
| 521 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 522 | esac |
| 523 | |
| 524 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 525 | *_armcc*|*_yotta*) |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 526 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 527 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
| 528 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 529 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 530 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR";; |
| 531 | esac |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 532 | |
| 533 | msg "info: output_env.sh" |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 534 | case $RUN_COMPONENTS in |
| 535 | *_armcc*|*_yotta*) |
| 536 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 537 | *) set "$@" RUN_ARMCC=0;; |
| 538 | esac |
| 539 | "$@" scripts/output_env.sh |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 540 | } |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 541 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 542 | |
| 543 | |
| 544 | ################################################################ |
| 545 | #### Basic checks |
| 546 | ################################################################ |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 547 | |
| 548 | # |
| 549 | # Test Suites to be executed |
| 550 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 551 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 552 | # 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] | 553 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 554 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 555 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 556 | # |
| 557 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 558 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 559 | component_check_recursion () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 560 | msg "test: recursion.pl" # < 1s |
| 561 | record_status tests/scripts/recursion.pl library/*.c |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 562 | } |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 563 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 564 | component_check_generated_files () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 565 | msg "test: freshness of generated source files" # < 1s |
| 566 | record_status tests/scripts/check-generated-files.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 567 | } |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 568 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 569 | component_check_doxy_blocks () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 570 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 571 | record_status tests/scripts/check-doxy-blocks.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 572 | } |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 573 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 574 | component_check_files () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 575 | msg "test: check-files.py" # < 1s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 576 | record_status tests/scripts/check-files.py |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 577 | } |
Manuel Pégourié-Gonnard | 77d56bb | 2015-07-28 15:00:37 +0200 | [diff] [blame] | 578 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 579 | component_check_names () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 580 | msg "test/build: declared and exported names" # < 3s |
Gilles Peskine | e952fdf | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 581 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 582 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 583 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 584 | component_check_doxygen_warnings () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 585 | msg "test: doxygen warnings" # ~ 3s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 586 | record_status tests/scripts/doxygen.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 587 | } |
Andres Amaya Garcia | dd29c2f | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 588 | |
Simon Butcher | 948f264 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 589 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 590 | ################################################################ |
| 591 | #### Build and test many configurations and targets |
| 592 | ################################################################ |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 593 | |
k-stachowiak | 45d0ba1 | 2019-06-04 13:14:58 +0200 | [diff] [blame] | 594 | component_test_large_ecdsa_key_signature () { |
| 595 | |
| 596 | SMALL_MPI_MAX_SIZE=136 # Small enough to interfere with the EC signatures |
| 597 | |
| 598 | msg "build: cmake + MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE}, gcc, ASan" # ~ 1 min 50s |
| 599 | scripts/config.pl set MBEDTLS_MPI_MAX_SIZE $SMALL_MPI_MAX_SIZE |
| 600 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 601 | make |
| 602 | |
| 603 | INEVITABLY_PRESENT_FILE=Makefile |
| 604 | SIGNATURE_FILE="${INEVITABLY_PRESENT_FILE}.sig" # Warning, this is rm -f'ed below |
| 605 | |
| 606 | msg "test: pk_sign secp521r1_prv.der for MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE} (ASan build)" # ~ 5s |
| 607 | if_build_succeeded programs/pkey/pk_sign tests/data_files/secp521r1_prv.der $INEVITABLY_PRESENT_FILE |
| 608 | rm -f $SIGNATURE_FILE |
| 609 | } |
| 610 | |
Gilles Peskine | 1270d32 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 611 | component_test_default_out_of_box () { |
| 612 | msg "build: make, default config (out-of-box)" # ~1min |
| 613 | make |
| 614 | |
| 615 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 616 | make test |
| 617 | |
| 618 | msg "selftest: make, default config (out-of-box)" # ~10s |
| 619 | programs/test/selftest |
| 620 | } |
| 621 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 622 | component_build_yotta () { |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 623 | # Note - use of yotta is deprecated, and yotta also requires armcc to be on the |
| 624 | # path, and uses whatever version of armcc it finds there. |
| 625 | msg "build: create and build yotta module" # ~ 30s |
| 626 | record_status tests/scripts/yotta-build.sh |
| 627 | } |
| 628 | support_build_yotta () { |
| 629 | [ $YOTTA -ne 0 ] |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 630 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 631 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 632 | component_test_default_cmake_gcc_asan () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 633 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 634 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 635 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 636 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 637 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 638 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 639 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 640 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 641 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 642 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 643 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 644 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 645 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 646 | |
Hanno Becker | 167ae43 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 647 | component_test_full_cmake_gcc_asan () { |
| 648 | msg "build: full config, cmake, gcc, ASan" |
| 649 | scripts/config.pl full |
| 650 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 651 | make |
| 652 | |
| 653 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 654 | make test |
| 655 | |
| 656 | msg "test: ssl-opt.sh (full config, ASan build)" |
| 657 | if_build_succeeded tests/ssl-opt.sh |
| 658 | |
| 659 | msg "test: compat.sh (full config, ASan build)" |
| 660 | if_build_succeeded tests/compat.sh |
| 661 | } |
| 662 | |
Gilles Peskine | 3484ed8 | 2019-01-08 22:51:19 +0100 | [diff] [blame] | 663 | component_test_ref_configs () { |
| 664 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 665 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 666 | record_status tests/scripts/test-ref-configs.pl |
| 667 | } |
| 668 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 669 | component_test_sslv3 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 670 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 671 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 672 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 673 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 674 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 675 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 676 | make test |
| 677 | |
| 678 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
| 679 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 680 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
| 681 | |
| 682 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 683 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 684 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 685 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 686 | component_test_no_renegotiation () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 687 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 688 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 689 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 690 | make |
| 691 | |
| 692 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 693 | make test |
| 694 | |
| 695 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 696 | if_build_succeeded tests/ssl-opt.sh |
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_rsa_no_crt () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 700 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 701 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 702 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 703 | make |
| 704 | |
| 705 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 706 | make test |
| 707 | |
| 708 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 709 | if_build_succeeded tests/ssl-opt.sh -f RSA |
| 710 | |
| 711 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 712 | if_build_succeeded tests/compat.sh -t RSA |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 713 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 714 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 715 | component_test_full_cmake_clang () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 716 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 717 | scripts/config.pl full |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 718 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 719 | make |
| 720 | |
| 721 | msg "test: main suites (full config)" # ~ 5s |
| 722 | make test |
| 723 | |
| 724 | msg "test: ssl-opt.sh default (full config)" # ~ 1s |
| 725 | if_build_succeeded tests/ssl-opt.sh -f Default |
| 726 | |
Andres Amaya Garcia | 0a0e5b1 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 727 | msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min |
Andres Amaya Garcia | fea3d0a | 2019-02-19 20:20:57 +0000 | [diff] [blame] | 728 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 729 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 730 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 731 | component_build_deprecated () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 732 | msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 733 | scripts/config.pl full |
| 734 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
| 735 | # Build with -O -Wextra to catch a maximum of issues. |
| 736 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 737 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
| 738 | |
| 739 | msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s |
| 740 | # No cleanup, just tweak the configuration and rebuild |
| 741 | make clean |
| 742 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 743 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
| 744 | # Build with -O -Wextra to catch a maximum of issues. |
| 745 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 746 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 747 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 748 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 749 | component_test_depends_curves () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 750 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 751 | record_status tests/scripts/curves.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 752 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 753 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 754 | component_test_depends_hashes () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 755 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 756 | record_status tests/scripts/depends-hashes.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 757 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 758 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 759 | component_test_depends_pkalgs () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 760 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 761 | record_status tests/scripts/depends-pkalgs.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 762 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 763 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 764 | component_build_key_exchanges () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 765 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 766 | record_status tests/scripts/key-exchanges.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 767 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 768 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 769 | component_build_default_make_gcc () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 770 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 771 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 772 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 773 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 774 | component_test_no_platform () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 775 | # Full configuration build, without platform support, file IO and net sockets. |
| 776 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 777 | # IO, it should catch missing '#include <stdio.h>' |
| 778 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 779 | scripts/config.pl full |
| 780 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 781 | scripts/config.pl unset MBEDTLS_NET_C |
| 782 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 783 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 784 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 785 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 786 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 787 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 788 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 789 | scripts/config.pl unset MBEDTLS_FS_IO |
| 790 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 791 | # to re-enable platform integration features otherwise disabled in C99 builds |
| 792 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs |
| 793 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 794 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 795 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 796 | component_build_no_std_function () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 797 | # catch compile bugs in _uninit functions |
| 798 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 799 | scripts/config.pl full |
| 800 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 801 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 802 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
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_build_no_ssl_srv () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 806 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 807 | scripts/config.pl full |
| 808 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
| 809 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 810 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 811 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 812 | component_build_no_ssl_cli () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 813 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 814 | scripts/config.pl full |
| 815 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
| 816 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 817 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 818 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 819 | component_build_no_sockets () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 820 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 821 | # as that requires a POSIX platform (which isn't the same as C99). |
| 822 | 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] | 823 | scripts/config.pl full |
| 824 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 825 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
| 826 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 827 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 828 | |
Andrzej Kurek | 9a461a1 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 829 | component_test_memory_buffer_allocator_backtrace () { |
| 830 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 831 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Andrzej Kurek | 9a461a1 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 832 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 833 | scripts/config.pl set MBEDTLS_MEMORY_BACKTRACE |
Andrzej Kurek | 9a461a1 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 834 | CC=gcc cmake . |
| 835 | make |
| 836 | |
| 837 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 838 | make test |
| 839 | } |
| 840 | |
| 841 | component_test_memory_buffer_allocator () { |
| 842 | msg "build: default config with memory buffer allocator" |
| 843 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Hanno Becker | 7aad93c | 2019-06-03 16:35:02 +0100 | [diff] [blame] | 844 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 845 | CC=gcc cmake . |
| 846 | make |
| 847 | |
| 848 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 849 | make test |
| 850 | |
| 851 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
Andrzej Kurek | 6addfdd | 2019-09-05 10:09:37 -0400 | [diff] [blame^] | 852 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 853 | if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 854 | } |
| 855 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 856 | component_test_no_max_fragment_length () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 857 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 858 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 859 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 860 | make |
| 861 | |
| 862 | msg "test: ssl-opt.sh, MFL-related tests" |
| 863 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 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_null_entropy () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 867 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 868 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
| 869 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 870 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 871 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 872 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 873 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 4e7b323 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 874 | 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] | 875 | make |
| 876 | |
| 877 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 878 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 879 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 880 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 881 | component_test_platform_calloc_macro () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 882 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 883 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 884 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 885 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 886 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 887 | make |
| 888 | |
| 889 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 890 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 891 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 892 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 893 | component_test_make_shared () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 894 | msg "build/test: make shared" # ~ 40s |
| 895 | make SHARED=1 all check |
Gilles Peskine | 950de1e | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 896 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 897 | } |
| 898 | |
Gilles Peskine | 17ecb24 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 899 | component_test_cmake_shared () { |
| 900 | msg "build/test: cmake shared" # ~ 2min |
| 901 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 902 | make |
Gilles Peskine | 950de1e | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 903 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 17ecb24 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 904 | make test |
| 905 | } |
| 906 | |
Gilles Peskine | f852f5f | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 907 | component_build_mbedtls_config_file () { |
| 908 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 909 | # Use the full config so as to catch a maximum of places where |
| 910 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
| 911 | scripts/config.pl full |
| 912 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 913 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 914 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 915 | rm -f full_config.h |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 916 | } |
| 917 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 918 | component_test_m32_o0 () { |
| 919 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 920 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
| 921 | scripts/config.pl full |
Gilles Peskine | d535f4d | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 922 | make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32' |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 923 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 924 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 925 | make test |
| 926 | } |
| 927 | support_test_m32_o0 () { |
| 928 | case $(uname -m) in |
| 929 | *64*) true;; |
| 930 | *) false;; |
| 931 | esac |
| 932 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 933 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 934 | component_test_m32_o1 () { |
| 935 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 936 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
| 937 | scripts/config.pl full |
Andrzej Kurek | c7f97f1 | 2019-09-09 07:10:39 -0400 | [diff] [blame] | 938 | make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address' |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 939 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 940 | msg "test: i386, make, gcc -O1 (ASan build)" |
| 941 | make test |
Gilles Peskine | 1106429 | 2019-04-08 16:58:02 +0200 | [diff] [blame] | 942 | |
| 943 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 944 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 945 | } |
| 946 | support_test_m32_o1 () { |
| 947 | support_test_m32_o0 "$@" |
| 948 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 949 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 950 | component_test_mx32 () { |
| 951 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
| 952 | scripts/config.pl full |
Gilles Peskine | d535f4d | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 953 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 954 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 955 | msg "test: 64-bit ILP32, make, gcc" |
| 956 | make test |
| 957 | } |
| 958 | support_test_mx32 () { |
| 959 | case $(uname -m) in |
| 960 | amd64|x86_64) true;; |
| 961 | *) false;; |
| 962 | esac |
| 963 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 964 | |
Peter Kolbus | 16015dd | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 965 | component_test_min_mpi_window_size () { |
| 966 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
| 967 | scripts/config.pl set MBEDTLS_MPI_WINDOW_SIZE 1 |
| 968 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 969 | make |
| 970 | |
| 971 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 972 | make test |
| 973 | } |
| 974 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 975 | component_test_have_int32 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 976 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 977 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 978 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 979 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 980 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
| 981 | |
| 982 | msg "test: gcc, force 32-bit bignum limbs" |
| 983 | make test |
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_have_int64 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 987 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 988 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 989 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 990 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 991 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
| 992 | |
| 993 | msg "test: gcc, force 64-bit bignum limbs" |
| 994 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 995 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 996 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 997 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 998 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
Manuel Pégourié-Gonnard | 59bc9a1 | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 999 | scripts/config.pl baremetal |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1000 | 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] | 1001 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1002 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1003 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1004 | msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Manuel Pégourié-Gonnard | 59bc9a1 | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1005 | scripts/config.pl baremetal |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1006 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
| 1007 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 1008 | echo "Checking that software 64-bit division is not required" |
Gilles Peskine | 30bc385 | 2019-01-09 23:25:25 +0100 | [diff] [blame] | 1009 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1010 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1011 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1012 | component_build_armcc () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1013 | msg "build: ARM Compiler 5, make" |
Manuel Pégourié-Gonnard | 59bc9a1 | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1014 | scripts/config.pl baremetal |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1015 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1016 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 1017 | make clean |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1018 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1019 | # ARM Compiler 6 - Target ARMv7-A |
| 1020 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1021 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1022 | # ARM Compiler 6 - Target ARMv7-M |
| 1023 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1024 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1025 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1026 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1027 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1028 | # ARM Compiler 6 - Target ARMv8-M |
| 1029 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1030 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1031 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1032 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1033 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1034 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1035 | component_test_allow_sha1 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1036 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1037 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
| 1038 | make CFLAGS='-Werror -Wall -Wextra' |
| 1039 | msg "test: allow SHA1 in certificates by default" |
| 1040 | make test |
| 1041 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1042 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1043 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1044 | component_build_mingw () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1045 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1046 | 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 |
| 1047 | |
| 1048 | # note Make tests only builds the tests, but doesn't run them |
| 1049 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
| 1050 | make WINDOWS_BUILD=1 clean |
| 1051 | |
| 1052 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
| 1053 | 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 |
| 1054 | 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 |
| 1055 | make WINDOWS_BUILD=1 clean |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1056 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1057 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1058 | component_test_memsan () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1059 | msg "build: MSan (clang)" # ~ 1 min 20s |
| 1060 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1061 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1062 | make |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1063 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1064 | msg "test: main suites (MSan)" # ~ 10s |
| 1065 | make test |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1066 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1067 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
| 1068 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1069 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1070 | # Optional part(s) |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1071 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1072 | if [ "$MEMORY" -gt 0 ]; then |
| 1073 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
| 1074 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1075 | fi |
| 1076 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1077 | |
Gilles Peskine | 9f55364 | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1078 | component_test_valgrind () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1079 | msg "build: Release (clang)" |
| 1080 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1081 | make |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1082 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1083 | msg "test: main suites valgrind (Release)" |
| 1084 | make memcheck |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1085 | |
Gilles Peskine | 26cae71 | 2019-04-08 17:00:56 +0200 | [diff] [blame] | 1086 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1087 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1088 | if [ "$MEMORY" -gt 0 ]; then |
| 1089 | msg "test: ssl-opt.sh --memcheck (Release)" |
| 1090 | if_build_succeeded tests/ssl-opt.sh --memcheck |
| 1091 | fi |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1092 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1093 | if [ "$MEMORY" -gt 1 ]; then |
| 1094 | msg "test: compat.sh --memcheck (Release)" |
| 1095 | if_build_succeeded tests/compat.sh --memcheck |
| 1096 | fi |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1097 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1098 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1099 | component_test_cmake_out_of_source () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1100 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1101 | MBEDTLS_ROOT_DIR="$PWD" |
| 1102 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1103 | cd "$OUT_OF_SOURCE_DIR" |
| 1104 | cmake "$MBEDTLS_ROOT_DIR" |
| 1105 | make |
| 1106 | |
| 1107 | msg "test: cmake 'out-of-source' build" |
| 1108 | make test |
| 1109 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 1110 | # Also ensure that there are no error messages such as |
| 1111 | # "No such file or directory", which would indicate that some required |
| 1112 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 1113 | # may exit with status 0 but emit errors). |
| 1114 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 1115 | if [ -s ssl-opt.err ]; then |
| 1116 | cat ssl-opt.err >&2 |
| 1117 | record_status [ ! -s ssl-opt.err ] |
| 1118 | rm ssl-opt.err |
| 1119 | fi |
| 1120 | cd "$MBEDTLS_ROOT_DIR" |
| 1121 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1122 | unset MBEDTLS_ROOT_DIR |
| 1123 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1124 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1125 | |
| 1126 | |
| 1127 | ################################################################ |
| 1128 | #### Termination |
| 1129 | ################################################################ |
| 1130 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1131 | post_report () { |
| 1132 | msg "Done, cleaning up" |
| 1133 | cleanup |
| 1134 | |
| 1135 | final_report |
| 1136 | } |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | ################################################################ |
| 1141 | #### Run all the things |
| 1142 | ################################################################ |
| 1143 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1144 | # Run one component and clean up afterwards. |
| 1145 | run_component () { |
Gilles Peskine | 72adb43 | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1146 | # Back up the configuration in case the component modifies it. |
| 1147 | # The cleanup function will restore it. |
| 1148 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | 11ddca6 | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1149 | current_component="$1" |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1150 | "$@" |
| 1151 | cleanup |
| 1152 | } |
| 1153 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1154 | # Preliminary setup |
| 1155 | pre_check_environment |
| 1156 | pre_initialize_variables |
| 1157 | pre_parse_command_line "$@" |
| 1158 | |
| 1159 | pre_check_git |
| 1160 | build_status=0 |
| 1161 | if [ $KEEP_GOING -eq 1 ]; then |
| 1162 | pre_setup_keep_going |
| 1163 | else |
| 1164 | record_status () { |
| 1165 | "$@" |
| 1166 | } |
| 1167 | fi |
| 1168 | pre_print_configuration |
| 1169 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1170 | cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1171 | |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 1172 | # Run the requested tests. |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 1173 | for component in $RUN_COMPONENTS; do |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1174 | run_component "component_$component" |
| 1175 | done |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1176 | |
| 1177 | # We're done. |
| 1178 | post_report |