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 | 4e9f712 | 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 | 09b4f19 | 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 | 4e9f712 | 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 | 09b4f19 | 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) |
| 78 | # * arm-gcc and mingw-gcc |
| 79 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
| 80 | # * Yotta build dependencies, unless invoked with --no-yotta |
| 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 | 2906a0a | 2019-01-09 22:29:17 +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. |
| 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. |
| 105 | # * support_XXX: if support_XXX exists and returns false then |
| 106 | # component_XXX is not run by default. |
| 107 | # * post_XXX: things to do after running the tests. |
| 108 | # * other: miscellaneous support functions. |
| 109 | # |
| 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 | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 148 | pre_check_environment () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 149 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +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 | 57db6ff | 2019-01-08 22:04:31 +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 | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 159 | MEMORY=0 |
| 160 | FORCE=0 |
| 161 | KEEP_GOING=0 |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 162 | YOTTA=1 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 163 | |
Manuel Pégourié-Gonnard | 54d95b1 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 164 | # Seed value used with the --release-test option. |
Manuel Pégourié-Gonnard | e4a5c05 | 2020-06-22 10:11:47 +0200 | [diff] [blame] | 165 | # |
| 166 | # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if |
| 167 | # both values are kept in sync. If you change the value here because it |
| 168 | # breaks some tests, you'll definitely want to change it in |
| 169 | # basic-build-test.sh as well. |
Manuel Pégourié-Gonnard | 54d95b1 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 170 | RELEASE_SEED=1 |
| 171 | |
Antonin Décimo | 8fd9156 | 2019-01-23 15:24:37 +0100 | [diff] [blame] | 172 | # Default commands, can be overridden by the environment |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 173 | : ${OPENSSL:="openssl"} |
| 174 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 175 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 176 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 177 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 178 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 179 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 180 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 181 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Gilles Peskine | f1709bb | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 182 | : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 183 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 184 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
Gilles Peskine | 7120f77 | 2019-01-06 20:15:26 +0000 | [diff] [blame] | 185 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 186 | export MAKEFLAGS="-j" |
| 187 | fi |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 188 | |
Gilles Peskine | c20a405 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 189 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Gilles Peskine | 4c2697f | 2019-10-21 19:06:33 +0200 | [diff] [blame] | 190 | ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | c20a405 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 191 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 192 | # Gather the list of available components. These are the functions |
| 193 | # defined in this script whose name starts with "component_". |
| 194 | # Parse the script with sed, because in sh there is no way to list |
| 195 | # defined functions. |
| 196 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 197 | |
| 198 | # Exclude components that are not supported on this platform. |
| 199 | SUPPORTED_COMPONENTS= |
| 200 | for component in $ALL_COMPONENTS; do |
| 201 | case $(type "support_$component" 2>&1) in |
| 202 | *' function'*) |
| 203 | if ! support_$component; then continue; fi;; |
| 204 | esac |
| 205 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 206 | done |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 207 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 208 | |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 209 | # Test whether the component $1 is included in the command line patterns. |
| 210 | is_component_included() |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 211 | { |
| 212 | set -f |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 213 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 214 | set +f |
| 215 | case ${1#component_} in $pattern) return 0;; esac |
| 216 | done |
| 217 | set +f |
| 218 | return 1 |
| 219 | } |
| 220 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 221 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 222 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 223 | cat <<EOF |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 224 | Usage: $0 [OPTION]... [COMPONENT]... |
| 225 | Run mbedtls release validation tests. |
| 226 | By default, run all tests. With one or more COMPONENT, run only those. |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 227 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 228 | |
| 229 | Examples: |
| 230 | $0 "check_*" |
| 231 | Run all sanity checks. |
| 232 | $0 --no-armcc --except test_memsan |
| 233 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 234 | |
| 235 | Special options: |
| 236 | -h|--help Print this help and exit. |
Gilles Peskine | b3241cb | 2019-01-08 23:44:07 +0100 | [diff] [blame] | 237 | --list-all-components List all available test components and exit. |
| 238 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 239 | |
| 240 | General options: |
| 241 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 242 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 243 | -m|--memory Additional optional memory tests. |
Gilles Peskine | f1709bb | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 244 | --arm-none-eabi-gcc-prefix=<string> |
| 245 | Prefix for a cross-compiler for arm-none-eabi |
| 246 | (default: "${ARM_NONE_EABI_GCC_PREFIX}") |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 247 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 248 | --except Exclude the COMPONENTs listed on the command line, |
| 249 | instead of running only those. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 250 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 251 | --no-force Refuse to overwrite modified files (default). |
| 252 | --no-keep-going Stop at the first error (default). |
| 253 | --no-memory No additional memory tests (default). |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 254 | --no-yotta Skip yotta module build. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 255 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 19ceb71 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 256 | --random-seed Use a random seed value for randomized tests (default). |
Manuel Pégourié-Gonnard | 54d95b1 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 257 | -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 258 | -s|--seed Integer seed value to use for this test run. |
Gilles Peskine | 2a22a80 | 2017-12-21 15:19:00 +0100 | [diff] [blame] | 259 | --yotta Build yotta module (on by default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 260 | |
| 261 | Tool path options: |
| 262 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 263 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 264 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 265 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 266 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 267 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 268 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 269 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3. |
| 270 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 271 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 272 | |
| 273 | # remove built files as well as the cmake cache/config |
| 274 | cleanup() |
| 275 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 276 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 277 | cd "$MBEDTLS_ROOT_DIR" |
| 278 | fi |
| 279 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 280 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 281 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 282 | # Remove CMake artefacts |
| 283 | find . -name .git -prune -o -name yotta -prune -o \ |
| 284 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 285 | \( -iname cmake_install.cmake -o \ |
| 286 | -iname CTestTestfile.cmake -o \ |
| 287 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 288 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 289 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 290 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 291 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 292 | |
| 293 | if [ -f "$CONFIG_BAK" ]; then |
| 294 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 295 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 296 | } |
| 297 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 298 | # Executed on exit. May be redefined depending on command line options. |
| 299 | final_report () { |
| 300 | : |
| 301 | } |
| 302 | |
| 303 | fatal_signal () { |
| 304 | cleanup |
| 305 | final_report $1 |
| 306 | trap - $1 |
| 307 | kill -$1 $$ |
| 308 | } |
| 309 | |
| 310 | trap 'fatal_signal HUP' HUP |
| 311 | trap 'fatal_signal INT' INT |
| 312 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 313 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 314 | msg() |
| 315 | { |
Gilles Peskine | 11ddca6 | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 316 | if [ -n "${current_component:-}" ]; then |
| 317 | current_section="${current_component#component_}: $1" |
| 318 | else |
| 319 | current_section="$1" |
| 320 | fi |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 321 | echo "" |
| 322 | echo "******************************************************************" |
Gilles Peskine | 11ddca6 | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 323 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 324 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 325 | echo "******************************************************************" |
| 326 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 327 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 328 | armc6_build_test() |
| 329 | { |
| 330 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 331 | |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 332 | msg "build: ARM Compiler 6 ($FLAGS)" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 333 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 334 | WARNING_CFLAGS='-xc -std=c99' make lib |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 335 | |
| 336 | msg "size: ARM Compiler 6 ($FLAGS)" |
| 337 | "$ARMC6_FROMELF" -z library/*.o |
| 338 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 339 | make clean |
| 340 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 341 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 342 | err_msg() |
| 343 | { |
| 344 | echo "$1" >&2 |
| 345 | } |
| 346 | |
| 347 | check_tools() |
| 348 | { |
| 349 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 350 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 351 | err_msg "$TOOL not found!" |
| 352 | exit 1 |
| 353 | fi |
| 354 | done |
| 355 | } |
| 356 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 357 | pre_parse_command_line () { |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 358 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 359 | all_except=0 |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 360 | no_armcc= |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 361 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 362 | while [ $# -gt 0 ]; do |
| 363 | case "$1" in |
Gilles Peskine | f1709bb | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 364 | --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 365 | --armcc) no_armcc=;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 366 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 367 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 368 | --except) all_except=1;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 369 | --force|-f) FORCE=1;; |
| 370 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 371 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 372 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 373 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 374 | --help|-h) usage; exit;; |
| 375 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | b3241cb | 2019-01-08 23:44:07 +0100 | [diff] [blame] | 376 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 377 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 378 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 379 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 380 | --no-force) FORCE=0;; |
| 381 | --no-keep-going) KEEP_GOING=0;; |
| 382 | --no-memory) MEMORY=0;; |
| 383 | --no-yotta) YOTTA=0;; |
| 384 | --openssl) shift; OPENSSL="$1";; |
| 385 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 386 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
| 387 | --random-seed) unset SEED;; |
Manuel Pégourié-Gonnard | 54d95b1 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 388 | --release-test|-r) SEED=$RELEASE_SEED;; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 389 | --seed|-s) shift; SEED="$1";; |
| 390 | --yotta) YOTTA=1;; |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 391 | -*) |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 392 | echo >&2 "Unknown option: $1" |
| 393 | echo >&2 "Run $0 --help for usage." |
| 394 | exit 120 |
| 395 | ;; |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 396 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 397 | esac |
| 398 | shift |
| 399 | done |
Gilles Peskine | 91bd8b7 | 2019-01-08 23:01:34 +0100 | [diff] [blame] | 400 | |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 401 | # With no list of components, run everything. |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 402 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 403 | all_except=1 |
| 404 | fi |
| 405 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 406 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 407 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 408 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 409 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
| 410 | # --no-armcc also disables yotta. |
| 411 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_yotta*" |
| 412 | fi |
| 413 | |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 414 | # Build the list of components to run. |
Gilles Peskine | ff7238f | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 415 | RUN_COMPONENTS= |
| 416 | for component in $SUPPORTED_COMPONENTS; do |
| 417 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 418 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 419 | fi |
| 420 | done |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 421 | |
| 422 | unset all_except |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 423 | unset no_armcc |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 424 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 425 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 426 | pre_check_git () { |
| 427 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | c780095 | 2019-01-09 23:14:09 +0100 | [diff] [blame] | 428 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 429 | if [ $YOTTA -eq 1 ]; then |
Gilles Peskine | c780095 | 2019-01-09 23:14:09 +0100 | [diff] [blame] | 430 | rm -rf yotta/module |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 431 | fi |
| 432 | git checkout-index -f -q $CONFIG_H |
| 433 | cleanup |
| 434 | else |
| 435 | |
| 436 | if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then |
| 437 | err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'" |
| 438 | echo "You can either delete your work and retry, or force the test to overwrite the" |
| 439 | echo "test by rerunning the script as: $0 --force" |
| 440 | exit 1 |
| 441 | fi |
| 442 | |
| 443 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 444 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 445 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 446 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 447 | exit 1 |
| 448 | fi |
| 449 | |
Gilles Peskine | c9663b1 | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 450 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 451 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 452 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 453 | echo "script as: $0 --force" |
| 454 | exit 1 |
| 455 | fi |
Gilles Peskine | da51925 | 2017-11-30 13:22:04 +0100 | [diff] [blame] | 456 | fi |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 457 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 458 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 459 | pre_setup_keep_going () { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 460 | failure_summary= |
| 461 | failure_count=0 |
| 462 | start_red= |
| 463 | end_color= |
| 464 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 465 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 466 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 467 | start_red=$(printf '\033[31m') |
| 468 | end_color=$(printf '\033[0m') |
| 469 | ;; |
| 470 | esac |
| 471 | fi |
| 472 | record_status () { |
| 473 | if "$@"; then |
| 474 | last_status=0 |
| 475 | else |
| 476 | last_status=$? |
| 477 | text="$current_section: $* -> $last_status" |
| 478 | failure_summary="$failure_summary |
| 479 | $text" |
| 480 | failure_count=$((failure_count + 1)) |
| 481 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 482 | fi |
| 483 | } |
| 484 | make () { |
| 485 | case "$*" in |
| 486 | *test|*check) |
| 487 | if [ $build_status -eq 0 ]; then |
| 488 | record_status command make "$@" |
| 489 | else |
| 490 | echo "(skipped because the build failed)" |
| 491 | fi |
| 492 | ;; |
| 493 | *) |
| 494 | record_status command make "$@" |
| 495 | build_status=$last_status |
| 496 | ;; |
| 497 | esac |
| 498 | } |
| 499 | final_report () { |
| 500 | if [ $failure_count -gt 0 ]; then |
| 501 | echo |
| 502 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 503 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 504 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 5113bde | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 505 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 506 | elif [ -z "${1-}" ]; then |
| 507 | echo "SUCCESS :)" |
| 508 | fi |
| 509 | if [ -n "${1-}" ]; then |
| 510 | echo "Killed by SIG$1." |
| 511 | fi |
| 512 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 515 | if_build_succeeded () { |
| 516 | if [ $build_status -eq 0 ]; then |
| 517 | record_status "$@" |
| 518 | fi |
| 519 | } |
| 520 | |
Gilles Peskine | 30bc385 | 2019-01-09 23:25:25 +0100 | [diff] [blame] | 521 | # to be used instead of ! for commands run with |
| 522 | # record_status or if_build_succeeded |
| 523 | not() { |
| 524 | ! "$@" |
| 525 | } |
| 526 | |
| 527 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 528 | pre_print_configuration () { |
| 529 | msg "info: $0 configuration" |
| 530 | echo "MEMORY: $MEMORY" |
| 531 | echo "FORCE: $FORCE" |
| 532 | echo "SEED: ${SEED-"UNSET"}" |
| 533 | echo "OPENSSL: $OPENSSL" |
| 534 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 535 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 536 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 537 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 538 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 539 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 540 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 541 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 542 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 543 | # Make sure the tools we need are available. |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 544 | pre_check_tools () { |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 545 | # Build the list of variables to pass to output_env.sh. |
| 546 | set env |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 547 | |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 548 | case " $RUN_COMPONENTS " in |
| 549 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 550 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 551 | # is a good enough approximation in practice. |
| 552 | *" test_"*) |
| 553 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 554 | # and ssl-opt.sh, we just export the variables they require. |
| 555 | export OPENSSL_CMD="$OPENSSL" |
| 556 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 557 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 558 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 559 | if [ -n "${SEED-}" ]; then |
| 560 | export SEED |
| 561 | fi |
| 562 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 563 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 564 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 565 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
| 566 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" \ |
| 567 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 568 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 569 | ;; |
| 570 | esac |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 571 | |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 572 | case " $RUN_COMPONENTS " in |
| 573 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 574 | esac |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 575 | |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 576 | case " $RUN_COMPONENTS " in |
Gilles Peskine | f1709bb | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 577 | *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";; |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 578 | esac |
| 579 | |
| 580 | case " $RUN_COMPONENTS " in |
| 581 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 582 | esac |
| 583 | |
| 584 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 585 | *_armcc*|*_yotta*) |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 586 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 587 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 588 | ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf" |
Gilles Peskine | 541fb1e | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 589 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 590 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 591 | ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf" |
| 592 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \ |
| 593 | "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 594 | esac |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 595 | |
| 596 | msg "info: output_env.sh" |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 597 | case $RUN_COMPONENTS in |
| 598 | *_armcc*|*_yotta*) |
| 599 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 600 | *) set "$@" RUN_ARMCC=0;; |
| 601 | esac |
| 602 | "$@" scripts/output_env.sh |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 603 | } |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 604 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 605 | |
| 606 | |
| 607 | ################################################################ |
| 608 | #### Basic checks |
| 609 | ################################################################ |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 610 | |
| 611 | # |
| 612 | # Test Suites to be executed |
| 613 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 614 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 615 | # 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] | 616 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 617 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 618 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 619 | # |
| 620 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 621 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 622 | component_check_recursion () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 623 | msg "test: recursion.pl" # < 1s |
| 624 | record_status tests/scripts/recursion.pl library/*.c |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 625 | } |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 626 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 627 | component_check_generated_files () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 628 | msg "test: freshness of generated source files" # < 1s |
| 629 | record_status tests/scripts/check-generated-files.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 630 | } |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 631 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 632 | component_check_doxy_blocks () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 633 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 634 | record_status tests/scripts/check-doxy-blocks.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 635 | } |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 636 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 637 | component_check_files () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 638 | msg "test: check-files.py" # < 1s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 639 | record_status tests/scripts/check-files.py |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 640 | } |
Manuel Pégourié-Gonnard | 77d56bb | 2015-07-28 15:00:37 +0200 | [diff] [blame] | 641 | |
Gilles Peskine | c318925 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 642 | component_check_changelog () { |
| 643 | msg "Check: changelog entries" # < 1s |
| 644 | rm -f ChangeLog.new |
| 645 | record_status scripts/assemble_changelog.py -o ChangeLog.new |
| 646 | if [ -e ChangeLog.new ]; then |
| 647 | # Show the diff for information. It isn't an error if the diff is |
| 648 | # non-empty. |
| 649 | diff -u ChangeLog ChangeLog.new || true |
| 650 | rm ChangeLog.new |
| 651 | fi |
| 652 | } |
| 653 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 654 | component_check_names () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 655 | msg "test/build: declared and exported names" # < 3s |
Gilles Peskine | e952fdf | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 656 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 657 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 658 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 659 | component_check_doxygen_warnings () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 660 | msg "test: doxygen warnings" # ~ 3s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 661 | record_status tests/scripts/doxygen.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 662 | } |
Andres Amaya Garcia | dd29c2f | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 663 | |
Simon Butcher | 948f264 | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 664 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 665 | ################################################################ |
| 666 | #### Build and test many configurations and targets |
| 667 | ################################################################ |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 668 | |
k-stachowiak | 45d0ba1 | 2019-06-04 13:14:58 +0200 | [diff] [blame] | 669 | component_test_large_ecdsa_key_signature () { |
| 670 | |
| 671 | SMALL_MPI_MAX_SIZE=136 # Small enough to interfere with the EC signatures |
| 672 | |
| 673 | msg "build: cmake + MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE}, gcc, ASan" # ~ 1 min 50s |
| 674 | scripts/config.pl set MBEDTLS_MPI_MAX_SIZE $SMALL_MPI_MAX_SIZE |
| 675 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 676 | make |
| 677 | |
| 678 | INEVITABLY_PRESENT_FILE=Makefile |
| 679 | SIGNATURE_FILE="${INEVITABLY_PRESENT_FILE}.sig" # Warning, this is rm -f'ed below |
| 680 | |
| 681 | msg "test: pk_sign secp521r1_prv.der for MBEDTLS_MPI_MAX_SIZE=${SMALL_MPI_MAX_SIZE} (ASan build)" # ~ 5s |
| 682 | if_build_succeeded programs/pkey/pk_sign tests/data_files/secp521r1_prv.der $INEVITABLY_PRESENT_FILE |
| 683 | rm -f $SIGNATURE_FILE |
| 684 | } |
| 685 | |
Gilles Peskine | 1270d32 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 686 | component_test_default_out_of_box () { |
| 687 | msg "build: make, default config (out-of-box)" # ~1min |
| 688 | make |
| 689 | |
| 690 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 691 | make test |
| 692 | |
| 693 | msg "selftest: make, default config (out-of-box)" # ~10s |
Gilles Peskine | bfda033 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 694 | if_build_succeeded programs/test/selftest |
Gilles Peskine | 1270d32 | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 695 | } |
| 696 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 697 | component_build_yotta () { |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 698 | # Note - use of yotta is deprecated, and yotta also requires armcc to be on the |
| 699 | # path, and uses whatever version of armcc it finds there. |
| 700 | msg "build: create and build yotta module" # ~ 30s |
| 701 | record_status tests/scripts/yotta-build.sh |
| 702 | } |
| 703 | support_build_yotta () { |
| 704 | [ $YOTTA -ne 0 ] |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 705 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 706 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 707 | component_test_default_cmake_gcc_asan () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 708 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 709 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 710 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 711 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 712 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 713 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 714 | |
Gilles Peskine | bfda033 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 715 | msg "test: selftest (ASan build)" # ~ 10s |
| 716 | if_build_succeeded programs/test/selftest |
| 717 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 718 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 719 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 720 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 721 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 722 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 723 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 724 | |
Hanno Becker | 167ae43 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 725 | component_test_full_cmake_gcc_asan () { |
| 726 | msg "build: full config, cmake, gcc, ASan" |
| 727 | scripts/config.pl full |
| 728 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 729 | make |
| 730 | |
| 731 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 732 | make test |
| 733 | |
Gilles Peskine | bfda033 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 734 | msg "test: selftest (ASan build)" # ~ 10s |
| 735 | if_build_succeeded programs/test/selftest |
| 736 | |
Hanno Becker | 167ae43 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 737 | msg "test: ssl-opt.sh (full config, ASan build)" |
| 738 | if_build_succeeded tests/ssl-opt.sh |
| 739 | |
| 740 | msg "test: compat.sh (full config, ASan build)" |
| 741 | if_build_succeeded tests/compat.sh |
| 742 | } |
| 743 | |
Manuel Pégourié-Gonnard | 51e2494 | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 744 | component_test_zlib_make() { |
| 745 | msg "build: zlib enabled, make" |
| 746 | scripts/config.pl set MBEDTLS_ZLIB_SUPPORT |
| 747 | make ZLIB=1 CFLAGS='-Werror -O1' |
| 748 | |
| 749 | msg "test: main suites (zlib, make)" |
| 750 | make test |
| 751 | |
| 752 | msg "test: ssl-opt.sh (zlib, make)" |
| 753 | if_build_succeeded tests/ssl-opt.sh |
| 754 | } |
Manuel Pégourié-Gonnard | 2150fb2 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 755 | support_test_zlib_make () { |
| 756 | base=support_test_zlib_$$ |
| 757 | cat <<'EOF' > ${base}.c |
| 758 | #include "zlib.h" |
| 759 | int main(void) { return 0; } |
| 760 | EOF |
| 761 | gcc -o ${base}.exe ${base}.c -lz 2>/dev/null |
| 762 | ret=$? |
| 763 | rm -f ${base}.* |
| 764 | return $ret |
| 765 | } |
Manuel Pégourié-Gonnard | 51e2494 | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 766 | |
| 767 | component_test_zlib_cmake() { |
| 768 | msg "build: zlib enabled, cmake" |
| 769 | scripts/config.pl set MBEDTLS_ZLIB_SUPPORT |
| 770 | cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check . |
| 771 | make |
| 772 | |
| 773 | msg "test: main suites (zlib, cmake)" |
| 774 | make test |
| 775 | |
| 776 | msg "test: ssl-opt.sh (zlib, cmake)" |
| 777 | if_build_succeeded tests/ssl-opt.sh |
| 778 | } |
Manuel Pégourié-Gonnard | 2150fb2 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 779 | support_test_zlib_cmake () { |
| 780 | support_test_zlib_make "$@" |
| 781 | } |
Manuel Pégourié-Gonnard | 51e2494 | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 782 | |
Gilles Peskine | 3484ed8 | 2019-01-08 22:51:19 +0100 | [diff] [blame] | 783 | component_test_ref_configs () { |
| 784 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 785 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 786 | record_status tests/scripts/test-ref-configs.pl |
| 787 | } |
| 788 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 789 | component_test_sslv3 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 790 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 791 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 792 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 793 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 794 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 795 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 796 | make test |
| 797 | |
| 798 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
| 799 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 800 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
| 801 | |
| 802 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 803 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 804 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 805 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 806 | component_test_no_renegotiation () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 807 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 808 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 809 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 810 | make |
| 811 | |
| 812 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 813 | make test |
| 814 | |
| 815 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 816 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 817 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 818 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 819 | component_test_rsa_no_crt () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 820 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 821 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 822 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 823 | make |
| 824 | |
| 825 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 826 | make test |
| 827 | |
| 828 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 829 | if_build_succeeded tests/ssl-opt.sh -f RSA |
| 830 | |
| 831 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 832 | if_build_succeeded tests/compat.sh -t RSA |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 833 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 834 | |
Manuel Pégourié-Gonnard | c98fde5 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 835 | component_test_no_ctr_drbg () { |
| 836 | msg "build: Full minus CTR_DRBG" |
| 837 | scripts/config.pl full |
| 838 | scripts/config.pl unset MBEDTLS_CTR_DRBG_C |
| 839 | |
| 840 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 841 | make |
| 842 | |
| 843 | msg "test: no CTR_DRBG" |
| 844 | make test |
| 845 | |
Manuel Pégourié-Gonnard | cdfa2f9 | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 846 | # no ssl-opt.sh/compat.sh as they all depend on CTR_DRBG so far |
| 847 | } |
| 848 | |
| 849 | component_test_no_hmac_drbg () { |
| 850 | msg "build: Full minus HMAC_DRBG" |
| 851 | scripts/config.pl full |
| 852 | scripts/config.pl unset MBEDTLS_HMAC_DRBG_C |
| 853 | scripts/config.pl unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 854 | |
| 855 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 856 | make |
| 857 | |
| 858 | msg "test: no HMAC_DRBG" |
| 859 | make test |
| 860 | |
| 861 | # No ssl-opt.sh/compat.sh as they never use HMAC_DRBG so far, |
| 862 | # so there's little value in running those lengthy tests here. |
Manuel Pégourié-Gonnard | c98fde5 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 863 | } |
| 864 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 865 | component_test_full_cmake_clang () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 866 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 867 | scripts/config.pl full |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 868 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 869 | make |
| 870 | |
| 871 | msg "test: main suites (full config)" # ~ 5s |
| 872 | make test |
| 873 | |
| 874 | msg "test: ssl-opt.sh default (full config)" # ~ 1s |
| 875 | if_build_succeeded tests/ssl-opt.sh -f Default |
| 876 | |
Andres Amaya Garcia | 0a0e5b1 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 877 | msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min |
Andres Amaya Garcia | fea3d0a | 2019-02-19 20:20:57 +0000 | [diff] [blame] | 878 | 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' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 879 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 880 | |
Gilles Peskine | adaaddb | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 881 | component_test_default_no_deprecated () { |
| 882 | # Test that removing the deprecated features from the default |
| 883 | # configuration leaves something consistent. |
| 884 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 885 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
Gilles Peskine | adaaddb | 2020-04-28 14:04:28 +0200 | [diff] [blame] | 886 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 887 | |
| 888 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 889 | make test |
| 890 | } |
| 891 | |
| 892 | component_test_full_deprecated_warning () { |
| 893 | # Test that there is nothing deprecated in the full configuraration. |
| 894 | # A deprecated feature would trigger a warning (made fatal) from |
| 895 | # MBEDTLS_DEPRECATED_WARNING. |
| 896 | msg "build: make, full + MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 897 | scripts/config.pl full |
| 898 | scripts/config.pl unset MBEDTLS_DEPRECATED_REMOVED |
| 899 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
| 900 | # There are currently no tests for any deprecated feature. |
| 901 | # If some are added, 'make test' would trigger warnings here. |
| 902 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 903 | |
| 904 | msg "test: make, full + MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
| 905 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 906 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 907 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 908 | component_test_depends_curves () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 909 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 910 | record_status tests/scripts/curves.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 911 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 912 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 913 | component_test_depends_hashes () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 914 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 915 | record_status tests/scripts/depends-hashes.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 916 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 917 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 918 | component_test_depends_pkalgs () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 919 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 920 | record_status tests/scripts/depends-pkalgs.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 921 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 922 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 923 | component_build_key_exchanges () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 924 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 925 | record_status tests/scripts/key-exchanges.pl |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 926 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 927 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 928 | component_build_default_make_gcc () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 929 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 930 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 931 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 932 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 933 | component_test_no_platform () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 934 | # Full configuration build, without platform support, file IO and net sockets. |
| 935 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 936 | # IO, it should catch missing '#include <stdio.h>' |
| 937 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 938 | scripts/config.pl full |
| 939 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 940 | scripts/config.pl unset MBEDTLS_NET_C |
| 941 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 942 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 943 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 944 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 945 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 946 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | a21c5e9 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 947 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 948 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 949 | scripts/config.pl unset MBEDTLS_FS_IO |
| 950 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 951 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | c924712 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 952 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 953 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 954 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 955 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 956 | component_build_no_std_function () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 957 | # catch compile bugs in _uninit functions |
| 958 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 959 | scripts/config.pl full |
| 960 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 961 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | a21c5e9 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 962 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | c924712 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 963 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 964 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 965 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 966 | component_build_no_ssl_srv () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 967 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 968 | scripts/config.pl full |
| 969 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | c924712 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 970 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 971 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 972 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 973 | component_build_no_ssl_cli () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 974 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 975 | scripts/config.pl full |
| 976 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | c924712 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 977 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 978 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 979 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 980 | component_build_no_sockets () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 981 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 982 | # as that requires a POSIX platform (which isn't the same as C99). |
| 983 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 984 | scripts/config.pl full |
| 985 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 986 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | c924712 | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 987 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 988 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 989 | |
Andrzej Kurek | 9a461a1 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 990 | component_test_memory_buffer_allocator_backtrace () { |
| 991 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 992 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Andrzej Kurek | 9a461a1 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 993 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 994 | scripts/config.pl set MBEDTLS_MEMORY_BACKTRACE |
Andrzej Kurek | 9b1c248 | 2019-09-10 02:58:34 -0400 | [diff] [blame] | 995 | scripts/config.pl set MBEDTLS_MEMORY_DEBUG |
Andrzej Kurek | 9a461a1 | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 996 | CC=gcc cmake . |
| 997 | make |
| 998 | |
| 999 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1000 | make test |
| 1001 | } |
| 1002 | |
| 1003 | component_test_memory_buffer_allocator () { |
| 1004 | msg "build: default config with memory buffer allocator" |
| 1005 | scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Hanno Becker | 7aad93c | 2019-06-03 16:35:02 +0100 | [diff] [blame] | 1006 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1007 | CC=gcc cmake . |
| 1008 | make |
| 1009 | |
| 1010 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1011 | make test |
| 1012 | |
| 1013 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
Andrzej Kurek | 6addfdd | 2019-09-05 10:09:37 -0400 | [diff] [blame] | 1014 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 1015 | if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | f5baaaa | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1016 | } |
| 1017 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1018 | component_test_no_max_fragment_length () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1019 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1020 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1021 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1022 | make |
| 1023 | |
| 1024 | msg "test: ssl-opt.sh, MFL-related tests" |
| 1025 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1026 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1027 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1028 | component_test_null_entropy () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1029 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1030 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
| 1031 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 1032 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 1033 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | a21c5e9 | 2020-04-28 10:41:20 +0200 | [diff] [blame] | 1034 | scripts/config.pl unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1035 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 1036 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 4e7b323 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 1037 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON . |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1038 | make |
| 1039 | |
| 1040 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 1041 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1042 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1043 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1044 | component_test_platform_calloc_macro () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1045 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1046 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 1047 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 1048 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 1049 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1050 | make |
| 1051 | |
| 1052 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 1053 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1054 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1055 | |
Gilles Peskine | 0981a5d | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1056 | component_test_malloc_0_null () { |
| 1057 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
| 1058 | scripts/config.pl full |
| 1059 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1060 | 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' |
| 1061 | |
| 1062 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 1063 | make test |
| 1064 | |
| 1065 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 1066 | # Just the calloc selftest. "make test" ran the others as part of the |
| 1067 | # test suites. |
| 1068 | if_build_succeeded programs/test/selftest calloc |
| 1069 | } |
| 1070 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1071 | component_test_make_shared () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1072 | msg "build/test: make shared" # ~ 40s |
| 1073 | make SHARED=1 all check |
Gilles Peskine | 950de1e | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1074 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1075 | } |
| 1076 | |
Gilles Peskine | 17ecb24 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1077 | component_test_cmake_shared () { |
| 1078 | msg "build/test: cmake shared" # ~ 2min |
| 1079 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 1080 | make |
Gilles Peskine | 950de1e | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1081 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 17ecb24 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1082 | make test |
| 1083 | } |
| 1084 | |
Gilles Peskine | fa0e8b5 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1085 | test_build_opt () { |
| 1086 | info=$1 cc=$2; shift 2 |
| 1087 | for opt in "$@"; do |
| 1088 | msg "build/test: $cc $opt, $info" # ~ 30s |
| 1089 | make CC="$cc" CFLAGS="$opt -Wall -Wextra -Werror" |
| 1090 | # We're confident enough in compilers to not run _all_ the tests, |
| 1091 | # but at least run the unit tests. In particular, runs with |
| 1092 | # optimizations use inline assembly whereas runs with -O0 |
| 1093 | # skip inline assembly. |
| 1094 | make test # ~30s |
| 1095 | make clean |
| 1096 | done |
| 1097 | } |
| 1098 | |
| 1099 | component_test_clang_opt () { |
| 1100 | scripts/config.pl full |
| 1101 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 1102 | } |
| 1103 | |
| 1104 | component_test_gcc_opt () { |
| 1105 | scripts/config.pl full |
| 1106 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 1107 | } |
| 1108 | |
Gilles Peskine | f852f5f | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1109 | component_build_mbedtls_config_file () { |
| 1110 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 1111 | # Use the full config so as to catch a maximum of places where |
| 1112 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
| 1113 | scripts/config.pl full |
| 1114 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 1115 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 1116 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 1117 | rm -f full_config.h |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1118 | } |
| 1119 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1120 | component_test_m32_o0 () { |
| 1121 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 1122 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
| 1123 | scripts/config.pl full |
Gilles Peskine | c20a405 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1124 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1125 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1126 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 1127 | make test |
| 1128 | } |
| 1129 | support_test_m32_o0 () { |
| 1130 | case $(uname -m) in |
| 1131 | *64*) true;; |
| 1132 | *) false;; |
| 1133 | esac |
| 1134 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1135 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1136 | component_test_m32_o1 () { |
| 1137 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 1138 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
| 1139 | scripts/config.pl full |
Gilles Peskine | c20a405 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1140 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1141 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1142 | msg "test: i386, make, gcc -O1 (ASan build)" |
| 1143 | make test |
Gilles Peskine | 1106429 | 2019-04-08 16:58:02 +0200 | [diff] [blame] | 1144 | |
| 1145 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 1146 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1147 | } |
| 1148 | support_test_m32_o1 () { |
| 1149 | support_test_m32_o0 "$@" |
| 1150 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1151 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1152 | component_test_mx32 () { |
| 1153 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
| 1154 | scripts/config.pl full |
Gilles Peskine | d535f4d | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 1155 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1156 | |
Gilles Peskine | 3fbdd21 | 2019-01-08 23:33:45 +0100 | [diff] [blame] | 1157 | msg "test: 64-bit ILP32, make, gcc" |
| 1158 | make test |
| 1159 | } |
| 1160 | support_test_mx32 () { |
| 1161 | case $(uname -m) in |
| 1162 | amd64|x86_64) true;; |
| 1163 | *) false;; |
| 1164 | esac |
| 1165 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1166 | |
Peter Kolbus | 16015dd | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1167 | component_test_min_mpi_window_size () { |
| 1168 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
| 1169 | scripts/config.pl set MBEDTLS_MPI_WINDOW_SIZE 1 |
| 1170 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1171 | make |
| 1172 | |
| 1173 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 1174 | make test |
| 1175 | } |
| 1176 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1177 | component_test_have_int32 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1178 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1179 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 1180 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 1181 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 1182 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
| 1183 | |
| 1184 | msg "test: gcc, force 32-bit bignum limbs" |
| 1185 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1186 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1187 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1188 | component_test_have_int64 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1189 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1190 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 1191 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 1192 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 1193 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
| 1194 | |
| 1195 | msg "test: gcc, force 64-bit bignum limbs" |
| 1196 | make test |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1197 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1198 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1199 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1200 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s |
Manuel Pégourié-Gonnard | 59bc9a1 | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1201 | scripts/config.pl baremetal |
Gilles Peskine | 009908b | 2020-04-30 22:54:00 +0200 | [diff] [blame] | 1202 | 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 | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1203 | |
| 1204 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" |
| 1205 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1206 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1207 | |
Gilles Peskine | a27af6f | 2020-04-30 23:22:55 +0200 | [diff] [blame] | 1208 | component_build_arm_none_eabi_gcc_arm5vte () { |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1209 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s |
Gilles Peskine | a27af6f | 2020-04-30 23:22:55 +0200 | [diff] [blame] | 1210 | scripts/config.pl baremetal |
| 1211 | # Build for a target platform that's close to what Debian uses |
| 1212 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 1213 | # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. |
| 1214 | # It would be better to build with arm-linux-gnueabi-gcc but |
| 1215 | # we don't have that on our CI at this time. |
| 1216 | 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 | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1217 | |
| 1218 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" |
| 1219 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | a27af6f | 2020-04-30 23:22:55 +0200 | [diff] [blame] | 1220 | } |
| 1221 | |
Gilles Peskine | 4fb7a2f | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 1222 | component_build_arm_none_eabi_gcc_m0plus () { |
| 1223 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s |
| 1224 | scripts/config.pl baremetal |
| 1225 | 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 | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1226 | |
| 1227 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os" |
| 1228 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1229 | } |
| 1230 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1231 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | f1709bb | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1232 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX} -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Manuel Pégourié-Gonnard | 59bc9a1 | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1233 | scripts/config.pl baremetal |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1234 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | f1709bb | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1235 | 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 |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1236 | echo "Checking that software 64-bit division is not required" |
Gilles Peskine | 30bc385 | 2019-01-09 23:25:25 +0100 | [diff] [blame] | 1237 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1238 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1239 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1240 | component_build_armcc () { |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1241 | msg "build: ARM Compiler 5" |
Manuel Pégourié-Gonnard | 59bc9a1 | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1242 | scripts/config.pl baremetal |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1243 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
Gilles Peskine | 81b60fb | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1244 | |
| 1245 | msg "size: ARM Compiler 5" |
| 1246 | "$ARMC5_FROMELF" -z library/*.o |
| 1247 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1248 | make clean |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1249 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1250 | # ARM Compiler 6 - Target ARMv7-A |
| 1251 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1252 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1253 | # ARM Compiler 6 - Target ARMv7-M |
| 1254 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1255 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1256 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1257 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1258 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1259 | # ARM Compiler 6 - Target ARMv8-M |
| 1260 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1261 | |
Gilles Peskine | 5308487 | 2019-01-09 23:13:54 +0100 | [diff] [blame] | 1262 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1263 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1264 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1265 | |
Andres Amaya Garcia | bb13e3b | 2018-12-05 22:03:56 +0000 | [diff] [blame] | 1266 | component_build_ssl_hw_record_accel() { |
| 1267 | msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled" |
| 1268 | scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL |
| 1269 | make CFLAGS='-Werror -O1' |
| 1270 | } |
| 1271 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1272 | component_test_allow_sha1 () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1273 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1274 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
| 1275 | make CFLAGS='-Werror -Wall -Wextra' |
| 1276 | msg "test: allow SHA1 in certificates by default" |
| 1277 | make test |
| 1278 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1279 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1280 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1281 | component_build_mingw () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1282 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1283 | 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 |
| 1284 | |
| 1285 | # note Make tests only builds the tests, but doesn't run them |
| 1286 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
| 1287 | make WINDOWS_BUILD=1 clean |
| 1288 | |
| 1289 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
| 1290 | 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 |
| 1291 | 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 |
| 1292 | make WINDOWS_BUILD=1 clean |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1293 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1294 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1295 | component_test_memsan () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1296 | msg "build: MSan (clang)" # ~ 1 min 20s |
| 1297 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1298 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1299 | make |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1300 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1301 | msg "test: main suites (MSan)" # ~ 10s |
| 1302 | make test |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1303 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1304 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
| 1305 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1306 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1307 | # Optional part(s) |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1308 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1309 | if [ "$MEMORY" -gt 0 ]; then |
| 1310 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
| 1311 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1312 | fi |
| 1313 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1314 | |
Gilles Peskine | 9f55364 | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1315 | component_test_valgrind () { |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1316 | msg "build: Release (clang)" |
| 1317 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1318 | make |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1319 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1320 | msg "test: main suites valgrind (Release)" |
| 1321 | make memcheck |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1322 | |
Gilles Peskine | 26cae71 | 2019-04-08 17:00:56 +0200 | [diff] [blame] | 1323 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1324 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1325 | if [ "$MEMORY" -gt 0 ]; then |
| 1326 | msg "test: ssl-opt.sh --memcheck (Release)" |
| 1327 | if_build_succeeded tests/ssl-opt.sh --memcheck |
| 1328 | fi |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1329 | |
Gilles Peskine | 770ad7e | 2019-01-08 23:19:08 +0100 | [diff] [blame] | 1330 | if [ "$MEMORY" -gt 1 ]; then |
| 1331 | msg "test: compat.sh --memcheck (Release)" |
| 1332 | if_build_succeeded tests/compat.sh --memcheck |
| 1333 | fi |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1334 | } |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1335 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1336 | component_test_cmake_out_of_source () { |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1337 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1338 | MBEDTLS_ROOT_DIR="$PWD" |
| 1339 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1340 | cd "$OUT_OF_SOURCE_DIR" |
| 1341 | cmake "$MBEDTLS_ROOT_DIR" |
| 1342 | make |
| 1343 | |
| 1344 | msg "test: cmake 'out-of-source' build" |
| 1345 | make test |
| 1346 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 1347 | # Also ensure that there are no error messages such as |
| 1348 | # "No such file or directory", which would indicate that some required |
| 1349 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 1350 | # may exit with status 0 but emit errors). |
| 1351 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 1352 | if [ -s ssl-opt.err ]; then |
| 1353 | cat ssl-opt.err >&2 |
| 1354 | record_status [ ! -s ssl-opt.err ] |
| 1355 | rm ssl-opt.err |
| 1356 | fi |
| 1357 | cd "$MBEDTLS_ROOT_DIR" |
| 1358 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1359 | unset MBEDTLS_ROOT_DIR |
| 1360 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1361 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1362 | |
| 1363 | |
| 1364 | ################################################################ |
| 1365 | #### Termination |
| 1366 | ################################################################ |
| 1367 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1368 | post_report () { |
| 1369 | msg "Done, cleaning up" |
| 1370 | cleanup |
| 1371 | |
| 1372 | final_report |
| 1373 | } |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | ################################################################ |
| 1378 | #### Run all the things |
| 1379 | ################################################################ |
| 1380 | |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1381 | # Run one component and clean up afterwards. |
| 1382 | run_component () { |
Gilles Peskine | 72adb43 | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1383 | # Back up the configuration in case the component modifies it. |
| 1384 | # The cleanup function will restore it. |
| 1385 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | 11ddca6 | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1386 | current_component="$1" |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1387 | "$@" |
| 1388 | cleanup |
| 1389 | } |
| 1390 | |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1391 | # Preliminary setup |
| 1392 | pre_check_environment |
| 1393 | pre_initialize_variables |
| 1394 | pre_parse_command_line "$@" |
| 1395 | |
| 1396 | pre_check_git |
| 1397 | build_status=0 |
| 1398 | if [ $KEEP_GOING -eq 1 ]; then |
| 1399 | pre_setup_keep_going |
| 1400 | else |
| 1401 | record_status () { |
| 1402 | "$@" |
| 1403 | } |
| 1404 | fi |
| 1405 | pre_print_configuration |
| 1406 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1407 | cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1408 | |
Gilles Peskine | eb39b9b | 2019-01-08 23:41:00 +0100 | [diff] [blame] | 1409 | # Run the requested tests. |
Gilles Peskine | 6e98423 | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 1410 | for component in $RUN_COMPONENTS; do |
Gilles Peskine | 1a2ca72 | 2019-01-08 22:35:16 +0100 | [diff] [blame] | 1411 | run_component "component_$component" |
| 1412 | done |
Gilles Peskine | 57db6ff | 2019-01-08 22:04:31 +0100 | [diff] [blame] | 1413 | |
| 1414 | # We're done. |
| 1415 | post_report |