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