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