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