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