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