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