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) |
Andrzej Kurek | 05be06c | 2018-06-28 04:41:50 -0400 | [diff] [blame] | 38 | # * G++ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 39 | # * arm-gcc and mingw-gcc |
| 40 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 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 | 8f07312 | 2018-11-27 15:58:47 +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. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 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. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 65 | # * support_XXX: if support_XXX exists and returns false then |
| 66 | # component_XXX is not run by default. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 67 | # * post_XXX: things to do after running the tests. |
| 68 | # * other: miscellaneous support functions. |
| 69 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 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 | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 108 | pre_check_environment () { |
Gilles Peskine | a16c2b1 | 2019-01-06 19:58:02 +0000 | [diff] [blame] | 109 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +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 | 8f07312 | 2018-11-27 15:58:47 +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 | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 119 | MEMORY=0 |
| 120 | FORCE=0 |
| 121 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 122 | |
Antonin Décimo | d5f4759 | 2019-01-23 15:24:37 +0100 | [diff] [blame] | 123 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 124 | : ${OPENSSL:="openssl"} |
| 125 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 126 | : ${OPENSSL_NEXT:="$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} |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 134 | : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 135 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 136 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
Gilles Peskine | a1fc4b5 | 2019-01-06 20:15:26 +0000 | [diff] [blame] | 137 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 138 | export MAKEFLAGS="-j" |
| 139 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 140 | |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 141 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Gilles Peskine | ac47906 | 2019-10-21 19:06:33 +0200 | [diff] [blame] | 142 | ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 143 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 144 | # Gather the list of available components. These are the functions |
| 145 | # defined in this script whose name starts with "component_". |
| 146 | # Parse the script with sed, because in sh there is no way to list |
| 147 | # defined functions. |
| 148 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 149 | |
| 150 | # Exclude components that are not supported on this platform. |
| 151 | SUPPORTED_COMPONENTS= |
| 152 | for component in $ALL_COMPONENTS; do |
| 153 | case $(type "support_$component" 2>&1) in |
| 154 | *' function'*) |
| 155 | if ! support_$component; then continue; fi;; |
| 156 | esac |
| 157 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 158 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 159 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 160 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 161 | # Test whether the component $1 is included in the command line patterns. |
| 162 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 163 | { |
| 164 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 165 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 166 | set +f |
| 167 | case ${1#component_} in $pattern) return 0;; esac |
| 168 | done |
| 169 | set +f |
| 170 | return 1 |
| 171 | } |
| 172 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 173 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 174 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 175 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 176 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 177 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 178 | By default, run all tests. With one or more COMPONENT, run only those. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 179 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 180 | |
| 181 | Examples: |
| 182 | $0 "check_*" |
| 183 | Run all sanity checks. |
| 184 | $0 --no-armcc --except test_memsan |
| 185 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 186 | |
| 187 | Special options: |
| 188 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 189 | --list-all-components List all available test components and exit. |
| 190 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 191 | |
| 192 | General options: |
| 193 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 194 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 195 | -m|--memory Additional optional memory tests. |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 196 | --arm-none-eabi-gcc-prefix=<string> |
| 197 | Prefix for a cross-compiler for arm-none-eabi |
| 198 | (default: "${ARM_NONE_EABI_GCC_PREFIX}") |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 199 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 200 | --except Exclude the COMPONENTs listed on the command line, |
| 201 | instead of running only those. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 202 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 203 | --no-force Refuse to overwrite modified files (default). |
| 204 | --no-keep-going Stop at the first error (default). |
| 205 | --no-memory No additional memory tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 206 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 207 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 208 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 209 | -s|--seed Integer seed value to use for this test run. |
| 210 | |
| 211 | Tool path options: |
| 212 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 213 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 214 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 215 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 216 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 217 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 218 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 219 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3. |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 220 | --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 221 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 222 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 223 | |
| 224 | # remove built files as well as the cmake cache/config |
| 225 | cleanup() |
| 226 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 227 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 228 | cd "$MBEDTLS_ROOT_DIR" |
| 229 | fi |
| 230 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 231 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 232 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 233 | # Remove CMake artefacts |
Simon Butcher | 3ad2efd | 2018-05-02 14:49:38 +0100 | [diff] [blame] | 234 | find . -name .git -prune \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 235 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 236 | \( -iname cmake_install.cmake -o \ |
| 237 | -iname CTestTestfile.cmake -o \ |
| 238 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 239 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 240 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 241 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 242 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 243 | |
| 244 | if [ -f "$CONFIG_BAK" ]; then |
| 245 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 246 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 247 | } |
| 248 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 249 | # Executed on exit. May be redefined depending on command line options. |
| 250 | final_report () { |
| 251 | : |
| 252 | } |
| 253 | |
| 254 | fatal_signal () { |
| 255 | cleanup |
| 256 | final_report $1 |
| 257 | trap - $1 |
| 258 | kill -$1 $$ |
| 259 | } |
| 260 | |
| 261 | trap 'fatal_signal HUP' HUP |
| 262 | trap 'fatal_signal INT' INT |
| 263 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 264 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 265 | msg() |
| 266 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 267 | if [ -n "${current_component:-}" ]; then |
| 268 | current_section="${current_component#component_}: $1" |
| 269 | else |
| 270 | current_section="$1" |
| 271 | fi |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 272 | echo "" |
| 273 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 274 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 275 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 276 | echo "******************************************************************" |
| 277 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 278 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 279 | armc6_build_test() |
| 280 | { |
| 281 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 282 | |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 283 | msg "build: ARM Compiler 6 ($FLAGS)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 284 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 285 | WARNING_CFLAGS='-xc -std=c99' make lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 286 | |
| 287 | msg "size: ARM Compiler 6 ($FLAGS)" |
| 288 | "$ARMC6_FROMELF" -z library/*.o |
| 289 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 290 | make clean |
| 291 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 292 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 293 | err_msg() |
| 294 | { |
| 295 | echo "$1" >&2 |
| 296 | } |
| 297 | |
| 298 | check_tools() |
| 299 | { |
| 300 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 301 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 302 | err_msg "$TOOL not found!" |
| 303 | exit 1 |
| 304 | fi |
| 305 | done |
| 306 | } |
| 307 | |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 308 | check_headers_in_cpp () { |
Peter Kolbus | 3098707 | 2019-02-01 17:19:08 -0600 | [diff] [blame] | 309 | ls include/mbedtls | grep "\.h$" >headers.txt |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 310 | <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' | |
| 311 | sort | |
| 312 | diff headers.txt - |
| 313 | rm headers.txt |
| 314 | } |
| 315 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 316 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 317 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 318 | all_except=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 319 | no_armcc= |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 320 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 321 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 322 | case "$1" in |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 323 | --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 324 | --armcc) no_armcc=;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 325 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 326 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 327 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 328 | --force|-f) FORCE=1;; |
| 329 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 330 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 331 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 332 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 333 | --help|-h) usage; exit;; |
| 334 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 335 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 336 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 337 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 338 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 339 | --no-force) FORCE=0;; |
| 340 | --no-keep-going) KEEP_GOING=0;; |
| 341 | --no-memory) MEMORY=0;; |
| 342 | --openssl) shift; OPENSSL="$1";; |
| 343 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 344 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
| 345 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
| 346 | --random-seed) unset SEED;; |
| 347 | --release-test|-r) SEED=1;; |
| 348 | --seed|-s) shift; SEED="$1";; |
| 349 | -*) |
| 350 | echo >&2 "Unknown option: $1" |
| 351 | echo >&2 "Run $0 --help for usage." |
| 352 | exit 120 |
| 353 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 354 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 355 | esac |
| 356 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 357 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 358 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 359 | # With no list of components, run everything. |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 360 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 361 | all_except=1 |
| 362 | fi |
| 363 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 364 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 365 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 366 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 367 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
| 368 | fi |
| 369 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 370 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 371 | RUN_COMPONENTS= |
| 372 | for component in $SUPPORTED_COMPONENTS; do |
| 373 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 374 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 375 | fi |
| 376 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 377 | |
| 378 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 379 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 380 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 381 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 382 | pre_check_git () { |
| 383 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 384 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 385 | git checkout-index -f -q $CONFIG_H |
| 386 | cleanup |
| 387 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 388 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 389 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 390 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 391 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 392 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 393 | exit 1 |
| 394 | fi |
| 395 | |
Gilles Peskine | d1174cf | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 396 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 397 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 398 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 399 | echo "script as: $0 --force" |
| 400 | exit 1 |
| 401 | fi |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 402 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 403 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 404 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 405 | pre_setup_keep_going () { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 406 | failure_summary= |
| 407 | failure_count=0 |
| 408 | start_red= |
| 409 | end_color= |
| 410 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 411 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 412 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 413 | start_red=$(printf '\033[31m') |
| 414 | end_color=$(printf '\033[0m') |
| 415 | ;; |
| 416 | esac |
| 417 | fi |
| 418 | record_status () { |
| 419 | if "$@"; then |
| 420 | last_status=0 |
| 421 | else |
| 422 | last_status=$? |
| 423 | text="$current_section: $* -> $last_status" |
| 424 | failure_summary="$failure_summary |
| 425 | $text" |
| 426 | failure_count=$((failure_count + 1)) |
| 427 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 428 | fi |
| 429 | } |
| 430 | make () { |
| 431 | case "$*" in |
| 432 | *test|*check) |
| 433 | if [ $build_status -eq 0 ]; then |
| 434 | record_status command make "$@" |
| 435 | else |
| 436 | echo "(skipped because the build failed)" |
| 437 | fi |
| 438 | ;; |
| 439 | *) |
| 440 | record_status command make "$@" |
| 441 | build_status=$last_status |
| 442 | ;; |
| 443 | esac |
| 444 | } |
| 445 | final_report () { |
| 446 | if [ $failure_count -gt 0 ]; then |
| 447 | echo |
| 448 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 449 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 450 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 7c1258d | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 451 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 452 | elif [ -z "${1-}" ]; then |
| 453 | echo "SUCCESS :)" |
| 454 | fi |
| 455 | if [ -n "${1-}" ]; then |
| 456 | echo "Killed by SIG$1." |
| 457 | fi |
| 458 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 459 | } |
| 460 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 461 | if_build_succeeded () { |
| 462 | if [ $build_status -eq 0 ]; then |
| 463 | record_status "$@" |
| 464 | fi |
| 465 | } |
| 466 | |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 467 | # to be used instead of ! for commands run with |
| 468 | # record_status or if_build_succeeded |
| 469 | not() { |
| 470 | ! "$@" |
| 471 | } |
| 472 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 473 | pre_print_configuration () { |
| 474 | msg "info: $0 configuration" |
| 475 | echo "MEMORY: $MEMORY" |
| 476 | echo "FORCE: $FORCE" |
| 477 | echo "SEED: ${SEED-"UNSET"}" |
| 478 | echo "OPENSSL: $OPENSSL" |
| 479 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 480 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 481 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 482 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 483 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 484 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 485 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 486 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 487 | } |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 488 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 489 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 490 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 491 | # Build the list of variables to pass to output_env.sh. |
| 492 | set env |
| 493 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 494 | case " $RUN_COMPONENTS " in |
| 495 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 496 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 497 | # is a good enough approximation in practice. |
| 498 | *" test_"*) |
| 499 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 500 | # and ssl-opt.sh, we just export the variables they require. |
| 501 | export OPENSSL_CMD="$OPENSSL" |
| 502 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 503 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 504 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 505 | if [ -n "${SEED-}" ]; then |
| 506 | export SEED |
| 507 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 508 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 509 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 510 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 511 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 512 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 513 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 514 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 515 | ;; |
| 516 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 517 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 518 | case " $RUN_COMPONENTS " in |
| 519 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 520 | esac |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 521 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 522 | case " $RUN_COMPONENTS " in |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 523 | *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";; |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 524 | esac |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 525 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 526 | case " $RUN_COMPONENTS " in |
| 527 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 528 | esac |
| 529 | |
| 530 | case " $RUN_COMPONENTS " in |
| 531 | *" test_zeroize "*) check_tools "gdb";; |
| 532 | esac |
| 533 | |
| 534 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 535 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 536 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 537 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 538 | ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 539 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 540 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 541 | ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf" |
| 542 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \ |
| 543 | "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 544 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 545 | |
| 546 | msg "info: output_env.sh" |
| 547 | case $RUN_COMPONENTS in |
| 548 | *_armcc*) |
| 549 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 550 | *) set "$@" RUN_ARMCC=0;; |
| 551 | esac |
| 552 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 553 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 554 | |
| 555 | |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 556 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 557 | ################################################################ |
| 558 | #### Basic checks |
| 559 | ################################################################ |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 560 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 561 | # |
| 562 | # Test Suites to be executed |
| 563 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 564 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 565 | # 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] | 566 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 567 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 568 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 569 | # |
| 570 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 571 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 572 | component_check_recursion () { |
| 573 | msg "test: recursion.pl" # < 1s |
| 574 | record_status tests/scripts/recursion.pl library/*.c |
| 575 | } |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 576 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 577 | component_check_generated_files () { |
| 578 | msg "test: freshness of generated source files" # < 1s |
| 579 | record_status tests/scripts/check-generated-files.sh |
| 580 | } |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 581 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 582 | component_check_doxy_blocks () { |
| 583 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 584 | record_status tests/scripts/check-doxy-blocks.pl |
| 585 | } |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 586 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 587 | component_check_files () { |
| 588 | msg "test: check-files.py" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 589 | record_status tests/scripts/check-files.py |
| 590 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 591 | |
Gilles Peskine | 3c23c82 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 592 | component_check_changelog () { |
| 593 | msg "Check: changelog entries" # < 1s |
| 594 | rm -f ChangeLog.new |
| 595 | record_status scripts/assemble_changelog.py -o ChangeLog.new |
| 596 | if [ -e ChangeLog.new ]; then |
| 597 | # Show the diff for information. It isn't an error if the diff is |
| 598 | # non-empty. |
| 599 | diff -u ChangeLog ChangeLog.new || true |
| 600 | rm ChangeLog.new |
| 601 | fi |
| 602 | } |
| 603 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 604 | component_check_names () { |
| 605 | msg "test/build: declared and exported names" # < 3s |
Gilles Peskine | 473f2d4 | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 606 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 607 | } |
Manuel Pégourié-Gonnard | a687baf | 2015-04-09 11:09:03 +0200 | [diff] [blame] | 608 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 609 | component_check_doxygen_warnings () { |
| 610 | msg "test: doxygen warnings" # ~ 3s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 611 | record_status tests/scripts/doxygen.sh |
| 612 | } |
Manuel Pégourié-Gonnard | 1d552e7 | 2016-01-04 16:49:09 +0100 | [diff] [blame] | 613 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 614 | |
| 615 | |
| 616 | ################################################################ |
| 617 | #### Build and test many configurations and targets |
| 618 | ################################################################ |
| 619 | |
k-stachowiak | 11f38e2 | 2019-06-04 13:14:58 +0200 | [diff] [blame] | 620 | component_test_large_ecdsa_key_signature () { |
| 621 | |
| 622 | SMALL_MPI_MAX_SIZE=136 # Small enough to interfere with the EC signatures |
| 623 | |
| 624 | msg "build: cmake + MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE}, gcc, ASan" # ~ 1 min 50s |
| 625 | scripts/config.pl set MBEDTLS_MPI_MAX_SIZE $SMALL_MPI_MAX_SIZE |
| 626 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 627 | make |
| 628 | |
| 629 | INEVITABLY_PRESENT_FILE=Makefile |
| 630 | SIGNATURE_FILE="${INEVITABLY_PRESENT_FILE}.sig" # Warning, this is rm -f'ed below |
| 631 | |
| 632 | msg "test: pk_sign secp521r1_prv.der for MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE} (ASan build)" # ~ 5s |
| 633 | if_build_succeeded programs/pkey/pk_sign tests/data_files/secp521r1_prv.der $INEVITABLY_PRESENT_FILE |
| 634 | rm -f $SIGNATURE_FILE |
| 635 | } |
| 636 | |
Gilles Peskine | 99a3310 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 637 | component_test_default_out_of_box () { |
| 638 | msg "build: make, default config (out-of-box)" # ~1min |
| 639 | make |
| 640 | |
| 641 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 642 | make test |
| 643 | |
| 644 | msg "selftest: make, default config (out-of-box)" # ~10s |
Gilles Peskine | 5bd9f56 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 645 | if_build_succeeded programs/test/selftest |
Gilles Peskine | 99a3310 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 646 | } |
| 647 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 648 | component_test_default_cmake_gcc_asan () { |
| 649 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 650 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 651 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 652 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 653 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 654 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 655 | |
Gilles Peskine | 5bd9f56 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 656 | msg "test: selftest (ASan build)" # ~ 10s |
| 657 | if_build_succeeded programs/test/selftest |
| 658 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 659 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
| 660 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 661 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 662 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 663 | if_build_succeeded tests/compat.sh |
| 664 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 665 | |
Hanno Becker | f8799e8 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 666 | component_test_full_cmake_gcc_asan () { |
| 667 | msg "build: full config, cmake, gcc, ASan" |
| 668 | scripts/config.pl full |
| 669 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 670 | make |
| 671 | |
| 672 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 673 | make test |
| 674 | |
Gilles Peskine | 5bd9f56 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 675 | msg "test: selftest (ASan build)" # ~ 10s |
| 676 | if_build_succeeded programs/test/selftest |
| 677 | |
Hanno Becker | f8799e8 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 678 | msg "test: ssl-opt.sh (full config, ASan build)" |
| 679 | if_build_succeeded tests/ssl-opt.sh |
| 680 | |
| 681 | msg "test: compat.sh (full config, ASan build)" |
| 682 | if_build_succeeded tests/compat.sh |
| 683 | } |
| 684 | |
Manuel Pégourié-Gonnard | 4ef189d | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 685 | component_test_zlib_make() { |
| 686 | msg "build: zlib enabled, make" |
| 687 | scripts/config.pl set MBEDTLS_ZLIB_SUPPORT |
| 688 | make ZLIB=1 CFLAGS='-Werror -O1' |
| 689 | |
| 690 | msg "test: main suites (zlib, make)" |
| 691 | make test |
| 692 | |
| 693 | msg "test: ssl-opt.sh (zlib, make)" |
| 694 | if_build_succeeded tests/ssl-opt.sh |
| 695 | } |
Manuel Pégourié-Gonnard | 114d339 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 696 | support_test_zlib_make () { |
| 697 | base=support_test_zlib_$$ |
| 698 | cat <<'EOF' > ${base}.c |
| 699 | #include "zlib.h" |
| 700 | int main(void) { return 0; } |
| 701 | EOF |
| 702 | gcc -o ${base}.exe ${base}.c -lz 2>/dev/null |
| 703 | ret=$? |
| 704 | rm -f ${base}.* |
| 705 | return $ret |
| 706 | } |
Manuel Pégourié-Gonnard | 4ef189d | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 707 | |
| 708 | component_test_zlib_cmake() { |
| 709 | msg "build: zlib enabled, cmake" |
| 710 | scripts/config.pl set MBEDTLS_ZLIB_SUPPORT |
| 711 | cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check . |
| 712 | make |
| 713 | |
| 714 | msg "test: main suites (zlib, cmake)" |
| 715 | make test |
| 716 | |
| 717 | msg "test: ssl-opt.sh (zlib, cmake)" |
| 718 | if_build_succeeded tests/ssl-opt.sh |
| 719 | } |
Manuel Pégourié-Gonnard | 114d339 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 720 | support_test_zlib_cmake () { |
| 721 | support_test_zlib_make "$@" |
| 722 | } |
Manuel Pégourié-Gonnard | 4ef189d | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 723 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 724 | component_test_ref_configs () { |
| 725 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 726 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 727 | record_status tests/scripts/test-ref-configs.pl |
| 728 | } |
| 729 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 730 | component_test_sslv3 () { |
| 731 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 732 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 733 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 734 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 735 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 736 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 737 | make test |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 738 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 739 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
| 740 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 741 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 742 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 743 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 744 | if_build_succeeded tests/ssl-opt.sh |
| 745 | } |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 746 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 747 | component_test_no_renegotiation () { |
| 748 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 749 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 750 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 751 | make |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 752 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 753 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 754 | make test |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 755 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 756 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 757 | if_build_succeeded tests/ssl-opt.sh |
| 758 | } |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 759 | |
Hanno Becker | e562e7d | 2019-05-10 14:45:37 +0100 | [diff] [blame] | 760 | component_test_no_pem_no_fs () { |
| 761 | msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" |
| 762 | scripts/config.pl unset MBEDTLS_PEM_PARSE_C |
| 763 | scripts/config.pl unset MBEDTLS_FS_IO |
| 764 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 765 | make |
| 766 | |
| 767 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 768 | make test |
| 769 | |
| 770 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
| 771 | if_build_succeeded tests/ssl-opt.sh |
| 772 | } |
| 773 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 774 | component_test_rsa_no_crt () { |
| 775 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 776 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 777 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 778 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 779 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 780 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 781 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 782 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 783 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 784 | if_build_succeeded tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 785 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 786 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 787 | if_build_succeeded tests/compat.sh -t RSA |
| 788 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 789 | |
Manuel Pégourié-Gonnard | 014ff5b | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 790 | component_test_no_ctr_drbg () { |
| 791 | msg "build: Full minus CTR_DRBG" |
| 792 | scripts/config.pl full |
| 793 | scripts/config.pl unset MBEDTLS_CTR_DRBG_C |
| 794 | |
| 795 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 796 | make |
| 797 | |
| 798 | msg "test: no CTR_DRBG" |
| 799 | make test |
| 800 | |
Manuel Pégourié-Gonnard | c5243c1 | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 801 | # no ssl-opt.sh/compat.sh as they all depend on CTR_DRBG so far |
| 802 | } |
| 803 | |
| 804 | component_test_no_hmac_drbg () { |
| 805 | msg "build: Full minus HMAC_DRBG" |
| 806 | scripts/config.pl full |
| 807 | scripts/config.pl unset MBEDTLS_HMAC_DRBG_C |
| 808 | scripts/config.pl unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 809 | |
| 810 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 811 | make |
| 812 | |
| 813 | msg "test: no HMAC_DRBG" |
| 814 | make test |
| 815 | |
| 816 | # No ssl-opt.sh/compat.sh as they never use HMAC_DRBG so far, |
| 817 | # so there's little value in running those lengthy tests here. |
Manuel Pégourié-Gonnard | 014ff5b | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 818 | } |
| 819 | |
Manuel Pégourié-Gonnard | 23983f3 | 2020-05-19 12:38:31 +0200 | [diff] [blame] | 820 | component_test_ecp_no_internal_rng () { |
| 821 | msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules" |
| 822 | scripts/config.pl set MBEDTLS_ECP_NO_INTERNAL_RNG |
| 823 | scripts/config.pl unset MBEDTLS_CTR_DRBG_C |
| 824 | scripts/config.pl unset MBEDTLS_HMAC_DRBG_C |
| 825 | scripts/config.pl unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 826 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG |
| 827 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto |
| 828 | |
| 829 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 830 | make |
| 831 | |
| 832 | msg "test: ECP_NO_INTERNAL_RNG, no DRBG module" |
| 833 | make test |
| 834 | |
| 835 | # no SSL tests as they all depend on having a DRBG |
| 836 | } |
| 837 | |
Manuel Pégourié-Gonnard | 047986c | 2020-06-04 09:43:14 +0200 | [diff] [blame^] | 838 | component_test_ecp_restartable_no_internal_rng () { |
| 839 | msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG" |
| 840 | scripts/config.pl set MBEDTLS_ECP_NO_INTERNAL_RNG |
| 841 | scripts/config.pl set MBEDTLS_ECP_RESTARTABLE |
| 842 | scripts/config.pl unset MBEDTLS_CTR_DRBG_C |
| 843 | scripts/config.pl unset MBEDTLS_HMAC_DRBG_C |
| 844 | scripts/config.pl unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 845 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG |
| 846 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto |
| 847 | |
| 848 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 849 | make |
| 850 | |
| 851 | msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module" |
| 852 | make test |
| 853 | |
| 854 | # no SSL tests as they all depend on having a DRBG |
| 855 | } |
| 856 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 857 | component_test_small_ssl_out_content_len () { |
| 858 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 859 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 860 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
| 861 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 862 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 863 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 864 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
| 865 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" |
| 866 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 867 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 868 | component_test_small_ssl_in_content_len () { |
| 869 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 870 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 871 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
| 872 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 873 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 874 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 875 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
| 876 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment" |
| 877 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 878 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 879 | component_test_small_ssl_dtls_max_buffering () { |
| 880 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 881 | scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
| 882 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 883 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 884 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 885 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
| 886 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
| 887 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 888 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 889 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 890 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 891 | scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240 |
| 892 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 893 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 894 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 895 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
| 896 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
| 897 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 898 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 899 | component_test_full_cmake_clang () { |
| 900 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 901 | scripts/config.pl full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 902 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 903 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 904 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 905 | msg "test: main suites (full config)" # ~ 5s |
| 906 | make test |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 907 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 908 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
| 909 | if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 910 | |
Andres Amaya Garcia | ac9c522 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 911 | msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min |
Andres Amaya Garcia | 37e0a8c | 2019-02-19 20:20:57 +0000 | [diff] [blame] | 912 | 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' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 913 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 914 | msg "test: compat.sh ARIA + ChachaPoly" |
| 915 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 916 | } |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 917 | |
Gilles Peskine | 77b1f30 | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 918 | component_test_default_no_deprecated () { |
| 919 | # Test that removing the deprecated features from the default |
| 920 | # configuration leaves something consistent. |
| 921 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 922 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
Gilles Peskine | 77b1f30 | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 923 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 924 | |
| 925 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 926 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 927 | } |
Gilles Peskine | 0afe624 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 928 | |
Gilles Peskine | 77b1f30 | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 929 | component_test_full_deprecated_warning () { |
| 930 | # Test that there is nothing deprecated in the full configuration. |
| 931 | # A deprecated feature would trigger a warning (made fatal) from |
| 932 | # MBEDTLS_DEPRECATED_WARNING. |
| 933 | msg "build: make, full + MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 934 | scripts/config.pl full |
| 935 | scripts/config.pl unset MBEDTLS_DEPRECATED_REMOVED |
| 936 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
| 937 | # There are currently no tests for any deprecated feature. |
| 938 | # If some are added, 'make test' would trigger warnings here. |
| 939 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 940 | |
| 941 | msg "test: make, full + MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
| 942 | make test |
| 943 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 944 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 945 | component_test_depends_curves () { |
| 946 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 947 | record_status tests/scripts/curves.pl |
| 948 | } |
Manuel Pégourié-Gonnard | 1fe6bb9 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 949 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 950 | component_test_depends_hashes () { |
| 951 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 952 | record_status tests/scripts/depends-hashes.pl |
| 953 | } |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 954 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 955 | component_test_depends_pkalgs () { |
| 956 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 957 | record_status tests/scripts/depends-pkalgs.pl |
| 958 | } |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 959 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 960 | component_build_key_exchanges () { |
| 961 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 962 | record_status tests/scripts/key-exchanges.pl |
| 963 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 964 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 965 | component_build_default_make_gcc_and_cxx () { |
| 966 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 967 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 968 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 969 | msg "test: verify header list in cpp_dummy_build.cpp" |
| 970 | record_status check_headers_in_cpp |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 971 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 972 | msg "build: Unix make, incremental g++" |
| 973 | make TEST_CPP=1 |
| 974 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 975 | |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 976 | component_test_check_params_functionality () { |
| 977 | msg "build+test: MBEDTLS_CHECK_PARAMS functionality" |
| 978 | scripts/config.pl full # includes CHECK_PARAMS |
| 979 | # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed(). |
| 980 | scripts/config.pl unset MBEDTLS_CHECK_PARAMS_ASSERT |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 981 | # Only build and run tests. Do not build sample programs, because |
| 982 | # they don't have a mbedtls_param_failed() function. |
| 983 | make CC=gcc CFLAGS='-Werror -O1' lib test |
| 984 | } |
| 985 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 986 | component_test_check_params_without_platform () { |
| 987 | msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" |
| 988 | scripts/config.pl full # includes CHECK_PARAMS |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 989 | # Keep MBEDTLS_PARAM_FAILED as assert. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 990 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 991 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 992 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 993 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 994 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 995 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 996 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 997 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 998 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 999 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1000 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 1001 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1002 | component_test_check_params_silent () { |
| 1003 | msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" |
| 1004 | scripts/config.pl full # includes CHECK_PARAMS |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1005 | # Set MBEDTLS_PARAM_FAILED to nothing. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1006 | sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" |
| 1007 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1008 | } |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1009 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1010 | component_test_no_platform () { |
| 1011 | # Full configuration build, without platform support, file IO and net sockets. |
| 1012 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 1013 | # IO, it should catch missing '#include <stdio.h>' |
| 1014 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1015 | scripts/config.pl full |
| 1016 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 1017 | scripts/config.pl unset MBEDTLS_NET_C |
| 1018 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 1019 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1020 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1021 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1022 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 1023 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1024 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1025 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1026 | scripts/config.pl unset MBEDTLS_FS_IO |
| 1027 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 1028 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1029 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 1030 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1031 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1032 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1033 | component_build_no_std_function () { |
| 1034 | # catch compile bugs in _uninit functions |
| 1035 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1036 | scripts/config.pl full |
| 1037 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 1038 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1039 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1040 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1041 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1042 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1043 | component_build_no_ssl_srv () { |
| 1044 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1045 | scripts/config.pl full |
| 1046 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1047 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1048 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1049 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1050 | component_build_no_ssl_cli () { |
| 1051 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1052 | scripts/config.pl full |
| 1053 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1054 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1055 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1056 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1057 | component_build_no_sockets () { |
| 1058 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 1059 | # as that requires a POSIX platform (which isn't the same as C99). |
| 1060 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1061 | scripts/config.pl full |
| 1062 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 1063 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1064 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1065 | } |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1066 | |
Andrzej Kurek | 1d07082 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1067 | component_test_memory_buffer_allocator_backtrace () { |
| 1068 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1069 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Andrzej Kurek | 1d07082 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1070 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1071 | scripts/config.pl set MBEDTLS_MEMORY_BACKTRACE |
Andrzej Kurek | 60ebd98 | 2019-09-10 02:58:34 -0400 | [diff] [blame] | 1072 | scripts/config.pl set MBEDTLS_MEMORY_DEBUG |
Andrzej Kurek | 1d07082 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1073 | CC=gcc cmake . |
| 1074 | make |
| 1075 | |
| 1076 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1077 | make test |
| 1078 | } |
| 1079 | |
| 1080 | component_test_memory_buffer_allocator () { |
| 1081 | msg "build: default config with memory buffer allocator" |
| 1082 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Hanno Becker | d130b98 | 2019-06-03 16:35:02 +0100 | [diff] [blame] | 1083 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1084 | CC=gcc cmake . |
| 1085 | make |
| 1086 | |
| 1087 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1088 | make test |
| 1089 | |
| 1090 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
Andrzej Kurek | 1f5a596 | 2019-09-05 10:09:37 -0400 | [diff] [blame] | 1091 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 1092 | if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1095 | component_test_no_max_fragment_length () { |
| 1096 | # Run max fragment length tests with MFL disabled |
| 1097 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1098 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1099 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1100 | make |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1101 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1102 | msg "test: ssl-opt.sh, MFL-related tests" |
| 1103 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
| 1104 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1105 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1106 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 1107 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1108 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1109 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1110 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
| 1111 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1112 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1113 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1114 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
| 1115 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer" |
| 1116 | } |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1117 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1118 | component_test_null_entropy () { |
| 1119 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1120 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
| 1121 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 1122 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 1123 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1124 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1125 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 1126 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 5fa32a7 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 1127 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON . |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1128 | make |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1129 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1130 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 1131 | make test |
| 1132 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1133 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1134 | component_test_platform_calloc_macro () { |
| 1135 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1136 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 1137 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 1138 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 1139 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1140 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1141 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1142 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 1143 | make test |
| 1144 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1145 | |
Gilles Peskine | c6b0986 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1146 | component_test_malloc_0_null () { |
| 1147 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
| 1148 | scripts/config.pl full |
| 1149 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1150 | 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' |
| 1151 | |
| 1152 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 1153 | make test |
| 1154 | |
| 1155 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 1156 | # Just the calloc selftest. "make test" ran the others as part of the |
| 1157 | # test suites. |
| 1158 | if_build_succeeded programs/test/selftest calloc |
| 1159 | } |
| 1160 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1161 | component_test_aes_fewer_tables () { |
| 1162 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1163 | scripts/config.pl set MBEDTLS_AES_FEWER_TABLES |
| 1164 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1165 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1166 | msg "test: AES_FEWER_TABLES" |
| 1167 | make test |
| 1168 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1169 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1170 | component_test_aes_rom_tables () { |
| 1171 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1172 | scripts/config.pl set MBEDTLS_AES_ROM_TABLES |
| 1173 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1174 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1175 | msg "test: AES_ROM_TABLES" |
| 1176 | make test |
| 1177 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1178 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1179 | component_test_aes_fewer_tables_and_rom_tables () { |
| 1180 | msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1181 | scripts/config.pl set MBEDTLS_AES_FEWER_TABLES |
| 1182 | scripts/config.pl set MBEDTLS_AES_ROM_TABLES |
| 1183 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1184 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1185 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 1186 | make test |
| 1187 | } |
| 1188 | |
| 1189 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1190 | msg "build/test: make shared" # ~ 40s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1191 | make SHARED=1 all check |
Gilles Peskine | dc25c32 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1192 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1193 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 1194 | |
Gilles Peskine | 2c47ffc | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1195 | component_test_cmake_shared () { |
| 1196 | msg "build/test: cmake shared" # ~ 2min |
| 1197 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 1198 | make |
Gilles Peskine | dc25c32 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1199 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 2c47ffc | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1200 | make test |
| 1201 | } |
| 1202 | |
Gilles Peskine | 0fe92c2 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1203 | test_build_opt () { |
| 1204 | info=$1 cc=$2; shift 2 |
| 1205 | for opt in "$@"; do |
| 1206 | msg "build/test: $cc $opt, $info" # ~ 30s |
Gilles Peskine | 313bb50 | 2020-04-14 20:08:41 +0200 | [diff] [blame] | 1207 | make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror" |
Gilles Peskine | 0fe92c2 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1208 | # We're confident enough in compilers to not run _all_ the tests, |
| 1209 | # but at least run the unit tests. In particular, runs with |
| 1210 | # optimizations use inline assembly whereas runs with -O0 |
| 1211 | # skip inline assembly. |
| 1212 | make test # ~30s |
| 1213 | make clean |
| 1214 | done |
| 1215 | } |
| 1216 | |
| 1217 | component_test_clang_opt () { |
| 1218 | scripts/config.pl full |
| 1219 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 1220 | } |
| 1221 | |
| 1222 | component_test_gcc_opt () { |
| 1223 | scripts/config.pl full |
| 1224 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 1225 | } |
| 1226 | |
Gilles Peskine | 87bf1b5 | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1227 | component_build_mbedtls_config_file () { |
| 1228 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 1229 | # Use the full config so as to catch a maximum of places where |
| 1230 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
| 1231 | scripts/config.pl full |
| 1232 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 1233 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 1234 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 1235 | rm -f full_config.h |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1238 | component_test_m32_o0 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1239 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 1240 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 1241 | scripts/config.pl full |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1242 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1243 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1244 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 1245 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1246 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1247 | support_test_m32_o0 () { |
| 1248 | case $(uname -m) in |
| 1249 | *64*) true;; |
| 1250 | *) false;; |
| 1251 | esac |
| 1252 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1253 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1254 | component_test_m32_o1 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1255 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 1256 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1257 | scripts/config.pl full |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1258 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1259 | |
| 1260 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1261 | make test |
Gilles Peskine | 7dd44b2 | 2019-04-08 16:58:02 +0200 | [diff] [blame] | 1262 | |
| 1263 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 1264 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1265 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1266 | support_test_m32_o1 () { |
| 1267 | support_test_m32_o0 "$@" |
| 1268 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1269 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1270 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1271 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 1272 | scripts/config.pl full |
Gilles Peskine | 8118e46 | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 1273 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1274 | |
| 1275 | msg "test: 64-bit ILP32, make, gcc" |
| 1276 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1277 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1278 | support_test_mx32 () { |
| 1279 | case $(uname -m) in |
| 1280 | amd64|x86_64) true;; |
| 1281 | *) false;; |
| 1282 | esac |
| 1283 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1284 | |
Peter Kolbus | 1e2aa72 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1285 | component_test_min_mpi_window_size () { |
| 1286 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
| 1287 | scripts/config.pl set MBEDTLS_MPI_WINDOW_SIZE 1 |
| 1288 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1289 | make |
| 1290 | |
| 1291 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 1292 | make test |
| 1293 | } |
| 1294 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1295 | component_test_have_int32 () { |
| 1296 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1297 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 1298 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 1299 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 1300 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1301 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1302 | msg "test: gcc, force 32-bit bignum limbs" |
| 1303 | make test |
| 1304 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 1305 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1306 | component_test_have_int64 () { |
| 1307 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1308 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 1309 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 1310 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 1311 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 1312 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1313 | msg "test: gcc, force 64-bit bignum limbs" |
| 1314 | make test |
| 1315 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1316 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1317 | component_test_no_udbl_division () { |
| 1318 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1319 | scripts/config.pl full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1320 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
| 1321 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1322 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1323 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 1324 | make test |
| 1325 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1326 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1327 | component_test_no_64bit_multiplication () { |
| 1328 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1329 | scripts/config.pl full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1330 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 1331 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1332 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1333 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 1334 | make test |
| 1335 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1336 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1337 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1338 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s |
Manuel Pégourié-Gonnard | 6e6ae9b | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1339 | scripts/config.pl baremetal |
Gilles Peskine | fcccfbc | 2020-04-30 22:54:00 +0200 | [diff] [blame] | 1340 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra -O1' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1341 | |
| 1342 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" |
| 1343 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1344 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1345 | |
Gilles Peskine | 560f332 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1346 | component_build_arm_none_eabi_gcc_arm5vte () { |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1347 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s |
Gilles Peskine | 0bd284d | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 1348 | scripts/config.pl baremetal |
Gilles Peskine | 560f332 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1349 | # Build for a target platform that's close to what Debian uses |
| 1350 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 1351 | # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. |
| 1352 | # It would be better to build with arm-linux-gnueabi-gcc but |
| 1353 | # we don't have that on our CI at this time. |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1354 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1355 | |
| 1356 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" |
| 1357 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 0bd284d | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 1358 | } |
| 1359 | |
Gilles Peskine | dac156b | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 1360 | component_build_arm_none_eabi_gcc_m0plus () { |
| 1361 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s |
| 1362 | scripts/config.pl baremetal |
| 1363 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1364 | |
| 1365 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os" |
| 1366 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1367 | } |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1368 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1369 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1370 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX} -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1371 | scripts/config.pl baremetal |
Simon Butcher | 1c71965 | 2016-06-27 19:02:12 +0100 | [diff] [blame] | 1372 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1373 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra' lib |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1374 | echo "Checking that software 64-bit division is not required" |
| 1375 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
| 1376 | } |
| 1377 | |
Manuel Pégourié-Gonnard | bbc60db | 2015-06-22 14:31:50 +0200 | [diff] [blame] | 1378 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1379 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX} MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1380 | scripts/config.pl baremetal |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1381 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1382 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1383 | echo "Checking that software 64-bit multiplication is not required" |
| 1384 | if_build_succeeded not grep __aeabi_lmul library/*.o |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1385 | } |
Simon Butcher | bc6a486 | 2016-03-07 17:35:59 +0000 | [diff] [blame] | 1386 | |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1387 | component_build_armcc () { |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1388 | msg "build: ARM Compiler 5" |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1389 | scripts/config.pl baremetal |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1390 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1391 | |
| 1392 | msg "size: ARM Compiler 5" |
| 1393 | "$ARMC5_FROMELF" -z library/*.o |
| 1394 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1395 | make clean |
| 1396 | |
| 1397 | # ARM Compiler 6 - Target ARMv7-A |
| 1398 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
| 1399 | |
| 1400 | # ARM Compiler 6 - Target ARMv7-M |
Simon Butcher | 4df5eaf | 2016-08-24 22:58:31 +0300 | [diff] [blame] | 1401 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1402 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1403 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1404 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1405 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1406 | # ARM Compiler 6 - Target ARMv8-M |
| 1407 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1408 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1409 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1410 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1411 | } |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1412 | |
Andres Amaya Garcia | 9f3bdb8 | 2018-12-05 22:03:56 +0000 | [diff] [blame] | 1413 | component_build_ssl_hw_record_accel() { |
| 1414 | msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled" |
| 1415 | scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL |
| 1416 | make CFLAGS='-Werror -O1' |
| 1417 | } |
| 1418 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1419 | component_test_allow_sha1 () { |
| 1420 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1421 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
| 1422 | make CFLAGS='-Werror -Wall -Wextra' |
| 1423 | msg "test: allow SHA1 in certificates by default" |
| 1424 | make test |
| 1425 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
| 1426 | } |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1427 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1428 | component_build_mingw () { |
| 1429 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1430 | 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 |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 1431 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1432 | # note Make tests only builds the tests, but doesn't run them |
| 1433 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
| 1434 | make WINDOWS_BUILD=1 clean |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 1435 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1436 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
| 1437 | 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 |
| 1438 | 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 |
| 1439 | make WINDOWS_BUILD=1 clean |
| 1440 | } |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 1441 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1442 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1443 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1444 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1445 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1446 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 1447 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1448 | msg "test: main suites (MSan)" # ~ 10s |
| 1449 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1450 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1451 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1452 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1453 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1454 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1455 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1456 | if [ "$MEMORY" -gt 0 ]; then |
| 1457 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1458 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1459 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1460 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1461 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1462 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1463 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1464 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1465 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1466 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1467 | msg "test: main suites valgrind (Release)" |
| 1468 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1469 | |
Gilles Peskine | 0a47c4f | 2019-04-08 17:00:56 +0200 | [diff] [blame] | 1470 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1471 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1472 | if [ "$MEMORY" -gt 0 ]; then |
| 1473 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1474 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1475 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1476 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1477 | if [ "$MEMORY" -gt 1 ]; then |
| 1478 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1479 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1480 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1481 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1482 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1483 | component_test_cmake_out_of_source () { |
| 1484 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1485 | MBEDTLS_ROOT_DIR="$PWD" |
| 1486 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1487 | cd "$OUT_OF_SOURCE_DIR" |
| 1488 | cmake "$MBEDTLS_ROOT_DIR" |
| 1489 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1490 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1491 | msg "test: cmake 'out-of-source' build" |
| 1492 | make test |
| 1493 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 1494 | # Also ensure that there are no error messages such as |
| 1495 | # "No such file or directory", which would indicate that some required |
| 1496 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 1497 | # may exit with status 0 but emit errors). |
| 1498 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 1499 | if [ -s ssl-opt.err ]; then |
| 1500 | cat ssl-opt.err >&2 |
| 1501 | record_status [ ! -s ssl-opt.err ] |
| 1502 | rm ssl-opt.err |
| 1503 | fi |
| 1504 | cd "$MBEDTLS_ROOT_DIR" |
| 1505 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1506 | unset MBEDTLS_ROOT_DIR |
| 1507 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1508 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1509 | component_test_zeroize () { |
| 1510 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 1511 | # different combinations of compilers and optimization flags by using an |
| 1512 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 1513 | # system in all cases that the script fails, so we must manually search the |
| 1514 | # output to check whether the pass string is present and no failure strings |
| 1515 | # were printed. |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1516 | |
| 1517 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 1518 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 1519 | gdb_disable_aslr= |
| 1520 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 1521 | gdb_disable_aslr='set disable-randomization off' |
| 1522 | fi |
| 1523 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1524 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1525 | for compiler in clang gcc; do |
| 1526 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 1527 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1528 | if_build_succeeded gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1529 | if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log |
| 1530 | if_build_succeeded not grep -i "error" test_zeroize.log |
| 1531 | rm -f test_zeroize.log |
| 1532 | make clean |
| 1533 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 1534 | done |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1535 | |
| 1536 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1537 | } |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 1538 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1539 | component_check_python_files () { |
| 1540 | msg "Lint: Python scripts" |
| 1541 | record_status tests/scripts/check-python-files.sh |
| 1542 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1543 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1544 | component_check_generate_test_code () { |
| 1545 | msg "uint test: generate_test_code.py" |
| 1546 | record_status ./tests/scripts/test_generate_test_code.py |
| 1547 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1548 | |
| 1549 | ################################################################ |
| 1550 | #### Termination |
| 1551 | ################################################################ |
| 1552 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1553 | post_report () { |
| 1554 | msg "Done, cleaning up" |
| 1555 | cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1556 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1557 | final_report |
| 1558 | } |
| 1559 | |
| 1560 | |
| 1561 | |
| 1562 | ################################################################ |
| 1563 | #### Run all the things |
| 1564 | ################################################################ |
| 1565 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1566 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1567 | run_component () { |
Gilles Peskine | 608953e | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1568 | # Back up the configuration in case the component modifies it. |
| 1569 | # The cleanup function will restore it. |
| 1570 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1571 | current_component="$1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1572 | "$@" |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1573 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1574 | } |
| 1575 | |
| 1576 | # Preliminary setup |
| 1577 | pre_check_environment |
| 1578 | pre_initialize_variables |
| 1579 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 1580 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1581 | pre_check_git |
| 1582 | build_status=0 |
| 1583 | if [ $KEEP_GOING -eq 1 ]; then |
| 1584 | pre_setup_keep_going |
| 1585 | else |
| 1586 | record_status () { |
| 1587 | "$@" |
| 1588 | } |
| 1589 | fi |
| 1590 | pre_print_configuration |
| 1591 | pre_check_tools |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1592 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1593 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 1594 | # Run the requested tests. |
| 1595 | for component in $RUN_COMPONENTS; do |
| 1596 | run_component "component_$component" |
| 1597 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1598 | |
| 1599 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1600 | post_report |