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 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 5 | # Copyright (c) 2014-2017, ARM Limited, All Rights Reserved |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 7 | # |
| 8 | # This file is provided under the Apache License 2.0, or the |
| 9 | # GNU General Public License v2.0 or later. |
| 10 | # |
| 11 | # ********** |
| 12 | # Apache License 2.0: |
Bence Szépkúti | 51b41d5 | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 13 | # |
| 14 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 15 | # not use this file except in compliance with the License. |
| 16 | # You may obtain a copy of the License at |
| 17 | # |
| 18 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | # |
| 20 | # Unless required by applicable law or agreed to in writing, software |
| 21 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 22 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 23 | # See the License for the specific language governing permissions and |
| 24 | # limitations under the License. |
| 25 | # |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 26 | # ********** |
| 27 | # |
| 28 | # ********** |
| 29 | # GNU General Public License v2.0 or later: |
| 30 | # |
| 31 | # This program is free software; you can redistribute it and/or modify |
| 32 | # it under the terms of the GNU General Public License as published by |
| 33 | # the Free Software Foundation; either version 2 of the License, or |
| 34 | # (at your option) any later version. |
| 35 | # |
| 36 | # This program is distributed in the hope that it will be useful, |
| 37 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 38 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 39 | # GNU General Public License for more details. |
| 40 | # |
| 41 | # You should have received a copy of the GNU General Public License along |
| 42 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 43 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 44 | # |
| 45 | # ********** |
| 46 | # |
Bence Szépkúti | 51b41d5 | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 47 | # This file is part of Mbed TLS (https://tls.mbed.org) |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 48 | |
| 49 | |
| 50 | |
| 51 | ################################################################ |
| 52 | #### Documentation |
| 53 | ################################################################ |
| 54 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 55 | # Purpose |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 56 | # ------- |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 57 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 58 | # To run all tests possible or available on the platform. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 59 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 60 | # Notes for users |
| 61 | # --------------- |
| 62 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 63 | # Warning: the test is destructive. It includes various build modes and |
| 64 | # configurations, and can and will arbitrarily change the current CMake |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 65 | # configuration. The following files must be committed into git: |
| 66 | # * include/mbedtls/config.h |
| 67 | # * Makefile, library/Makefile, programs/Makefile, tests/Makefile |
| 68 | # After running this script, the CMake cache will be lost and CMake |
| 69 | # will no longer be initialised. |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 70 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 71 | # The script assumes the presence of a number of tools: |
| 72 | # * Basic Unix tools (Windows users note: a Unix-style find must be before |
| 73 | # the Windows find in the PATH) |
| 74 | # * Perl |
| 75 | # * GNU Make |
| 76 | # * CMake |
| 77 | # * 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] | 78 | # * G++ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 79 | # * arm-gcc and mingw-gcc |
| 80 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 81 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
| 82 | # interoperability tests. If they don't support SSLv3 then a legacy |
| 83 | # version of these tools must be present as well (search for LEGACY |
| 84 | # below). |
| 85 | # See the invocation of check_tools below for details. |
| 86 | # |
| 87 | # This script must be invoked from the toplevel directory of a git |
| 88 | # working copy of Mbed TLS. |
| 89 | # |
| 90 | # Note that the output is not saved. You may want to run |
| 91 | # script -c tests/scripts/all.sh |
| 92 | # or |
| 93 | # tests/scripts/all.sh >all.log 2>&1 |
| 94 | # |
| 95 | # Notes for maintainers |
| 96 | # --------------------- |
| 97 | # |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 98 | # The bulk of the code is organized into functions that follow one of the |
| 99 | # following naming conventions: |
| 100 | # * pre_XXX: things to do before running the tests, in order. |
| 101 | # * component_XXX: independent components. They can be run in any order. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 102 | # * component_check_XXX: quick tests that aren't worth parallelizing. |
| 103 | # * component_build_XXX: build things but don't run them. |
| 104 | # * component_test_XXX: build and test. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 105 | # * support_XXX: if support_XXX exists and returns false then |
| 106 | # component_XXX is not run by default. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 107 | # * post_XXX: things to do after running the tests. |
| 108 | # * other: miscellaneous support functions. |
| 109 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 110 | # Each component must start by invoking `msg` with a short informative message. |
| 111 | # |
| 112 | # The framework performs some cleanup tasks after each component. This |
| 113 | # means that components can assume that the working directory is in a |
| 114 | # cleaned-up state, and don't need to perform the cleanup themselves. |
| 115 | # * Run `make clean`. |
| 116 | # * Restore `include/mbedtks/config.h` from a backup made before running |
| 117 | # the component. |
| 118 | # * Check out `Makefile`, `library/Makefile`, `programs/Makefile` and |
| 119 | # `tests/Makefile` from git. This cleans up after an in-tree use of |
| 120 | # CMake. |
| 121 | # |
| 122 | # Any command that is expected to fail must be protected so that the |
| 123 | # script keeps running in --keep-going mode despite `set -e`. In keep-going |
| 124 | # mode, if a protected command fails, this is logged as a failure and the |
| 125 | # script will exit with a failure status once it has run all components. |
| 126 | # Commands can be protected in any of the following ways: |
| 127 | # * `make` is a function which runs the `make` command with protection. |
| 128 | # Note that you must write `make VAR=value`, not `VAR=value make`, |
| 129 | # because the `VAR=value make` syntax doesn't work with functions. |
| 130 | # * Put `report_status` before the command to protect it. |
| 131 | # * Put `if_build_successful` before a command. This protects it, and |
| 132 | # additionally skips it if a prior invocation of `make` in the same |
| 133 | # component failed. |
| 134 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 135 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 136 | # have to be exact, but in general you should add slower tests towards |
| 137 | # the end and fast checks near the beginning. |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 138 | |
| 139 | |
| 140 | |
| 141 | ################################################################ |
| 142 | #### Initialization and command line parsing |
| 143 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 144 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 145 | # Abort on errors (and uninitialised variables) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 146 | set -eu |
| 147 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 148 | pre_check_environment () { |
Gilles Peskine | a16c2b1 | 2019-01-06 19:58:02 +0000 | [diff] [blame] | 149 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 150 | echo "Must be run from mbed TLS root" >&2 |
| 151 | exit 1 |
| 152 | fi |
| 153 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 154 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 155 | pre_initialize_variables () { |
| 156 | CONFIG_H='include/mbedtls/config.h' |
| 157 | CONFIG_BAK="$CONFIG_H.bak" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 158 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 159 | MEMORY=0 |
| 160 | FORCE=0 |
| 161 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 162 | |
Antonin Décimo | d5f4759 | 2019-01-23 15:24:37 +0100 | [diff] [blame] | 163 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 164 | : ${OPENSSL:="openssl"} |
| 165 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 166 | : ${OPENSSL_NEXT:="$OPENSSL"} |
| 167 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 168 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 169 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 170 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 171 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 172 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 173 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 174 | : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 175 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 176 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
Gilles Peskine | a1fc4b5 | 2019-01-06 20:15:26 +0000 | [diff] [blame] | 177 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 178 | export MAKEFLAGS="-j" |
| 179 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 180 | |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 181 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Gilles Peskine | ac47906 | 2019-10-21 19:06:33 +0200 | [diff] [blame] | 182 | ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 183 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 184 | # Gather the list of available components. These are the functions |
| 185 | # defined in this script whose name starts with "component_". |
| 186 | # Parse the script with sed, because in sh there is no way to list |
| 187 | # defined functions. |
| 188 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 189 | |
| 190 | # Exclude components that are not supported on this platform. |
| 191 | SUPPORTED_COMPONENTS= |
| 192 | for component in $ALL_COMPONENTS; do |
| 193 | case $(type "support_$component" 2>&1) in |
| 194 | *' function'*) |
| 195 | if ! support_$component; then continue; fi;; |
| 196 | esac |
| 197 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 198 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 199 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 200 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 201 | # Test whether the component $1 is included in the command line patterns. |
| 202 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 203 | { |
| 204 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 205 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 206 | set +f |
| 207 | case ${1#component_} in $pattern) return 0;; esac |
| 208 | done |
| 209 | set +f |
| 210 | return 1 |
| 211 | } |
| 212 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 213 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 214 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 215 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 216 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 217 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 218 | By default, run all tests. With one or more COMPONENT, run only those. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 219 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 220 | |
| 221 | Examples: |
| 222 | $0 "check_*" |
| 223 | Run all sanity checks. |
| 224 | $0 --no-armcc --except test_memsan |
| 225 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 226 | |
| 227 | Special options: |
| 228 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 229 | --list-all-components List all available test components and exit. |
| 230 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 231 | |
| 232 | General options: |
| 233 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 234 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 235 | -m|--memory Additional optional memory tests. |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 236 | --arm-none-eabi-gcc-prefix=<string> |
| 237 | Prefix for a cross-compiler for arm-none-eabi |
| 238 | (default: "${ARM_NONE_EABI_GCC_PREFIX}") |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 239 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 240 | --except Exclude the COMPONENTs listed on the command line, |
| 241 | instead of running only those. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 242 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 243 | --no-force Refuse to overwrite modified files (default). |
| 244 | --no-keep-going Stop at the first error (default). |
| 245 | --no-memory No additional memory tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 246 | --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] | 247 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 248 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 249 | -s|--seed Integer seed value to use for this test run. |
| 250 | |
| 251 | Tool path options: |
| 252 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 253 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 254 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 255 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 256 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 257 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 258 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 259 | --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] | 260 | --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] | 261 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 262 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 263 | |
| 264 | # remove built files as well as the cmake cache/config |
| 265 | cleanup() |
| 266 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 267 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 268 | cd "$MBEDTLS_ROOT_DIR" |
| 269 | fi |
| 270 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 271 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 272 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 273 | # Remove CMake artefacts |
Simon Butcher | 3ad2efd | 2018-05-02 14:49:38 +0100 | [diff] [blame] | 274 | find . -name .git -prune \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 275 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 276 | \( -iname cmake_install.cmake -o \ |
| 277 | -iname CTestTestfile.cmake -o \ |
| 278 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 279 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 280 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 281 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 282 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 283 | |
| 284 | if [ -f "$CONFIG_BAK" ]; then |
| 285 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 286 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 287 | } |
| 288 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 289 | # Executed on exit. May be redefined depending on command line options. |
| 290 | final_report () { |
| 291 | : |
| 292 | } |
| 293 | |
| 294 | fatal_signal () { |
| 295 | cleanup |
| 296 | final_report $1 |
| 297 | trap - $1 |
| 298 | kill -$1 $$ |
| 299 | } |
| 300 | |
| 301 | trap 'fatal_signal HUP' HUP |
| 302 | trap 'fatal_signal INT' INT |
| 303 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 304 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 305 | msg() |
| 306 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 307 | if [ -n "${current_component:-}" ]; then |
| 308 | current_section="${current_component#component_}: $1" |
| 309 | else |
| 310 | current_section="$1" |
| 311 | fi |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 312 | echo "" |
| 313 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 314 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 315 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 316 | echo "******************************************************************" |
| 317 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 318 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 319 | armc6_build_test() |
| 320 | { |
| 321 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 322 | |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 323 | msg "build: ARM Compiler 6 ($FLAGS)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 324 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 325 | WARNING_CFLAGS='-xc -std=c99' make lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 326 | |
| 327 | msg "size: ARM Compiler 6 ($FLAGS)" |
| 328 | "$ARMC6_FROMELF" -z library/*.o |
| 329 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 330 | make clean |
| 331 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 332 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 333 | err_msg() |
| 334 | { |
| 335 | echo "$1" >&2 |
| 336 | } |
| 337 | |
| 338 | check_tools() |
| 339 | { |
| 340 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 341 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 342 | err_msg "$TOOL not found!" |
| 343 | exit 1 |
| 344 | fi |
| 345 | done |
| 346 | } |
| 347 | |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 348 | check_headers_in_cpp () { |
Peter Kolbus | 3098707 | 2019-02-01 17:19:08 -0600 | [diff] [blame] | 349 | ls include/mbedtls | grep "\.h$" >headers.txt |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 350 | <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' | |
| 351 | sort | |
| 352 | diff headers.txt - |
| 353 | rm headers.txt |
| 354 | } |
| 355 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 356 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 357 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 358 | all_except=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 359 | no_armcc= |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 360 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 361 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 362 | case "$1" in |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 363 | --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 364 | --armcc) no_armcc=;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 365 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 366 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 367 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 368 | --force|-f) FORCE=1;; |
| 369 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 370 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 371 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 372 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 373 | --help|-h) usage; exit;; |
| 374 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 375 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 376 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 377 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 378 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 379 | --no-force) FORCE=0;; |
| 380 | --no-keep-going) KEEP_GOING=0;; |
| 381 | --no-memory) MEMORY=0;; |
| 382 | --openssl) shift; OPENSSL="$1";; |
| 383 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 384 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
| 385 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
| 386 | --random-seed) unset SEED;; |
| 387 | --release-test|-r) SEED=1;; |
| 388 | --seed|-s) shift; SEED="$1";; |
| 389 | -*) |
| 390 | echo >&2 "Unknown option: $1" |
| 391 | echo >&2 "Run $0 --help for usage." |
| 392 | exit 120 |
| 393 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 394 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 395 | esac |
| 396 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 397 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 398 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 399 | # With no list of components, run everything. |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 400 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 401 | all_except=1 |
| 402 | fi |
| 403 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 404 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 405 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 406 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 407 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
| 408 | fi |
| 409 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 410 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 411 | RUN_COMPONENTS= |
| 412 | for component in $SUPPORTED_COMPONENTS; do |
| 413 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 414 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 415 | fi |
| 416 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 417 | |
| 418 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 419 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 420 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 421 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 422 | pre_check_git () { |
| 423 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 424 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 425 | git checkout-index -f -q $CONFIG_H |
| 426 | cleanup |
| 427 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 428 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 429 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 430 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 431 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 432 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 433 | exit 1 |
| 434 | fi |
| 435 | |
Gilles Peskine | d1174cf | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 436 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 437 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 438 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 439 | echo "script as: $0 --force" |
| 440 | exit 1 |
| 441 | fi |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 442 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 443 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 444 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 445 | pre_setup_keep_going () { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 446 | failure_summary= |
| 447 | failure_count=0 |
| 448 | start_red= |
| 449 | end_color= |
| 450 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 451 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 452 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 453 | start_red=$(printf '\033[31m') |
| 454 | end_color=$(printf '\033[0m') |
| 455 | ;; |
| 456 | esac |
| 457 | fi |
| 458 | record_status () { |
| 459 | if "$@"; then |
| 460 | last_status=0 |
| 461 | else |
| 462 | last_status=$? |
| 463 | text="$current_section: $* -> $last_status" |
| 464 | failure_summary="$failure_summary |
| 465 | $text" |
| 466 | failure_count=$((failure_count + 1)) |
| 467 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 468 | fi |
| 469 | } |
| 470 | make () { |
| 471 | case "$*" in |
| 472 | *test|*check) |
| 473 | if [ $build_status -eq 0 ]; then |
| 474 | record_status command make "$@" |
| 475 | else |
| 476 | echo "(skipped because the build failed)" |
| 477 | fi |
| 478 | ;; |
| 479 | *) |
| 480 | record_status command make "$@" |
| 481 | build_status=$last_status |
| 482 | ;; |
| 483 | esac |
| 484 | } |
| 485 | final_report () { |
| 486 | if [ $failure_count -gt 0 ]; then |
| 487 | echo |
| 488 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 489 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 490 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 7c1258d | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 491 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 492 | elif [ -z "${1-}" ]; then |
| 493 | echo "SUCCESS :)" |
| 494 | fi |
| 495 | if [ -n "${1-}" ]; then |
| 496 | echo "Killed by SIG$1." |
| 497 | fi |
| 498 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 499 | } |
| 500 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 501 | if_build_succeeded () { |
| 502 | if [ $build_status -eq 0 ]; then |
| 503 | record_status "$@" |
| 504 | fi |
| 505 | } |
| 506 | |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 507 | # to be used instead of ! for commands run with |
| 508 | # record_status or if_build_succeeded |
| 509 | not() { |
| 510 | ! "$@" |
| 511 | } |
| 512 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 513 | pre_print_configuration () { |
| 514 | msg "info: $0 configuration" |
| 515 | echo "MEMORY: $MEMORY" |
| 516 | echo "FORCE: $FORCE" |
| 517 | echo "SEED: ${SEED-"UNSET"}" |
| 518 | echo "OPENSSL: $OPENSSL" |
| 519 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 520 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 521 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 522 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 523 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 524 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 525 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 526 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 527 | } |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 528 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 529 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 530 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 531 | # Build the list of variables to pass to output_env.sh. |
| 532 | set env |
| 533 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 534 | case " $RUN_COMPONENTS " in |
| 535 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 536 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 537 | # is a good enough approximation in practice. |
| 538 | *" test_"*) |
| 539 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 540 | # and ssl-opt.sh, we just export the variables they require. |
| 541 | export OPENSSL_CMD="$OPENSSL" |
| 542 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 543 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 544 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 545 | if [ -n "${SEED-}" ]; then |
| 546 | export SEED |
| 547 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 548 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 549 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 550 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 551 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 552 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 553 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 554 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 555 | ;; |
| 556 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 557 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 558 | case " $RUN_COMPONENTS " in |
| 559 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 560 | esac |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 561 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 562 | case " $RUN_COMPONENTS " in |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 563 | *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";; |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 564 | esac |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 565 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 566 | case " $RUN_COMPONENTS " in |
| 567 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 568 | esac |
| 569 | |
| 570 | case " $RUN_COMPONENTS " in |
| 571 | *" test_zeroize "*) check_tools "gdb";; |
| 572 | esac |
| 573 | |
| 574 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 575 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 576 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 577 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 578 | ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 579 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 580 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 581 | ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf" |
| 582 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \ |
| 583 | "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 584 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 585 | |
| 586 | msg "info: output_env.sh" |
| 587 | case $RUN_COMPONENTS in |
| 588 | *_armcc*) |
| 589 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 590 | *) set "$@" RUN_ARMCC=0;; |
| 591 | esac |
| 592 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 593 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 594 | |
| 595 | |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 596 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 597 | ################################################################ |
| 598 | #### Basic checks |
| 599 | ################################################################ |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 600 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 601 | # |
| 602 | # Test Suites to be executed |
| 603 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 604 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 605 | # 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] | 606 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 607 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 608 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 609 | # |
| 610 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 611 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 612 | component_check_recursion () { |
| 613 | msg "test: recursion.pl" # < 1s |
| 614 | record_status tests/scripts/recursion.pl library/*.c |
| 615 | } |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 616 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 617 | component_check_generated_files () { |
| 618 | msg "test: freshness of generated source files" # < 1s |
| 619 | record_status tests/scripts/check-generated-files.sh |
| 620 | } |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 621 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 622 | component_check_doxy_blocks () { |
| 623 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 624 | record_status tests/scripts/check-doxy-blocks.pl |
| 625 | } |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 626 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 627 | component_check_files () { |
| 628 | msg "test: check-files.py" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 629 | record_status tests/scripts/check-files.py |
| 630 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 631 | |
Gilles Peskine | 3c23c82 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 632 | component_check_changelog () { |
| 633 | msg "Check: changelog entries" # < 1s |
| 634 | rm -f ChangeLog.new |
| 635 | record_status scripts/assemble_changelog.py -o ChangeLog.new |
| 636 | if [ -e ChangeLog.new ]; then |
| 637 | # Show the diff for information. It isn't an error if the diff is |
| 638 | # non-empty. |
| 639 | diff -u ChangeLog ChangeLog.new || true |
| 640 | rm ChangeLog.new |
| 641 | fi |
| 642 | } |
| 643 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 644 | component_check_names () { |
| 645 | msg "test/build: declared and exported names" # < 3s |
Gilles Peskine | 473f2d4 | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 646 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 647 | } |
Manuel Pégourié-Gonnard | a687baf | 2015-04-09 11:09:03 +0200 | [diff] [blame] | 648 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 649 | component_check_doxygen_warnings () { |
| 650 | msg "test: doxygen warnings" # ~ 3s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 651 | record_status tests/scripts/doxygen.sh |
| 652 | } |
Manuel Pégourié-Gonnard | 1d552e7 | 2016-01-04 16:49:09 +0100 | [diff] [blame] | 653 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 654 | |
| 655 | |
| 656 | ################################################################ |
| 657 | #### Build and test many configurations and targets |
| 658 | ################################################################ |
| 659 | |
k-stachowiak | 11f38e2 | 2019-06-04 13:14:58 +0200 | [diff] [blame] | 660 | component_test_large_ecdsa_key_signature () { |
| 661 | |
| 662 | SMALL_MPI_MAX_SIZE=136 # Small enough to interfere with the EC signatures |
| 663 | |
| 664 | msg "build: cmake + MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE}, gcc, ASan" # ~ 1 min 50s |
| 665 | scripts/config.pl set MBEDTLS_MPI_MAX_SIZE $SMALL_MPI_MAX_SIZE |
| 666 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 667 | make |
| 668 | |
| 669 | INEVITABLY_PRESENT_FILE=Makefile |
| 670 | SIGNATURE_FILE="${INEVITABLY_PRESENT_FILE}.sig" # Warning, this is rm -f'ed below |
| 671 | |
| 672 | msg "test: pk_sign secp521r1_prv.der for MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE} (ASan build)" # ~ 5s |
| 673 | if_build_succeeded programs/pkey/pk_sign tests/data_files/secp521r1_prv.der $INEVITABLY_PRESENT_FILE |
| 674 | rm -f $SIGNATURE_FILE |
| 675 | } |
| 676 | |
Gilles Peskine | 99a3310 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 677 | component_test_default_out_of_box () { |
| 678 | msg "build: make, default config (out-of-box)" # ~1min |
| 679 | make |
| 680 | |
| 681 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 682 | make test |
| 683 | |
| 684 | msg "selftest: make, default config (out-of-box)" # ~10s |
Gilles Peskine | 5bd9f56 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 685 | if_build_succeeded programs/test/selftest |
Gilles Peskine | 99a3310 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 686 | } |
| 687 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 688 | component_test_default_cmake_gcc_asan () { |
| 689 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 690 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 691 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 692 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 693 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 694 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 695 | |
Gilles Peskine | 5bd9f56 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 696 | msg "test: selftest (ASan build)" # ~ 10s |
| 697 | if_build_succeeded programs/test/selftest |
| 698 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 699 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
| 700 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 701 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 702 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 703 | if_build_succeeded tests/compat.sh |
| 704 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 705 | |
Hanno Becker | f8799e8 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 706 | component_test_full_cmake_gcc_asan () { |
| 707 | msg "build: full config, cmake, gcc, ASan" |
| 708 | scripts/config.pl full |
| 709 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 710 | make |
| 711 | |
| 712 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 713 | make test |
| 714 | |
Gilles Peskine | 5bd9f56 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 715 | msg "test: selftest (ASan build)" # ~ 10s |
| 716 | if_build_succeeded programs/test/selftest |
| 717 | |
Hanno Becker | f8799e8 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 718 | msg "test: ssl-opt.sh (full config, ASan build)" |
| 719 | if_build_succeeded tests/ssl-opt.sh |
| 720 | |
| 721 | msg "test: compat.sh (full config, ASan build)" |
| 722 | if_build_succeeded tests/compat.sh |
| 723 | } |
| 724 | |
Manuel Pégourié-Gonnard | 4ef189d | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 725 | component_test_zlib_make() { |
| 726 | msg "build: zlib enabled, make" |
| 727 | scripts/config.pl set MBEDTLS_ZLIB_SUPPORT |
| 728 | make ZLIB=1 CFLAGS='-Werror -O1' |
| 729 | |
| 730 | msg "test: main suites (zlib, make)" |
| 731 | make test |
| 732 | |
| 733 | msg "test: ssl-opt.sh (zlib, make)" |
| 734 | if_build_succeeded tests/ssl-opt.sh |
| 735 | } |
Manuel Pégourié-Gonnard | 114d339 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 736 | support_test_zlib_make () { |
| 737 | base=support_test_zlib_$$ |
| 738 | cat <<'EOF' > ${base}.c |
| 739 | #include "zlib.h" |
| 740 | int main(void) { return 0; } |
| 741 | EOF |
| 742 | gcc -o ${base}.exe ${base}.c -lz 2>/dev/null |
| 743 | ret=$? |
| 744 | rm -f ${base}.* |
| 745 | return $ret |
| 746 | } |
Manuel Pégourié-Gonnard | 4ef189d | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 747 | |
| 748 | component_test_zlib_cmake() { |
| 749 | msg "build: zlib enabled, cmake" |
| 750 | scripts/config.pl set MBEDTLS_ZLIB_SUPPORT |
| 751 | cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check . |
| 752 | make |
| 753 | |
| 754 | msg "test: main suites (zlib, cmake)" |
| 755 | make test |
| 756 | |
| 757 | msg "test: ssl-opt.sh (zlib, cmake)" |
| 758 | if_build_succeeded tests/ssl-opt.sh |
| 759 | } |
Manuel Pégourié-Gonnard | 114d339 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 760 | support_test_zlib_cmake () { |
| 761 | support_test_zlib_make "$@" |
| 762 | } |
Manuel Pégourié-Gonnard | 4ef189d | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 763 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 764 | component_test_ref_configs () { |
| 765 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 766 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 767 | record_status tests/scripts/test-ref-configs.pl |
| 768 | } |
| 769 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 770 | component_test_sslv3 () { |
| 771 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 772 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 773 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 774 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 775 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 776 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 777 | make test |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 778 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 779 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
| 780 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 781 | 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] | 782 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 783 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 784 | if_build_succeeded tests/ssl-opt.sh |
| 785 | } |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 786 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 787 | component_test_no_renegotiation () { |
| 788 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 789 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 790 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 791 | make |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 792 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 793 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 794 | make test |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 795 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 796 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 797 | if_build_succeeded tests/ssl-opt.sh |
| 798 | } |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 799 | |
Hanno Becker | e562e7d | 2019-05-10 14:45:37 +0100 | [diff] [blame] | 800 | component_test_no_pem_no_fs () { |
| 801 | msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" |
| 802 | scripts/config.pl unset MBEDTLS_PEM_PARSE_C |
| 803 | scripts/config.pl unset MBEDTLS_FS_IO |
| 804 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 805 | make |
| 806 | |
| 807 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 808 | make test |
| 809 | |
| 810 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
| 811 | if_build_succeeded tests/ssl-opt.sh |
| 812 | } |
| 813 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 814 | component_test_rsa_no_crt () { |
| 815 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 816 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 817 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 818 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 819 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 820 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 821 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 822 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 823 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 824 | if_build_succeeded tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 825 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 826 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 827 | if_build_succeeded tests/compat.sh -t RSA |
| 828 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 829 | |
Manuel Pégourié-Gonnard | 014ff5b | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 830 | component_test_no_ctr_drbg () { |
| 831 | msg "build: Full minus CTR_DRBG" |
| 832 | scripts/config.pl full |
| 833 | scripts/config.pl unset MBEDTLS_CTR_DRBG_C |
| 834 | |
| 835 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 836 | make |
| 837 | |
| 838 | msg "test: no CTR_DRBG" |
| 839 | make test |
| 840 | |
Manuel Pégourié-Gonnard | c5243c1 | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 841 | # no ssl-opt.sh/compat.sh as they all depend on CTR_DRBG so far |
| 842 | } |
| 843 | |
| 844 | component_test_no_hmac_drbg () { |
| 845 | msg "build: Full minus HMAC_DRBG" |
| 846 | scripts/config.pl full |
| 847 | scripts/config.pl unset MBEDTLS_HMAC_DRBG_C |
| 848 | scripts/config.pl unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 849 | |
| 850 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 851 | make |
| 852 | |
| 853 | msg "test: no HMAC_DRBG" |
| 854 | make test |
| 855 | |
| 856 | # No ssl-opt.sh/compat.sh as they never use HMAC_DRBG so far, |
| 857 | # so there's little value in running those lengthy tests here. |
Manuel Pégourié-Gonnard | 014ff5b | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 858 | } |
| 859 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 860 | component_test_small_ssl_out_content_len () { |
| 861 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 862 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 863 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
| 864 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 865 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 866 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 867 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
| 868 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" |
| 869 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 870 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 871 | component_test_small_ssl_in_content_len () { |
| 872 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 873 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 874 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
| 875 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 876 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 877 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 878 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
| 879 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment" |
| 880 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 881 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 882 | component_test_small_ssl_dtls_max_buffering () { |
| 883 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 884 | scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
| 885 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 886 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 887 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 888 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
| 889 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
| 890 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 891 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 892 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 893 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 894 | scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240 |
| 895 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 896 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 897 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 898 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
| 899 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
| 900 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 901 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 902 | component_test_full_cmake_clang () { |
| 903 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 904 | scripts/config.pl full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 905 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 906 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 907 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 908 | msg "test: main suites (full config)" # ~ 5s |
| 909 | make test |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 910 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 911 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
| 912 | 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] | 913 | |
Andres Amaya Garcia | ac9c522 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 914 | msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min |
Andres Amaya Garcia | 37e0a8c | 2019-02-19 20:20:57 +0000 | [diff] [blame] | 915 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 916 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 917 | msg "test: compat.sh ARIA + ChachaPoly" |
| 918 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 919 | } |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 920 | |
Gilles Peskine | 77b1f30 | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 921 | component_test_default_no_deprecated () { |
| 922 | # Test that removing the deprecated features from the default |
| 923 | # configuration leaves something consistent. |
| 924 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 925 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
Gilles Peskine | 77b1f30 | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 926 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 927 | |
| 928 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 929 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 930 | } |
Gilles Peskine | 0afe624 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 931 | |
Gilles Peskine | 77b1f30 | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 932 | component_test_full_deprecated_warning () { |
| 933 | # Test that there is nothing deprecated in the full configuration. |
| 934 | # A deprecated feature would trigger a warning (made fatal) from |
| 935 | # MBEDTLS_DEPRECATED_WARNING. |
| 936 | msg "build: make, full + MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 937 | scripts/config.pl full |
| 938 | scripts/config.pl unset MBEDTLS_DEPRECATED_REMOVED |
| 939 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
| 940 | # There are currently no tests for any deprecated feature. |
| 941 | # If some are added, 'make test' would trigger warnings here. |
| 942 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 943 | |
| 944 | msg "test: make, full + MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
| 945 | make test |
| 946 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 947 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 948 | component_test_depends_curves () { |
| 949 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 950 | record_status tests/scripts/curves.pl |
| 951 | } |
Manuel Pégourié-Gonnard | 1fe6bb9 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 952 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 953 | component_test_depends_hashes () { |
| 954 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 955 | record_status tests/scripts/depends-hashes.pl |
| 956 | } |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 957 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 958 | component_test_depends_pkalgs () { |
| 959 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 960 | record_status tests/scripts/depends-pkalgs.pl |
| 961 | } |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 962 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 963 | component_build_key_exchanges () { |
| 964 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 965 | record_status tests/scripts/key-exchanges.pl |
| 966 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 967 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 968 | component_build_default_make_gcc_and_cxx () { |
| 969 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 970 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 971 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 972 | msg "test: verify header list in cpp_dummy_build.cpp" |
| 973 | record_status check_headers_in_cpp |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 974 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 975 | msg "build: Unix make, incremental g++" |
| 976 | make TEST_CPP=1 |
| 977 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 978 | |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 979 | component_test_check_params_functionality () { |
| 980 | msg "build+test: MBEDTLS_CHECK_PARAMS functionality" |
| 981 | scripts/config.pl full # includes CHECK_PARAMS |
| 982 | # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed(). |
| 983 | scripts/config.pl unset MBEDTLS_CHECK_PARAMS_ASSERT |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 984 | # Only build and run tests. Do not build sample programs, because |
| 985 | # they don't have a mbedtls_param_failed() function. |
| 986 | make CC=gcc CFLAGS='-Werror -O1' lib test |
| 987 | } |
| 988 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 989 | component_test_check_params_without_platform () { |
| 990 | msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" |
| 991 | scripts/config.pl full # includes CHECK_PARAMS |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 992 | # Keep MBEDTLS_PARAM_FAILED as assert. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 993 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 994 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 995 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 996 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 997 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 998 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 999 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1000 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 1001 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 1002 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1003 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 1004 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1005 | component_test_check_params_silent () { |
| 1006 | msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" |
| 1007 | scripts/config.pl full # includes CHECK_PARAMS |
Gilles Peskine | dcab202 | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1008 | # Set MBEDTLS_PARAM_FAILED to nothing. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1009 | sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" |
| 1010 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1011 | } |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1012 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1013 | component_test_no_platform () { |
| 1014 | # Full configuration build, without platform support, file IO and net sockets. |
| 1015 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 1016 | # IO, it should catch missing '#include <stdio.h>' |
| 1017 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1018 | scripts/config.pl full |
| 1019 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 1020 | scripts/config.pl unset MBEDTLS_NET_C |
| 1021 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 1022 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1023 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1024 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1025 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 1026 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1027 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1028 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1029 | scripts/config.pl unset MBEDTLS_FS_IO |
| 1030 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 1031 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1032 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 1033 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1034 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1035 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1036 | component_build_no_std_function () { |
| 1037 | # catch compile bugs in _uninit functions |
| 1038 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1039 | scripts/config.pl full |
| 1040 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 1041 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1042 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1043 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1044 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1045 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1046 | component_build_no_ssl_srv () { |
| 1047 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1048 | scripts/config.pl full |
| 1049 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1050 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1051 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1052 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1053 | component_build_no_ssl_cli () { |
| 1054 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1055 | scripts/config.pl full |
| 1056 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1057 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1058 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1059 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1060 | component_build_no_sockets () { |
| 1061 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 1062 | # as that requires a POSIX platform (which isn't the same as C99). |
| 1063 | 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] | 1064 | scripts/config.pl full |
| 1065 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 1066 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | 99d70d8 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1067 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1068 | } |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1069 | |
Andrzej Kurek | 1d07082 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1070 | component_test_memory_buffer_allocator_backtrace () { |
| 1071 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1072 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Andrzej Kurek | 1d07082 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1073 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1074 | scripts/config.pl set MBEDTLS_MEMORY_BACKTRACE |
Andrzej Kurek | 60ebd98 | 2019-09-10 02:58:34 -0400 | [diff] [blame] | 1075 | scripts/config.pl set MBEDTLS_MEMORY_DEBUG |
Andrzej Kurek | 1d07082 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1076 | CC=gcc cmake . |
| 1077 | make |
| 1078 | |
| 1079 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1080 | make test |
| 1081 | } |
| 1082 | |
| 1083 | component_test_memory_buffer_allocator () { |
| 1084 | msg "build: default config with memory buffer allocator" |
| 1085 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Hanno Becker | d130b98 | 2019-06-03 16:35:02 +0100 | [diff] [blame] | 1086 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1087 | CC=gcc cmake . |
| 1088 | make |
| 1089 | |
| 1090 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1091 | make test |
| 1092 | |
| 1093 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
Andrzej Kurek | 1f5a596 | 2019-09-05 10:09:37 -0400 | [diff] [blame] | 1094 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 1095 | if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | 74b5e34 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1096 | } |
| 1097 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1098 | component_test_no_max_fragment_length () { |
| 1099 | # Run max fragment length tests with MFL disabled |
| 1100 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1101 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1102 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1103 | make |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1104 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1105 | msg "test: ssl-opt.sh, MFL-related tests" |
| 1106 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
| 1107 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1108 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1109 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 1110 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1111 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1112 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1113 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
| 1114 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1115 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1116 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1117 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
| 1118 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer" |
| 1119 | } |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1120 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1121 | component_test_null_entropy () { |
| 1122 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1123 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
| 1124 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 1125 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 1126 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | df4f7c1 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1127 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1128 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 1129 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 5fa32a7 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 1130 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON . |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1131 | make |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1132 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1133 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 1134 | make test |
| 1135 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1136 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1137 | component_test_platform_calloc_macro () { |
| 1138 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1139 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 1140 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 1141 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 1142 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1143 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1144 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1145 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 1146 | make test |
| 1147 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1148 | |
Gilles Peskine | c6b0986 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1149 | component_test_malloc_0_null () { |
| 1150 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
| 1151 | scripts/config.pl full |
| 1152 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1153 | make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' -O -Werror -Wall -Wextra -fsanitize=address,undefined" LDFLAGS='-fsanitize=address,undefined' |
| 1154 | |
| 1155 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 1156 | make test |
| 1157 | |
| 1158 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 1159 | # Just the calloc selftest. "make test" ran the others as part of the |
| 1160 | # test suites. |
| 1161 | if_build_succeeded programs/test/selftest calloc |
| 1162 | } |
| 1163 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1164 | component_test_aes_fewer_tables () { |
| 1165 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1166 | scripts/config.pl set MBEDTLS_AES_FEWER_TABLES |
| 1167 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1168 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1169 | msg "test: AES_FEWER_TABLES" |
| 1170 | make test |
| 1171 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1172 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1173 | component_test_aes_rom_tables () { |
| 1174 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1175 | scripts/config.pl set MBEDTLS_AES_ROM_TABLES |
| 1176 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1177 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1178 | msg "test: AES_ROM_TABLES" |
| 1179 | make test |
| 1180 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1181 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1182 | component_test_aes_fewer_tables_and_rom_tables () { |
| 1183 | 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] | 1184 | scripts/config.pl set MBEDTLS_AES_FEWER_TABLES |
| 1185 | scripts/config.pl set MBEDTLS_AES_ROM_TABLES |
| 1186 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1187 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1188 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 1189 | make test |
| 1190 | } |
| 1191 | |
| 1192 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1193 | msg "build/test: make shared" # ~ 40s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1194 | make SHARED=1 all check |
Gilles Peskine | dc25c32 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1195 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1196 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 1197 | |
Gilles Peskine | 2c47ffc | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1198 | component_test_cmake_shared () { |
| 1199 | msg "build/test: cmake shared" # ~ 2min |
| 1200 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 1201 | make |
Gilles Peskine | dc25c32 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1202 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 2c47ffc | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1203 | make test |
| 1204 | } |
| 1205 | |
Gilles Peskine | 0fe92c2 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1206 | test_build_opt () { |
| 1207 | info=$1 cc=$2; shift 2 |
| 1208 | for opt in "$@"; do |
| 1209 | msg "build/test: $cc $opt, $info" # ~ 30s |
Gilles Peskine | 313bb50 | 2020-04-14 20:08:41 +0200 | [diff] [blame] | 1210 | make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror" |
Gilles Peskine | 0fe92c2 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1211 | # We're confident enough in compilers to not run _all_ the tests, |
| 1212 | # but at least run the unit tests. In particular, runs with |
| 1213 | # optimizations use inline assembly whereas runs with -O0 |
| 1214 | # skip inline assembly. |
| 1215 | make test # ~30s |
| 1216 | make clean |
| 1217 | done |
| 1218 | } |
| 1219 | |
| 1220 | component_test_clang_opt () { |
| 1221 | scripts/config.pl full |
| 1222 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 1223 | } |
| 1224 | |
| 1225 | component_test_gcc_opt () { |
| 1226 | scripts/config.pl full |
| 1227 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 1228 | } |
| 1229 | |
Gilles Peskine | 87bf1b5 | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1230 | component_build_mbedtls_config_file () { |
| 1231 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 1232 | # Use the full config so as to catch a maximum of places where |
| 1233 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
| 1234 | scripts/config.pl full |
| 1235 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 1236 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 1237 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 1238 | rm -f full_config.h |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1239 | } |
| 1240 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1241 | component_test_m32_o0 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1242 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 1243 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 1244 | scripts/config.pl full |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1245 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1246 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1247 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 1248 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1249 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1250 | support_test_m32_o0 () { |
| 1251 | case $(uname -m) in |
| 1252 | *64*) true;; |
| 1253 | *) false;; |
| 1254 | esac |
| 1255 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1256 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1257 | component_test_m32_o1 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1258 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 1259 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1260 | scripts/config.pl full |
Gilles Peskine | ff26b04 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1261 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1262 | |
| 1263 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1264 | make test |
Gilles Peskine | 7dd44b2 | 2019-04-08 16:58:02 +0200 | [diff] [blame] | 1265 | |
| 1266 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 1267 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1268 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1269 | support_test_m32_o1 () { |
| 1270 | support_test_m32_o0 "$@" |
| 1271 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1272 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1273 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1274 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 1275 | scripts/config.pl full |
Gilles Peskine | 8118e46 | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 1276 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1277 | |
| 1278 | msg "test: 64-bit ILP32, make, gcc" |
| 1279 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1280 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1281 | support_test_mx32 () { |
| 1282 | case $(uname -m) in |
| 1283 | amd64|x86_64) true;; |
| 1284 | *) false;; |
| 1285 | esac |
| 1286 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1287 | |
Peter Kolbus | 1e2aa72 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1288 | component_test_min_mpi_window_size () { |
| 1289 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
| 1290 | scripts/config.pl set MBEDTLS_MPI_WINDOW_SIZE 1 |
| 1291 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1292 | make |
| 1293 | |
| 1294 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 1295 | make test |
| 1296 | } |
| 1297 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1298 | component_test_have_int32 () { |
| 1299 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1300 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 1301 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 1302 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 1303 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1304 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1305 | msg "test: gcc, force 32-bit bignum limbs" |
| 1306 | make test |
| 1307 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 1308 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1309 | component_test_have_int64 () { |
| 1310 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1311 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 1312 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 1313 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 1314 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 1315 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1316 | msg "test: gcc, force 64-bit bignum limbs" |
| 1317 | make test |
| 1318 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1319 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1320 | component_test_no_udbl_division () { |
| 1321 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1322 | scripts/config.pl full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1323 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
| 1324 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1325 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1326 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 1327 | make test |
| 1328 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1329 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1330 | component_test_no_64bit_multiplication () { |
| 1331 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1332 | scripts/config.pl full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1333 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 1334 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1335 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1336 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 1337 | make test |
| 1338 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1339 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1340 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1341 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s |
Manuel Pégourié-Gonnard | 6e6ae9b | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1342 | scripts/config.pl baremetal |
Gilles Peskine | fcccfbc | 2020-04-30 22:54:00 +0200 | [diff] [blame] | 1343 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra -O1' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1344 | |
| 1345 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" |
| 1346 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1347 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1348 | |
Gilles Peskine | 560f332 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1349 | component_build_arm_none_eabi_gcc_arm5vte () { |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1350 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s |
Gilles Peskine | 0bd284d | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 1351 | scripts/config.pl baremetal |
Gilles Peskine | 560f332 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1352 | # Build for a target platform that's close to what Debian uses |
| 1353 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 1354 | # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. |
| 1355 | # It would be better to build with arm-linux-gnueabi-gcc but |
| 1356 | # we don't have that on our CI at this time. |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1357 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1358 | |
| 1359 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" |
| 1360 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 0bd284d | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 1361 | } |
| 1362 | |
Gilles Peskine | dac156b | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 1363 | component_build_arm_none_eabi_gcc_m0plus () { |
| 1364 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s |
| 1365 | scripts/config.pl baremetal |
| 1366 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1367 | |
| 1368 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os" |
| 1369 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1370 | } |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1371 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1372 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1373 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX} -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1374 | scripts/config.pl baremetal |
Simon Butcher | 1c71965 | 2016-06-27 19:02:12 +0100 | [diff] [blame] | 1375 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1376 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -Wall -Wextra' lib |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1377 | echo "Checking that software 64-bit division is not required" |
| 1378 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
| 1379 | } |
| 1380 | |
Manuel Pégourié-Gonnard | bbc60db | 2015-06-22 14:31:50 +0200 | [diff] [blame] | 1381 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1382 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX} MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1383 | scripts/config.pl baremetal |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1384 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | a3c6c8a | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1385 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1386 | echo "Checking that software 64-bit multiplication is not required" |
| 1387 | if_build_succeeded not grep __aeabi_lmul library/*.o |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1388 | } |
Simon Butcher | bc6a486 | 2016-03-07 17:35:59 +0000 | [diff] [blame] | 1389 | |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1390 | component_build_armcc () { |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1391 | msg "build: ARM Compiler 5" |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1392 | scripts/config.pl baremetal |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1393 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
Gilles Peskine | e6c0c7d | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1394 | |
| 1395 | msg "size: ARM Compiler 5" |
| 1396 | "$ARMC5_FROMELF" -z library/*.o |
| 1397 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1398 | make clean |
| 1399 | |
| 1400 | # ARM Compiler 6 - Target ARMv7-A |
| 1401 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
| 1402 | |
| 1403 | # ARM Compiler 6 - Target ARMv7-M |
Simon Butcher | 4df5eaf | 2016-08-24 22:58:31 +0300 | [diff] [blame] | 1404 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1405 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1406 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1407 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1408 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1409 | # ARM Compiler 6 - Target ARMv8-M |
| 1410 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1411 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 1412 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1413 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1414 | } |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1415 | |
Andres Amaya Garcia | 9f3bdb8 | 2018-12-05 22:03:56 +0000 | [diff] [blame] | 1416 | component_build_ssl_hw_record_accel() { |
| 1417 | msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled" |
| 1418 | scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL |
| 1419 | make CFLAGS='-Werror -O1' |
| 1420 | } |
| 1421 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1422 | component_test_allow_sha1 () { |
| 1423 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1424 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
| 1425 | make CFLAGS='-Werror -Wall -Wextra' |
| 1426 | msg "test: allow SHA1 in certificates by default" |
| 1427 | make test |
| 1428 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
| 1429 | } |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1430 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1431 | component_build_mingw () { |
| 1432 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1433 | 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] | 1434 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1435 | # note Make tests only builds the tests, but doesn't run them |
| 1436 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
| 1437 | make WINDOWS_BUILD=1 clean |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 1438 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1439 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
| 1440 | 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 |
| 1441 | 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 |
| 1442 | make WINDOWS_BUILD=1 clean |
| 1443 | } |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 1444 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1445 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1446 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1447 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1448 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1449 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 1450 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1451 | msg "test: main suites (MSan)" # ~ 10s |
| 1452 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1453 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1454 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1455 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1456 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1457 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1458 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1459 | if [ "$MEMORY" -gt 0 ]; then |
| 1460 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1461 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1462 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1463 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1464 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1465 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1466 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1467 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1468 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1469 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1470 | msg "test: main suites valgrind (Release)" |
| 1471 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1472 | |
Gilles Peskine | 0a47c4f | 2019-04-08 17:00:56 +0200 | [diff] [blame] | 1473 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1474 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1475 | if [ "$MEMORY" -gt 0 ]; then |
| 1476 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1477 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1478 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1479 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1480 | if [ "$MEMORY" -gt 1 ]; then |
| 1481 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1482 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1483 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1484 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1485 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1486 | component_test_cmake_out_of_source () { |
| 1487 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1488 | MBEDTLS_ROOT_DIR="$PWD" |
| 1489 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1490 | cd "$OUT_OF_SOURCE_DIR" |
| 1491 | cmake "$MBEDTLS_ROOT_DIR" |
| 1492 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1493 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1494 | msg "test: cmake 'out-of-source' build" |
| 1495 | make test |
| 1496 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 1497 | # Also ensure that there are no error messages such as |
| 1498 | # "No such file or directory", which would indicate that some required |
| 1499 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 1500 | # may exit with status 0 but emit errors). |
| 1501 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 1502 | if [ -s ssl-opt.err ]; then |
| 1503 | cat ssl-opt.err >&2 |
| 1504 | record_status [ ! -s ssl-opt.err ] |
| 1505 | rm ssl-opt.err |
| 1506 | fi |
| 1507 | cd "$MBEDTLS_ROOT_DIR" |
| 1508 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1509 | unset MBEDTLS_ROOT_DIR |
| 1510 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1511 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1512 | component_test_zeroize () { |
| 1513 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 1514 | # different combinations of compilers and optimization flags by using an |
| 1515 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 1516 | # system in all cases that the script fails, so we must manually search the |
| 1517 | # output to check whether the pass string is present and no failure strings |
| 1518 | # were printed. |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1519 | |
| 1520 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 1521 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 1522 | gdb_disable_aslr= |
| 1523 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 1524 | gdb_disable_aslr='set disable-randomization off' |
| 1525 | fi |
| 1526 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1527 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1528 | for compiler in clang gcc; do |
| 1529 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 1530 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1531 | if_build_succeeded gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1532 | if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log |
| 1533 | if_build_succeeded not grep -i "error" test_zeroize.log |
| 1534 | rm -f test_zeroize.log |
| 1535 | make clean |
| 1536 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 1537 | done |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1538 | |
| 1539 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1540 | } |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 1541 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1542 | component_check_python_files () { |
| 1543 | msg "Lint: Python scripts" |
| 1544 | record_status tests/scripts/check-python-files.sh |
| 1545 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1546 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1547 | component_check_generate_test_code () { |
| 1548 | msg "uint test: generate_test_code.py" |
| 1549 | record_status ./tests/scripts/test_generate_test_code.py |
| 1550 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1551 | |
| 1552 | ################################################################ |
| 1553 | #### Termination |
| 1554 | ################################################################ |
| 1555 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1556 | post_report () { |
| 1557 | msg "Done, cleaning up" |
| 1558 | cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1559 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1560 | final_report |
| 1561 | } |
| 1562 | |
| 1563 | |
| 1564 | |
| 1565 | ################################################################ |
| 1566 | #### Run all the things |
| 1567 | ################################################################ |
| 1568 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1569 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1570 | run_component () { |
Gilles Peskine | 608953e | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1571 | # Back up the configuration in case the component modifies it. |
| 1572 | # The cleanup function will restore it. |
| 1573 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1574 | current_component="$1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1575 | "$@" |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1576 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1577 | } |
| 1578 | |
| 1579 | # Preliminary setup |
| 1580 | pre_check_environment |
| 1581 | pre_initialize_variables |
| 1582 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 1583 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1584 | pre_check_git |
| 1585 | build_status=0 |
| 1586 | if [ $KEEP_GOING -eq 1 ]; then |
| 1587 | pre_setup_keep_going |
| 1588 | else |
| 1589 | record_status () { |
| 1590 | "$@" |
| 1591 | } |
| 1592 | fi |
| 1593 | pre_print_configuration |
| 1594 | pre_check_tools |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1595 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1596 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 1597 | # Run the requested tests. |
| 1598 | for component in $RUN_COMPONENTS; do |
| 1599 | run_component "component_$component" |
| 1600 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1601 | |
| 1602 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1603 | post_report |