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 |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 27 | # * Makefile, library/Makefile, programs/Makefile, tests/Makefile, |
| 28 | # programs/fuzz/Makefile |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 29 | # After running this script, the CMake cache will be lost and CMake |
| 30 | # will no longer be initialised. |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 31 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 32 | # The script assumes the presence of a number of tools: |
| 33 | # * Basic Unix tools (Windows users note: a Unix-style find must be before |
| 34 | # the Windows find in the PATH) |
| 35 | # * Perl |
| 36 | # * GNU Make |
| 37 | # * CMake |
| 38 | # * 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] | 39 | # * G++ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 40 | # * arm-gcc and mingw-gcc |
| 41 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 42 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
| 43 | # interoperability tests. If they don't support SSLv3 then a legacy |
| 44 | # version of these tools must be present as well (search for LEGACY |
| 45 | # below). |
| 46 | # See the invocation of check_tools below for details. |
| 47 | # |
| 48 | # This script must be invoked from the toplevel directory of a git |
| 49 | # working copy of Mbed TLS. |
| 50 | # |
| 51 | # Note that the output is not saved. You may want to run |
| 52 | # script -c tests/scripts/all.sh |
| 53 | # or |
| 54 | # tests/scripts/all.sh >all.log 2>&1 |
| 55 | # |
| 56 | # Notes for maintainers |
| 57 | # --------------------- |
| 58 | # |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 59 | # The bulk of the code is organized into functions that follow one of the |
| 60 | # following naming conventions: |
| 61 | # * pre_XXX: things to do before running the tests, in order. |
| 62 | # * component_XXX: independent components. They can be run in any order. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 63 | # * component_check_XXX: quick tests that aren't worth parallelizing. |
| 64 | # * component_build_XXX: build things but don't run them. |
| 65 | # * component_test_XXX: build and test. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 66 | # * support_XXX: if support_XXX exists and returns false then |
| 67 | # component_XXX is not run by default. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 68 | # * post_XXX: things to do after running the tests. |
| 69 | # * other: miscellaneous support functions. |
| 70 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 71 | # Each component must start by invoking `msg` with a short informative message. |
| 72 | # |
| 73 | # The framework performs some cleanup tasks after each component. This |
| 74 | # means that components can assume that the working directory is in a |
| 75 | # cleaned-up state, and don't need to perform the cleanup themselves. |
| 76 | # * Run `make clean`. |
| 77 | # * Restore `include/mbedtks/config.h` from a backup made before running |
| 78 | # the component. |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 79 | # * Check out `Makefile`, `library/Makefile`, `programs/Makefile`, |
| 80 | # `tests/Makefile` and `programs/fuzz/Makefile` from git. |
| 81 | # This cleans up after an in-tree use of CMake. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 82 | # |
| 83 | # Any command that is expected to fail must be protected so that the |
| 84 | # script keeps running in --keep-going mode despite `set -e`. In keep-going |
| 85 | # mode, if a protected command fails, this is logged as a failure and the |
| 86 | # script will exit with a failure status once it has run all components. |
| 87 | # Commands can be protected in any of the following ways: |
| 88 | # * `make` is a function which runs the `make` command with protection. |
| 89 | # Note that you must write `make VAR=value`, not `VAR=value make`, |
| 90 | # because the `VAR=value make` syntax doesn't work with functions. |
| 91 | # * Put `report_status` before the command to protect it. |
| 92 | # * Put `if_build_successful` before a command. This protects it, and |
| 93 | # additionally skips it if a prior invocation of `make` in the same |
| 94 | # component failed. |
| 95 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 96 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 97 | # have to be exact, but in general you should add slower tests towards |
| 98 | # the end and fast checks near the beginning. |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 99 | |
| 100 | |
| 101 | |
| 102 | ################################################################ |
| 103 | #### Initialization and command line parsing |
| 104 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 105 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 106 | # Abort on errors (and uninitialised variables) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 107 | set -eu |
| 108 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 109 | pre_check_environment () { |
Gilles Peskine | a16c2b1 | 2019-01-06 19:58:02 +0000 | [diff] [blame] | 110 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 111 | echo "Must be run from mbed TLS root" >&2 |
| 112 | exit 1 |
| 113 | fi |
| 114 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 115 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 116 | pre_initialize_variables () { |
| 117 | CONFIG_H='include/mbedtls/config.h' |
| 118 | CONFIG_BAK="$CONFIG_H.bak" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 119 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 120 | append_outcome=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 121 | MEMORY=0 |
| 122 | FORCE=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 123 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 124 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 125 | : ${MBEDTLS_TEST_OUTCOME_FILE=} |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 126 | : ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 127 | export MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 128 | export MBEDTLS_TEST_PLATFORM |
| 129 | |
Jaeden Amero | c4cc251 | 2019-01-30 15:35:44 +0000 | [diff] [blame] | 130 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 131 | : ${OPENSSL:="openssl"} |
| 132 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 133 | : ${OPENSSL_NEXT:="$OPENSSL"} |
| 134 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 135 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 136 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 137 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 138 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 139 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 140 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 141 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 142 | # 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] | 143 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 144 | export MAKEFLAGS="-j" |
| 145 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 146 | |
Jaeden Amero | d48e9c7 | 2019-02-07 17:43:39 +0000 | [diff] [blame] | 147 | # Include more verbose output for failing tests run by CMake |
| 148 | export CTEST_OUTPUT_ON_FAILURE=1 |
| 149 | |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 150 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Gilles Peskine | 5ca393f | 2019-10-21 19:06:33 +0200 | [diff] [blame] | 151 | ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 152 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 153 | # Gather the list of available components. These are the functions |
| 154 | # defined in this script whose name starts with "component_". |
| 155 | # Parse the script with sed, because in sh there is no way to list |
| 156 | # defined functions. |
| 157 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 158 | |
| 159 | # Exclude components that are not supported on this platform. |
| 160 | SUPPORTED_COMPONENTS= |
| 161 | for component in $ALL_COMPONENTS; do |
| 162 | case $(type "support_$component" 2>&1) in |
| 163 | *' function'*) |
| 164 | if ! support_$component; then continue; fi;; |
| 165 | esac |
| 166 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 167 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 168 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 169 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 170 | # Test whether the component $1 is included in the command line patterns. |
| 171 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 172 | { |
| 173 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 174 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 175 | set +f |
| 176 | case ${1#component_} in $pattern) return 0;; esac |
| 177 | done |
| 178 | set +f |
| 179 | return 1 |
| 180 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 181 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 182 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 183 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 184 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 185 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 186 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 187 | 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] | 188 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 189 | |
| 190 | Examples: |
| 191 | $0 "check_*" |
| 192 | Run all sanity checks. |
| 193 | $0 --no-armcc --except test_memsan |
| 194 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 195 | |
| 196 | Special options: |
| 197 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 198 | --list-all-components List all available test components and exit. |
| 199 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 200 | |
| 201 | General options: |
| 202 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 203 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 204 | -m|--memory Additional optional memory tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 205 | --append-outcome Append to the outcome file (if used). |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 206 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 207 | --except Exclude the COMPONENTs listed on the command line, |
| 208 | instead of running only those. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 209 | --no-append-outcome Write a new outcome file and analyze it (default). |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 210 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 211 | --no-force Refuse to overwrite modified files (default). |
| 212 | --no-keep-going Stop at the first error (default). |
| 213 | --no-memory No additional memory tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 214 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 215 | --outcome-file=<path> File where test outcomes are written (not done if |
| 216 | empty; default: \$MBEDTLS_TEST_OUTCOME_FILE). |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 217 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 218 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 219 | -s|--seed Integer seed value to use for this test run. |
| 220 | |
| 221 | Tool path options: |
| 222 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 223 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 224 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 225 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 226 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 227 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 228 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 229 | --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] | 230 | --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] | 231 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 232 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 233 | |
| 234 | # remove built files as well as the cmake cache/config |
| 235 | cleanup() |
| 236 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 237 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 238 | cd "$MBEDTLS_ROOT_DIR" |
| 239 | fi |
| 240 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 241 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 242 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 243 | # Remove CMake artefacts |
Jaeden Amero | 2d0e00f | 2018-11-07 18:46:41 +0000 | [diff] [blame] | 244 | find . -name .git -prune -o \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 245 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 246 | \( -iname cmake_install.cmake -o \ |
| 247 | -iname CTestTestfile.cmake -o \ |
| 248 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 249 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 250 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 251 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 252 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 253 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 254 | # Remove any artifacts from the component_test_cmake_as_subdirectory test. |
| 255 | rm -rf programs/test/cmake_subproject/build |
| 256 | rm -f programs/test/cmake_subproject/Makefile |
| 257 | rm -f programs/test/cmake_subproject/cmake_subproject |
| 258 | |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 259 | if [ -f "$CONFIG_BAK" ]; then |
| 260 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 261 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 264 | # Executed on exit. May be redefined depending on command line options. |
| 265 | final_report () { |
| 266 | : |
| 267 | } |
| 268 | |
| 269 | fatal_signal () { |
| 270 | cleanup |
| 271 | final_report $1 |
| 272 | trap - $1 |
| 273 | kill -$1 $$ |
| 274 | } |
| 275 | |
| 276 | trap 'fatal_signal HUP' HUP |
| 277 | trap 'fatal_signal INT' INT |
| 278 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 279 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 280 | msg() |
| 281 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 282 | if [ -n "${current_component:-}" ]; then |
| 283 | current_section="${current_component#component_}: $1" |
| 284 | else |
| 285 | current_section="$1" |
| 286 | fi |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 287 | echo "" |
| 288 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 289 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 290 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 291 | echo "******************************************************************" |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 292 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 293 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 294 | armc6_build_test() |
| 295 | { |
| 296 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 297 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 298 | msg "build: ARM Compiler 6 ($FLAGS), make" |
| 299 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 300 | WARNING_CFLAGS='-xc -std=c99' make lib |
| 301 | make clean |
| 302 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 303 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 304 | err_msg() |
| 305 | { |
| 306 | echo "$1" >&2 |
| 307 | } |
| 308 | |
| 309 | check_tools() |
| 310 | { |
| 311 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 312 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 313 | err_msg "$TOOL not found!" |
| 314 | exit 1 |
| 315 | fi |
| 316 | done |
| 317 | } |
| 318 | |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 319 | check_headers_in_cpp () { |
Peter Kolbus | 1bc1a4c | 2019-02-01 17:19:08 -0600 | [diff] [blame] | 320 | ls include/mbedtls | grep "\.h$" >headers.txt |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 321 | <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' | |
| 322 | sort | |
| 323 | diff headers.txt - |
| 324 | rm headers.txt |
| 325 | } |
| 326 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 327 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 328 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 329 | all_except=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 330 | no_armcc= |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 331 | |
Jaeden Amero | 9b90f2e | 2018-11-02 18:34:17 +0000 | [diff] [blame] | 332 | # Note that legacy options are ignored instead of being omitted from this |
| 333 | # list of options, so invocations that worked with previous version of |
| 334 | # all.sh will still run and work properly. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 335 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 336 | case "$1" in |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 337 | --append-outcome) append_outcome=1;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 338 | --armcc) no_armcc=;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 339 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 340 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 341 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 342 | --force|-f) FORCE=1;; |
| 343 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 344 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 345 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 346 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 347 | --help|-h) usage; exit;; |
| 348 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 349 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 350 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 351 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 352 | --no-append-outcome) append_outcome=0;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 353 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 354 | --no-force) FORCE=0;; |
| 355 | --no-keep-going) KEEP_GOING=0;; |
| 356 | --no-memory) MEMORY=0;; |
| 357 | --openssl) shift; OPENSSL="$1";; |
| 358 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 359 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 360 | --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 361 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
| 362 | --random-seed) unset SEED;; |
| 363 | --release-test|-r) SEED=1;; |
| 364 | --seed|-s) shift; SEED="$1";; |
| 365 | -*) |
| 366 | echo >&2 "Unknown option: $1" |
| 367 | echo >&2 "Run $0 --help for usage." |
| 368 | exit 120 |
| 369 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 370 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 371 | esac |
| 372 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 373 | done |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 374 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 375 | # With no list of components, run everything. |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 376 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 377 | all_except=1 |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 378 | fi |
| 379 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 380 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 381 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 382 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 383 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 384 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 385 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 386 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 387 | RUN_COMPONENTS= |
| 388 | for component in $SUPPORTED_COMPONENTS; do |
| 389 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 390 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 391 | fi |
| 392 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 393 | |
| 394 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 395 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 396 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 397 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 398 | pre_check_git () { |
| 399 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 400 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 401 | git checkout-index -f -q $CONFIG_H |
| 402 | cleanup |
| 403 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 404 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 405 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 406 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 407 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 408 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 409 | exit 1 |
| 410 | fi |
| 411 | |
Gilles Peskine | d1174cf | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 412 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 413 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 414 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 415 | echo "script as: $0 --force" |
| 416 | exit 1 |
| 417 | fi |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 418 | fi |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 419 | } |
| 420 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 421 | pre_setup_keep_going () { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 422 | failure_summary= |
| 423 | failure_count=0 |
| 424 | start_red= |
| 425 | end_color= |
| 426 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 427 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 428 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 429 | start_red=$(printf '\033[31m') |
| 430 | end_color=$(printf '\033[0m') |
| 431 | ;; |
| 432 | esac |
| 433 | fi |
| 434 | record_status () { |
| 435 | if "$@"; then |
| 436 | last_status=0 |
| 437 | else |
| 438 | last_status=$? |
| 439 | text="$current_section: $* -> $last_status" |
| 440 | failure_summary="$failure_summary |
| 441 | $text" |
| 442 | failure_count=$((failure_count + 1)) |
| 443 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 444 | fi |
| 445 | } |
| 446 | make () { |
| 447 | case "$*" in |
| 448 | *test|*check) |
| 449 | if [ $build_status -eq 0 ]; then |
| 450 | record_status command make "$@" |
| 451 | else |
| 452 | echo "(skipped because the build failed)" |
| 453 | fi |
| 454 | ;; |
| 455 | *) |
| 456 | record_status command make "$@" |
| 457 | build_status=$last_status |
| 458 | ;; |
| 459 | esac |
| 460 | } |
| 461 | final_report () { |
| 462 | if [ $failure_count -gt 0 ]; then |
| 463 | echo |
| 464 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 465 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 466 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 7c1258d | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 467 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 468 | elif [ -z "${1-}" ]; then |
| 469 | echo "SUCCESS :)" |
| 470 | fi |
| 471 | if [ -n "${1-}" ]; then |
| 472 | echo "Killed by SIG$1." |
| 473 | fi |
| 474 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 475 | } |
| 476 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 477 | if_build_succeeded () { |
| 478 | if [ $build_status -eq 0 ]; then |
| 479 | record_status "$@" |
| 480 | fi |
| 481 | } |
| 482 | |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 483 | # to be used instead of ! for commands run with |
| 484 | # record_status or if_build_succeeded |
| 485 | not() { |
| 486 | ! "$@" |
| 487 | } |
| 488 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 489 | pre_prepare_outcome_file () { |
| 490 | case "$MBEDTLS_TEST_OUTCOME_FILE" in |
| 491 | [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; |
| 492 | esac |
| 493 | if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then |
| 494 | rm -f "$MBEDTLS_TEST_OUTCOME_FILE" |
| 495 | fi |
| 496 | } |
| 497 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 498 | pre_print_configuration () { |
| 499 | msg "info: $0 configuration" |
| 500 | echo "MEMORY: $MEMORY" |
| 501 | echo "FORCE: $FORCE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 502 | echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 503 | echo "SEED: ${SEED-"UNSET"}" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 504 | echo |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 505 | echo "OPENSSL: $OPENSSL" |
| 506 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 507 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 508 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 509 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 510 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 511 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 512 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 513 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 514 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 515 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 516 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 517 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 518 | # Build the list of variables to pass to output_env.sh. |
| 519 | set env |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 520 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 521 | case " $RUN_COMPONENTS " in |
| 522 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 523 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 524 | # is a good enough approximation in practice. |
| 525 | *" test_"*) |
| 526 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 527 | # and ssl-opt.sh, we just export the variables they require. |
| 528 | export OPENSSL_CMD="$OPENSSL" |
| 529 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 530 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 531 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 532 | if [ -n "${SEED-}" ]; then |
| 533 | export SEED |
| 534 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 535 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 536 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 537 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 538 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 539 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 540 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 541 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 542 | ;; |
| 543 | esac |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 544 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 545 | case " $RUN_COMPONENTS " in |
| 546 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 547 | esac |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 548 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 549 | case " $RUN_COMPONENTS " in |
| 550 | *_arm_none_eabi_gcc[_\ ]*) check_tools "arm-none-eabi-gcc";; |
| 551 | esac |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 552 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 553 | case " $RUN_COMPONENTS " in |
| 554 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 555 | esac |
| 556 | |
| 557 | case " $RUN_COMPONENTS " in |
| 558 | *" test_zeroize "*) check_tools "gdb";; |
| 559 | esac |
| 560 | |
| 561 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 562 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 563 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 564 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
| 565 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 566 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 567 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR";; |
| 568 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 569 | |
| 570 | msg "info: output_env.sh" |
| 571 | case $RUN_COMPONENTS in |
| 572 | *_armcc*) |
| 573 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 574 | *) set "$@" RUN_ARMCC=0;; |
| 575 | esac |
| 576 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 577 | } |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 578 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 579 | |
| 580 | |
| 581 | ################################################################ |
| 582 | #### Basic checks |
| 583 | ################################################################ |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 584 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 585 | # |
| 586 | # Test Suites to be executed |
| 587 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 588 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 589 | # 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] | 590 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 591 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 592 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 593 | # |
| 594 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 595 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 596 | component_check_recursion () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 597 | msg "Check: recursion.pl" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 598 | record_status tests/scripts/recursion.pl library/*.c |
| 599 | } |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 600 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 601 | component_check_generated_files () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 602 | msg "Check: freshness of generated source files" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 603 | record_status tests/scripts/check-generated-files.sh |
| 604 | } |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 605 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 606 | component_check_doxy_blocks () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 607 | msg "Check: doxygen markup outside doxygen blocks" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 608 | record_status tests/scripts/check-doxy-blocks.pl |
| 609 | } |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 610 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 611 | component_check_files () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 612 | msg "Check: file sanity checks (permissions, encodings)" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 613 | record_status tests/scripts/check-files.py |
| 614 | } |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 615 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 616 | component_check_names () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 617 | msg "Check: declared and exported names (builds the library)" # < 3s |
Gilles Peskine | 13f97dc | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 618 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 619 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 620 | |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 621 | component_check_test_cases () { |
| 622 | msg "Check: test case descriptions" # < 1s |
| 623 | record_status tests/scripts/check-test-cases.py |
| 624 | } |
| 625 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 626 | component_check_doxygen_warnings () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 627 | msg "Check: doxygen warnings (builds the documentation)" # ~ 3s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 628 | record_status tests/scripts/doxygen.sh |
| 629 | } |
Manuel Pégourié-Gonnard | 1d552e7 | 2016-01-04 16:49:09 +0100 | [diff] [blame] | 630 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 631 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 632 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 633 | ################################################################ |
| 634 | #### Build and test many configurations and targets |
| 635 | ################################################################ |
| 636 | |
Gilles Peskine | 7832c9f | 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 |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 640 | # Disable fancy stuff |
Gilles Peskine | 717cd76 | 2019-09-27 20:21:11 +0200 | [diff] [blame] | 641 | SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 642 | unset MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 643 | |
| 644 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 645 | make test |
| 646 | |
| 647 | msg "selftest: make, default config (out-of-box)" # ~10s |
| 648 | programs/test/selftest |
Gilles Peskine | 717cd76 | 2019-09-27 20:21:11 +0200 | [diff] [blame] | 649 | |
| 650 | export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE" |
| 651 | unset SAVE_MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 652 | } |
| 653 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 654 | component_test_default_cmake_gcc_asan () { |
| 655 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 656 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 657 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 658 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 659 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 660 | make test |
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: ssl-opt.sh (ASan build)" # ~ 1 min |
| 663 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 664 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 665 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 666 | if_build_succeeded tests/compat.sh |
| 667 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 668 | |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 669 | component_test_full_cmake_gcc_asan () { |
| 670 | msg "build: full config, cmake, gcc, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 671 | scripts/config.py full |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 672 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 673 | make |
| 674 | |
| 675 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 676 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 677 | |
| 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 | |
| 685 | component_test_zlib_make() { |
| 686 | msg "build: zlib enabled, make" |
| 687 | scripts/config.py 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 | } |
| 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 | } |
| 707 | |
| 708 | component_test_zlib_cmake() { |
| 709 | msg "build: zlib enabled, cmake" |
| 710 | scripts/config.py 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 | } |
| 720 | support_test_zlib_cmake () { |
| 721 | support_test_zlib_make "$@" |
Manuel Pégourié-Gonnard | f2e2902 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 722 | } |
Manuel Pégourié-Gonnard | 95e0449 | 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 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 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 | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 732 | scripts/config.py set MBEDTLS_SSL_PROTO_SSL3 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 733 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 734 | make |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [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 | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 749 | scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 750 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 751 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [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 | } |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 759 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +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.py unset MBEDTLS_PEM_PARSE_C |
| 763 | scripts/config.py unset MBEDTLS_FS_IO |
| 764 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem |
| 765 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS |
| 766 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 767 | make |
| 768 | |
| 769 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 770 | make test |
| 771 | |
| 772 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
| 773 | if_build_succeeded tests/ssl-opt.sh |
| 774 | } |
| 775 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 776 | component_test_rsa_no_crt () { |
| 777 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 778 | scripts/config.py set MBEDTLS_RSA_NO_CRT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 779 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 780 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 781 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 782 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 783 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 784 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 785 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 786 | if_build_succeeded tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 787 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 788 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 789 | if_build_succeeded tests/compat.sh -t RSA |
| 790 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 791 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 792 | component_test_new_ecdh_context () { |
| 793 | msg "build: new ECDH context (ASan build)" # ~ 6 min |
| 794 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 795 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 796 | make |
| 797 | |
| 798 | msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 799 | make test |
| 800 | |
| 801 | msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 802 | if_build_succeeded tests/ssl-opt.sh -f ECDH |
| 803 | |
| 804 | msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 805 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 806 | if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4' |
| 807 | } |
| 808 | |
| 809 | component_test_everest () { |
| 810 | msg "build: Everest ECDH context (ASan build)" # ~ 6 min |
| 811 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 812 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 813 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 814 | make |
| 815 | |
| 816 | msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 817 | make test |
| 818 | |
| 819 | msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 820 | if_build_succeeded tests/ssl-opt.sh -f ECDH |
| 821 | |
| 822 | msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 823 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 824 | if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4' |
| 825 | } |
| 826 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 827 | component_test_small_ssl_out_content_len () { |
| 828 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 829 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 830 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 831 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 832 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 833 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 834 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
| 835 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" |
| 836 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 837 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 838 | component_test_small_ssl_in_content_len () { |
| 839 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 840 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 841 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 842 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 843 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 844 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 845 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
| 846 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment" |
| 847 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 848 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 849 | component_test_small_ssl_dtls_max_buffering () { |
| 850 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 851 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 852 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 853 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 854 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 855 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
| 856 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
| 857 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 858 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 859 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 860 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 861 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 862 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 863 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 864 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 865 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
| 866 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
| 867 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 868 | |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 869 | component_test_psa_collect_statuses () { |
| 870 | msg "build+test: psa_collect_statuses" # ~30s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 871 | scripts/config.py full |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 872 | record_status tests/scripts/psa_collect_statuses.py |
| 873 | # Check that psa_crypto_init() succeeded at least once |
| 874 | record_status grep -q '^0:psa_crypto_init:' tests/statuses.log |
| 875 | rm -f tests/statuses.log |
| 876 | } |
| 877 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 878 | component_test_full_cmake_clang () { |
| 879 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 880 | scripts/config.py full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 881 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 882 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 883 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 884 | msg "test: main suites (full config, clang)" # ~ 5s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 885 | make test |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 886 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 887 | msg "test: psa_constant_names (full config, clang)" # ~ 1s |
Darryl Green | 45010a3 | 2019-02-06 13:43:58 +0000 | [diff] [blame] | 888 | record_status tests/scripts/test_psa_constant_names.py |
Gilles Peskine | 69e8f7f | 2020-02-26 19:51:43 +0100 | [diff] [blame] | 889 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 890 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
| 891 | 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] | 892 | |
Andres Amaya Garcia | 2dadab7 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 893 | msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min |
Andres Amaya Garcia | 419bd00 | 2019-02-19 20:20:57 +0000 | [diff] [blame] | 894 | 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] | 895 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 896 | msg "test: compat.sh ARIA + ChachaPoly" |
| 897 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 898 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 899 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 900 | component_build_deprecated () { |
| 901 | msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 902 | scripts/config.py full |
| 903 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 904 | # Build with -O -Wextra to catch a maximum of issues. |
| 905 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 906 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 907 | |
Gilles Peskine | 841b14b | 2019-11-26 17:37:37 +0100 | [diff] [blame] | 908 | msg "test: make, full config + DEPRECATED_WARNING, expect warnings" # ~ 30s |
| 909 | make -C tests clean |
| 910 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -DMBEDTLS_TEST_DEPRECATED' tests |
| 911 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 912 | msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s |
| 913 | # No cleanup, just tweak the configuration and rebuild |
| 914 | make clean |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 915 | scripts/config.py unset MBEDTLS_DEPRECATED_WARNING |
| 916 | scripts/config.py set MBEDTLS_DEPRECATED_REMOVED |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 917 | # Build with -O -Wextra to catch a maximum of issues. |
| 918 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 919 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
| 920 | } |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 921 | |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 922 | # Check that the specified libraries exist and are empty. |
| 923 | are_empty_libraries () { |
| 924 | nm "$@" >/dev/null 2>/dev/null |
| 925 | ! nm "$@" 2>/dev/null | grep -v ':$' | grep . |
| 926 | } |
| 927 | |
| 928 | component_build_crypto_default () { |
| 929 | msg "build: make, crypto only" |
| 930 | scripts/config.py crypto |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 931 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 932 | if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 933 | } |
| 934 | |
| 935 | component_build_crypto_full () { |
| 936 | msg "build: make, crypto only, full config" |
| 937 | scripts/config.py crypto_full |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 938 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 939 | if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 940 | } |
| 941 | |
| 942 | component_build_crypto_baremetal () { |
| 943 | msg "build: make, crypto only, baremetal config" |
| 944 | scripts/config.py crypto_baremetal |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 945 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 946 | if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 947 | } |
| 948 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 949 | component_test_depends_curves () { |
| 950 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 951 | record_status tests/scripts/curves.pl |
| 952 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 953 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 954 | component_test_depends_hashes () { |
| 955 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 956 | record_status tests/scripts/depends-hashes.pl |
| 957 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 958 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 959 | component_test_depends_pkalgs () { |
| 960 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 961 | record_status tests/scripts/depends-pkalgs.pl |
| 962 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 963 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 964 | component_build_key_exchanges () { |
| 965 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 966 | record_status tests/scripts/key-exchanges.pl |
| 967 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 968 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 969 | component_build_default_make_gcc_and_cxx () { |
| 970 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 971 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 972 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 973 | msg "test: verify header list in cpp_dummy_build.cpp" |
| 974 | record_status check_headers_in_cpp |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 975 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 976 | msg "build: Unix make, incremental g++" |
| 977 | make TEST_CPP=1 |
| 978 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 979 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 980 | component_test_no_use_psa_crypto_full_cmake_asan() { |
| 981 | # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh |
Gilles Peskine | dc3a179 | 2019-09-03 11:42:04 +0200 | [diff] [blame] | 982 | msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 983 | scripts/config.py full |
| 984 | scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC |
| 985 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 986 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 987 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
| 988 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Manuel Pégourié-Gonnard | d8167e8 | 2019-02-01 11:12:52 +0100 | [diff] [blame] | 989 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 990 | make |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 991 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 992 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 993 | make test |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 994 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 995 | msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 996 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 997 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 998 | msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 999 | if_build_succeeded tests/compat.sh |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 1000 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1001 | msg "test: compat.sh RC4, DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1002 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR' |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1003 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1004 | msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1005 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 1006 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1007 | |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1008 | component_test_check_params_functionality () { |
| 1009 | msg "build+test: MBEDTLS_CHECK_PARAMS functionality" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1010 | scripts/config.py full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1011 | # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed(). |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1012 | scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1013 | # Only build and run tests. Do not build sample programs, because |
| 1014 | # they don't have a mbedtls_param_failed() function. |
| 1015 | make CC=gcc CFLAGS='-Werror -O1' lib test |
| 1016 | } |
| 1017 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1018 | component_test_check_params_without_platform () { |
| 1019 | msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1020 | scripts/config.py full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1021 | # Keep MBEDTLS_PARAM_FAILED as assert. |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1022 | scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT |
| 1023 | scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT |
| 1024 | scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1025 | scripts/config.py unset MBEDTLS_PLATFORM_MEMORY |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame^] | 1026 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1027 | scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1028 | scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1029 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1030 | scripts/config.py unset MBEDTLS_PLATFORM_C |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1031 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1032 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1033 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1034 | component_test_check_params_silent () { |
| 1035 | msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1036 | scripts/config.py full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1037 | # Set MBEDTLS_PARAM_FAILED to nothing. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1038 | sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" |
| 1039 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1040 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1041 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1042 | component_test_no_platform () { |
| 1043 | # Full configuration build, without platform support, file IO and net sockets. |
| 1044 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 1045 | # IO, it should catch missing '#include <stdio.h>' |
| 1046 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1047 | scripts/config.py full |
| 1048 | scripts/config.py unset MBEDTLS_PLATFORM_C |
| 1049 | scripts/config.py unset MBEDTLS_NET_C |
| 1050 | scripts/config.py unset MBEDTLS_PLATFORM_MEMORY |
| 1051 | scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1052 | scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1053 | scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1054 | scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT |
| 1055 | scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame^] | 1056 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1057 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1058 | scripts/config.py unset MBEDTLS_FS_IO |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1059 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1060 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 1061 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1062 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 1063 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1064 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 1065 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1066 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 1067 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1068 | component_build_no_std_function () { |
| 1069 | # catch compile bugs in _uninit functions |
| 1070 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1071 | scripts/config.py full |
| 1072 | scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 1073 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame^] | 1074 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1075 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1076 | } |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 1077 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1078 | component_build_no_ssl_srv () { |
| 1079 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1080 | scripts/config.py full |
| 1081 | scripts/config.py unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1082 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1083 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1084 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1085 | component_build_no_ssl_cli () { |
| 1086 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1087 | scripts/config.py full |
| 1088 | scripts/config.py unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1089 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1090 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1091 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1092 | component_build_no_sockets () { |
| 1093 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 1094 | # as that requires a POSIX platform (which isn't the same as C99). |
| 1095 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1096 | scripts/config.py full |
| 1097 | scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 1098 | scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1099 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1100 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 1101 | |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1102 | component_test_memory_buffer_allocator_backtrace () { |
| 1103 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1104 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1105 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1106 | scripts/config.py set MBEDTLS_MEMORY_BACKTRACE |
| 1107 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1108 | CC=gcc cmake . |
| 1109 | make |
| 1110 | |
| 1111 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1112 | make test |
| 1113 | } |
| 1114 | |
| 1115 | component_test_memory_buffer_allocator () { |
| 1116 | msg "build: default config with memory buffer allocator" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1117 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1118 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1119 | CC=gcc cmake . |
| 1120 | make |
| 1121 | |
| 1122 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1123 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1124 | |
| 1125 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1126 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 1127 | if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1128 | } |
| 1129 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1130 | component_test_no_max_fragment_length () { |
| 1131 | # Run max fragment length tests with MFL disabled |
| 1132 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1133 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1134 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1135 | make |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1136 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1137 | msg "test: ssl-opt.sh, MFL-related tests" |
| 1138 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
| 1139 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 1140 | |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1141 | component_test_asan_remove_peer_certificate () { |
| 1142 | msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1143 | scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1144 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1145 | make |
| 1146 | |
| 1147 | msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1148 | make test |
| 1149 | |
| 1150 | msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1151 | if_build_succeeded tests/ssl-opt.sh |
| 1152 | |
| 1153 | msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1154 | if_build_succeeded tests/compat.sh |
| 1155 | } |
| 1156 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1157 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 1158 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1159 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1160 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1161 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1162 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1163 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1164 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1165 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
| 1166 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer" |
| 1167 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1168 | |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 1169 | component_test_variable_ssl_in_out_buffer_len () { |
| 1170 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)" |
| 1171 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1172 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1173 | make |
| 1174 | |
| 1175 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 1176 | make test |
| 1177 | |
| 1178 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 1179 | if_build_succeeded tests/ssl-opt.sh |
| 1180 | |
| 1181 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 1182 | if_build_succeeded tests/compat.sh |
| 1183 | } |
| 1184 | |
| 1185 | component_test_variable_ssl_in_out_buffer_len_CID () { |
| 1186 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)" |
| 1187 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1188 | scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID |
| 1189 | |
| 1190 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1191 | make |
| 1192 | |
| 1193 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID" |
| 1194 | make test |
| 1195 | |
| 1196 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" |
| 1197 | if_build_succeeded tests/ssl-opt.sh |
| 1198 | |
| 1199 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" |
| 1200 | if_build_succeeded tests/compat.sh |
| 1201 | } |
| 1202 | |
| 1203 | component_test_variable_ssl_in_out_buffer_len_record_splitting () { |
| 1204 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)" |
| 1205 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1206 | scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING |
| 1207 | |
| 1208 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1209 | make |
| 1210 | |
| 1211 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING" |
| 1212 | make test |
| 1213 | |
| 1214 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled" |
| 1215 | if_build_succeeded tests/ssl-opt.sh |
| 1216 | |
| 1217 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled" |
| 1218 | if_build_succeeded tests/compat.sh |
| 1219 | } |
| 1220 | |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 1221 | component_test_ssl_alloc_buffer_and_mfl () { |
| 1222 | msg "build: default config with memory buffer allocator and MFL extension" |
| 1223 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1224 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1225 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
| 1226 | scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1227 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1228 | CC=gcc cmake . |
| 1229 | make |
| 1230 | |
| 1231 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
| 1232 | make test |
| 1233 | |
| 1234 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
| 1235 | if_build_succeeded tests/ssl-opt.sh -f "Handshake memory usage" |
| 1236 | } |
| 1237 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1238 | component_test_when_no_ciphersuites_have_mac () { |
| 1239 | msg "build: when no ciphersuites have MAC" |
| 1240 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
| 1241 | scripts/config.py unset MBEDTLS_ARC4_C |
| 1242 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
| 1243 | make |
| 1244 | |
| 1245 | msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 1246 | make test |
| 1247 | |
| 1248 | msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 1249 | if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' |
| 1250 | } |
| 1251 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1252 | component_test_null_entropy () { |
| 1253 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1254 | scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY |
| 1255 | scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 1256 | scripts/config.py set MBEDTLS_ENTROPY_C |
| 1257 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame^] | 1258 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1259 | scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 1260 | scripts/config.py unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 5fa32a7 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 1261 | 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] | 1262 | make |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1263 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1264 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 1265 | make test |
| 1266 | } |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1267 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1268 | component_test_platform_calloc_macro () { |
| 1269 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1270 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1271 | scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 1272 | scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1273 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1274 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1275 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1276 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 1277 | make test |
| 1278 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1279 | |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1280 | component_test_malloc_0_null () { |
| 1281 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 1282 | scripts/config.py full |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1283 | make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1284 | |
| 1285 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 1286 | make test |
| 1287 | |
| 1288 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 1289 | # Just the calloc selftest. "make test" ran the others as part of the |
| 1290 | # test suites. |
| 1291 | if_build_succeeded programs/test/selftest calloc |
Gilles Peskine | 765d240 | 2020-02-11 18:26:34 +0100 | [diff] [blame] | 1292 | |
| 1293 | msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)" |
| 1294 | # Run a subset of the tests. The choice is a balance between coverage |
| 1295 | # and time (including time indirectly wasted due to flaky tests). |
| 1296 | # The current choice is to skip tests whose description includes |
| 1297 | # "proxy", which is an approximation of skipping tests that use the |
| 1298 | # UDP proxy, which tend to be slower and flakier. |
| 1299 | if_build_succeeded tests/ssl-opt.sh -e 'proxy' |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1300 | } |
| 1301 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1302 | component_test_aes_fewer_tables () { |
| 1303 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1304 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1305 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1306 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1307 | msg "test: AES_FEWER_TABLES" |
| 1308 | make test |
| 1309 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1310 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1311 | component_test_aes_rom_tables () { |
| 1312 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1313 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1314 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1315 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1316 | msg "test: AES_ROM_TABLES" |
| 1317 | make test |
| 1318 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1319 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1320 | component_test_aes_fewer_tables_and_rom_tables () { |
| 1321 | msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1322 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
| 1323 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1324 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1325 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1326 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 1327 | make test |
| 1328 | } |
| 1329 | |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1330 | component_test_ctr_drbg_aes_256_sha_256 () { |
| 1331 | msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 1332 | scripts/config.py full |
| 1333 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1334 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1335 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1336 | make |
| 1337 | |
| 1338 | msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 1339 | make test |
| 1340 | } |
| 1341 | |
| 1342 | component_test_ctr_drbg_aes_128_sha_512 () { |
| 1343 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 1344 | scripts/config.py full |
| 1345 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1346 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1347 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1348 | make |
| 1349 | |
| 1350 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
| 1351 | make test |
| 1352 | } |
| 1353 | |
| 1354 | component_test_ctr_drbg_aes_128_sha_256 () { |
| 1355 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 1356 | scripts/config.py full |
| 1357 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1358 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
| 1359 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1360 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1361 | make |
| 1362 | |
| 1363 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 1364 | make test |
| 1365 | } |
| 1366 | |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 1367 | component_test_se_default () { |
| 1368 | msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1369 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1370 | make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 1371 | |
| 1372 | msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
| 1373 | make test |
| 1374 | } |
| 1375 | |
| 1376 | component_test_se_full () { |
| 1377 | msg "build: full config + MBEDTLS_PSA_CRYPTO_SE_C" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1378 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1379 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1380 | make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 1381 | |
| 1382 | msg "test: full config + MBEDTLS_PSA_CRYPTO_SE_C" |
| 1383 | make test |
| 1384 | } |
| 1385 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1386 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1387 | msg "build/test: make shared" # ~ 40s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1388 | make SHARED=1 all check |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1389 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1390 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 1391 | |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1392 | component_test_cmake_shared () { |
| 1393 | msg "build/test: cmake shared" # ~ 2min |
| 1394 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 1395 | make |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1396 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1397 | make test |
| 1398 | } |
| 1399 | |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1400 | test_build_opt () { |
| 1401 | info=$1 cc=$2; shift 2 |
| 1402 | for opt in "$@"; do |
| 1403 | msg "build/test: $cc $opt, $info" # ~ 30s |
| 1404 | make CC="$cc" CFLAGS="$opt -Wall -Wextra -Werror" |
| 1405 | # We're confident enough in compilers to not run _all_ the tests, |
| 1406 | # but at least run the unit tests. In particular, runs with |
| 1407 | # optimizations use inline assembly whereas runs with -O0 |
| 1408 | # skip inline assembly. |
| 1409 | make test # ~30s |
| 1410 | make clean |
| 1411 | done |
| 1412 | } |
| 1413 | |
| 1414 | component_test_clang_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 1415 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1416 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 1417 | } |
| 1418 | |
| 1419 | component_test_gcc_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 1420 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1421 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 1422 | } |
| 1423 | |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1424 | component_build_mbedtls_config_file () { |
| 1425 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 1426 | # Use the full config so as to catch a maximum of places where |
| 1427 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1428 | scripts/config.py full |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1429 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 1430 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 1431 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 1432 | rm -f full_config.h |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1433 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 1434 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1435 | component_test_m32_o0 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1436 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 1437 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1438 | scripts/config.py full |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1439 | 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] | 1440 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1441 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 1442 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1443 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1444 | support_test_m32_o0 () { |
| 1445 | case $(uname -m) in |
| 1446 | *64*) true;; |
| 1447 | *) false;; |
| 1448 | esac |
| 1449 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1450 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1451 | component_test_m32_o1 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1452 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 1453 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1454 | scripts/config.py full |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1455 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1456 | |
| 1457 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1458 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1459 | |
| 1460 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 1461 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1462 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1463 | support_test_m32_o1 () { |
| 1464 | support_test_m32_o0 "$@" |
| 1465 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1466 | |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 1467 | component_test_m32_everest () { |
| 1468 | msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1469 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 1470 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1471 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 1472 | |
| 1473 | msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1474 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1475 | |
| 1476 | msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 1477 | if_build_succeeded tests/ssl-opt.sh -f ECDH |
| 1478 | |
| 1479 | msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 1480 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 1481 | if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4' |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 1482 | } |
| 1483 | support_test_m32_everest () { |
| 1484 | support_test_m32_o0 "$@" |
| 1485 | } |
| 1486 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1487 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1488 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1489 | scripts/config.py full |
Gilles Peskine | 5d26e7c | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 1490 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1491 | |
| 1492 | msg "test: 64-bit ILP32, make, gcc" |
| 1493 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1494 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1495 | support_test_mx32 () { |
| 1496 | case $(uname -m) in |
| 1497 | amd64|x86_64) true;; |
| 1498 | *) false;; |
| 1499 | esac |
| 1500 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1501 | |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1502 | component_test_min_mpi_window_size () { |
| 1503 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1504 | scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1 |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1505 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1506 | make |
| 1507 | |
| 1508 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 1509 | make test |
| 1510 | } |
| 1511 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1512 | component_test_have_int32 () { |
| 1513 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1514 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 1515 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1516 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1517 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1518 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1519 | msg "test: gcc, force 32-bit bignum limbs" |
| 1520 | make test |
| 1521 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 1522 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1523 | component_test_have_int64 () { |
| 1524 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1525 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 1526 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1527 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1528 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 1529 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1530 | msg "test: gcc, force 64-bit bignum limbs" |
| 1531 | make test |
| 1532 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1533 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1534 | component_test_no_udbl_division () { |
| 1535 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1536 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1537 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1538 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1539 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1540 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 1541 | make test |
| 1542 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1543 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1544 | component_test_no_64bit_multiplication () { |
| 1545 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1546 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1547 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1548 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1549 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1550 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 1551 | make test |
| 1552 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1553 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1554 | component_build_arm_none_eabi_gcc () { |
| 1555 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1556 | scripts/config.py baremetal |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1557 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 1558 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1559 | |
Gilles Peskine | 2c897d7 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1560 | component_build_arm_none_eabi_gcc_arm5vte () { |
Gilles Peskine | 8a52af9 | 2019-08-08 16:09:02 +0200 | [diff] [blame] | 1561 | msg "build: arm-none-eabi-gcc -march=arm5vte, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1562 | scripts/config.py baremetal |
Gilles Peskine | 2c897d7 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1563 | # Build for a target platform that's close to what Debian uses |
| 1564 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 1565 | # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. |
| 1566 | # It would be better to build with arm-linux-gnueabi-gcc but |
| 1567 | # we don't have that on our CI at this time. |
Gilles Peskine | 8a52af9 | 2019-08-08 16:09:02 +0200 | [diff] [blame] | 1568 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib |
Gilles Peskine | 93e4e03 | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 1569 | } |
| 1570 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1571 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
| 1572 | msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1573 | scripts/config.py baremetal |
| 1574 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1575 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 1576 | echo "Checking that software 64-bit division is not required" |
| 1577 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
| 1578 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1579 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1580 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
| 1581 | msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1582 | scripts/config.py baremetal |
| 1583 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1584 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib |
| 1585 | echo "Checking that software 64-bit multiplication is not required" |
| 1586 | if_build_succeeded not grep __aeabi_lmul library/*.o |
| 1587 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1588 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1589 | component_build_armcc () { |
| 1590 | msg "build: ARM Compiler 5, make" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1591 | scripts/config.py baremetal |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1592 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1593 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 1594 | make clean |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1595 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1596 | # ARM Compiler 6 - Target ARMv7-A |
| 1597 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1598 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1599 | # ARM Compiler 6 - Target ARMv7-M |
| 1600 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1601 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1602 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1603 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1604 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1605 | # ARM Compiler 6 - Target ARMv8-M |
| 1606 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1607 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1608 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1609 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1610 | } |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1611 | |
Manuel Pégourié-Gonnard | dd8807f | 2020-02-26 09:56:27 +0100 | [diff] [blame] | 1612 | component_build_ssl_hw_record_accel() { |
| 1613 | msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled" |
| 1614 | scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL |
| 1615 | make CFLAGS='-Werror -O1' |
| 1616 | } |
| 1617 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1618 | component_test_allow_sha1 () { |
| 1619 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1620 | scripts/config.py set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1621 | make CFLAGS='-Werror -Wall -Wextra' |
| 1622 | msg "test: allow SHA1 in certificates by default" |
| 1623 | make test |
| 1624 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
| 1625 | } |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 1626 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1627 | component_build_mingw () { |
| 1628 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1629 | 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 |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 1630 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1631 | # note Make tests only builds the tests, but doesn't run them |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1632 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1633 | make WINDOWS_BUILD=1 clean |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 1634 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1635 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1636 | 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 |
| 1637 | 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 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1638 | make WINDOWS_BUILD=1 clean |
| 1639 | } |
Jaeden Amero | 117b8a4 | 2019-04-17 15:19:26 +0100 | [diff] [blame] | 1640 | support_build_mingw() { |
| 1641 | case $(i686-w64-mingw32-gcc -dumpversion) in |
| 1642 | [0-5]*) false;; |
| 1643 | *) true;; |
| 1644 | esac |
| 1645 | } |
Simon Butcher | 91aef33 | 2016-11-17 09:20:50 +0000 | [diff] [blame] | 1646 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1647 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1648 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1649 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1650 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1651 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 1652 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1653 | msg "test: main suites (MSan)" # ~ 10s |
| 1654 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1655 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1656 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1657 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1658 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1659 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1660 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1661 | if [ "$MEMORY" -gt 0 ]; then |
| 1662 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1663 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1664 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1665 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1666 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1667 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1668 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1669 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1670 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1671 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1672 | msg "test: main suites valgrind (Release)" |
| 1673 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1674 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1675 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1676 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1677 | if [ "$MEMORY" -gt 0 ]; then |
| 1678 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1679 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1680 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1681 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1682 | if [ "$MEMORY" -gt 1 ]; then |
| 1683 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1684 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1685 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1686 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1687 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1688 | component_test_cmake_out_of_source () { |
| 1689 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1690 | MBEDTLS_ROOT_DIR="$PWD" |
| 1691 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1692 | cd "$OUT_OF_SOURCE_DIR" |
| 1693 | cmake "$MBEDTLS_ROOT_DIR" |
| 1694 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1695 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1696 | msg "test: cmake 'out-of-source' build" |
| 1697 | make test |
| 1698 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 1699 | # Also ensure that there are no error messages such as |
| 1700 | # "No such file or directory", which would indicate that some required |
| 1701 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 1702 | # may exit with status 0 but emit errors). |
| 1703 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 1704 | if [ -s ssl-opt.err ]; then |
| 1705 | cat ssl-opt.err >&2 |
| 1706 | record_status [ ! -s ssl-opt.err ] |
| 1707 | rm ssl-opt.err |
| 1708 | fi |
| 1709 | cd "$MBEDTLS_ROOT_DIR" |
| 1710 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1711 | unset MBEDTLS_ROOT_DIR |
| 1712 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1713 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 1714 | component_test_cmake_as_subdirectory () { |
| 1715 | msg "build: cmake 'as-subdirectory' build" |
| 1716 | MBEDTLS_ROOT_DIR="$PWD" |
| 1717 | |
| 1718 | cd programs/test/cmake_subproject |
| 1719 | cmake . |
| 1720 | make |
| 1721 | if_build_succeeded ./cmake_subproject |
| 1722 | |
| 1723 | cd "$MBEDTLS_ROOT_DIR" |
| 1724 | unset MBEDTLS_ROOT_DIR |
| 1725 | } |
| 1726 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1727 | component_test_zeroize () { |
| 1728 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 1729 | # different combinations of compilers and optimization flags by using an |
| 1730 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 1731 | # system in all cases that the script fails, so we must manually search the |
| 1732 | # output to check whether the pass string is present and no failure strings |
| 1733 | # were printed. |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1734 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1735 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 1736 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 1737 | gdb_disable_aslr= |
| 1738 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 1739 | gdb_disable_aslr='set disable-randomization off' |
| 1740 | fi |
| 1741 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1742 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1743 | for compiler in clang gcc; do |
| 1744 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 1745 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1746 | 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] | 1747 | if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log |
| 1748 | if_build_succeeded not grep -i "error" test_zeroize.log |
| 1749 | rm -f test_zeroize.log |
| 1750 | make clean |
| 1751 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 1752 | done |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 1753 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1754 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1755 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1756 | |
Gilles Peskine | aad2ebd | 2019-02-25 20:26:06 +0100 | [diff] [blame] | 1757 | support_check_python_files () { |
Simon Butcher | e30d03e | 2020-03-16 11:30:46 +0000 | [diff] [blame] | 1758 | # Find the installed version of Pylint. Installed as a distro package this can |
| 1759 | # be pylint3 and as a PEP egg, pylint. |
| 1760 | if type pylint >/dev/null 2>/dev/null || type pylint3 >/dev/null 2>/dev/null; then |
| 1761 | true; |
| 1762 | else |
| 1763 | false; |
| 1764 | fi |
Gilles Peskine | aad2ebd | 2019-02-25 20:26:06 +0100 | [diff] [blame] | 1765 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1766 | component_check_python_files () { |
| 1767 | msg "Lint: Python scripts" |
| 1768 | record_status tests/scripts/check-python-files.sh |
| 1769 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1770 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1771 | component_check_generate_test_code () { |
| 1772 | msg "uint test: generate_test_code.py" |
| 1773 | record_status ./tests/scripts/test_generate_test_code.py |
| 1774 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1775 | |
| 1776 | ################################################################ |
| 1777 | #### Termination |
| 1778 | ################################################################ |
| 1779 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1780 | post_report () { |
| 1781 | msg "Done, cleaning up" |
| 1782 | cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1783 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1784 | final_report |
| 1785 | } |
| 1786 | |
| 1787 | |
| 1788 | |
| 1789 | ################################################################ |
| 1790 | #### Run all the things |
| 1791 | ################################################################ |
| 1792 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1793 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1794 | run_component () { |
Gilles Peskine | 608953e | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1795 | # Back up the configuration in case the component modifies it. |
| 1796 | # The cleanup function will restore it. |
| 1797 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1798 | current_component="$1" |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 1799 | export MBEDTLS_TEST_CONFIGURATION="$current_component" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 1800 | |
| 1801 | # Unconditionally create a seedfile that's sufficiently long. |
| 1802 | # Do this before each component, because a previous component may |
| 1803 | # have messed it up or shortened it. |
| 1804 | dd if=/dev/urandom of=./tests/seedfile bs=64 count=1 |
| 1805 | |
| 1806 | # Run the component code. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1807 | "$@" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 1808 | |
| 1809 | # Restore the build tree to a clean state. |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1810 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1811 | } |
| 1812 | |
| 1813 | # Preliminary setup |
| 1814 | pre_check_environment |
| 1815 | pre_initialize_variables |
| 1816 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 1817 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1818 | pre_check_git |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 1819 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1820 | build_status=0 |
| 1821 | if [ $KEEP_GOING -eq 1 ]; then |
| 1822 | pre_setup_keep_going |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 1823 | else |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1824 | record_status () { |
| 1825 | "$@" |
| 1826 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1827 | fi |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 1828 | pre_prepare_outcome_file |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1829 | pre_print_configuration |
| 1830 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1831 | cleanup |
| 1832 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 1833 | # Run the requested tests. |
| 1834 | for component in $RUN_COMPONENTS; do |
| 1835 | run_component "component_$component" |
| 1836 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1837 | |
| 1838 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1839 | post_report |