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