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