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