Gilles Peskine | 62cf2e8 | 2020-03-27 16:35:23 +0100 | [diff] [blame] | 1 | #! /usr/bin/env bash |
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 | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 5 | # Copyright The Mbed TLS Contributors |
Bence Szépkúti | c7da1fe | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 19 | |
| 20 | |
| 21 | |
| 22 | ################################################################ |
| 23 | #### Documentation |
| 24 | ################################################################ |
| 25 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 26 | # Purpose |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 27 | # ------- |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 28 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 29 | # To run all tests possible or available on the platform. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 30 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 31 | # Notes for users |
| 32 | # --------------- |
| 33 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 34 | # Warning: the test is destructive. It includes various build modes and |
| 35 | # configurations, and can and will arbitrarily change the current CMake |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 36 | # configuration. The following files must be committed into git: |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 37 | # * include/mbedtls/mbedtls_config.h |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 38 | # * Makefile, library/Makefile, programs/Makefile, tests/Makefile, |
| 39 | # programs/fuzz/Makefile |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 40 | # After running this script, the CMake cache will be lost and CMake |
| 41 | # will no longer be initialised. |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 42 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 43 | # The script assumes the presence of a number of tools: |
| 44 | # * Basic Unix tools (Windows users note: a Unix-style find must be before |
| 45 | # the Windows find in the PATH) |
| 46 | # * Perl |
| 47 | # * GNU Make |
| 48 | # * CMake |
| 49 | # * 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] | 50 | # * G++ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 51 | # * arm-gcc and mingw-gcc |
| 52 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 53 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
Mateusz Starzyk | f5c5351 | 2021-04-15 13:28:52 +0200 | [diff] [blame] | 54 | # interoperability tests. If they don't support old features which we want |
| 55 | # to test, then a legacy version of these tools must be present as well |
| 56 | # (search for LEGACY below). |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 57 | # See the invocation of check_tools below for details. |
| 58 | # |
| 59 | # This script must be invoked from the toplevel directory of a git |
| 60 | # working copy of Mbed TLS. |
| 61 | # |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 62 | # The behavior on an error depends on whether --keep-going (alias -k) |
| 63 | # is in effect. |
| 64 | # * Without --keep-going: the script stops on the first error without |
| 65 | # cleaning up. This lets you work in the configuration of the failing |
| 66 | # component. |
| 67 | # * With --keep-going: the script runs all requested components and |
| 68 | # reports failures at the end. In particular the script always cleans |
| 69 | # up on exit. |
| 70 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 71 | # Note that the output is not saved. You may want to run |
| 72 | # script -c tests/scripts/all.sh |
| 73 | # or |
| 74 | # tests/scripts/all.sh >all.log 2>&1 |
| 75 | # |
| 76 | # Notes for maintainers |
| 77 | # --------------------- |
| 78 | # |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 79 | # The bulk of the code is organized into functions that follow one of the |
| 80 | # following naming conventions: |
| 81 | # * pre_XXX: things to do before running the tests, in order. |
| 82 | # * component_XXX: independent components. They can be run in any order. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 83 | # * component_check_XXX: quick tests that aren't worth parallelizing. |
| 84 | # * component_build_XXX: build things but don't run them. |
| 85 | # * component_test_XXX: build and test. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 86 | # * support_XXX: if support_XXX exists and returns false then |
| 87 | # component_XXX is not run by default. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 88 | # * post_XXX: things to do after running the tests. |
| 89 | # * other: miscellaneous support functions. |
| 90 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 91 | # Each component must start by invoking `msg` with a short informative message. |
| 92 | # |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 93 | # Warning: due to the way bash detects errors, the failure of a command |
| 94 | # inside 'if' or '!' is not detected. Use the 'not' function instead of '!'. |
| 95 | # |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 96 | # Each component is executed in a separate shell process. The component |
| 97 | # fails if any command in it returns a non-zero status. |
| 98 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 99 | # The framework performs some cleanup tasks after each component. This |
| 100 | # means that components can assume that the working directory is in a |
| 101 | # cleaned-up state, and don't need to perform the cleanup themselves. |
| 102 | # * Run `make clean`. |
Bence Szépkúti | 414d6bd | 2021-06-28 14:11:11 +0100 | [diff] [blame] | 103 | # * Restore `include/mbedtls/mbedtls_config.h` from a backup made before running |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 104 | # the component. |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 105 | # * Check out `Makefile`, `library/Makefile`, `programs/Makefile`, |
| 106 | # `tests/Makefile` and `programs/fuzz/Makefile` from git. |
| 107 | # This cleans up after an in-tree use of CMake. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 108 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 109 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 110 | # have to be exact, but in general you should add slower tests towards |
| 111 | # the end and fast checks near the beginning. |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 112 | |
| 113 | |
| 114 | |
| 115 | ################################################################ |
| 116 | #### Initialization and command line parsing |
| 117 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 118 | |
Gilles Peskine | 3664780 | 2020-03-28 18:50:49 +0100 | [diff] [blame] | 119 | # Abort on errors (even on the left-hand side of a pipe). |
| 120 | # Treat uninitialised variables as errors. |
| 121 | set -e -o pipefail -u |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 122 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 123 | pre_check_environment () { |
Gilles Peskine | a16c2b1 | 2019-01-06 19:58:02 +0000 | [diff] [blame] | 124 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 125 | echo "Must be run from mbed TLS root" >&2 |
| 126 | exit 1 |
| 127 | fi |
| 128 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 129 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 130 | pre_initialize_variables () { |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 131 | CONFIG_H='include/mbedtls/mbedtls_config.h' |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 132 | CRYPTO_CONFIG_H='include/psa/crypto_config.h' |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 133 | |
| 134 | # Files that are clobbered by some jobs will be backed up. Use a different |
| 135 | # suffix from auxiliary scripts so that all.sh and auxiliary scripts can |
| 136 | # independently decide when to remove the backup file. |
| 137 | backup_suffix='.all.bak' |
| 138 | # Files clobbered by config.py |
| 139 | files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H" |
Gilles Peskine | 568f53a | 2021-07-12 18:16:01 +0200 | [diff] [blame] | 140 | # Files clobbered by in-tree cmake |
| 141 | files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 142 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 143 | append_outcome=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 144 | MEMORY=0 |
| 145 | FORCE=0 |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 146 | QUIET=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 147 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 148 | |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 149 | # Seed value used with the --release-test option. |
Manuel Pégourié-Gonnard | 5430447 | 2020-06-22 10:11:47 +0200 | [diff] [blame] | 150 | # |
| 151 | # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if |
| 152 | # both values are kept in sync. If you change the value here because it |
| 153 | # breaks some tests, you'll definitely want to change it in |
| 154 | # basic-build-test.sh as well. |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 155 | RELEASE_SEED=1 |
| 156 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 157 | : ${MBEDTLS_TEST_OUTCOME_FILE=} |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 158 | : ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 159 | export MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 160 | export MBEDTLS_TEST_PLATFORM |
| 161 | |
Jaeden Amero | c4cc251 | 2019-01-30 15:35:44 +0000 | [diff] [blame] | 162 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 163 | : ${OPENSSL:="openssl"} |
| 164 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 165 | : ${OPENSSL_NEXT:="$OPENSSL"} |
| 166 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 167 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 168 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 169 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 170 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 171 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 172 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 173 | : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 174 | : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 175 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 176 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
Gilles Peskine | a1fc4b5 | 2019-01-06 20:15:26 +0000 | [diff] [blame] | 177 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 178 | export MAKEFLAGS="-j" |
| 179 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 180 | |
Gilles Peskine | 396853a | 2021-09-20 18:57:55 +0200 | [diff] [blame] | 181 | # Include more verbose output for failing tests run by CMake or make |
Jaeden Amero | d48e9c7 | 2019-02-07 17:43:39 +0000 | [diff] [blame] | 182 | export CTEST_OUTPUT_ON_FAILURE=1 |
| 183 | |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 184 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Gilles Peskine | 5ca393f | 2019-10-21 19:06:33 +0200 | [diff] [blame] | 185 | ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 186 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 187 | # Gather the list of available components. These are the functions |
| 188 | # defined in this script whose name starts with "component_". |
Gilles Peskine | 62cf2e8 | 2020-03-27 16:35:23 +0100 | [diff] [blame] | 189 | # Parse the script with sed. This way we get the functions in the order |
| 190 | # they are defined. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 191 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 192 | |
| 193 | # Exclude components that are not supported on this platform. |
| 194 | SUPPORTED_COMPONENTS= |
| 195 | for component in $ALL_COMPONENTS; do |
| 196 | case $(type "support_$component" 2>&1) in |
| 197 | *' function'*) |
| 198 | if ! support_$component; then continue; fi;; |
| 199 | esac |
| 200 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 201 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 202 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 203 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 204 | # Test whether the component $1 is included in the command line patterns. |
| 205 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 206 | { |
Gilles Peskine | 03af678 | 2021-08-06 11:35:17 +0200 | [diff] [blame] | 207 | # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS |
| 208 | # only does word splitting. |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 209 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 210 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 211 | set +f |
| 212 | case ${1#component_} in $pattern) return 0;; esac |
| 213 | done |
| 214 | set +f |
| 215 | return 1 |
| 216 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 217 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 218 | usage() |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 219 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 220 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 221 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 222 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 223 | 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] | 224 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 225 | |
| 226 | Examples: |
| 227 | $0 "check_*" |
| 228 | Run all sanity checks. |
| 229 | $0 --no-armcc --except test_memsan |
| 230 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 231 | |
| 232 | Special options: |
| 233 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 234 | --list-all-components List all available test components and exit. |
| 235 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 236 | |
| 237 | General options: |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 238 | -q|--quiet Only output component names, and errors if any. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 239 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 240 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 241 | -m|--memory Additional optional memory tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 242 | --append-outcome Append to the outcome file (if used). |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 243 | --arm-none-eabi-gcc-prefix=<string> |
| 244 | Prefix for a cross-compiler for arm-none-eabi |
| 245 | (default: "${ARM_NONE_EABI_GCC_PREFIX}") |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 246 | --arm-linux-gnueabi-gcc-prefix=<string> |
| 247 | Prefix for a cross-compiler for arm-linux-gnueabi |
| 248 | (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}") |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 249 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 250 | --restore First clean up the build tree, restoring backed up |
| 251 | files. Do not run any components unless they are |
| 252 | explicitly specified. |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 253 | --error-test Error test mode: run a failing function in addition |
Gilles Peskine | 86f6129 | 2021-08-05 15:11:33 +0200 | [diff] [blame] | 254 | to any specified component. May be repeated. |
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 | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 257 | --no-append-outcome Write a new outcome file and analyze it (default). |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 258 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 259 | --no-force Refuse to overwrite modified files (default). |
| 260 | --no-keep-going Stop at the first error (default). |
| 261 | --no-memory No additional memory tests (default). |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 262 | --no-quiet Print full ouput from components. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 263 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 264 | --outcome-file=<path> File where test outcomes are written (not done if |
| 265 | empty; default: \$MBEDTLS_TEST_OUTCOME_FILE). |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 266 | --random-seed Use a random seed value for randomized tests (default). |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 267 | -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] | 268 | -s|--seed Integer seed value to use for this test run. |
| 269 | |
| 270 | Tool path options: |
| 271 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 272 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 273 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 274 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 275 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 276 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 277 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
Mateusz Starzyk | 06b07fb | 2021-02-18 13:55:21 +0100 | [diff] [blame] | 278 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests.. |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 279 | --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] | 280 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 281 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 282 | |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 283 | # Cleanup before/after running a component. |
| 284 | # Remove built files as well as the cmake cache/config. |
| 285 | # Does not remove generated source files. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 286 | cleanup() |
| 287 | { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 288 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 289 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 290 | # Remove CMake artefacts |
Jaeden Amero | 2d0e00f | 2018-11-07 18:46:41 +0000 | [diff] [blame] | 291 | find . -name .git -prune -o \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 292 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 293 | \( -iname cmake_install.cmake -o \ |
| 294 | -iname CTestTestfile.cmake -o \ |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 295 | -iname CMakeCache.txt \) -exec rm -f {} \+ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 296 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 297 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 298 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 299 | # Remove any artifacts from the component_test_cmake_as_subdirectory test. |
| 300 | rm -rf programs/test/cmake_subproject/build |
| 301 | rm -f programs/test/cmake_subproject/Makefile |
| 302 | rm -f programs/test/cmake_subproject/cmake_subproject |
| 303 | |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 304 | # Remove any artifacts from the component_test_cmake_as_package test. |
| 305 | rm -rf programs/test/cmake_package/build |
| 306 | rm -f programs/test/cmake_package/Makefile |
| 307 | rm -f programs/test/cmake_package/cmake_package |
| 308 | |
| 309 | # Remove any artifacts from the component_test_cmake_as_installed_package test. |
| 310 | rm -rf programs/test/cmake_package_install/build |
| 311 | rm -f programs/test/cmake_package_install/Makefile |
| 312 | rm -f programs/test/cmake_package_install/cmake_package_install |
| 313 | |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 314 | # Restore files that may have been clobbered by the job |
| 315 | for x in $files_to_back_up; do |
| 316 | cp -p "$x$backup_suffix" "$x" |
| 317 | done |
| 318 | } |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 319 | |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 320 | # Final cleanup when this script exits (except when exiting on a failure |
| 321 | # in non-keep-going mode). |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 322 | final_cleanup () { |
| 323 | cleanup |
| 324 | |
| 325 | for x in $files_to_back_up; do |
| 326 | rm -f "$x$backup_suffix" |
| 327 | done |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 328 | } |
| 329 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 330 | # Executed on exit. May be redefined depending on command line options. |
| 331 | final_report () { |
| 332 | : |
| 333 | } |
| 334 | |
| 335 | fatal_signal () { |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 336 | final_cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 337 | final_report $1 |
| 338 | trap - $1 |
| 339 | kill -$1 $$ |
| 340 | } |
| 341 | |
| 342 | trap 'fatal_signal HUP' HUP |
| 343 | trap 'fatal_signal INT' INT |
| 344 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 345 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 346 | msg() |
| 347 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 348 | if [ -n "${current_component:-}" ]; then |
| 349 | current_section="${current_component#component_}: $1" |
| 350 | else |
| 351 | current_section="$1" |
| 352 | fi |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 353 | |
| 354 | if [ $QUIET -eq 1 ]; then |
| 355 | return |
| 356 | fi |
| 357 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 358 | echo "" |
| 359 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 360 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 361 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 362 | echo "******************************************************************" |
| 363 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 364 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 365 | armc6_build_test() |
| 366 | { |
| 367 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 368 | |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 369 | msg "build: ARM Compiler 6 ($FLAGS)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 370 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 371 | WARNING_CFLAGS='-xc -std=c99' make lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 372 | |
| 373 | msg "size: ARM Compiler 6 ($FLAGS)" |
| 374 | "$ARMC6_FROMELF" -z library/*.o |
| 375 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 376 | make clean |
| 377 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 378 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 379 | err_msg() |
| 380 | { |
| 381 | echo "$1" >&2 |
| 382 | } |
| 383 | |
| 384 | check_tools() |
| 385 | { |
| 386 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 387 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 388 | err_msg "$TOOL not found!" |
| 389 | exit 1 |
| 390 | fi |
| 391 | done |
| 392 | } |
| 393 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 394 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 395 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 396 | all_except=0 |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 397 | error_test=0 |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 398 | restore_first=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 399 | no_armcc= |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 400 | |
Jaeden Amero | 9b90f2e | 2018-11-02 18:34:17 +0000 | [diff] [blame] | 401 | # Note that legacy options are ignored instead of being omitted from this |
| 402 | # list of options, so invocations that worked with previous version of |
| 403 | # all.sh will still run and work properly. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 404 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 405 | case "$1" in |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 406 | --append-outcome) append_outcome=1;; |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 407 | --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 408 | --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 409 | --armcc) no_armcc=;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 410 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 411 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 412 | --error-test) error_test=$((error_test + 1));; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 413 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 414 | --force|-f) FORCE=1;; |
| 415 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 416 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 417 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 418 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 419 | --help|-h) usage; exit;; |
| 420 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 421 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 422 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 423 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 424 | --no-append-outcome) append_outcome=0;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 425 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 426 | --no-force) FORCE=0;; |
| 427 | --no-keep-going) KEEP_GOING=0;; |
| 428 | --no-memory) MEMORY=0;; |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 429 | --no-quiet) QUIET=0;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 430 | --openssl) shift; OPENSSL="$1";; |
| 431 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 432 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 433 | --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 434 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 435 | --quiet|-q) QUIET=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 436 | --random-seed) unset SEED;; |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 437 | --release-test|-r) SEED=$RELEASE_SEED;; |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 438 | --restore) restore_first=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 439 | --seed|-s) shift; SEED="$1";; |
| 440 | -*) |
| 441 | echo >&2 "Unknown option: $1" |
| 442 | echo >&2 "Run $0 --help for usage." |
| 443 | exit 120 |
| 444 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 445 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 446 | esac |
| 447 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 448 | done |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 449 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 450 | # With no list of components, run everything. |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 451 | if [ -z "$COMMAND_LINE_COMPONENTS" ] && [ $restore_first -eq 0 ]; then |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 452 | all_except=1 |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 453 | fi |
| 454 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 455 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 456 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 457 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 458 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 459 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 460 | |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 461 | # Error out if an explicitly requested component doesn't exist. |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 462 | if [ $all_except -eq 0 ]; then |
| 463 | unsupported=0 |
Gilles Peskine | 03af678 | 2021-08-06 11:35:17 +0200 | [diff] [blame] | 464 | # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS |
| 465 | # only does word splitting. |
Gilles Peskine | 1d475b6 | 2021-08-03 13:43:36 +0200 | [diff] [blame] | 466 | set -f |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 467 | for component in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 1d475b6 | 2021-08-03 13:43:36 +0200 | [diff] [blame] | 468 | set +f |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 469 | # If the requested name includes a wildcard character, don't |
| 470 | # check it. Accept wildcard patterns that don't match anything. |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 471 | case $component in |
| 472 | *[*?\[]*) continue;; |
| 473 | esac |
| 474 | case " $SUPPORTED_COMPONENTS " in |
| 475 | *" $component "*) :;; |
| 476 | *) |
| 477 | echo >&2 "Component $component was explicitly requested, but is not known or not supported." |
| 478 | unsupported=$((unsupported + 1));; |
| 479 | esac |
| 480 | done |
Gilles Peskine | 1d475b6 | 2021-08-03 13:43:36 +0200 | [diff] [blame] | 481 | set +f |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 482 | if [ $unsupported -ne 0 ]; then |
| 483 | exit 2 |
| 484 | fi |
| 485 | fi |
| 486 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 487 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 488 | RUN_COMPONENTS= |
| 489 | for component in $SUPPORTED_COMPONENTS; do |
| 490 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 491 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 492 | fi |
| 493 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 494 | |
| 495 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 496 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 497 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 498 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 499 | pre_check_git () { |
| 500 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 501 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 502 | git checkout-index -f -q $CONFIG_H |
| 503 | cleanup |
| 504 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 505 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 506 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 507 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 508 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 509 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 510 | exit 1 |
| 511 | fi |
| 512 | |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 513 | if ! git diff --quiet include/mbedtls/mbedtls_config.h; then |
| 514 | err_msg "Warning - the configuration file 'include/mbedtls/mbedtls_config.h' has been edited. " |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 515 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 516 | echo "script as: $0 --force" |
| 517 | exit 1 |
| 518 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 519 | fi |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 520 | } |
| 521 | |
Gilles Peskine | 568f53a | 2021-07-12 18:16:01 +0200 | [diff] [blame] | 522 | pre_restore_files () { |
| 523 | # If the makefiles have been generated by a framework such as cmake, |
| 524 | # restore them from git. If the makefiles look like modifications from |
| 525 | # the ones checked into git, take care not to modify them. Whatever |
| 526 | # this function leaves behind is what the script will restore before |
| 527 | # each component. |
| 528 | case "$(head -n1 Makefile)" in |
| 529 | *[Gg]enerated*) |
| 530 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 531 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 532 | ;; |
| 533 | esac |
| 534 | } |
| 535 | |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 536 | pre_back_up () { |
| 537 | for x in $files_to_back_up; do |
| 538 | cp -p "$x" "$x$backup_suffix" |
| 539 | done |
| 540 | } |
| 541 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 542 | pre_setup_keep_going () { |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 543 | failure_count=0 # Number of failed components |
| 544 | last_failure_status=0 # Last failure status in this component |
| 545 | |
Gilles Peskine | fec30cb | 2020-03-28 19:34:23 +0100 | [diff] [blame] | 546 | # See err_trap |
| 547 | previous_failure_status=0 |
| 548 | previous_failed_command= |
| 549 | previous_failure_funcall_depth=0 |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 550 | unset report_failed_command |
Gilles Peskine | fec30cb | 2020-03-28 19:34:23 +0100 | [diff] [blame] | 551 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 552 | start_red= |
| 553 | end_color= |
| 554 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 555 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 556 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 557 | start_red=$(printf '\033[31m') |
| 558 | end_color=$(printf '\033[0m') |
| 559 | ;; |
| 560 | esac |
| 561 | fi |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 562 | |
| 563 | # Keep a summary of failures in a file. We'll print it out at the end. |
| 564 | failure_summary_file=$PWD/all-sh-failures-$$.log |
| 565 | : >"$failure_summary_file" |
| 566 | |
| 567 | # Whether it makes sense to keep a component going after the specified |
| 568 | # command fails (test command) or not (configure or build). |
Gilles Peskine | 03af678 | 2021-08-06 11:35:17 +0200 | [diff] [blame] | 569 | # This function normally receives the failing simple command |
| 570 | # ($BASH_COMMAND) as an argument, but if $report_failed_command is set, |
| 571 | # this is passed instead. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 572 | # This doesn't have to be 100% accurate: all failures are recorded anyway. |
Gilles Peskine | c111e24 | 2021-08-02 23:29:53 +0200 | [diff] [blame] | 573 | # False positives result in running things that can't be expected to |
| 574 | # work. False negatives result in things not running after something else |
| 575 | # failed even though they might have given useful feedback. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 576 | can_keep_going_after_failure () { |
| 577 | case "$1" in |
| 578 | "msg "*) false;; |
Gilles Peskine | c111e24 | 2021-08-02 23:29:53 +0200 | [diff] [blame] | 579 | "cd "*) false;; |
| 580 | *make*[\ /]tests*) false;; # make tests, make CFLAGS=-I../tests, ... |
| 581 | *test*) true;; # make test, tests/stuff, env V=v tests/stuff, ... |
| 582 | *make*check*) true;; |
| 583 | "grep "*) true;; |
| 584 | "[ "*) true;; |
| 585 | "! "*) true;; |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 586 | *) false;; |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 587 | esac |
| 588 | } |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 589 | |
| 590 | # This function runs if there is any error in a component. |
| 591 | # It must either exit with a nonzero status, or set |
| 592 | # last_failure_status to a nonzero value. |
| 593 | err_trap () { |
| 594 | # Save $? (status of the failing command). This must be the very |
| 595 | # first thing, before $? is overridden. |
| 596 | last_failure_status=$? |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 597 | failed_command=${report_failed_command-$BASH_COMMAND} |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 598 | |
Gilles Peskine | fec30cb | 2020-03-28 19:34:23 +0100 | [diff] [blame] | 599 | if [[ $last_failure_status -eq $previous_failure_status && |
| 600 | "$failed_command" == "$previous_failed_command" && |
| 601 | ${#FUNCNAME[@]} == $((previous_failure_funcall_depth - 1)) ]] |
| 602 | then |
| 603 | # The same command failed twice in a row, but this time one level |
| 604 | # less deep in the function call stack. This happens when the last |
| 605 | # command of a function returns a nonzero status, and the function |
| 606 | # returns that same status. Ignore the second failure. |
| 607 | previous_failure_funcall_depth=${#FUNCNAME[@]} |
| 608 | return |
| 609 | fi |
| 610 | previous_failure_status=$last_failure_status |
| 611 | previous_failed_command=$failed_command |
| 612 | previous_failure_funcall_depth=${#FUNCNAME[@]} |
| 613 | |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 614 | text="$current_section: $failed_command -> $last_failure_status" |
| 615 | echo "${start_red}^^^^$text^^^^${end_color}" >&2 |
| 616 | echo "$text" >>"$failure_summary_file" |
| 617 | |
| 618 | # If the command is fatal (configure or build command), stop this |
| 619 | # component. Otherwise (test command) keep the component running |
| 620 | # (run more tests from the same build). |
| 621 | if ! can_keep_going_after_failure "$failed_command"; then |
| 622 | exit $last_failure_status |
| 623 | fi |
| 624 | } |
| 625 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 626 | final_report () { |
| 627 | if [ $failure_count -gt 0 ]; then |
| 628 | echo |
| 629 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 630 | echo "${start_red}FAILED: $failure_count components${end_color}" |
| 631 | cat "$failure_summary_file" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 632 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 633 | elif [ -z "${1-}" ]; then |
| 634 | echo "SUCCESS :)" |
| 635 | fi |
| 636 | if [ -n "${1-}" ]; then |
| 637 | echo "Killed by SIG$1." |
| 638 | fi |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 639 | rm -f "$failure_summary_file" |
| 640 | if [ $failure_count -gt 0 ]; then |
| 641 | exit 1 |
| 642 | fi |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 643 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 644 | } |
| 645 | |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 646 | # record_status() and if_build_succeeded() are kept temporarily for backward |
| 647 | # compatibility. Don't use them in new components. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 648 | record_status () { |
| 649 | "$@" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 650 | } |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 651 | if_build_succeeded () { |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 652 | "$@" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 653 | } |
| 654 | |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 655 | # '! true' does not trigger the ERR trap. Arrange to trigger it, with |
| 656 | # a reasonably informative error message (not just "$@"). |
| 657 | not () { |
| 658 | if "$@"; then |
| 659 | report_failed_command="! $*" |
| 660 | false |
| 661 | unset report_failed_command |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 662 | fi |
| 663 | } |
| 664 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 665 | pre_prepare_outcome_file () { |
| 666 | case "$MBEDTLS_TEST_OUTCOME_FILE" in |
| 667 | [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; |
| 668 | esac |
| 669 | if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then |
| 670 | rm -f "$MBEDTLS_TEST_OUTCOME_FILE" |
| 671 | fi |
| 672 | } |
| 673 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 674 | pre_print_configuration () { |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 675 | if [ $QUIET -eq 1 ]; then |
| 676 | return |
| 677 | fi |
| 678 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 679 | msg "info: $0 configuration" |
| 680 | echo "MEMORY: $MEMORY" |
| 681 | echo "FORCE: $FORCE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 682 | echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 683 | echo "SEED: ${SEED-"UNSET"}" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 684 | echo |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 685 | echo "OPENSSL: $OPENSSL" |
| 686 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 687 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 688 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 689 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 690 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 691 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 692 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 693 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 694 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 695 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 696 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 697 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 698 | # Build the list of variables to pass to output_env.sh. |
| 699 | set env |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 700 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 701 | case " $RUN_COMPONENTS " in |
| 702 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 703 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 704 | # is a good enough approximation in practice. |
| 705 | *" test_"*) |
| 706 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 707 | # and ssl-opt.sh, we just export the variables they require. |
| 708 | export OPENSSL_CMD="$OPENSSL" |
| 709 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 710 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 711 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 712 | if [ -n "${SEED-}" ]; then |
| 713 | export SEED |
| 714 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 715 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 716 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 717 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 718 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 719 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 720 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 721 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 722 | ;; |
| 723 | esac |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 724 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 725 | case " $RUN_COMPONENTS " in |
| 726 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 727 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 728 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 729 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 730 | *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";; |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 731 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 732 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 733 | case " $RUN_COMPONENTS " in |
| 734 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 735 | esac |
| 736 | |
| 737 | case " $RUN_COMPONENTS " in |
| 738 | *" test_zeroize "*) check_tools "gdb";; |
| 739 | esac |
| 740 | |
| 741 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 742 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 743 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 744 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 745 | ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 746 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 747 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 748 | ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf" |
| 749 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \ |
| 750 | "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 751 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 752 | |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 753 | # past this point, no call to check_tool, only printing output |
| 754 | if [ $QUIET -eq 1 ]; then |
| 755 | return |
| 756 | fi |
| 757 | |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 758 | msg "info: output_env.sh" |
| 759 | case $RUN_COMPONENTS in |
| 760 | *_armcc*) |
| 761 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 762 | *) set "$@" RUN_ARMCC=0;; |
| 763 | esac |
| 764 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 765 | } |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 766 | |
Gilles Peskine | 1570b59 | 2021-04-22 01:10:12 +0200 | [diff] [blame] | 767 | pre_generate_files() { |
Manuel Pégourié-Gonnard | 87db8a2 | 2021-06-18 13:30:14 +0200 | [diff] [blame] | 768 | # since make doesn't have proper dependencies, remove any possibly outdate |
| 769 | # file that might be around before generating fresh ones |
| 770 | make neat |
Gilles Peskine | 7238503 | 2021-07-08 19:07:07 +0200 | [diff] [blame] | 771 | if [ $QUIET -eq 1 ]; then |
Gilles Peskine | 7530163 | 2021-08-05 15:10:47 +0200 | [diff] [blame] | 772 | make generated_files >/dev/null |
Gilles Peskine | 7238503 | 2021-07-08 19:07:07 +0200 | [diff] [blame] | 773 | else |
| 774 | make generated_files |
| 775 | fi |
Gilles Peskine | 1570b59 | 2021-04-22 01:10:12 +0200 | [diff] [blame] | 776 | } |
| 777 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 778 | |
| 779 | |
| 780 | ################################################################ |
| 781 | #### Basic checks |
| 782 | ################################################################ |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 783 | |
| 784 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 785 | # Test Suites to be executed |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 786 | # |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame] | 787 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 788 | # 1. Catch possible problems early, by running first tests that run quickly |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 789 | # and/or are more likely to fail than others (eg I use Clang most of the |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 790 | # time, so start with a GCC build). |
| 791 | # 2. Minimize total running time, by avoiding useless rebuilds |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 792 | # |
Manuel Pégourié-Gonnard | 259b08a | 2016-01-08 16:27:41 +0100 | [diff] [blame] | 793 | # Indicative running times are given for reference. |
| 794 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 795 | component_check_recursion () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 796 | msg "Check: recursion.pl" # < 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 797 | tests/scripts/recursion.pl library/*.c |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 798 | } |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 799 | |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 800 | component_check_generated_files () { |
| 801 | msg "Check: check-generated-files, files generated with make" # 2s |
| 802 | make generated_files |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 803 | tests/scripts/check-generated-files.sh |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 804 | |
| 805 | msg "Check: check-generated-files -u, files present" # 2s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 806 | tests/scripts/check-generated-files.sh -u |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 807 | # Check that the generated files are considered up to date. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 808 | tests/scripts/check-generated-files.sh |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 809 | |
| 810 | msg "Check: check-generated-files -u, files absent" # 2s |
| 811 | command make neat |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 812 | tests/scripts/check-generated-files.sh -u |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 813 | # Check that the generated files are considered up to date. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 814 | tests/scripts/check-generated-files.sh |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 815 | |
| 816 | # This component ends with the generated files present in the source tree. |
| 817 | # This is necessary for subsequent components! |
| 818 | } |
| 819 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 820 | component_check_doxy_blocks () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 821 | msg "Check: doxygen markup outside doxygen blocks" # < 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 822 | tests/scripts/check-doxy-blocks.pl |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 823 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 824 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 825 | component_check_files () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 826 | msg "Check: file sanity checks (permissions, encodings)" # < 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 827 | tests/scripts/check_files.py |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 828 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 829 | |
Gilles Peskine | 30e0bb4 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 830 | component_check_changelog () { |
| 831 | msg "Check: changelog entries" # < 1s |
| 832 | rm -f ChangeLog.new |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 833 | scripts/assemble_changelog.py -o ChangeLog.new |
Gilles Peskine | 30e0bb4 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 834 | if [ -e ChangeLog.new ]; then |
| 835 | # Show the diff for information. It isn't an error if the diff is |
| 836 | # non-empty. |
| 837 | diff -u ChangeLog ChangeLog.new || true |
| 838 | rm ChangeLog.new |
| 839 | fi |
| 840 | } |
| 841 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 842 | component_check_names () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 843 | msg "Check: declared and exported names (builds the library)" # < 3s |
Yuto Takano | c3a6f63 | 2021-09-24 18:02:56 +0100 | [diff] [blame] | 844 | tests/scripts/check_names.py -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 845 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 846 | |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 847 | component_check_test_cases () { |
| 848 | msg "Check: test case descriptions" # < 1s |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 849 | if [ $QUIET -eq 1 ]; then |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 850 | opt='--quiet' |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 851 | else |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 852 | opt='' |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 853 | fi |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 854 | tests/scripts/check_test_cases.py $opt |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 855 | unset opt |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 856 | } |
| 857 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 858 | component_check_doxygen_warnings () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 859 | msg "Check: doxygen warnings (builds the documentation)" # ~ 3s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 860 | tests/scripts/doxygen.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 861 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 862 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 863 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 864 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 865 | ################################################################ |
| 866 | #### Build and test many configurations and targets |
| 867 | ################################################################ |
| 868 | |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 869 | component_test_default_out_of_box () { |
| 870 | msg "build: make, default config (out-of-box)" # ~1min |
| 871 | make |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 872 | # Disable fancy stuff |
Gilles Peskine | 717cd76 | 2019-09-27 20:21:11 +0200 | [diff] [blame] | 873 | SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 874 | unset MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 875 | |
| 876 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 877 | make test |
| 878 | |
| 879 | msg "selftest: make, default config (out-of-box)" # ~10s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 880 | programs/test/selftest |
Gilles Peskine | 717cd76 | 2019-09-27 20:21:11 +0200 | [diff] [blame] | 881 | |
| 882 | export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE" |
| 883 | unset SAVE_MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 884 | } |
| 885 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 886 | component_test_default_cmake_gcc_asan () { |
| 887 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 888 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 889 | make |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 890 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 891 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 892 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 893 | |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 894 | msg "test: selftest (ASan build)" # ~ 10s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 895 | programs/test/selftest |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 896 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 897 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 898 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 899 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 900 | msg "test: compat.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 901 | tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 902 | |
| 903 | msg "test: context-info.sh (ASan build)" # ~ 15 sec |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 904 | tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 905 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 906 | |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 907 | component_test_full_cmake_gcc_asan () { |
| 908 | msg "build: full config, cmake, gcc, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 909 | scripts/config.py full |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 910 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 911 | make |
| 912 | |
| 913 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 914 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 915 | |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 916 | msg "test: selftest (ASan build)" # ~ 10s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 917 | programs/test/selftest |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 918 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 919 | msg "test: ssl-opt.sh (full config, ASan build)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 920 | tests/ssl-opt.sh |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 921 | |
| 922 | msg "test: compat.sh (full config, ASan build)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 923 | tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 924 | |
| 925 | msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 926 | tests/context-info.sh |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 927 | } |
| 928 | |
Ronald Cron | c3623db | 2020-10-29 10:51:32 +0100 | [diff] [blame] | 929 | component_test_psa_crypto_key_id_encodes_owner () { |
| 930 | msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan" |
| 931 | scripts/config.py full |
| 932 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 933 | scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER |
| 934 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 935 | make |
| 936 | |
| 937 | msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan" |
| 938 | make test |
| 939 | } |
| 940 | |
Gilles Peskine | a354867 | 2021-06-17 11:37:52 +0200 | [diff] [blame] | 941 | # check_renamed_symbols HEADER LIB |
| 942 | # Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol |
| 943 | # name is LIB. |
| 944 | check_renamed_symbols () { |
| 945 | ! nm "$2" | sed 's/.* //' | |
| 946 | grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")" |
| 947 | } |
| 948 | |
Gilles Peskine | d1dcfd5 | 2021-06-15 18:37:38 +0200 | [diff] [blame] | 949 | component_build_psa_crypto_spm () { |
| 950 | msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc" |
| 951 | scripts/config.py full |
| 952 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 953 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS |
| 954 | scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER |
| 955 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM |
| 956 | # We can only compile, not link, since our test and sample programs |
| 957 | # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM |
| 958 | # is active. |
| 959 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib |
Gilles Peskine | a354867 | 2021-06-17 11:37:52 +0200 | [diff] [blame] | 960 | |
| 961 | # Check that if a symbol is renamed by crypto_spe.h, the non-renamed |
| 962 | # version is not present. |
| 963 | echo "Checking for renamed symbols in the library" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 964 | check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a |
Gilles Peskine | d1dcfd5 | 2021-06-15 18:37:38 +0200 | [diff] [blame] | 965 | } |
| 966 | |
Ronald Cron | 336678b | 2021-01-28 17:54:24 +0100 | [diff] [blame] | 967 | component_test_psa_crypto_client () { |
| 968 | msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make" |
| 969 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 970 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 971 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT |
| 972 | make |
| 973 | |
| 974 | msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make" |
| 975 | make test |
| 976 | } |
| 977 | |
Jaeden Amero | 424fa93 | 2021-05-14 08:34:32 +0100 | [diff] [blame] | 978 | component_test_psa_crypto_rsa_no_genprime() { |
| 979 | msg "build: default config minus MBEDTLS_GENPRIME" |
| 980 | scripts/config.py unset MBEDTLS_GENPRIME |
| 981 | make |
| 982 | |
| 983 | msg "test: default config minus MBEDTLS_GENPRIME" |
| 984 | make test |
| 985 | } |
| 986 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 987 | component_test_ref_configs () { |
| 988 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 989 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 990 | tests/scripts/test-ref-configs.pl |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 991 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 992 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 993 | component_test_no_renegotiation () { |
| 994 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 995 | scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 996 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 997 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 998 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 999 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1000 | make test |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 1001 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1002 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1003 | tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1004 | } |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 1005 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1006 | component_test_no_pem_no_fs () { |
| 1007 | msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" |
| 1008 | scripts/config.py unset MBEDTLS_PEM_PARSE_C |
| 1009 | scripts/config.py unset MBEDTLS_FS_IO |
| 1010 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem |
| 1011 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS |
| 1012 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1013 | make |
| 1014 | |
| 1015 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1016 | make test |
| 1017 | |
| 1018 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1019 | tests/ssl-opt.sh |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1020 | } |
| 1021 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1022 | component_test_rsa_no_crt () { |
| 1023 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1024 | scripts/config.py set MBEDTLS_RSA_NO_CRT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1025 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1026 | make |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 1027 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1028 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1029 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1030 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1031 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1032 | tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1033 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1034 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1035 | tests/compat.sh -t RSA |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 1036 | |
| 1037 | msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1038 | tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1039 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1040 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1041 | component_test_no_ctr_drbg_classic () { |
| 1042 | msg "build: Full minus CTR_DRBG, classic crypto in TLS" |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1043 | scripts/config.py full |
| 1044 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1045 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1046 | |
| 1047 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1048 | make |
| 1049 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1050 | msg "test: Full minus CTR_DRBG, classic crypto - main suites" |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1051 | make test |
| 1052 | |
Gilles Peskine | ba74904 | 2021-01-13 20:02:03 +0100 | [diff] [blame] | 1053 | # In this configuration, the TLS test programs use HMAC_DRBG. |
| 1054 | # The SSL tests are slow, so run a small subset, just enough to get |
| 1055 | # confidence that the SSL code copes with HMAC_DRBG. |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1056 | msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1057 | tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' |
Gilles Peskine | ba74904 | 2021-01-13 20:02:03 +0100 | [diff] [blame] | 1058 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1059 | msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1060 | tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1061 | } |
| 1062 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1063 | component_test_no_ctr_drbg_use_psa () { |
| 1064 | msg "build: Full minus CTR_DRBG, PSA crypto in TLS" |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1065 | scripts/config.py full |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1066 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1067 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1068 | |
| 1069 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1070 | make |
| 1071 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1072 | msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites" |
| 1073 | make test |
| 1074 | |
| 1075 | # In this configuration, the TLS test programs use HMAC_DRBG. |
| 1076 | # The SSL tests are slow, so run a small subset, just enough to get |
| 1077 | # confidence that the SSL code copes with HMAC_DRBG. |
| 1078 | msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1079 | tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1080 | |
| 1081 | msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1082 | tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | component_test_no_hmac_drbg_classic () { |
| 1086 | msg "build: Full minus HMAC_DRBG, classic crypto in TLS" |
| 1087 | scripts/config.py full |
| 1088 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1089 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 1090 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1091 | |
| 1092 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1093 | make |
| 1094 | |
| 1095 | msg "test: Full minus HMAC_DRBG, classic crypto - main suites" |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1096 | make test |
| 1097 | |
Gilles Peskine | a222434 | 2020-11-19 22:14:34 +0100 | [diff] [blame] | 1098 | # Normally our ECDSA implementation uses deterministic ECDSA. But since |
| 1099 | # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used |
| 1100 | # instead. |
| 1101 | # Test SSL with non-deterministic ECDSA. Only test features that |
| 1102 | # might be affected by how ECDSA signature is performed. |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1103 | msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1104 | tests/ssl-opt.sh -f 'Default\|SSL async private: sign' |
Gilles Peskine | a222434 | 2020-11-19 22:14:34 +0100 | [diff] [blame] | 1105 | |
| 1106 | # To save time, only test one protocol version, since this part of |
| 1107 | # the protocol is identical in (D)TLS up to 1.2. |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1108 | msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1109 | tests/compat.sh -m tls1_2 -t 'ECDSA' |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1110 | } |
| 1111 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1112 | component_test_no_hmac_drbg_use_psa () { |
| 1113 | msg "build: Full minus HMAC_DRBG, PSA crypto in TLS" |
| 1114 | scripts/config.py full |
| 1115 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1116 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 1117 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 1118 | |
| 1119 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1120 | make |
| 1121 | |
| 1122 | msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites" |
| 1123 | make test |
| 1124 | |
| 1125 | # Normally our ECDSA implementation uses deterministic ECDSA. But since |
| 1126 | # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used |
| 1127 | # instead. |
| 1128 | # Test SSL with non-deterministic ECDSA. Only test features that |
| 1129 | # might be affected by how ECDSA signature is performed. |
| 1130 | msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1131 | tests/ssl-opt.sh -f 'Default\|SSL async private: sign' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1132 | |
| 1133 | # To save time, only test one protocol version, since this part of |
| 1134 | # the protocol is identical in (D)TLS up to 1.2. |
| 1135 | msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1136 | tests/compat.sh -m tls1_2 -t 'ECDSA' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | component_test_psa_external_rng_no_drbg_classic () { |
| 1140 | msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS" |
| 1141 | scripts/config.py full |
| 1142 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1143 | scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG |
Gilles Peskine | 38c12fd | 2021-02-08 21:02:53 +0100 | [diff] [blame] | 1144 | scripts/config.py unset MBEDTLS_ENTROPY_C |
| 1145 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1146 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1147 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1148 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1149 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
Gilles Peskine | 8eb2943 | 2021-02-03 20:07:11 +0100 | [diff] [blame] | 1150 | # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG, |
| 1151 | # the SSL test programs don't have an RNG and can't work. Explicitly |
| 1152 | # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG. |
| 1153 | make CFLAGS="$ASAN_CFLAGS -O2 -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1154 | |
| 1155 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites" |
| 1156 | make test |
| 1157 | |
Gilles Peskine | 8eb2943 | 2021-02-03 20:07:11 +0100 | [diff] [blame] | 1158 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1159 | tests/ssl-opt.sh -f 'Default' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | component_test_psa_external_rng_no_drbg_use_psa () { |
| 1163 | msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS" |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1164 | scripts/config.py full |
| 1165 | scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG |
Gilles Peskine | 38c12fd | 2021-02-08 21:02:53 +0100 | [diff] [blame] | 1166 | scripts/config.py unset MBEDTLS_ENTROPY_C |
| 1167 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1168 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1169 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1170 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1171 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1172 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1173 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1174 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites" |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1175 | make test |
| 1176 | |
Gilles Peskine | 8eb2943 | 2021-02-03 20:07:11 +0100 | [diff] [blame] | 1177 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1178 | tests/ssl-opt.sh -f 'Default\|opaque' |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | component_test_psa_external_rng_use_psa_crypto () { |
| 1182 | msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" |
| 1183 | scripts/config.py full |
| 1184 | scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG |
| 1185 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 1186 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1187 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1188 | |
| 1189 | msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" |
| 1190 | make test |
| 1191 | |
Gilles Peskine | ba74904 | 2021-01-13 20:02:03 +0100 | [diff] [blame] | 1192 | msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1193 | tests/ssl-opt.sh -f 'Default\|opaque' |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1194 | } |
| 1195 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1196 | component_test_everest () { |
| 1197 | msg "build: Everest ECDH context (ASan build)" # ~ 6 min |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1198 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 1199 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1200 | make |
| 1201 | |
| 1202 | msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1203 | make test |
| 1204 | |
| 1205 | msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1206 | tests/ssl-opt.sh -f ECDH |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1207 | |
| 1208 | msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 1209 | # Exclude some symmetric ciphers that are redundant here to gain time. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1210 | tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA\|DES' |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1211 | } |
| 1212 | |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1213 | component_test_everest_curve25519_only () { |
| 1214 | msg "build: Everest ECDH context, only Curve25519" # ~ 6 min |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1215 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 1216 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 1217 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 1218 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
TRodziewicz | 7c1d41d | 2021-04-23 13:33:44 +0200 | [diff] [blame] | 1219 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1220 | # Disable all curves |
| 1221 | for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do |
| 1222 | scripts/config.py unset "$c" |
| 1223 | done |
| 1224 | scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED |
| 1225 | |
| 1226 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1227 | |
| 1228 | msg "test: Everest ECDH context, only Curve25519" # ~ 50s |
| 1229 | make test |
| 1230 | } |
| 1231 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1232 | component_test_small_ssl_out_content_len () { |
| 1233 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1234 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1235 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1236 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1237 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1238 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1239 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1240 | tests/ssl-opt.sh -f "Max fragment\|Large packet" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1241 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1242 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1243 | component_test_small_ssl_in_content_len () { |
| 1244 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1245 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 1246 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1247 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1248 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1249 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1250 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1251 | tests/ssl-opt.sh -f "Max fragment" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1252 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1253 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1254 | component_test_small_ssl_dtls_max_buffering () { |
| 1255 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1256 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1257 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1258 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1259 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1260 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1261 | tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1262 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1263 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1264 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 1265 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1266 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1267 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1268 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1269 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1270 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1271 | tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1272 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1273 | |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1274 | component_test_psa_collect_statuses () { |
| 1275 | msg "build+test: psa_collect_statuses" # ~30s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1276 | scripts/config.py full |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1277 | tests/scripts/psa_collect_statuses.py |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1278 | # Check that psa_crypto_init() succeeded at least once |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1279 | grep -q '^0:psa_crypto_init:' tests/statuses.log |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1280 | rm -f tests/statuses.log |
| 1281 | } |
| 1282 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1283 | component_test_full_cmake_clang () { |
| 1284 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1285 | scripts/config.py full |
Gilles Peskine | dbf7b7e | 2021-10-07 19:34:57 +0200 | [diff] [blame] | 1286 | 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] | 1287 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1288 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 1289 | msg "test: main suites (full config, clang)" # ~ 5s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1290 | make test |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 1291 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 1292 | msg "test: psa_constant_names (full config, clang)" # ~ 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1293 | tests/scripts/test_psa_constant_names.py |
Gilles Peskine | 69e8f7f | 2020-02-26 19:51:43 +0100 | [diff] [blame] | 1294 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1295 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1296 | tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1297 | |
TRodziewicz | 10e8cf5 | 2021-05-31 17:58:57 +0200 | [diff] [blame] | 1298 | msg "test: compat.sh DES, 3DES & NULL (full config)" # ~ 2 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1299 | env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1300 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1301 | msg "test: compat.sh ARIA + ChachaPoly" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1302 | env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1303 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1304 | |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1305 | component_test_memsan_constant_flow () { |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1306 | # This tests both (1) accesses to undefined memory, and (2) branches or |
| 1307 | # memory access depending on secret values. To distinguish between those: |
| 1308 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist? |
| 1309 | # - or alternatively, change the build type to MemSanDbg, which enables |
| 1310 | # origin tracking and nicer stack traces (which are useful for debugging |
| 1311 | # anyway), and check if the origin was TEST_CF_SECRET() or something else. |
| 1312 | msg "build: cmake MSan (clang), full config with constant flow testing" |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1313 | scripts/config.py full |
| 1314 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN |
| 1315 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1316 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1317 | make |
| 1318 | |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1319 | msg "test: main suites (Msan + constant flow)" |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1320 | make test |
| 1321 | } |
| 1322 | |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 1323 | component_test_valgrind_constant_flow () { |
| 1324 | # This tests both (1) everything that valgrind's memcheck usually checks |
| 1325 | # (heap buffer overflows, use of uninitialized memory, use-after-free, |
| 1326 | # etc.) and (2) branches or memory access depending on secret values, |
| 1327 | # which will be reported as uninitialized memory. To distinguish between |
| 1328 | # secret and actually uninitialized: |
| 1329 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist? |
| 1330 | # - or alternatively, build with debug info and manually run the offending |
| 1331 | # test suite with valgrind --track-origins=yes, then check if the origin |
| 1332 | # was TEST_CF_SECRET() or something else. |
| 1333 | msg "build: cmake release GCC, full config with constant flow testing" |
| 1334 | scripts/config.py full |
| 1335 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND |
| 1336 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1337 | make |
| 1338 | |
| 1339 | # this only shows a summary of the results (how many of each type) |
| 1340 | # details are left in Testing/<date>/DynamicAnalysis.xml |
| 1341 | msg "test: main suites (valgrind + constant flow)" |
| 1342 | make memcheck |
| 1343 | } |
| 1344 | |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1345 | component_test_default_no_deprecated () { |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1346 | # Test that removing the deprecated features from the default |
| 1347 | # configuration leaves something consistent. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1348 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
| 1349 | scripts/config.py set MBEDTLS_DEPRECATED_REMOVED |
| 1350 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1351 | |
| 1352 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 1353 | make test |
| 1354 | } |
| 1355 | |
| 1356 | component_test_full_no_deprecated () { |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1357 | msg "build: make, full_no_deprecated config" # ~ 30s |
| 1358 | scripts/config.py full_no_deprecated |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1359 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1360 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1361 | msg "test: make, full_no_deprecated config" # ~ 5s |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1362 | make test |
| 1363 | } |
| 1364 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1365 | component_test_full_no_deprecated_deprecated_warning () { |
| 1366 | # Test that there is nothing deprecated in "full_no_deprecated". |
| 1367 | # A deprecated feature would trigger a warning (made fatal) from |
| 1368 | # MBEDTLS_DEPRECATED_WARNING. |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1369 | msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 1370 | scripts/config.py full_no_deprecated |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1371 | scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED |
| 1372 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
| 1373 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1374 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1375 | msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1376 | make test |
| 1377 | } |
| 1378 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1379 | component_test_full_deprecated_warning () { |
| 1380 | # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes |
| 1381 | # with only certain whitelisted types of warnings. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1382 | msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1383 | scripts/config.py full |
| 1384 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1385 | # Expect warnings from '#warning' directives in check_config.h. |
| 1386 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 1387 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1388 | msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
| 1389 | # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features. |
| 1390 | # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1391 | # Expect warnings from '#warning' directives in check_config.h and |
| 1392 | # from the use of deprecated functions in test suites. |
| 1393 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -Wno-error=cpp -DMBEDTLS_TEST_DEPRECATED' tests |
Gilles Peskine | 841b14b | 2019-11-26 17:37:37 +0100 | [diff] [blame] | 1394 | |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1395 | msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s |
| 1396 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1397 | } |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 1398 | |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1399 | # Check that the specified libraries exist and are empty. |
| 1400 | are_empty_libraries () { |
| 1401 | nm "$@" >/dev/null 2>/dev/null |
| 1402 | ! nm "$@" 2>/dev/null | grep -v ':$' | grep . |
| 1403 | } |
| 1404 | |
| 1405 | component_build_crypto_default () { |
| 1406 | msg "build: make, crypto only" |
| 1407 | scripts/config.py crypto |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1408 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1409 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | component_build_crypto_full () { |
| 1413 | msg "build: make, crypto only, full config" |
| 1414 | scripts/config.py crypto_full |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1415 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1416 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | component_build_crypto_baremetal () { |
| 1420 | msg "build: make, crypto only, baremetal config" |
| 1421 | scripts/config.py crypto_baremetal |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1422 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1423 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1424 | } |
| 1425 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1426 | component_test_depends_curves () { |
| 1427 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1428 | tests/scripts/curves.pl |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1429 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 1430 | |
John Durkop | c14be90 | 2020-08-20 06:16:41 -0700 | [diff] [blame] | 1431 | component_test_depends_curves_psa () { |
| 1432 | msg "test/build: curves.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)" |
| 1433 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1434 | tests/scripts/curves.pl |
John Durkop | c14be90 | 2020-08-20 06:16:41 -0700 | [diff] [blame] | 1435 | } |
| 1436 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1437 | component_test_depends_hashes () { |
| 1438 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1439 | tests/scripts/depends-hashes.pl |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1440 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 1441 | |
John Durkop | 2ec2eaa | 2020-08-24 18:29:15 -0700 | [diff] [blame] | 1442 | component_test_depends_hashes_psa () { |
| 1443 | msg "test/build: depends-hashes.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)" |
| 1444 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1445 | tests/scripts/depends-hashes.pl |
John Durkop | 2ec2eaa | 2020-08-24 18:29:15 -0700 | [diff] [blame] | 1446 | } |
| 1447 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1448 | component_test_depends_pkalgs () { |
| 1449 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1450 | tests/scripts/depends-pkalgs.pl |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1451 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1452 | |
John Durkop | 619e09e | 2020-09-08 22:19:56 -0700 | [diff] [blame] | 1453 | component_test_depends_pkalgs_psa () { |
| 1454 | msg "test/build: depends-pkalgs.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)" |
| 1455 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1456 | tests/scripts/depends-pkalgs.pl |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1457 | } |
| 1458 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1459 | component_build_key_exchanges () { |
| 1460 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1461 | tests/scripts/key-exchanges.pl |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1462 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1463 | |
Gilles Peskine | 03ab544 | 2021-07-09 15:19:28 +0200 | [diff] [blame] | 1464 | component_test_make_cxx () { |
| 1465 | msg "build: Unix make, full, gcc + g++" |
| 1466 | scripts/config.py full |
| 1467 | make TEST_CPP=1 lib programs |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1468 | |
Gilles Peskine | 03ab544 | 2021-07-09 15:19:28 +0200 | [diff] [blame] | 1469 | msg "test: cpp_dummy_build" |
| 1470 | programs/test/cpp_dummy_build |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1471 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1472 | |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 1473 | component_build_module_alt () { |
| 1474 | msg "build: MBEDTLS_XXX_ALT" # ~30s |
| 1475 | scripts/config.py full |
| 1476 | # Disable options that are incompatible with some ALT implementations. |
| 1477 | # aesni.c and padlock.c reference mbedtls_aes_context fields directly. |
| 1478 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1479 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 1480 | # You can only have one threading implementation: alt or pthread, not both. |
| 1481 | scripts/config.py unset MBEDTLS_THREADING_PTHREAD |
Gilles Peskine | 5c3f18d | 2021-05-31 21:21:12 +0200 | [diff] [blame] | 1482 | # The SpecifiedECDomain parsing code accesses mbedtls_ecp_group fields |
| 1483 | # directly and assumes the implementation works with partial groups. |
| 1484 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 1485 | # Enable all MBEDTLS_XXX_ALT for whole modules. Do not enable |
| 1486 | # MBEDTLS_XXX_YYY_ALT which are for single functions. |
| 1487 | scripts/config.py set-all 'MBEDTLS_([A-Z0-9]*|NIST_KW)_ALT' |
Gilles Peskine | 1628a9c | 2021-05-31 22:09:58 +0200 | [diff] [blame] | 1488 | scripts/config.py unset MBEDTLS_DHM_ALT #incompatible with MBEDTLS_DEBUG_C |
| 1489 | # We can only compile, not link, since we don't have any implementations |
| 1490 | # suitable for testing with the dummy alt headers. |
| 1491 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib |
| 1492 | } |
| 1493 | |
| 1494 | component_build_dhm_alt () { |
| 1495 | msg "build: MBEDTLS_DHM_ALT" # ~30s |
| 1496 | scripts/config.py full |
| 1497 | scripts/config.py set MBEDTLS_DHM_ALT |
| 1498 | # debug.c currently references mbedtls_dhm_context fields directly. |
| 1499 | scripts/config.py unset MBEDTLS_DEBUG_C |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 1500 | # We can only compile, not link, since we don't have any implementations |
| 1501 | # suitable for testing with the dummy alt headers. |
| 1502 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib |
| 1503 | } |
| 1504 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1505 | component_test_no_use_psa_crypto_full_cmake_asan() { |
| 1506 | # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh |
Gilles Peskine | dc3a179 | 2019-09-03 11:42:04 +0200 | [diff] [blame] | 1507 | msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1508 | scripts/config.py full |
| 1509 | scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC |
| 1510 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 1511 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1512 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | dc6d838 | 2020-04-12 14:21:55 +0200 | [diff] [blame] | 1513 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1514 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Manuel Pégourié-Gonnard | d8167e8 | 2019-02-01 11:12:52 +0100 | [diff] [blame] | 1515 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1516 | make |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 1517 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1518 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1519 | make test |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 1520 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1521 | msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1522 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1523 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1524 | msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1525 | tests/compat.sh |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 1526 | |
TRodziewicz | 10e8cf5 | 2021-05-31 17:58:57 +0200 | [diff] [blame] | 1527 | msg "test: compat.sh DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1528 | env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES' |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1529 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1530 | msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1531 | env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1532 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1533 | |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1534 | component_test_psa_crypto_config_basic() { |
Ronald Cron | 067de3b | 2021-03-11 11:49:03 +0100 | [diff] [blame] | 1535 | # Test the library excluding all Mbed TLS cryptographic support for which |
| 1536 | # we have an accelerator support. Acceleration is faked with the |
| 1537 | # transparent test driver. |
| 1538 | msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG + as much acceleration as supported" |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1539 | scripts/config.py full |
| 1540 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1541 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1542 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | 067de3b | 2021-03-11 11:49:03 +0100 | [diff] [blame] | 1543 | |
| 1544 | # There is no intended accelerator support for ALG STREAM_CIPHER and |
| 1545 | # ALG_ECB_NO_PADDING. Therefore, asking for them in the build implies the |
| 1546 | # inclusion of the Mbed TLS cipher operations. As we want to test here with |
| 1547 | # cipher operations solely supported by accelerators, disabled those |
| 1548 | # PSA configuration options. |
| 1549 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER |
| 1550 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING |
| 1551 | |
| 1552 | # Don't test DES encryption as: |
| 1553 | # 1) It is not an issue if we don't test all cipher types here. |
| 1554 | # 2) That way we don't have to modify in psa_crypto.c the compilation |
| 1555 | # guards MBEDTLS_PSA_BUILTIN_KEY_TYPE_DES for the code they guard to be |
| 1556 | # available to the test driver. Modifications that we would need to |
| 1557 | # revert when we move to compile the test driver separately. |
| 1558 | # We also disable MBEDTLS_DES_C as the dependencies on DES in PSA test |
| 1559 | # suites are still based on MBEDTLS_DES_C and not PSA_WANT_KEY_TYPE_DES. |
| 1560 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_DES |
| 1561 | scripts/config.py unset MBEDTLS_DES_C |
| 1562 | |
Gilles Peskine | 3587dfd | 2021-09-20 19:20:04 +0200 | [diff] [blame] | 1563 | loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" |
| 1564 | loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" |
Ronald Cron | 17b3afc | 2020-12-10 18:17:09 +0100 | [diff] [blame] | 1565 | loc_cflags="${loc_cflags} -I../tests/include -O2" |
| 1566 | |
| 1567 | make CC=gcc CFLAGS="$loc_cflags" LDFLAGS="$ASAN_CFLAGS" |
| 1568 | unset loc_cflags |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1569 | |
John Durkop | 4377bf7 | 2020-10-23 01:26:57 -0700 | [diff] [blame] | 1570 | msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG" |
| 1571 | make test |
| 1572 | } |
| 1573 | |
| 1574 | component_test_psa_crypto_config_no_driver() { |
| 1575 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG |
| 1576 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS" |
| 1577 | scripts/config.py full |
| 1578 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1579 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1580 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | e7012c7 | 2020-10-26 09:55:01 -0700 | [diff] [blame] | 1581 | make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | 4377bf7 | 2020-10-23 01:26:57 -0700 | [diff] [blame] | 1582 | |
| 1583 | msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS" |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1584 | make test |
| 1585 | } |
| 1586 | |
John Durkop | 8ac0b80 | 2020-10-23 01:32:15 -0700 | [diff] [blame] | 1587 | # This should be renamed to test and updated once the accelerator ECDSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1588 | component_build_psa_accel_alg_ecdsa() { |
John Durkop | dd544e1 | 2020-10-12 21:47:19 -0700 | [diff] [blame] | 1589 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_ECDSA |
| 1590 | # without MBEDTLS_ECDSA_C |
John Durkop | 28baa1f | 2020-10-23 00:51:52 -0700 | [diff] [blame] | 1591 | # PSA_WANT_ALG_ECDSA and PSA_WANT_ALG_DETERMINISTIC_ECDSA are already |
| 1592 | # set in include/psa/crypto_config.h |
John Durkop | dd544e1 | 2020-10-12 21:47:19 -0700 | [diff] [blame] | 1593 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_ECDSA without MBEDTLS_ECDSA_C" |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1594 | scripts/config.py full |
| 1595 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1596 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1597 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1598 | scripts/config.py unset MBEDTLS_ECDSA_C |
John Durkop | 28baa1f | 2020-10-23 00:51:52 -0700 | [diff] [blame] | 1599 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 1600 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1601 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
John Durkop | 28baa1f | 2020-10-23 00:51:52 -0700 | [diff] [blame] | 1602 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDSA -DMBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | d895939 | 2020-09-20 23:09:17 -0700 | [diff] [blame] | 1603 | } |
| 1604 | |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1605 | # This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1606 | component_build_psa_accel_alg_ecdh() { |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1607 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_ECDH |
| 1608 | # without MBEDTLS_ECDH_C |
| 1609 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C" |
| 1610 | scripts/config.py full |
| 1611 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1612 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1613 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1614 | scripts/config.py unset MBEDTLS_ECDH_C |
| 1615 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 1616 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 1617 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 1618 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 1619 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 1620 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1621 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1622 | } |
| 1623 | |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1624 | # This should be renamed to test and updated once the accelerator ECC key pair code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1625 | component_build_psa_accel_key_type_ecc_key_pair() { |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 1626 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_ECC_KEY_PAIR |
| 1627 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR" |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1628 | scripts/config.py full |
| 1629 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1630 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1631 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 1632 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1 |
John Durkop | 07cc04a | 2020-11-16 22:08:34 -0800 | [diff] [blame] | 1633 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1 |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1634 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 1635 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1636 | } |
| 1637 | |
| 1638 | # This should be renamed to test and updated once the accelerator ECC public key code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1639 | component_build_psa_accel_key_type_ecc_public_key() { |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 1640 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY |
| 1641 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY" |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1642 | scripts/config.py full |
| 1643 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1644 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1645 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 1646 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1 |
| 1647 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1648 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 1649 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 1650 | } |
| 1651 | |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1652 | # This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1653 | component_build_psa_accel_alg_hmac() { |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1654 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_HMAC |
| 1655 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HMAC" |
| 1656 | scripts/config.py full |
| 1657 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1658 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1659 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1660 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1661 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1662 | } |
| 1663 | |
| 1664 | # This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1665 | component_build_psa_accel_alg_hkdf() { |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1666 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_HKDF |
| 1667 | # without MBEDTLS_HKDF_C |
| 1668 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C" |
| 1669 | scripts/config.py full |
| 1670 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1671 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1672 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1673 | scripts/config.py unset MBEDTLS_HKDF_C |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1674 | # Make sure to unset TLS1_3_EXPERIMENTAL since it requires HKDF_C and will not build properly without it. |
| 1675 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1676 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1677 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1678 | } |
| 1679 | |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1680 | # This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test. |
| 1681 | component_build_psa_accel_alg_md5() { |
| 1682 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_MD5 without other hashes |
| 1683 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD5 - other hashes" |
| 1684 | scripts/config.py full |
| 1685 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1686 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1687 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1688 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 1689 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 1690 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 1691 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 1692 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 1693 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
| 1694 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1695 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1696 | } |
| 1697 | |
| 1698 | # This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test. |
| 1699 | component_build_psa_accel_alg_ripemd160() { |
| 1700 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RIPEMD160 without other hashes |
| 1701 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RIPEMD160 - other hashes" |
| 1702 | scripts/config.py full |
| 1703 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1704 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1705 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1706 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 1707 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 1708 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 1709 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 1710 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 1711 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
| 1712 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1713 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1714 | } |
| 1715 | |
| 1716 | # This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test. |
| 1717 | component_build_psa_accel_alg_sha1() { |
| 1718 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_1 without other hashes |
| 1719 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_1 - other hashes" |
| 1720 | scripts/config.py full |
| 1721 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1722 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1723 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1724 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 1725 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 1726 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 1727 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 1728 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 1729 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
| 1730 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1731 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1732 | } |
| 1733 | |
| 1734 | # This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test. |
| 1735 | component_build_psa_accel_alg_sha224() { |
| 1736 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_224 without other hashes |
| 1737 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_224 - other hashes" |
| 1738 | scripts/config.py full |
| 1739 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1740 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1741 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1742 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 1743 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 1744 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 1745 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 1746 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
| 1747 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1748 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1749 | } |
| 1750 | |
| 1751 | # This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test. |
| 1752 | component_build_psa_accel_alg_sha256() { |
| 1753 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_256 without other hashes |
| 1754 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_256 - other hashes" |
| 1755 | scripts/config.py full |
| 1756 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1757 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1758 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1759 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 1760 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 1761 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 1762 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 1763 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 1764 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
| 1765 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1766 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1767 | } |
| 1768 | |
| 1769 | # This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test. |
| 1770 | component_build_psa_accel_alg_sha384() { |
| 1771 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_384 without other hashes |
| 1772 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_384 - other hashes" |
| 1773 | scripts/config.py full |
| 1774 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1775 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1776 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1777 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 1778 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 1779 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 1780 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 1781 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 1782 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1783 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1784 | } |
| 1785 | |
| 1786 | # This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test. |
| 1787 | component_build_psa_accel_alg_sha512() { |
| 1788 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_512 without other hashes |
| 1789 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_512 - other hashes" |
| 1790 | scripts/config.py full |
| 1791 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1792 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1793 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 1794 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 1795 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 1796 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 1797 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 1798 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 1799 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 1800 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1801 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1802 | } |
| 1803 | |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1804 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1805 | component_build_psa_accel_alg_rsa_pkcs1v15_crypt() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1806 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 1807 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1808 | scripts/config.py full |
| 1809 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1810 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1811 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1812 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 1813 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 1814 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
| 1815 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1816 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1817 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1818 | } |
| 1819 | |
| 1820 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1821 | component_build_psa_accel_alg_rsa_pkcs1v15_sign() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1822 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PKCS1V15_SIGN and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 1823 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 1824 | scripts/config.py full |
| 1825 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1826 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1827 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1828 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 1829 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 1830 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
| 1831 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1832 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1833 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1834 | } |
| 1835 | |
| 1836 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1837 | component_build_psa_accel_alg_rsa_oaep() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1838 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_OAEP and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 1839 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 1840 | scripts/config.py full |
| 1841 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1842 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1843 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1844 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_OAEP 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 1845 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 1846 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 1847 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1848 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1849 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1850 | } |
| 1851 | |
| 1852 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1853 | component_build_psa_accel_alg_rsa_pss() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1854 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PSS and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 1855 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 1856 | scripts/config.py full |
| 1857 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1858 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1859 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1860 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 1861 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 1862 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 1863 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1864 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1865 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1866 | } |
| 1867 | |
| 1868 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1869 | component_build_psa_accel_key_type_rsa_key_pair() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1870 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_RSA_KEY_PAIR and PSA_WANT_ALG_RSA_PSS |
| 1871 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + PSA_WANT_ALG_RSA_PSS" |
| 1872 | scripts/config.py full |
| 1873 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1874 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1875 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1876 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1 |
| 1877 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1 |
| 1878 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1879 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1880 | } |
| 1881 | |
| 1882 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 1883 | component_build_psa_accel_key_type_rsa_public_key() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 1884 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY and PSA_WANT_ALG_RSA_PSS |
| 1885 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS" |
| 1886 | scripts/config.py full |
| 1887 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 1888 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1889 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1890 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1 |
| 1891 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1 |
| 1892 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1893 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 1894 | } |
| 1895 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1896 | component_test_no_platform () { |
| 1897 | # Full configuration build, without platform support, file IO and net sockets. |
| 1898 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 1899 | # IO, it should catch missing '#include <stdio.h>' |
| 1900 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1901 | scripts/config.py full |
| 1902 | scripts/config.py unset MBEDTLS_PLATFORM_C |
| 1903 | scripts/config.py unset MBEDTLS_NET_C |
| 1904 | scripts/config.py unset MBEDTLS_PLATFORM_MEMORY |
| 1905 | scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1906 | scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1907 | scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1908 | scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT |
| 1909 | scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 1910 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1911 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1912 | scripts/config.py unset MBEDTLS_FS_IO |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1913 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1914 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 1915 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1916 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 1917 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1918 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 1919 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1920 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 1921 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1922 | component_build_no_std_function () { |
| 1923 | # catch compile bugs in _uninit functions |
| 1924 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1925 | scripts/config.py full |
| 1926 | scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 1927 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 1928 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | f4d2fd4 | 2021-10-08 11:45:47 +0200 | [diff] [blame^] | 1929 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
Gilles Peskine | dbf7b7e | 2021-10-07 19:34:57 +0200 | [diff] [blame] | 1930 | make |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1931 | } |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 1932 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1933 | component_build_no_ssl_srv () { |
| 1934 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1935 | scripts/config.py full |
| 1936 | scripts/config.py unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1937 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1938 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1939 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1940 | component_build_no_ssl_cli () { |
| 1941 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1942 | scripts/config.py full |
| 1943 | scripts/config.py unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1944 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1945 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1946 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1947 | component_build_no_sockets () { |
| 1948 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 1949 | # as that requires a POSIX platform (which isn't the same as C99). |
| 1950 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1951 | scripts/config.py full |
| 1952 | scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 1953 | scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1954 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1955 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 1956 | |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1957 | component_test_memory_buffer_allocator_backtrace () { |
| 1958 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1959 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1960 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1961 | scripts/config.py set MBEDTLS_MEMORY_BACKTRACE |
| 1962 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1963 | CC=gcc cmake . |
| 1964 | make |
| 1965 | |
| 1966 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1967 | make test |
| 1968 | } |
| 1969 | |
| 1970 | component_test_memory_buffer_allocator () { |
| 1971 | msg "build: default config with memory buffer allocator" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1972 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1973 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1974 | CC=gcc cmake . |
| 1975 | make |
| 1976 | |
| 1977 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1978 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1979 | |
| 1980 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1981 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1982 | tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1983 | } |
| 1984 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1985 | component_test_no_max_fragment_length () { |
| 1986 | # Run max fragment length tests with MFL disabled |
| 1987 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1988 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1989 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1990 | make |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1991 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1992 | msg "test: ssl-opt.sh, MFL-related tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1993 | tests/ssl-opt.sh -f "Max fragment length" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1994 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1995 | |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1996 | component_test_asan_remove_peer_certificate () { |
| 1997 | msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1998 | scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1999 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2000 | make |
| 2001 | |
| 2002 | msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 2003 | make test |
| 2004 | |
| 2005 | msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2006 | tests/ssl-opt.sh |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 2007 | |
| 2008 | msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2009 | tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 2010 | |
| 2011 | msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2012 | tests/context-info.sh |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 2013 | } |
| 2014 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2015 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 2016 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2017 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 2018 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 2019 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2020 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2021 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 2022 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2023 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2024 | tests/ssl-opt.sh -f "Max fragment length\|Large buffer" |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 2025 | |
| 2026 | msg "test: context-info.sh (disabled MFL extension case)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2027 | tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2028 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 2029 | |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 2030 | component_test_variable_ssl_in_out_buffer_len () { |
| 2031 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)" |
| 2032 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 2033 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2034 | make |
| 2035 | |
| 2036 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 2037 | make test |
| 2038 | |
| 2039 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2040 | tests/ssl-opt.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 2041 | |
| 2042 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2043 | tests/compat.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 2044 | } |
| 2045 | |
| 2046 | component_test_variable_ssl_in_out_buffer_len_CID () { |
| 2047 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)" |
| 2048 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 2049 | scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID |
| 2050 | |
| 2051 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2052 | make |
| 2053 | |
| 2054 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID" |
| 2055 | make test |
| 2056 | |
| 2057 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2058 | tests/ssl-opt.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 2059 | |
| 2060 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2061 | tests/compat.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 2062 | } |
| 2063 | |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 2064 | component_test_ssl_alloc_buffer_and_mfl () { |
| 2065 | msg "build: default config with memory buffer allocator and MFL extension" |
| 2066 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 2067 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 2068 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
| 2069 | scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 2070 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 2071 | CC=gcc cmake . |
| 2072 | make |
| 2073 | |
| 2074 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
| 2075 | make test |
| 2076 | |
| 2077 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2078 | tests/ssl-opt.sh -f "Handshake memory usage" |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 2079 | } |
| 2080 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2081 | component_test_when_no_ciphersuites_have_mac () { |
| 2082 | msg "build: when no ciphersuites have MAC" |
| 2083 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2084 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
TRodziewicz | 2add5c1 | 2021-04-28 16:50:20 +0200 | [diff] [blame] | 2085 | scripts/config.py unset MBEDTLS_CMAC_C |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2086 | make |
| 2087 | |
| 2088 | msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 2089 | make test |
| 2090 | |
| 2091 | msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2092 | tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2093 | } |
| 2094 | |
Raoul Strackx | a4e8614 | 2020-06-15 17:03:13 +0200 | [diff] [blame] | 2095 | component_test_no_date_time () { |
| 2096 | msg "build: default config without MBEDTLS_HAVE_TIME_DATE" |
| 2097 | scripts/config.py unset MBEDTLS_HAVE_TIME_DATE |
Gilles Peskine | f4d2fd4 | 2021-10-08 11:45:47 +0200 | [diff] [blame^] | 2098 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
Raoul Strackx | a4e8614 | 2020-06-15 17:03:13 +0200 | [diff] [blame] | 2099 | make |
| 2100 | |
| 2101 | msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" |
| 2102 | make test |
| 2103 | } |
| 2104 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2105 | component_test_platform_calloc_macro () { |
| 2106 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2107 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 2108 | scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 2109 | scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2110 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2111 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 2112 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2113 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 2114 | make test |
| 2115 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 2116 | |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 2117 | component_test_malloc_0_null () { |
| 2118 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 2119 | scripts/config.py full |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 2120 | make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 2121 | |
| 2122 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 2123 | make test |
| 2124 | |
| 2125 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 2126 | # Just the calloc selftest. "make test" ran the others as part of the |
| 2127 | # test suites. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2128 | programs/test/selftest calloc |
Gilles Peskine | 765d240 | 2020-02-11 18:26:34 +0100 | [diff] [blame] | 2129 | |
| 2130 | msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)" |
| 2131 | # Run a subset of the tests. The choice is a balance between coverage |
| 2132 | # and time (including time indirectly wasted due to flaky tests). |
| 2133 | # The current choice is to skip tests whose description includes |
| 2134 | # "proxy", which is an approximation of skipping tests that use the |
| 2135 | # UDP proxy, which tend to be slower and flakier. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2136 | tests/ssl-opt.sh -e 'proxy' |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 2137 | } |
| 2138 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2139 | component_test_aes_fewer_tables () { |
| 2140 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2141 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2142 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 2143 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2144 | msg "test: AES_FEWER_TABLES" |
| 2145 | make test |
| 2146 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 2147 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2148 | component_test_aes_rom_tables () { |
| 2149 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2150 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2151 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 2152 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2153 | msg "test: AES_ROM_TABLES" |
| 2154 | make test |
| 2155 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 2156 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2157 | component_test_aes_fewer_tables_and_rom_tables () { |
| 2158 | msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2159 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
| 2160 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2161 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 2162 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2163 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 2164 | make test |
| 2165 | } |
| 2166 | |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 2167 | component_test_ctr_drbg_aes_256_sha_256 () { |
| 2168 | msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 2169 | scripts/config.py full |
| 2170 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 2171 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 2172 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2173 | make |
| 2174 | |
| 2175 | msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 2176 | make test |
| 2177 | } |
| 2178 | |
| 2179 | component_test_ctr_drbg_aes_128_sha_512 () { |
| 2180 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 2181 | scripts/config.py full |
| 2182 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 2183 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 2184 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2185 | make |
| 2186 | |
| 2187 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
| 2188 | make test |
| 2189 | } |
| 2190 | |
| 2191 | component_test_ctr_drbg_aes_128_sha_256 () { |
| 2192 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 2193 | scripts/config.py full |
| 2194 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 2195 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
| 2196 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 2197 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2198 | make |
| 2199 | |
| 2200 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 2201 | make test |
| 2202 | } |
| 2203 | |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 2204 | component_test_se_default () { |
| 2205 | msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2206 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 2207 | make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 2208 | |
| 2209 | msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
| 2210 | make test |
| 2211 | } |
| 2212 | |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 2213 | component_test_psa_crypto_drivers () { |
Steven Cooreman | 55ae217 | 2020-07-17 19:46:15 +0200 | [diff] [blame] | 2214 | msg "build: MBEDTLS_PSA_CRYPTO_DRIVERS w/ driver hooks" |
Steven Cooreman | 753f973 | 2021-03-15 11:38:44 +0100 | [diff] [blame] | 2215 | scripts/config.py full |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 2216 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
Steven Cooreman | 6801f08 | 2021-02-19 17:21:22 +0100 | [diff] [blame] | 2217 | scripts/config.py set MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS |
Gilles Peskine | 3587dfd | 2021-09-20 19:20:04 +0200 | [diff] [blame] | 2218 | loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" |
| 2219 | loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" |
Ronald Cron | 17b3afc | 2020-12-10 18:17:09 +0100 | [diff] [blame] | 2220 | loc_cflags="${loc_cflags} -I../tests/include -O2" |
| 2221 | |
| 2222 | make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS" |
| 2223 | unset loc_cflags |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 2224 | |
Steven Cooreman | 753f973 | 2021-03-15 11:38:44 +0100 | [diff] [blame] | 2225 | msg "test: full + MBEDTLS_PSA_CRYPTO_DRIVERS" |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 2226 | make test |
| 2227 | } |
| 2228 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2229 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2230 | msg "build/test: make shared" # ~ 40s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 2231 | make SHARED=1 all check |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 2232 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2233 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 2234 | |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 2235 | component_test_cmake_shared () { |
| 2236 | msg "build/test: cmake shared" # ~ 2min |
| 2237 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 2238 | make |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 2239 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 2240 | make test |
| 2241 | } |
| 2242 | |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 2243 | test_build_opt () { |
| 2244 | info=$1 cc=$2; shift 2 |
| 2245 | for opt in "$@"; do |
| 2246 | msg "build/test: $cc $opt, $info" # ~ 30s |
Gilles Peskine | e094a18 | 2020-04-14 20:08:41 +0200 | [diff] [blame] | 2247 | make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror" |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 2248 | # We're confident enough in compilers to not run _all_ the tests, |
| 2249 | # but at least run the unit tests. In particular, runs with |
| 2250 | # optimizations use inline assembly whereas runs with -O0 |
| 2251 | # skip inline assembly. |
| 2252 | make test # ~30s |
| 2253 | make clean |
| 2254 | done |
| 2255 | } |
| 2256 | |
| 2257 | component_test_clang_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 2258 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 2259 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 2260 | } |
| 2261 | |
| 2262 | component_test_gcc_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 2263 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 2264 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 2265 | } |
| 2266 | |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 2267 | component_build_mbedtls_config_file () { |
| 2268 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 2269 | # Use the full config so as to catch a maximum of places where |
| 2270 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2271 | scripts/config.py full |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 2272 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 2273 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 2274 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 2275 | rm -f full_config.h |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 2276 | } |
| 2277 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2278 | component_test_m32_o0 () { |
Gilles Peskine | 77f0535 | 2021-10-07 19:27:16 +0200 | [diff] [blame] | 2279 | # Build without optimization, so as to use portable C code (in a 32-bit |
| 2280 | # build) and not the i386-specific inline assembly. |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 2281 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2282 | scripts/config.py full |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 2283 | 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] | 2284 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 2285 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 2286 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2287 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2288 | support_test_m32_o0 () { |
| 2289 | case $(uname -m) in |
| 2290 | *64*) true;; |
| 2291 | *) false;; |
| 2292 | esac |
| 2293 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 2294 | |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 2295 | component_test_m32_o2 () { |
| 2296 | # Build with optimization, to use the i386 specific inline assembly |
| 2297 | # and go faster for tests. |
| 2298 | msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2299 | scripts/config.py full |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 2300 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 2301 | |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 2302 | msg "test: i386, make, gcc -O2 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 2303 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2304 | |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 2305 | msg "test ssl-opt.sh, i386, make, gcc-O2" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2306 | tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2307 | } |
Gilles Peskine | cf52222 | 2021-10-07 19:25:29 +0200 | [diff] [blame] | 2308 | support_test_m32_o2 () { |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2309 | support_test_m32_o0 "$@" |
| 2310 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 2311 | |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 2312 | component_test_m32_everest () { |
| 2313 | msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2314 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 2315 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 2316 | |
| 2317 | msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 2318 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2319 | |
| 2320 | msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2321 | tests/ssl-opt.sh -f ECDH |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2322 | |
| 2323 | msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 2324 | # Exclude some symmetric ciphers that are redundant here to gain time. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2325 | tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA\|DES' |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 2326 | } |
| 2327 | support_test_m32_everest () { |
| 2328 | support_test_m32_o0 "$@" |
| 2329 | } |
| 2330 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2331 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 2332 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2333 | scripts/config.py full |
Gilles Peskine | 5d26e7c | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 2334 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 2335 | |
| 2336 | msg "test: 64-bit ILP32, make, gcc" |
| 2337 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2338 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2339 | support_test_mx32 () { |
| 2340 | case $(uname -m) in |
| 2341 | amd64|x86_64) true;; |
| 2342 | *) false;; |
| 2343 | esac |
| 2344 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 2345 | |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 2346 | component_test_min_mpi_window_size () { |
| 2347 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2348 | scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1 |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 2349 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2350 | make |
| 2351 | |
| 2352 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 2353 | make test |
| 2354 | } |
| 2355 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2356 | component_test_have_int32 () { |
| 2357 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2358 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 2359 | scripts/config.py unset MBEDTLS_AESNI_C |
| 2360 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2361 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 2362 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2363 | msg "test: gcc, force 32-bit bignum limbs" |
| 2364 | make test |
| 2365 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 2366 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2367 | component_test_have_int64 () { |
| 2368 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2369 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 2370 | scripts/config.py unset MBEDTLS_AESNI_C |
| 2371 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2372 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 2373 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2374 | msg "test: gcc, force 64-bit bignum limbs" |
| 2375 | make test |
| 2376 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 2377 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2378 | component_test_no_udbl_division () { |
| 2379 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2380 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2381 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2382 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2383 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2384 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 2385 | make test |
| 2386 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2387 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2388 | component_test_no_64bit_multiplication () { |
| 2389 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2390 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2391 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2392 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2393 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2394 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 2395 | make test |
| 2396 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2397 | |
Gilles Peskine | 3809f5f | 2020-11-09 15:40:05 +0100 | [diff] [blame] | 2398 | component_test_no_strings () { |
| 2399 | msg "build: no strings" # ~10s |
| 2400 | scripts/config.py full |
| 2401 | # Disable options that activate a large amount of string constants. |
| 2402 | scripts/config.py unset MBEDTLS_DEBUG_C |
| 2403 | scripts/config.py unset MBEDTLS_ERROR_C |
| 2404 | scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY |
| 2405 | scripts/config.py unset MBEDTLS_VERSION_FEATURES |
| 2406 | make CFLAGS='-Werror -Os' |
| 2407 | |
| 2408 | msg "test: no strings" # ~ 10s |
| 2409 | make test |
| 2410 | } |
| 2411 | |
Hanno Becker | c5722d1 | 2020-10-09 11:10:42 +0100 | [diff] [blame] | 2412 | component_test_no_x509_info () { |
| 2413 | msg "build: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s |
| 2414 | scripts/config.pl full |
| 2415 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 2416 | scripts/config.pl set MBEDTLS_X509_REMOVE_INFO |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 2417 | make CFLAGS='-Werror -O2' |
Hanno Becker | c5722d1 | 2020-10-09 11:10:42 +0100 | [diff] [blame] | 2418 | |
| 2419 | msg "test: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s |
| 2420 | make test |
| 2421 | |
| 2422 | msg "test: ssl-opt.sh, full + MBEDTLS_X509_REMOVE_INFO" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2423 | tests/ssl-opt.sh |
Hanno Becker | c5722d1 | 2020-10-09 11:10:42 +0100 | [diff] [blame] | 2424 | } |
| 2425 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2426 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 2427 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2428 | scripts/config.py baremetal |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 2429 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -O1' lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 2430 | |
| 2431 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" |
| 2432 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2433 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2434 | |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 2435 | component_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 2436 | msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2437 | scripts/config.py baremetal |
Gilles Peskine | 2c897d7 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 2438 | # Build for a target platform that's close to what Debian uses |
| 2439 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 2440 | # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 2441 | # Build everything including programs, see for example |
| 2442 | # https://github.com/ARMmbed/mbedtls/pull/3449#issuecomment-675313720 |
| 2443 | 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' |
| 2444 | |
| 2445 | msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1" |
| 2446 | ${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o |
| 2447 | } |
| 2448 | support_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 2449 | type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1 |
| 2450 | } |
| 2451 | |
| 2452 | component_build_arm_none_eabi_gcc_arm5vte () { |
| 2453 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s |
| 2454 | scripts/config.py baremetal |
| 2455 | # This is an imperfect substitute for |
| 2456 | # component_build_arm_linux_gnueabi_gcc_arm5vte |
Manuel Pégourié-Gonnard | ae505ee | 2021-07-06 09:44:59 +0200 | [diff] [blame] | 2457 | # in case the gcc-arm-linux-gnueabi toolchain is not available |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 2458 | 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 | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 2459 | |
| 2460 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" |
| 2461 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 93e4e03 | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 2462 | } |
| 2463 | |
Gilles Peskine | 6e2fb86 | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 2464 | component_build_arm_none_eabi_gcc_m0plus () { |
| 2465 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s |
| 2466 | scripts/config.py baremetal |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 2467 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 2468 | |
| 2469 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os" |
| 2470 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 6e2fb86 | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 2471 | } |
| 2472 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2473 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 2474 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2475 | scripts/config.py baremetal |
| 2476 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 2477 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2478 | echo "Checking that software 64-bit division is not required" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2479 | not grep __aeabi_uldiv library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2480 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2481 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2482 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 2483 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2484 | scripts/config.py baremetal |
| 2485 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 2486 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2487 | echo "Checking that software 64-bit multiplication is not required" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2488 | not grep __aeabi_lmul library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2489 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 2490 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2491 | component_build_armcc () { |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 2492 | msg "build: ARM Compiler 5" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2493 | scripts/config.py baremetal |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2494 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 2495 | |
| 2496 | msg "size: ARM Compiler 5" |
| 2497 | "$ARMC5_FROMELF" -z library/*.o |
| 2498 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2499 | make clean |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 2500 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2501 | # ARM Compiler 6 - Target ARMv7-A |
| 2502 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 2503 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2504 | # ARM Compiler 6 - Target ARMv7-M |
| 2505 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 2506 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2507 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 2508 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 2509 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2510 | # ARM Compiler 6 - Target ARMv8-M |
| 2511 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 2512 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 2513 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 2514 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2515 | } |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 2516 | |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 2517 | component_test_tls13_experimental () { |
Hanno Becker | 6c53ecc | 2021-08-01 19:20:10 +0100 | [diff] [blame] | 2518 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding" |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 2519 | scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
Hanno Becker | 6c53ecc | 2021-08-01 19:20:10 +0100 | [diff] [blame] | 2520 | scripts/config.pl set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1 |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 2521 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2522 | make |
Hanno Becker | 6c53ecc | 2021-08-01 19:20:10 +0100 | [diff] [blame] | 2523 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding" |
| 2524 | make test |
Jerry Yu | 7a5ab04 | 2021-09-15 19:22:29 +0800 | [diff] [blame] | 2525 | msg "ssl-opt.sh (TLS 1.3 experimental)" |
| 2526 | if_build_succeeded tests/ssl-opt.sh |
Hanno Becker | 6c53ecc | 2021-08-01 19:20:10 +0100 | [diff] [blame] | 2527 | } |
| 2528 | |
| 2529 | component_test_tls13_experimental_with_padding () { |
| 2530 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding" |
| 2531 | scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
| 2532 | scripts/config.pl set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 16 |
| 2533 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2534 | make |
| 2535 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding" |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 2536 | make test |
Hanno Becker | ae33685 | 2021-07-24 05:27:16 +0100 | [diff] [blame] | 2537 | msg "ssl-opt.sh (TLS 1.3 experimental)" |
| 2538 | if_build_succeeded tests/ssl-opt.sh |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 2539 | } |
| 2540 | |
Jerry Yu | 7a5ab04 | 2021-09-15 19:22:29 +0800 | [diff] [blame] | 2541 | component_test_tls13_experimental_with_ecp_restartable () { |
| 2542 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with ecp_restartable" |
| 2543 | scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
| 2544 | scripts/config.py set MBEDTLS_ECP_RESTARTABLE |
| 2545 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2546 | make |
| 2547 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with ecp_restartable" |
| 2548 | make test |
| 2549 | msg "ssl-opt.sh (TLS 1.3 experimental)" |
| 2550 | if_build_succeeded tests/ssl-opt.sh |
| 2551 | } |
| 2552 | |
| 2553 | component_test_tls13_experimental_with_everest () { |
| 2554 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with Everest" |
| 2555 | scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
| 2556 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 2557 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
| 2558 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 2559 | make |
| 2560 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with Everest" |
| 2561 | make test |
| 2562 | msg "ssl-opt.sh (TLS 1.3 experimental)" |
| 2563 | if_build_succeeded tests/ssl-opt.sh |
| 2564 | } |
| 2565 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2566 | component_build_mingw () { |
| 2567 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 2568 | 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 |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 2569 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2570 | # note Make tests only builds the tests, but doesn't run them |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 2571 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2572 | make WINDOWS_BUILD=1 clean |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 2573 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2574 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 2575 | 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 |
| 2576 | 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 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2577 | make WINDOWS_BUILD=1 clean |
| 2578 | } |
Jaeden Amero | 117b8a4 | 2019-04-17 15:19:26 +0100 | [diff] [blame] | 2579 | support_build_mingw() { |
| 2580 | case $(i686-w64-mingw32-gcc -dumpversion) in |
| 2581 | [0-5]*) false;; |
| 2582 | *) true;; |
| 2583 | esac |
| 2584 | } |
Simon Butcher | 91aef33 | 2016-11-17 09:20:50 +0000 | [diff] [blame] | 2585 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2586 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2587 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2588 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2589 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 2590 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 2591 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2592 | msg "test: main suites (MSan)" # ~ 10s |
| 2593 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 2594 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2595 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2596 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 2597 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2598 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 2599 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2600 | if [ "$MEMORY" -gt 0 ]; then |
| 2601 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2602 | tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2603 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2604 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2605 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 2606 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2607 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2608 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 2609 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2610 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2611 | msg "test: main suites valgrind (Release)" |
| 2612 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2613 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 2614 | # Optional parts (slow; currently broken on OS X because programs don't |
| 2615 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2616 | if [ "$MEMORY" -gt 0 ]; then |
| 2617 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2618 | tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2619 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2620 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2621 | if [ "$MEMORY" -gt 1 ]; then |
| 2622 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2623 | tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 2624 | fi |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 2625 | |
| 2626 | if [ "$MEMORY" -gt 0 ]; then |
| 2627 | msg "test: context-info.sh --memcheck (Release)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2628 | tests/context-info.sh --memcheck |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 2629 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2630 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2631 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2632 | component_test_cmake_out_of_source () { |
| 2633 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2634 | MBEDTLS_ROOT_DIR="$PWD" |
| 2635 | mkdir "$OUT_OF_SOURCE_DIR" |
| 2636 | cd "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | dbf7b7e | 2021-10-07 19:34:57 +0200 | [diff] [blame] | 2637 | cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2638 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2639 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2640 | msg "test: cmake 'out-of-source' build" |
| 2641 | make test |
| 2642 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 2643 | # Also ensure that there are no error messages such as |
| 2644 | # "No such file or directory", which would indicate that some required |
| 2645 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 2646 | # may exit with status 0 but emit errors). |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2647 | ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
Gilles Peskine | f7e956c | 2020-03-28 18:56:09 +0100 | [diff] [blame] | 2648 | cat ssl-opt.err >&2 |
| 2649 | # If ssl-opt.err is non-empty, record an error and keep going. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2650 | [ ! -s ssl-opt.err ] |
Gilles Peskine | f7e956c | 2020-03-28 18:56:09 +0100 | [diff] [blame] | 2651 | rm ssl-opt.err |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2652 | cd "$MBEDTLS_ROOT_DIR" |
| 2653 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2654 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 2655 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 2656 | component_test_cmake_as_subdirectory () { |
| 2657 | msg "build: cmake 'as-subdirectory' build" |
| 2658 | MBEDTLS_ROOT_DIR="$PWD" |
| 2659 | |
| 2660 | cd programs/test/cmake_subproject |
| 2661 | cmake . |
| 2662 | make |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2663 | ./cmake_subproject |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 2664 | |
| 2665 | cd "$MBEDTLS_ROOT_DIR" |
| 2666 | unset MBEDTLS_ROOT_DIR |
| 2667 | } |
| 2668 | |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 2669 | component_test_cmake_as_package () { |
| 2670 | msg "build: cmake 'as-package' build" |
| 2671 | MBEDTLS_ROOT_DIR="$PWD" |
| 2672 | |
| 2673 | cd programs/test/cmake_package |
| 2674 | cmake . |
| 2675 | make |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2676 | ./cmake_package |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 2677 | |
| 2678 | cd "$MBEDTLS_ROOT_DIR" |
| 2679 | unset MBEDTLS_ROOT_DIR |
| 2680 | } |
| 2681 | |
| 2682 | component_test_cmake_as_package_install () { |
| 2683 | msg "build: cmake 'as-installed-package' build" |
| 2684 | MBEDTLS_ROOT_DIR="$PWD" |
| 2685 | |
| 2686 | cd programs/test/cmake_package_install |
| 2687 | cmake . |
| 2688 | make |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2689 | ./cmake_package_install |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 2690 | |
| 2691 | cd "$MBEDTLS_ROOT_DIR" |
| 2692 | unset MBEDTLS_ROOT_DIR |
| 2693 | } |
| 2694 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2695 | component_test_zeroize () { |
| 2696 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 2697 | # different combinations of compilers and optimization flags by using an |
| 2698 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 2699 | # system in all cases that the script fails, so we must manually search the |
| 2700 | # output to check whether the pass string is present and no failure strings |
| 2701 | # were printed. |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 2702 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 2703 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 2704 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 2705 | gdb_disable_aslr= |
| 2706 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 2707 | gdb_disable_aslr='set disable-randomization off' |
| 2708 | fi |
| 2709 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2710 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 2711 | for compiler in clang gcc; do |
| 2712 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 2713 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2714 | gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log |
| 2715 | grep "The buffer was correctly zeroized" test_zeroize.log |
| 2716 | not grep -i "error" test_zeroize.log |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 2717 | rm -f test_zeroize.log |
| 2718 | make clean |
| 2719 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 2720 | done |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 2721 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 2722 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2723 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 2724 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2725 | component_check_python_files () { |
| 2726 | msg "Lint: Python scripts" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2727 | tests/scripts/check-python-files.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2728 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 2729 | |
Joe Subbiani | d614c0b | 2021-07-29 11:18:29 +0100 | [diff] [blame] | 2730 | component_check_test_helpers () { |
| 2731 | msg "unit test: generate_test_code.py" |
Manuel Pégourié-Gonnard | dfb114a | 2020-06-02 11:40:08 +0200 | [diff] [blame] | 2732 | # unittest writes out mundane stuff like number or tests run on stderr. |
| 2733 | # Our convention is to reserve stderr for actual errors, and write |
| 2734 | # harmless info on stdout so it can be suppress with --quiet. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2735 | ./tests/scripts/test_generate_test_code.py 2>&1 |
Joe Subbiani | d614c0b | 2021-07-29 11:18:29 +0100 | [diff] [blame] | 2736 | |
Joe Subbiani | a25ffab | 2021-08-06 09:41:27 +0100 | [diff] [blame] | 2737 | msg "unit test: translate_ciphers.py" |
| 2738 | python3 -m unittest tests/scripts/translate_ciphers.py 2>&1 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2739 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 2740 | |
| 2741 | ################################################################ |
| 2742 | #### Termination |
| 2743 | ################################################################ |
| 2744 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2745 | post_report () { |
| 2746 | msg "Done, cleaning up" |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 2747 | final_cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2748 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2749 | final_report |
| 2750 | } |
| 2751 | |
| 2752 | |
| 2753 | |
| 2754 | ################################################################ |
| 2755 | #### Run all the things |
| 2756 | ################################################################ |
| 2757 | |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2758 | # Function invoked by --error-test to test error reporting. |
| 2759 | pseudo_component_error_test () { |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 2760 | msg "Testing error reporting $error_test_i" |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2761 | if [ $KEEP_GOING -ne 0 ]; then |
| 2762 | echo "Expect three failing commands." |
| 2763 | fi |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 2764 | # If the component doesn't run in a subshell, changing error_test_i to an |
| 2765 | # invalid integer will cause an error in the loop that runs this function. |
| 2766 | error_test_i=this_should_not_be_used_since_the_component_runs_in_a_subshell |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 2767 | # Expected error: 'grep non_existent /dev/null -> 1' |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2768 | grep non_existent /dev/null |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 2769 | # Expected error: '! grep -q . tests/scripts/all.sh -> 1' |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2770 | not grep -q . "$0" |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 2771 | # Expected error: 'make unknown_target -> 2' |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2772 | make unknown_target |
| 2773 | false "this should not be executed" |
| 2774 | } |
| 2775 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 2776 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2777 | run_component () { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 2778 | current_component="$1" |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 2779 | export MBEDTLS_TEST_CONFIGURATION="$current_component" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 2780 | |
| 2781 | # Unconditionally create a seedfile that's sufficiently long. |
| 2782 | # Do this before each component, because a previous component may |
| 2783 | # have messed it up or shortened it. |
Gilles Peskine | 88a0745 | 2021-07-08 19:03:50 +0200 | [diff] [blame] | 2784 | local dd_cmd |
| 2785 | dd_cmd=(dd if=/dev/urandom of=./tests/seedfile bs=64 count=1) |
| 2786 | case $OSTYPE in |
| 2787 | linux*|freebsd*|openbsd*|darwin*) dd_cmd+=(status=none) |
| 2788 | esac |
| 2789 | "${dd_cmd[@]}" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 2790 | |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 2791 | # Run the component in a subshell, with error trapping and output |
| 2792 | # redirection set up based on the relevant options. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 2793 | if [ $KEEP_GOING -eq 1 ]; then |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 2794 | # We want to keep running if the subshell fails, so 'set -e' must |
| 2795 | # be off when the subshell runs. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 2796 | set +e |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 2797 | fi |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 2798 | ( |
| 2799 | if [ $QUIET -eq 1 ]; then |
| 2800 | # msg() will be silenced, so just print the component name here. |
| 2801 | echo "${current_component#component_}" |
| 2802 | exec >/dev/null |
| 2803 | fi |
| 2804 | if [ $KEEP_GOING -eq 1 ]; then |
| 2805 | # Keep "set -e" off, and run an ERR trap instead to record failures. |
| 2806 | set -E |
| 2807 | trap err_trap ERR |
| 2808 | fi |
| 2809 | # The next line is what runs the component |
| 2810 | "$@" |
| 2811 | if [ $KEEP_GOING -eq 1 ]; then |
| 2812 | trap - ERR |
| 2813 | exit $last_failure_status |
| 2814 | fi |
| 2815 | ) |
| 2816 | component_status=$? |
| 2817 | if [ $KEEP_GOING -eq 1 ]; then |
| 2818 | set -e |
| 2819 | if [ $component_status -ne 0 ]; then |
| 2820 | failure_count=$((failure_count + 1)) |
| 2821 | fi |
| 2822 | fi |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 2823 | |
| 2824 | # Restore the build tree to a clean state. |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 2825 | cleanup |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 2826 | unset current_component |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2827 | } |
| 2828 | |
| 2829 | # Preliminary setup |
| 2830 | pre_check_environment |
| 2831 | pre_initialize_variables |
| 2832 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 2833 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2834 | pre_check_git |
Gilles Peskine | 568f53a | 2021-07-12 18:16:01 +0200 | [diff] [blame] | 2835 | pre_restore_files |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 2836 | pre_back_up |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 2837 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2838 | build_status=0 |
| 2839 | if [ $KEEP_GOING -eq 1 ]; then |
| 2840 | pre_setup_keep_going |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2841 | fi |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 2842 | pre_prepare_outcome_file |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2843 | pre_print_configuration |
| 2844 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2845 | cleanup |
Gilles Peskine | 1570b59 | 2021-04-22 01:10:12 +0200 | [diff] [blame] | 2846 | pre_generate_files |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2847 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 2848 | # Run the requested tests. |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 2849 | for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2850 | run_component pseudo_component_error_test |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 2851 | done |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 2852 | unset error_test_i |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 2853 | for component in $RUN_COMPONENTS; do |
| 2854 | run_component "component_$component" |
| 2855 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2856 | |
| 2857 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2858 | post_report |