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" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 130 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 131 | append_outcome=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 132 | MEMORY=0 |
| 133 | FORCE=0 |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 134 | QUIET=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 135 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 136 | |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 137 | # Seed value used with the --release-test option. |
Manuel Pégourié-Gonnard | 5430447 | 2020-06-22 10:11:47 +0200 | [diff] [blame] | 138 | # |
| 139 | # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if |
| 140 | # both values are kept in sync. If you change the value here because it |
| 141 | # breaks some tests, you'll definitely want to change it in |
| 142 | # basic-build-test.sh as well. |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 143 | RELEASE_SEED=1 |
| 144 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 145 | : ${MBEDTLS_TEST_OUTCOME_FILE=} |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 146 | : ${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] | 147 | export MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 148 | export MBEDTLS_TEST_PLATFORM |
| 149 | |
Jaeden Amero | c4cc251 | 2019-01-30 15:35:44 +0000 | [diff] [blame] | 150 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 151 | : ${OPENSSL:="openssl"} |
| 152 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 153 | : ${OPENSSL_NEXT:="$OPENSSL"} |
| 154 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 155 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 156 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 157 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 158 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 159 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 160 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 161 | : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 162 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 163 | # 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] | 164 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 165 | export MAKEFLAGS="-j" |
| 166 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 167 | |
Jaeden Amero | d48e9c7 | 2019-02-07 17:43:39 +0000 | [diff] [blame] | 168 | # Include more verbose output for failing tests run by CMake |
| 169 | export CTEST_OUTPUT_ON_FAILURE=1 |
| 170 | |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 171 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Gilles Peskine | 5ca393f | 2019-10-21 19:06:33 +0200 | [diff] [blame] | 172 | ASAN_CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 173 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 174 | # Gather the list of available components. These are the functions |
| 175 | # defined in this script whose name starts with "component_". |
| 176 | # Parse the script with sed, because in sh there is no way to list |
| 177 | # defined functions. |
| 178 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 179 | |
| 180 | # Exclude components that are not supported on this platform. |
| 181 | SUPPORTED_COMPONENTS= |
| 182 | for component in $ALL_COMPONENTS; do |
| 183 | case $(type "support_$component" 2>&1) in |
| 184 | *' function'*) |
| 185 | if ! support_$component; then continue; fi;; |
| 186 | esac |
| 187 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 188 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 189 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 190 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 191 | # Test whether the component $1 is included in the command line patterns. |
| 192 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 193 | { |
| 194 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 195 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 196 | set +f |
| 197 | case ${1#component_} in $pattern) return 0;; esac |
| 198 | done |
| 199 | set +f |
| 200 | return 1 |
| 201 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 202 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 203 | usage() |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 204 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 205 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 206 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 207 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 208 | 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] | 209 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 210 | |
| 211 | Examples: |
| 212 | $0 "check_*" |
| 213 | Run all sanity checks. |
| 214 | $0 --no-armcc --except test_memsan |
| 215 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 216 | |
| 217 | Special options: |
| 218 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 219 | --list-all-components List all available test components and exit. |
| 220 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 221 | |
| 222 | General options: |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 223 | -q|--quiet Only output component names, and errors if any. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 224 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 225 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 226 | -m|--memory Additional optional memory tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 227 | --append-outcome Append to the outcome file (if used). |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 228 | --arm-none-eabi-gcc-prefix=<string> |
| 229 | Prefix for a cross-compiler for arm-none-eabi |
| 230 | (default: "${ARM_NONE_EABI_GCC_PREFIX}") |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 231 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 232 | --except Exclude the COMPONENTs listed on the command line, |
| 233 | instead of running only those. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 234 | --no-append-outcome Write a new outcome file and analyze it (default). |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 235 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 236 | --no-force Refuse to overwrite modified files (default). |
| 237 | --no-keep-going Stop at the first error (default). |
| 238 | --no-memory No additional memory tests (default). |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 239 | --no-quiet Print full ouput from components. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 240 | --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] | 241 | --outcome-file=<path> File where test outcomes are written (not done if |
| 242 | empty; default: \$MBEDTLS_TEST_OUTCOME_FILE). |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 243 | --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] | 244 | -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] | 245 | -s|--seed Integer seed value to use for this test run. |
| 246 | |
| 247 | Tool path options: |
| 248 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 249 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 250 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 251 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 252 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 253 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 254 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 255 | --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] | 256 | --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] | 257 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 258 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 259 | |
| 260 | # remove built files as well as the cmake cache/config |
| 261 | cleanup() |
| 262 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 263 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 264 | cd "$MBEDTLS_ROOT_DIR" |
| 265 | fi |
| 266 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 267 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 268 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 269 | # Remove CMake artefacts |
Jaeden Amero | 2d0e00f | 2018-11-07 18:46:41 +0000 | [diff] [blame] | 270 | find . -name .git -prune -o \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 271 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 272 | \( -iname cmake_install.cmake -o \ |
| 273 | -iname CTestTestfile.cmake -o \ |
| 274 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 275 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 276 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 277 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 278 | 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] | 279 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 280 | # Remove any artifacts from the component_test_cmake_as_subdirectory test. |
| 281 | rm -rf programs/test/cmake_subproject/build |
| 282 | rm -f programs/test/cmake_subproject/Makefile |
| 283 | rm -f programs/test/cmake_subproject/cmake_subproject |
| 284 | |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 285 | if [ -f "$CONFIG_BAK" ]; then |
| 286 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 287 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 288 | } |
| 289 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 290 | # Executed on exit. May be redefined depending on command line options. |
| 291 | final_report () { |
| 292 | : |
| 293 | } |
| 294 | |
| 295 | fatal_signal () { |
| 296 | cleanup |
| 297 | final_report $1 |
| 298 | trap - $1 |
| 299 | kill -$1 $$ |
| 300 | } |
| 301 | |
| 302 | trap 'fatal_signal HUP' HUP |
| 303 | trap 'fatal_signal INT' INT |
| 304 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 305 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 306 | msg() |
| 307 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 308 | if [ -n "${current_component:-}" ]; then |
| 309 | current_section="${current_component#component_}: $1" |
| 310 | else |
| 311 | current_section="$1" |
| 312 | fi |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 313 | |
| 314 | if [ $QUIET -eq 1 ]; then |
| 315 | return |
| 316 | fi |
| 317 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 318 | echo "" |
| 319 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 320 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 321 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 322 | echo "******************************************************************" |
| 323 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 324 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 325 | armc6_build_test() |
| 326 | { |
| 327 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 328 | |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 329 | msg "build: ARM Compiler 6 ($FLAGS)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 330 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 331 | WARNING_CFLAGS='-xc -std=c99' make lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 332 | |
| 333 | msg "size: ARM Compiler 6 ($FLAGS)" |
| 334 | "$ARMC6_FROMELF" -z library/*.o |
| 335 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 336 | make clean |
| 337 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 338 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 339 | err_msg() |
| 340 | { |
| 341 | echo "$1" >&2 |
| 342 | } |
| 343 | |
| 344 | check_tools() |
| 345 | { |
| 346 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 347 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 348 | err_msg "$TOOL not found!" |
| 349 | exit 1 |
| 350 | fi |
| 351 | done |
| 352 | } |
| 353 | |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 354 | check_headers_in_cpp () { |
Peter Kolbus | 1bc1a4c | 2019-02-01 17:19:08 -0600 | [diff] [blame] | 355 | ls include/mbedtls | grep "\.h$" >headers.txt |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 356 | <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' | |
| 357 | sort | |
| 358 | diff headers.txt - |
| 359 | rm headers.txt |
| 360 | } |
| 361 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 362 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 363 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 364 | all_except=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 365 | no_armcc= |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 366 | |
Jaeden Amero | 9b90f2e | 2018-11-02 18:34:17 +0000 | [diff] [blame] | 367 | # Note that legacy options are ignored instead of being omitted from this |
| 368 | # list of options, so invocations that worked with previous version of |
| 369 | # all.sh will still run and work properly. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 370 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 371 | case "$1" in |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 372 | --append-outcome) append_outcome=1;; |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 373 | --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 374 | --armcc) no_armcc=;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 375 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 376 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 377 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 378 | --force|-f) FORCE=1;; |
| 379 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 380 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 381 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 382 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 383 | --help|-h) usage; exit;; |
| 384 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 385 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 386 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 387 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 388 | --no-append-outcome) append_outcome=0;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 389 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 390 | --no-force) FORCE=0;; |
| 391 | --no-keep-going) KEEP_GOING=0;; |
| 392 | --no-memory) MEMORY=0;; |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 393 | --no-quiet) QUIET=0;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 394 | --openssl) shift; OPENSSL="$1";; |
| 395 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 396 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 397 | --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 398 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 399 | --quiet|-q) QUIET=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 400 | --random-seed) unset SEED;; |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 401 | --release-test|-r) SEED=$RELEASE_SEED;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 402 | --seed|-s) shift; SEED="$1";; |
| 403 | -*) |
| 404 | echo >&2 "Unknown option: $1" |
| 405 | echo >&2 "Run $0 --help for usage." |
| 406 | exit 120 |
| 407 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 408 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 409 | esac |
| 410 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 411 | done |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 412 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 413 | # With no list of components, run everything. |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 414 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 415 | all_except=1 |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 416 | fi |
| 417 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 418 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 419 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 420 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 421 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 422 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 423 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 424 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 425 | RUN_COMPONENTS= |
| 426 | for component in $SUPPORTED_COMPONENTS; do |
| 427 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 428 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 429 | fi |
| 430 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 431 | |
| 432 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 433 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 434 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 435 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 436 | pre_check_git () { |
| 437 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 438 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 439 | git checkout-index -f -q $CONFIG_H |
| 440 | cleanup |
| 441 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 442 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 443 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 444 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 445 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 446 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 447 | exit 1 |
| 448 | fi |
| 449 | |
Gilles Peskine | d1174cf | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 450 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 451 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 452 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 453 | echo "script as: $0 --force" |
| 454 | exit 1 |
| 455 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 456 | fi |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 457 | } |
| 458 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 459 | pre_setup_keep_going () { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 460 | failure_summary= |
| 461 | failure_count=0 |
| 462 | start_red= |
| 463 | end_color= |
| 464 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 465 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 466 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 467 | start_red=$(printf '\033[31m') |
| 468 | end_color=$(printf '\033[0m') |
| 469 | ;; |
| 470 | esac |
| 471 | fi |
| 472 | record_status () { |
| 473 | if "$@"; then |
| 474 | last_status=0 |
| 475 | else |
| 476 | last_status=$? |
| 477 | text="$current_section: $* -> $last_status" |
| 478 | failure_summary="$failure_summary |
| 479 | $text" |
| 480 | failure_count=$((failure_count + 1)) |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 481 | echo "${start_red}^^^^$text^^^^${end_color}" >&2 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 482 | fi |
| 483 | } |
| 484 | make () { |
| 485 | case "$*" in |
| 486 | *test|*check) |
| 487 | if [ $build_status -eq 0 ]; then |
| 488 | record_status command make "$@" |
| 489 | else |
| 490 | echo "(skipped because the build failed)" |
| 491 | fi |
| 492 | ;; |
| 493 | *) |
| 494 | record_status command make "$@" |
| 495 | build_status=$last_status |
| 496 | ;; |
| 497 | esac |
| 498 | } |
| 499 | final_report () { |
| 500 | if [ $failure_count -gt 0 ]; then |
| 501 | echo |
| 502 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 503 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 504 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 7c1258d | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 505 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 506 | elif [ -z "${1-}" ]; then |
| 507 | echo "SUCCESS :)" |
| 508 | fi |
| 509 | if [ -n "${1-}" ]; then |
| 510 | echo "Killed by SIG$1." |
| 511 | fi |
| 512 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 515 | if_build_succeeded () { |
| 516 | if [ $build_status -eq 0 ]; then |
| 517 | record_status "$@" |
| 518 | fi |
| 519 | } |
| 520 | |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 521 | # to be used instead of ! for commands run with |
| 522 | # record_status or if_build_succeeded |
| 523 | not() { |
| 524 | ! "$@" |
| 525 | } |
| 526 | |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 527 | pre_setup_quiet_redirect () { |
| 528 | if [ $QUIET -ne 1 ]; then |
| 529 | redirect_out () { |
| 530 | "$@" |
| 531 | } |
Manuel Pégourié-Gonnard | f1f180a | 2020-06-08 10:46:35 +0200 | [diff] [blame] | 532 | redirect_err () { |
| 533 | "$@" |
| 534 | } |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 535 | else |
| 536 | redirect_out () { |
| 537 | "$@" >/dev/null |
| 538 | } |
Manuel Pégourié-Gonnard | f1f180a | 2020-06-08 10:46:35 +0200 | [diff] [blame] | 539 | redirect_err () { |
| 540 | "$@" 2>/dev/null |
| 541 | } |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 542 | fi |
| 543 | } |
| 544 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 545 | pre_prepare_outcome_file () { |
| 546 | case "$MBEDTLS_TEST_OUTCOME_FILE" in |
| 547 | [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; |
| 548 | esac |
| 549 | if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then |
| 550 | rm -f "$MBEDTLS_TEST_OUTCOME_FILE" |
| 551 | fi |
| 552 | } |
| 553 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 554 | pre_print_configuration () { |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 555 | if [ $QUIET -eq 1 ]; then |
| 556 | return |
| 557 | fi |
| 558 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 559 | msg "info: $0 configuration" |
| 560 | echo "MEMORY: $MEMORY" |
| 561 | echo "FORCE: $FORCE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 562 | echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 563 | echo "SEED: ${SEED-"UNSET"}" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 564 | echo |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 565 | echo "OPENSSL: $OPENSSL" |
| 566 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 567 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 568 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 569 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 570 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 571 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 572 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 573 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 574 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 575 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 576 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 577 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 578 | # Build the list of variables to pass to output_env.sh. |
| 579 | set env |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 580 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 581 | case " $RUN_COMPONENTS " in |
| 582 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 583 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 584 | # is a good enough approximation in practice. |
| 585 | *" test_"*) |
| 586 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 587 | # and ssl-opt.sh, we just export the variables they require. |
| 588 | export OPENSSL_CMD="$OPENSSL" |
| 589 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 590 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 591 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 592 | if [ -n "${SEED-}" ]; then |
| 593 | export SEED |
| 594 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 595 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 596 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 597 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 598 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 599 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 600 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 601 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 602 | ;; |
| 603 | esac |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 604 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 605 | case " $RUN_COMPONENTS " in |
| 606 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 607 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 608 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 609 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 610 | *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";; |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 611 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 612 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 613 | case " $RUN_COMPONENTS " in |
| 614 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 615 | esac |
| 616 | |
| 617 | case " $RUN_COMPONENTS " in |
| 618 | *" test_zeroize "*) check_tools "gdb";; |
| 619 | esac |
| 620 | |
| 621 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 622 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 623 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 624 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 625 | ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 626 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 627 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 628 | ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf" |
| 629 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \ |
| 630 | "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 631 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 632 | |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 633 | # past this point, no call to check_tool, only printing output |
| 634 | if [ $QUIET -eq 1 ]; then |
| 635 | return |
| 636 | fi |
| 637 | |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 638 | msg "info: output_env.sh" |
| 639 | case $RUN_COMPONENTS in |
| 640 | *_armcc*) |
| 641 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 642 | *) set "$@" RUN_ARMCC=0;; |
| 643 | esac |
| 644 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 645 | } |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 646 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 647 | |
| 648 | |
| 649 | ################################################################ |
| 650 | #### Basic checks |
| 651 | ################################################################ |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 652 | |
| 653 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 654 | # Test Suites to be executed |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 655 | # |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame] | 656 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 657 | # 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] | 658 | # 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] | 659 | # time, so start with a GCC build). |
| 660 | # 2. Minimize total running time, by avoiding useless rebuilds |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 661 | # |
Manuel Pégourié-Gonnard | 259b08a | 2016-01-08 16:27:41 +0100 | [diff] [blame] | 662 | # Indicative running times are given for reference. |
| 663 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 664 | component_check_recursion () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 665 | msg "Check: recursion.pl" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 666 | record_status tests/scripts/recursion.pl library/*.c |
| 667 | } |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 668 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 669 | component_check_generated_files () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 670 | msg "Check: freshness of generated source files" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 671 | record_status tests/scripts/check-generated-files.sh |
| 672 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 673 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 674 | component_check_doxy_blocks () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 675 | msg "Check: doxygen markup outside doxygen blocks" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 676 | record_status tests/scripts/check-doxy-blocks.pl |
| 677 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 678 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 679 | component_check_files () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 680 | msg "Check: file sanity checks (permissions, encodings)" # < 1s |
Gilles Peskine | fb4f933 | 2020-06-25 14:18:34 +0200 | [diff] [blame] | 681 | record_status tests/scripts/check_files.py |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 682 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 683 | |
Gilles Peskine | 30e0bb4 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 684 | component_check_changelog () { |
| 685 | msg "Check: changelog entries" # < 1s |
| 686 | rm -f ChangeLog.new |
| 687 | record_status scripts/assemble_changelog.py -o ChangeLog.new |
| 688 | if [ -e ChangeLog.new ]; then |
| 689 | # Show the diff for information. It isn't an error if the diff is |
| 690 | # non-empty. |
| 691 | diff -u ChangeLog ChangeLog.new || true |
| 692 | rm ChangeLog.new |
| 693 | fi |
| 694 | } |
| 695 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 696 | component_check_names () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 697 | msg "Check: declared and exported names (builds the library)" # < 3s |
Gilles Peskine | 13f97dc | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 698 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 699 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 700 | |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 701 | component_check_test_cases () { |
| 702 | msg "Check: test case descriptions" # < 1s |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 703 | if [ $QUIET -eq 1 ]; then |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 704 | opt='--quiet' |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 705 | else |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 706 | opt='' |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 707 | fi |
Gilles Peskine | fb4f933 | 2020-06-25 14:18:34 +0200 | [diff] [blame] | 708 | record_status tests/scripts/check_test_cases.py $opt |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 709 | unset opt |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 710 | } |
| 711 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 712 | component_check_doxygen_warnings () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 713 | msg "Check: doxygen warnings (builds the documentation)" # ~ 3s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 714 | record_status tests/scripts/doxygen.sh |
| 715 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 716 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 717 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 718 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 719 | ################################################################ |
| 720 | #### Build and test many configurations and targets |
| 721 | ################################################################ |
| 722 | |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 723 | component_test_default_out_of_box () { |
| 724 | msg "build: make, default config (out-of-box)" # ~1min |
| 725 | make |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 726 | # Disable fancy stuff |
Gilles Peskine | 717cd76 | 2019-09-27 20:21:11 +0200 | [diff] [blame] | 727 | SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 728 | unset MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 729 | |
| 730 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 731 | make test |
| 732 | |
| 733 | msg "selftest: make, default config (out-of-box)" # ~10s |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 734 | if_build_succeeded programs/test/selftest |
Gilles Peskine | 717cd76 | 2019-09-27 20:21:11 +0200 | [diff] [blame] | 735 | |
| 736 | export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE" |
| 737 | unset SAVE_MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 738 | } |
| 739 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 740 | component_test_default_cmake_gcc_asan () { |
| 741 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 742 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 743 | make |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 744 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 745 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 746 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 747 | |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 748 | msg "test: selftest (ASan build)" # ~ 10s |
| 749 | if_build_succeeded programs/test/selftest |
| 750 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 751 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
| 752 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 753 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 754 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 755 | if_build_succeeded tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 756 | |
| 757 | msg "test: context-info.sh (ASan build)" # ~ 15 sec |
| 758 | if_build_succeeded tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 759 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 760 | |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 761 | component_test_full_cmake_gcc_asan () { |
| 762 | msg "build: full config, cmake, gcc, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 763 | scripts/config.py full |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 764 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 765 | make |
| 766 | |
| 767 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 768 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 769 | |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 770 | msg "test: selftest (ASan build)" # ~ 10s |
| 771 | if_build_succeeded programs/test/selftest |
| 772 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 773 | msg "test: ssl-opt.sh (full config, ASan build)" |
| 774 | if_build_succeeded tests/ssl-opt.sh |
| 775 | |
| 776 | msg "test: compat.sh (full config, ASan build)" |
| 777 | if_build_succeeded tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 778 | |
| 779 | msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec |
| 780 | if_build_succeeded tests/context-info.sh |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | component_test_zlib_make() { |
| 784 | msg "build: zlib enabled, make" |
| 785 | scripts/config.py set MBEDTLS_ZLIB_SUPPORT |
| 786 | make ZLIB=1 CFLAGS='-Werror -O1' |
| 787 | |
| 788 | msg "test: main suites (zlib, make)" |
| 789 | make test |
| 790 | |
| 791 | msg "test: ssl-opt.sh (zlib, make)" |
| 792 | if_build_succeeded tests/ssl-opt.sh |
| 793 | } |
| 794 | support_test_zlib_make () { |
| 795 | base=support_test_zlib_$$ |
| 796 | cat <<'EOF' > ${base}.c |
| 797 | #include "zlib.h" |
| 798 | int main(void) { return 0; } |
| 799 | EOF |
| 800 | gcc -o ${base}.exe ${base}.c -lz 2>/dev/null |
| 801 | ret=$? |
| 802 | rm -f ${base}.* |
| 803 | return $ret |
| 804 | } |
| 805 | |
| 806 | component_test_zlib_cmake() { |
| 807 | msg "build: zlib enabled, cmake" |
| 808 | scripts/config.py set MBEDTLS_ZLIB_SUPPORT |
| 809 | cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check . |
| 810 | make |
| 811 | |
| 812 | msg "test: main suites (zlib, cmake)" |
| 813 | make test |
| 814 | |
| 815 | msg "test: ssl-opt.sh (zlib, cmake)" |
| 816 | if_build_succeeded tests/ssl-opt.sh |
| 817 | } |
| 818 | support_test_zlib_cmake () { |
| 819 | support_test_zlib_make "$@" |
Manuel Pégourié-Gonnard | f2e2902 | 2020-01-24 10:17:20 +0100 | [diff] [blame] | 820 | } |
Manuel Pégourié-Gonnard | 95e0449 | 2020-01-02 11:45:12 +0100 | [diff] [blame] | 821 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 822 | component_test_ref_configs () { |
| 823 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 824 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 825 | record_status tests/scripts/test-ref-configs.pl |
| 826 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 827 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 828 | component_test_sslv3 () { |
| 829 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 830 | scripts/config.py set MBEDTLS_SSL_PROTO_SSL3 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 831 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 832 | make |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 833 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 834 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 835 | make test |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 836 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 837 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
| 838 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 839 | 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] | 840 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 841 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 842 | if_build_succeeded tests/ssl-opt.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 843 | |
| 844 | msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec |
| 845 | if_build_succeeded tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 846 | } |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 847 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 848 | component_test_no_renegotiation () { |
| 849 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 850 | scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 851 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 852 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 853 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 854 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 855 | make test |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 856 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 857 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 858 | if_build_succeeded tests/ssl-opt.sh |
| 859 | } |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 860 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 861 | component_test_no_pem_no_fs () { |
| 862 | msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" |
| 863 | scripts/config.py unset MBEDTLS_PEM_PARSE_C |
| 864 | scripts/config.py unset MBEDTLS_FS_IO |
| 865 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem |
| 866 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS |
| 867 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 868 | make |
| 869 | |
| 870 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 871 | make test |
| 872 | |
| 873 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
| 874 | if_build_succeeded tests/ssl-opt.sh |
| 875 | } |
| 876 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 877 | component_test_rsa_no_crt () { |
| 878 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 879 | scripts/config.py set MBEDTLS_RSA_NO_CRT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 880 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 881 | make |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 882 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 883 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 884 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 885 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 886 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 887 | if_build_succeeded tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 888 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 889 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 890 | if_build_succeeded tests/compat.sh -t RSA |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 891 | |
| 892 | msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec |
| 893 | if_build_succeeded tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 894 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 895 | |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 896 | component_test_no_ctr_drbg () { |
| 897 | msg "build: Full minus CTR_DRBG" |
| 898 | scripts/config.py full |
| 899 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 900 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG |
| 901 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto |
| 902 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C # requires PSA Crypto |
| 903 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO # requires PSA Crypto |
| 904 | |
| 905 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 906 | make |
| 907 | |
| 908 | msg "test: no CTR_DRBG" |
| 909 | make test |
| 910 | |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 911 | # no ssl-opt.sh/compat.sh as they all depend on CTR_DRBG so far |
| 912 | } |
| 913 | |
| 914 | component_test_no_hmac_drbg () { |
| 915 | msg "build: Full minus HMAC_DRBG" |
| 916 | scripts/config.py full |
| 917 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 918 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 919 | |
| 920 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 921 | make |
| 922 | |
| 923 | msg "test: no HMAC_DRBG" |
| 924 | make test |
| 925 | |
| 926 | # No ssl-opt.sh/compat.sh as they never use HMAC_DRBG so far, |
| 927 | # so there's little value in running those lengthy tests here. |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 928 | } |
| 929 | |
Manuel Pégourié-Gonnard | 1a3f9ed | 2020-05-19 12:38:31 +0200 | [diff] [blame] | 930 | component_test_ecp_no_internal_rng () { |
| 931 | msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules" |
| 932 | scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG |
| 933 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 934 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 935 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 936 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG |
| 937 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto |
| 938 | |
| 939 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 940 | make |
| 941 | |
| 942 | msg "test: ECP_NO_INTERNAL_RNG, no DRBG module" |
| 943 | make test |
| 944 | |
| 945 | # no SSL tests as they all depend on having a DRBG |
| 946 | } |
| 947 | |
Manuel Pégourié-Gonnard | 53fb66d | 2020-06-04 09:43:14 +0200 | [diff] [blame] | 948 | component_test_ecp_restartable_no_internal_rng () { |
| 949 | msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG" |
| 950 | scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG |
| 951 | scripts/config.py set MBEDTLS_ECP_RESTARTABLE |
| 952 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 953 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 954 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 955 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG |
| 956 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto |
| 957 | |
| 958 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 959 | make |
| 960 | |
| 961 | msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module" |
| 962 | make test |
| 963 | |
| 964 | # no SSL tests as they all depend on having a DRBG |
| 965 | } |
| 966 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 967 | component_test_new_ecdh_context () { |
| 968 | msg "build: new ECDH context (ASan build)" # ~ 6 min |
| 969 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 970 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 971 | make |
| 972 | |
| 973 | msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 974 | make test |
| 975 | |
| 976 | msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 977 | if_build_succeeded tests/ssl-opt.sh -f ECDH |
| 978 | |
| 979 | msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 980 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 981 | if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4' |
| 982 | } |
| 983 | |
| 984 | component_test_everest () { |
| 985 | msg "build: Everest ECDH context (ASan build)" # ~ 6 min |
| 986 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 987 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 988 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 989 | make |
| 990 | |
| 991 | msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 992 | make test |
| 993 | |
| 994 | msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 995 | if_build_succeeded tests/ssl-opt.sh -f ECDH |
| 996 | |
| 997 | msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 998 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 999 | if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4' |
| 1000 | } |
| 1001 | |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1002 | component_test_everest_curve25519_only () { |
| 1003 | msg "build: Everest ECDH context, only Curve25519" # ~ 6 min |
| 1004 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 1005 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 1006 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 1007 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 1008 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 1009 | # Disable all curves |
| 1010 | for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do |
| 1011 | scripts/config.py unset "$c" |
| 1012 | done |
| 1013 | scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED |
| 1014 | |
| 1015 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1016 | |
| 1017 | msg "test: Everest ECDH context, only Curve25519" # ~ 50s |
| 1018 | make test |
| 1019 | } |
| 1020 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1021 | component_test_small_ssl_out_content_len () { |
| 1022 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1023 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1024 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1025 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1026 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1027 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1028 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
| 1029 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" |
| 1030 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1031 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1032 | component_test_small_ssl_in_content_len () { |
| 1033 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1034 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 1035 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1036 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1037 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1038 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1039 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
| 1040 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment" |
| 1041 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1042 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1043 | component_test_small_ssl_dtls_max_buffering () { |
| 1044 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1045 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1046 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1047 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1048 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1049 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
| 1050 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
| 1051 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1052 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1053 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 1054 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1055 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1056 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1057 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1058 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1059 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
| 1060 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
| 1061 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1062 | |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1063 | component_test_psa_collect_statuses () { |
| 1064 | msg "build+test: psa_collect_statuses" # ~30s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1065 | scripts/config.py full |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1066 | record_status tests/scripts/psa_collect_statuses.py |
| 1067 | # Check that psa_crypto_init() succeeded at least once |
| 1068 | record_status grep -q '^0:psa_crypto_init:' tests/statuses.log |
| 1069 | rm -f tests/statuses.log |
| 1070 | } |
| 1071 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1072 | component_test_full_cmake_clang () { |
| 1073 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1074 | scripts/config.py full |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1075 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 1076 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1077 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 1078 | msg "test: main suites (full config, clang)" # ~ 5s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1079 | make test |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 1080 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 1081 | msg "test: psa_constant_names (full config, clang)" # ~ 1s |
Darryl Green | 45010a3 | 2019-02-06 13:43:58 +0000 | [diff] [blame] | 1082 | record_status tests/scripts/test_psa_constant_names.py |
Gilles Peskine | 69e8f7f | 2020-02-26 19:51:43 +0100 | [diff] [blame] | 1083 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1084 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
| 1085 | 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] | 1086 | |
Andres Amaya Garcia | 2dadab7 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 1087 | 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] | 1088 | 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] | 1089 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1090 | msg "test: compat.sh ARIA + ChachaPoly" |
| 1091 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 1092 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1093 | |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1094 | component_test_memsan_constant_flow () { |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1095 | # This tests both (1) accesses to undefined memory, and (2) branches or |
| 1096 | # memory access depending on secret values. To distinguish between those: |
| 1097 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist? |
| 1098 | # - or alternatively, change the build type to MemSanDbg, which enables |
| 1099 | # origin tracking and nicer stack traces (which are useful for debugging |
| 1100 | # anyway), and check if the origin was TEST_CF_SECRET() or something else. |
| 1101 | 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] | 1102 | scripts/config.py full |
| 1103 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN |
| 1104 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1105 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1106 | make |
| 1107 | |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1108 | msg "test: main suites (Msan + constant flow)" |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1109 | make test |
| 1110 | } |
| 1111 | |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 1112 | component_test_valgrind_constant_flow () { |
| 1113 | # This tests both (1) everything that valgrind's memcheck usually checks |
| 1114 | # (heap buffer overflows, use of uninitialized memory, use-after-free, |
| 1115 | # etc.) and (2) branches or memory access depending on secret values, |
| 1116 | # which will be reported as uninitialized memory. To distinguish between |
| 1117 | # secret and actually uninitialized: |
| 1118 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist? |
| 1119 | # - or alternatively, build with debug info and manually run the offending |
| 1120 | # test suite with valgrind --track-origins=yes, then check if the origin |
| 1121 | # was TEST_CF_SECRET() or something else. |
| 1122 | msg "build: cmake release GCC, full config with constant flow testing" |
| 1123 | scripts/config.py full |
| 1124 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND |
| 1125 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1126 | make |
| 1127 | |
| 1128 | # this only shows a summary of the results (how many of each type) |
| 1129 | # details are left in Testing/<date>/DynamicAnalysis.xml |
| 1130 | msg "test: main suites (valgrind + constant flow)" |
| 1131 | make memcheck |
| 1132 | } |
| 1133 | |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1134 | component_test_default_no_deprecated () { |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1135 | # Test that removing the deprecated features from the default |
| 1136 | # configuration leaves something consistent. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1137 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
| 1138 | scripts/config.py set MBEDTLS_DEPRECATED_REMOVED |
| 1139 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1140 | |
| 1141 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 1142 | make test |
| 1143 | } |
| 1144 | |
| 1145 | component_test_full_no_deprecated () { |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1146 | msg "build: make, full_no_deprecated config" # ~ 30s |
| 1147 | scripts/config.py full_no_deprecated |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1148 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1149 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1150 | msg "test: make, full_no_deprecated config" # ~ 5s |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1151 | make test |
| 1152 | } |
| 1153 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1154 | component_test_full_no_deprecated_deprecated_warning () { |
| 1155 | # Test that there is nothing deprecated in "full_no_deprecated". |
| 1156 | # A deprecated feature would trigger a warning (made fatal) from |
| 1157 | # MBEDTLS_DEPRECATED_WARNING. |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1158 | msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 1159 | scripts/config.py full_no_deprecated |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1160 | scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED |
| 1161 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
| 1162 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1163 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1164 | msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1165 | make test |
| 1166 | } |
| 1167 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1168 | component_test_full_deprecated_warning () { |
| 1169 | # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes |
| 1170 | # with only certain whitelisted types of warnings. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1171 | msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1172 | scripts/config.py full |
| 1173 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1174 | # Expect warnings from '#warning' directives in check_config.h. |
| 1175 | 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] | 1176 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1177 | msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
| 1178 | # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features. |
| 1179 | # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1180 | # Expect warnings from '#warning' directives in check_config.h and |
| 1181 | # from the use of deprecated functions in test suites. |
| 1182 | 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] | 1183 | |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1184 | msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s |
| 1185 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1186 | } |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 1187 | |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1188 | # Check that the specified libraries exist and are empty. |
| 1189 | are_empty_libraries () { |
| 1190 | nm "$@" >/dev/null 2>/dev/null |
| 1191 | ! nm "$@" 2>/dev/null | grep -v ':$' | grep . |
| 1192 | } |
| 1193 | |
| 1194 | component_build_crypto_default () { |
| 1195 | msg "build: make, crypto only" |
| 1196 | scripts/config.py crypto |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1197 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1198 | if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 1199 | } |
| 1200 | |
| 1201 | component_build_crypto_full () { |
| 1202 | msg "build: make, crypto only, full config" |
| 1203 | scripts/config.py crypto_full |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1204 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1205 | if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 1206 | } |
| 1207 | |
| 1208 | component_build_crypto_baremetal () { |
| 1209 | msg "build: make, crypto only, baremetal config" |
| 1210 | scripts/config.py crypto_baremetal |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1211 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1212 | if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 1213 | } |
| 1214 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1215 | component_test_depends_curves () { |
| 1216 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1217 | record_status tests/scripts/curves.pl |
| 1218 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 1219 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1220 | component_test_depends_hashes () { |
| 1221 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1222 | record_status tests/scripts/depends-hashes.pl |
| 1223 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 1224 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1225 | component_test_depends_pkalgs () { |
| 1226 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1227 | record_status tests/scripts/depends-pkalgs.pl |
| 1228 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1229 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1230 | component_build_key_exchanges () { |
| 1231 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1232 | record_status tests/scripts/key-exchanges.pl |
| 1233 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1234 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1235 | component_build_default_make_gcc_and_cxx () { |
| 1236 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1237 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1238 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1239 | msg "test: verify header list in cpp_dummy_build.cpp" |
| 1240 | record_status check_headers_in_cpp |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1241 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1242 | msg "build: Unix make, incremental g++" |
| 1243 | make TEST_CPP=1 |
| 1244 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 1245 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1246 | component_test_no_use_psa_crypto_full_cmake_asan() { |
| 1247 | # 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] | 1248 | msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1249 | scripts/config.py full |
| 1250 | scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC |
| 1251 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 1252 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1253 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | dc6d838 | 2020-04-12 14:21:55 +0200 | [diff] [blame] | 1254 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1255 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Manuel Pégourié-Gonnard | d8167e8 | 2019-02-01 11:12:52 +0100 | [diff] [blame] | 1256 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1257 | make |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 1258 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1259 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1260 | make test |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 1261 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1262 | msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1263 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1264 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1265 | msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1266 | if_build_succeeded tests/compat.sh |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 1267 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1268 | 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] | 1269 | 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] | 1270 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 1271 | msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 1272 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 1273 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1274 | |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1275 | component_test_check_params_functionality () { |
| 1276 | msg "build+test: MBEDTLS_CHECK_PARAMS functionality" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1277 | scripts/config.py full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1278 | # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed(). |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1279 | scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1280 | # Only build and run tests. Do not build sample programs, because |
| 1281 | # they don't have a mbedtls_param_failed() function. |
| 1282 | make CC=gcc CFLAGS='-Werror -O1' lib test |
| 1283 | } |
| 1284 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1285 | component_test_check_params_without_platform () { |
| 1286 | msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1287 | scripts/config.py full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1288 | # Keep MBEDTLS_PARAM_FAILED as assert. |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1289 | scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT |
| 1290 | scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT |
| 1291 | scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1292 | scripts/config.py unset MBEDTLS_PLATFORM_MEMORY |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 1293 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1294 | scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1295 | scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1296 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1297 | scripts/config.py unset MBEDTLS_PLATFORM_C |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1298 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1299 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1300 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1301 | component_test_check_params_silent () { |
| 1302 | msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1303 | scripts/config.py full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 1304 | # Set MBEDTLS_PARAM_FAILED to nothing. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 1305 | sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" |
| 1306 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 1307 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 1308 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1309 | component_test_no_platform () { |
| 1310 | # Full configuration build, without platform support, file IO and net sockets. |
| 1311 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 1312 | # IO, it should catch missing '#include <stdio.h>' |
| 1313 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1314 | scripts/config.py full |
| 1315 | scripts/config.py unset MBEDTLS_PLATFORM_C |
| 1316 | scripts/config.py unset MBEDTLS_NET_C |
| 1317 | scripts/config.py unset MBEDTLS_PLATFORM_MEMORY |
| 1318 | scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 1319 | scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 1320 | scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 1321 | scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT |
| 1322 | scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 1323 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1324 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1325 | scripts/config.py unset MBEDTLS_FS_IO |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1326 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1327 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 1328 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1329 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 1330 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1331 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 1332 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1333 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 1334 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1335 | component_build_no_std_function () { |
| 1336 | # catch compile bugs in _uninit functions |
| 1337 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1338 | scripts/config.py full |
| 1339 | scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 1340 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 1341 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1342 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1343 | } |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 1344 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1345 | component_build_no_ssl_srv () { |
| 1346 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1347 | scripts/config.py full |
| 1348 | scripts/config.py unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1349 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1350 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1351 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1352 | component_build_no_ssl_cli () { |
| 1353 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1354 | scripts/config.py full |
| 1355 | scripts/config.py unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 1356 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1357 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 1358 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1359 | component_build_no_sockets () { |
| 1360 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 1361 | # as that requires a POSIX platform (which isn't the same as C99). |
| 1362 | 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] | 1363 | scripts/config.py full |
| 1364 | scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 1365 | 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] | 1366 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1367 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 1368 | |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1369 | component_test_memory_buffer_allocator_backtrace () { |
| 1370 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1371 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1372 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1373 | scripts/config.py set MBEDTLS_MEMORY_BACKTRACE |
| 1374 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 1375 | CC=gcc cmake . |
| 1376 | make |
| 1377 | |
| 1378 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1379 | make test |
| 1380 | } |
| 1381 | |
| 1382 | component_test_memory_buffer_allocator () { |
| 1383 | msg "build: default config with memory buffer allocator" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1384 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1385 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1386 | CC=gcc cmake . |
| 1387 | make |
| 1388 | |
| 1389 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1390 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1391 | |
| 1392 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1393 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 1394 | if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 1395 | } |
| 1396 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1397 | component_test_no_max_fragment_length () { |
| 1398 | # Run max fragment length tests with MFL disabled |
| 1399 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1400 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1401 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1402 | make |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 1403 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1404 | msg "test: ssl-opt.sh, MFL-related tests" |
| 1405 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
| 1406 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1407 | |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1408 | component_test_asan_remove_peer_certificate () { |
| 1409 | 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] | 1410 | scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1411 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1412 | make |
| 1413 | |
| 1414 | msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1415 | make test |
| 1416 | |
| 1417 | msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1418 | if_build_succeeded tests/ssl-opt.sh |
| 1419 | |
| 1420 | msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1421 | if_build_succeeded tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 1422 | |
| 1423 | msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 1424 | if_build_succeeded tests/context-info.sh |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 1425 | } |
| 1426 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1427 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 1428 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1429 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1430 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1431 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1432 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1433 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1434 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1435 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
| 1436 | 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] | 1437 | |
| 1438 | msg "test: context-info.sh (disabled MFL extension case)" |
| 1439 | if_build_succeeded tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1440 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1441 | |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 1442 | component_test_variable_ssl_in_out_buffer_len () { |
| 1443 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)" |
| 1444 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1445 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1446 | make |
| 1447 | |
| 1448 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 1449 | make test |
| 1450 | |
| 1451 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 1452 | if_build_succeeded tests/ssl-opt.sh |
| 1453 | |
| 1454 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 1455 | if_build_succeeded tests/compat.sh |
| 1456 | } |
| 1457 | |
| 1458 | component_test_variable_ssl_in_out_buffer_len_CID () { |
| 1459 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)" |
| 1460 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1461 | scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID |
| 1462 | |
| 1463 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1464 | make |
| 1465 | |
| 1466 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID" |
| 1467 | make test |
| 1468 | |
| 1469 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" |
| 1470 | if_build_succeeded tests/ssl-opt.sh |
| 1471 | |
| 1472 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" |
| 1473 | if_build_succeeded tests/compat.sh |
| 1474 | } |
| 1475 | |
| 1476 | component_test_variable_ssl_in_out_buffer_len_record_splitting () { |
| 1477 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)" |
| 1478 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1479 | scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING |
| 1480 | |
| 1481 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1482 | make |
| 1483 | |
| 1484 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING" |
| 1485 | make test |
| 1486 | |
| 1487 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled" |
| 1488 | if_build_succeeded tests/ssl-opt.sh |
| 1489 | |
| 1490 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled" |
| 1491 | if_build_succeeded tests/compat.sh |
| 1492 | } |
| 1493 | |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 1494 | component_test_ssl_alloc_buffer_and_mfl () { |
| 1495 | msg "build: default config with memory buffer allocator and MFL extension" |
| 1496 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1497 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1498 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
| 1499 | scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 1500 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 1501 | CC=gcc cmake . |
| 1502 | make |
| 1503 | |
| 1504 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
| 1505 | make test |
| 1506 | |
| 1507 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
| 1508 | if_build_succeeded tests/ssl-opt.sh -f "Handshake memory usage" |
| 1509 | } |
| 1510 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1511 | component_test_when_no_ciphersuites_have_mac () { |
| 1512 | msg "build: when no ciphersuites have MAC" |
| 1513 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
| 1514 | scripts/config.py unset MBEDTLS_ARC4_C |
| 1515 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
| 1516 | make |
| 1517 | |
| 1518 | msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 1519 | make test |
| 1520 | |
| 1521 | msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 1522 | if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' |
| 1523 | } |
| 1524 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1525 | component_test_null_entropy () { |
| 1526 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1527 | scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY |
| 1528 | scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 1529 | scripts/config.py set MBEDTLS_ENTROPY_C |
| 1530 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 1531 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1532 | scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 1533 | scripts/config.py unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 5fa32a7 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 1534 | 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] | 1535 | make |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1536 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1537 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 1538 | make test |
| 1539 | } |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1540 | |
Raoul Strackx | a4e8614 | 2020-06-15 17:03:13 +0200 | [diff] [blame] | 1541 | component_test_no_date_time () { |
| 1542 | msg "build: default config without MBEDTLS_HAVE_TIME_DATE" |
| 1543 | scripts/config.py unset MBEDTLS_HAVE_TIME_DATE |
| 1544 | CC=gcc cmake |
| 1545 | make |
| 1546 | |
| 1547 | msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" |
| 1548 | make test |
| 1549 | } |
| 1550 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1551 | component_test_platform_calloc_macro () { |
| 1552 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1553 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1554 | scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 1555 | scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1556 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1557 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1558 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1559 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 1560 | make test |
| 1561 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1562 | |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1563 | component_test_malloc_0_null () { |
| 1564 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 1565 | scripts/config.py full |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1566 | 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] | 1567 | |
| 1568 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 1569 | make test |
| 1570 | |
| 1571 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 1572 | # Just the calloc selftest. "make test" ran the others as part of the |
| 1573 | # test suites. |
| 1574 | if_build_succeeded programs/test/selftest calloc |
Gilles Peskine | 765d240 | 2020-02-11 18:26:34 +0100 | [diff] [blame] | 1575 | |
| 1576 | msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)" |
| 1577 | # Run a subset of the tests. The choice is a balance between coverage |
| 1578 | # and time (including time indirectly wasted due to flaky tests). |
| 1579 | # The current choice is to skip tests whose description includes |
| 1580 | # "proxy", which is an approximation of skipping tests that use the |
| 1581 | # UDP proxy, which tend to be slower and flakier. |
| 1582 | if_build_succeeded tests/ssl-opt.sh -e 'proxy' |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 1583 | } |
| 1584 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1585 | component_test_aes_fewer_tables () { |
| 1586 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1587 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1588 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1589 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1590 | msg "test: AES_FEWER_TABLES" |
| 1591 | make test |
| 1592 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1593 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1594 | component_test_aes_rom_tables () { |
| 1595 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1596 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1597 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1598 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1599 | msg "test: AES_ROM_TABLES" |
| 1600 | make test |
| 1601 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1602 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1603 | component_test_aes_fewer_tables_and_rom_tables () { |
| 1604 | 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] | 1605 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
| 1606 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1607 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 1608 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1609 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 1610 | make test |
| 1611 | } |
| 1612 | |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1613 | component_test_ctr_drbg_aes_256_sha_256 () { |
| 1614 | msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 1615 | scripts/config.py full |
| 1616 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1617 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1618 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1619 | make |
| 1620 | |
| 1621 | msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 1622 | make test |
| 1623 | } |
| 1624 | |
| 1625 | component_test_ctr_drbg_aes_128_sha_512 () { |
| 1626 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 1627 | scripts/config.py full |
| 1628 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1629 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1630 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1631 | make |
| 1632 | |
| 1633 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
| 1634 | make test |
| 1635 | } |
| 1636 | |
| 1637 | component_test_ctr_drbg_aes_128_sha_256 () { |
| 1638 | 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] | 1639 | scripts/config.py full |
| 1640 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1641 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
| 1642 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 1643 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1644 | make |
| 1645 | |
| 1646 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 1647 | make test |
| 1648 | } |
| 1649 | |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 1650 | component_test_se_default () { |
| 1651 | msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1652 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1653 | make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 1654 | |
| 1655 | msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
| 1656 | make test |
| 1657 | } |
| 1658 | |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 1659 | component_test_psa_crypto_drivers () { |
| 1660 | msg "build: MBEDTLS_PSA_CRYPTO_DRIVERS, signature" |
| 1661 | scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS |
| 1662 | scripts/config.py set MBEDTLS_TEST_HOOKS |
| 1663 | # Need to include the test driver header path in order to build |
| 1664 | make CC=gcc CFLAGS="$ASAN_CFLAGS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1665 | |
| 1666 | msg "test: MBEDTLS_PSA_CRYPTO_DRIVERS, signature" |
| 1667 | make test |
| 1668 | } |
| 1669 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1670 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1671 | msg "build/test: make shared" # ~ 40s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1672 | make SHARED=1 all check |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1673 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1674 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 1675 | |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1676 | component_test_cmake_shared () { |
| 1677 | msg "build/test: cmake shared" # ~ 2min |
| 1678 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 1679 | make |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 1680 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 1681 | make test |
| 1682 | } |
| 1683 | |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1684 | test_build_opt () { |
| 1685 | info=$1 cc=$2; shift 2 |
| 1686 | for opt in "$@"; do |
| 1687 | msg "build/test: $cc $opt, $info" # ~ 30s |
Gilles Peskine | e094a18 | 2020-04-14 20:08:41 +0200 | [diff] [blame] | 1688 | make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror" |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1689 | # We're confident enough in compilers to not run _all_ the tests, |
| 1690 | # but at least run the unit tests. In particular, runs with |
| 1691 | # optimizations use inline assembly whereas runs with -O0 |
| 1692 | # skip inline assembly. |
| 1693 | make test # ~30s |
| 1694 | make clean |
| 1695 | done |
| 1696 | } |
| 1697 | |
| 1698 | component_test_clang_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 1699 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1700 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 1701 | } |
| 1702 | |
| 1703 | component_test_gcc_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 1704 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 1705 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 1706 | } |
| 1707 | |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1708 | component_build_mbedtls_config_file () { |
| 1709 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 1710 | # Use the full config so as to catch a maximum of places where |
| 1711 | # the check of MBEDTLS_CONFIG_FILE might be missing. |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1712 | scripts/config.py full |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 1713 | sed 's!"check_config.h"!"mbedtls/check_config.h"!' <"$CONFIG_H" >full_config.h |
| 1714 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 1715 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 1716 | rm -f full_config.h |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1717 | } |
| 1718 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1719 | component_test_m32_o0 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1720 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 1721 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1722 | scripts/config.py full |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1723 | 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] | 1724 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1725 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 1726 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1727 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1728 | support_test_m32_o0 () { |
| 1729 | case $(uname -m) in |
| 1730 | *64*) true;; |
| 1731 | *) false;; |
| 1732 | esac |
| 1733 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1734 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1735 | component_test_m32_o1 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1736 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 1737 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1738 | scripts/config.py full |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1739 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1740 | |
| 1741 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1742 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1743 | |
| 1744 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 1745 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1746 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1747 | support_test_m32_o1 () { |
| 1748 | support_test_m32_o0 "$@" |
| 1749 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1750 | |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 1751 | component_test_m32_everest () { |
| 1752 | msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1753 | scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT |
| 1754 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 1755 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 1756 | |
| 1757 | msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1758 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1759 | |
| 1760 | msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 1761 | if_build_succeeded tests/ssl-opt.sh -f ECDH |
| 1762 | |
| 1763 | msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 1764 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 1765 | 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] | 1766 | } |
| 1767 | support_test_m32_everest () { |
| 1768 | support_test_m32_o0 "$@" |
| 1769 | } |
| 1770 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1771 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1772 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1773 | scripts/config.py full |
Gilles Peskine | 5d26e7c | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 1774 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1775 | |
| 1776 | msg "test: 64-bit ILP32, make, gcc" |
| 1777 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1778 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1779 | support_test_mx32 () { |
| 1780 | case $(uname -m) in |
| 1781 | amd64|x86_64) true;; |
| 1782 | *) false;; |
| 1783 | esac |
| 1784 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1785 | |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1786 | component_test_min_mpi_window_size () { |
| 1787 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1788 | scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1 |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 1789 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1790 | make |
| 1791 | |
| 1792 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 1793 | make test |
| 1794 | } |
| 1795 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1796 | component_test_have_int32 () { |
| 1797 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1798 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 1799 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1800 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1801 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1802 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1803 | msg "test: gcc, force 32-bit bignum limbs" |
| 1804 | make test |
| 1805 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 1806 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1807 | component_test_have_int64 () { |
| 1808 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1809 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 1810 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1811 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1812 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 1813 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1814 | msg "test: gcc, force 64-bit bignum limbs" |
| 1815 | make test |
| 1816 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1817 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1818 | component_test_no_udbl_division () { |
| 1819 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1820 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1821 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1822 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1823 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1824 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 1825 | make test |
| 1826 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1827 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1828 | component_test_no_64bit_multiplication () { |
| 1829 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1830 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1831 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1832 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1833 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1834 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 1835 | make test |
| 1836 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1837 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1838 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1839 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1840 | scripts/config.py baremetal |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 1841 | 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] | 1842 | |
| 1843 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1" |
| 1844 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1845 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1846 | |
Gilles Peskine | 2c897d7 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1847 | component_build_arm_none_eabi_gcc_arm5vte () { |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1848 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1849 | scripts/config.py baremetal |
Gilles Peskine | 2c897d7 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 1850 | # Build for a target platform that's close to what Debian uses |
| 1851 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 1852 | # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. |
| 1853 | # It would be better to build with arm-linux-gnueabi-gcc but |
| 1854 | # we don't have that on our CI at this time. |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 1855 | 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] | 1856 | |
| 1857 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" |
| 1858 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 93e4e03 | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 1859 | } |
| 1860 | |
Gilles Peskine | 6e2fb86 | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 1861 | component_build_arm_none_eabi_gcc_m0plus () { |
| 1862 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus" # ~ 10s |
| 1863 | scripts/config.py baremetal |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 1864 | 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] | 1865 | |
| 1866 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os" |
| 1867 | ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o |
Gilles Peskine | 6e2fb86 | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 1868 | } |
| 1869 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1870 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1871 | 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] | 1872 | scripts/config.py baremetal |
| 1873 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 1874 | 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] | 1875 | echo "Checking that software 64-bit division is not required" |
| 1876 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
| 1877 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1878 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1879 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 1880 | 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] | 1881 | scripts/config.py baremetal |
| 1882 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 1883 | 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] | 1884 | echo "Checking that software 64-bit multiplication is not required" |
| 1885 | if_build_succeeded not grep __aeabi_lmul library/*.o |
| 1886 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1887 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1888 | component_build_armcc () { |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1889 | msg "build: ARM Compiler 5" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1890 | scripts/config.py baremetal |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1891 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 1892 | |
| 1893 | msg "size: ARM Compiler 5" |
| 1894 | "$ARMC5_FROMELF" -z library/*.o |
| 1895 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1896 | make clean |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1897 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1898 | # ARM Compiler 6 - Target ARMv7-A |
| 1899 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1900 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1901 | # ARM Compiler 6 - Target ARMv7-M |
| 1902 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1903 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1904 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1905 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1906 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1907 | # ARM Compiler 6 - Target ARMv8-M |
| 1908 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1909 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1910 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1911 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1912 | } |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1913 | |
Manuel Pégourié-Gonnard | dd8807f | 2020-02-26 09:56:27 +0100 | [diff] [blame] | 1914 | component_build_ssl_hw_record_accel() { |
| 1915 | msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled" |
| 1916 | scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL |
| 1917 | make CFLAGS='-Werror -O1' |
| 1918 | } |
| 1919 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1920 | component_test_allow_sha1 () { |
| 1921 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1922 | scripts/config.py set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1923 | make CFLAGS='-Werror -Wall -Wextra' |
| 1924 | msg "test: allow SHA1 in certificates by default" |
| 1925 | make test |
| 1926 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
| 1927 | } |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 1928 | |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 1929 | component_test_tls13_experimental () { |
| 1930 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled" |
| 1931 | scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL |
| 1932 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1933 | make |
| 1934 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled" |
| 1935 | make test |
| 1936 | } |
| 1937 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1938 | component_build_mingw () { |
| 1939 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1940 | 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] | 1941 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1942 | # note Make tests only builds the tests, but doesn't run them |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1943 | 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] | 1944 | make WINDOWS_BUILD=1 clean |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 1945 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1946 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 1947 | 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 |
| 1948 | 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] | 1949 | make WINDOWS_BUILD=1 clean |
| 1950 | } |
Jaeden Amero | 117b8a4 | 2019-04-17 15:19:26 +0100 | [diff] [blame] | 1951 | support_build_mingw() { |
| 1952 | case $(i686-w64-mingw32-gcc -dumpversion) in |
| 1953 | [0-5]*) false;; |
| 1954 | *) true;; |
| 1955 | esac |
| 1956 | } |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 1957 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1958 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1959 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1960 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1961 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1962 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 1963 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1964 | msg "test: main suites (MSan)" # ~ 10s |
| 1965 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1966 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1967 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1968 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1969 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1970 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1971 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1972 | if [ "$MEMORY" -gt 0 ]; then |
| 1973 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1974 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1975 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1976 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1977 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1978 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1979 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1980 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1981 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1982 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1983 | msg "test: main suites valgrind (Release)" |
| 1984 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1985 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1986 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1987 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1988 | if [ "$MEMORY" -gt 0 ]; then |
| 1989 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1990 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1991 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1992 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1993 | if [ "$MEMORY" -gt 1 ]; then |
| 1994 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1995 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1996 | fi |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 1997 | |
| 1998 | if [ "$MEMORY" -gt 0 ]; then |
| 1999 | msg "test: context-info.sh --memcheck (Release)" |
| 2000 | if_build_succeeded tests/context-info.sh --memcheck |
| 2001 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2002 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2003 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2004 | component_test_cmake_out_of_source () { |
| 2005 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2006 | MBEDTLS_ROOT_DIR="$PWD" |
| 2007 | mkdir "$OUT_OF_SOURCE_DIR" |
| 2008 | cd "$OUT_OF_SOURCE_DIR" |
| 2009 | cmake "$MBEDTLS_ROOT_DIR" |
| 2010 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 2011 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2012 | msg "test: cmake 'out-of-source' build" |
| 2013 | make test |
| 2014 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 2015 | # Also ensure that there are no error messages such as |
| 2016 | # "No such file or directory", which would indicate that some required |
| 2017 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 2018 | # may exit with status 0 but emit errors). |
| 2019 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 2020 | if [ -s ssl-opt.err ]; then |
| 2021 | cat ssl-opt.err >&2 |
| 2022 | record_status [ ! -s ssl-opt.err ] |
| 2023 | rm ssl-opt.err |
| 2024 | fi |
| 2025 | cd "$MBEDTLS_ROOT_DIR" |
| 2026 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 2027 | unset MBEDTLS_ROOT_DIR |
| 2028 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 2029 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 2030 | component_test_cmake_as_subdirectory () { |
| 2031 | msg "build: cmake 'as-subdirectory' build" |
| 2032 | MBEDTLS_ROOT_DIR="$PWD" |
| 2033 | |
| 2034 | cd programs/test/cmake_subproject |
| 2035 | cmake . |
| 2036 | make |
| 2037 | if_build_succeeded ./cmake_subproject |
| 2038 | |
| 2039 | cd "$MBEDTLS_ROOT_DIR" |
| 2040 | unset MBEDTLS_ROOT_DIR |
| 2041 | } |
| 2042 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2043 | component_test_zeroize () { |
| 2044 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 2045 | # different combinations of compilers and optimization flags by using an |
| 2046 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 2047 | # system in all cases that the script fails, so we must manually search the |
| 2048 | # output to check whether the pass string is present and no failure strings |
| 2049 | # were printed. |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 2050 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 2051 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 2052 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 2053 | gdb_disable_aslr= |
| 2054 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 2055 | gdb_disable_aslr='set disable-randomization off' |
| 2056 | fi |
| 2057 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2058 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 2059 | for compiler in clang gcc; do |
| 2060 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 2061 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 2062 | 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] | 2063 | if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log |
| 2064 | if_build_succeeded not grep -i "error" test_zeroize.log |
| 2065 | rm -f test_zeroize.log |
| 2066 | make clean |
| 2067 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 2068 | done |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 2069 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 2070 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2071 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 2072 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2073 | component_check_python_files () { |
| 2074 | msg "Lint: Python scripts" |
| 2075 | record_status tests/scripts/check-python-files.sh |
| 2076 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 2077 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2078 | component_check_generate_test_code () { |
| 2079 | msg "uint test: generate_test_code.py" |
Manuel Pégourié-Gonnard | dfb114a | 2020-06-02 11:40:08 +0200 | [diff] [blame] | 2080 | # unittest writes out mundane stuff like number or tests run on stderr. |
| 2081 | # Our convention is to reserve stderr for actual errors, and write |
| 2082 | # harmless info on stdout so it can be suppress with --quiet. |
| 2083 | record_status ./tests/scripts/test_generate_test_code.py 2>&1 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2084 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 2085 | |
| 2086 | ################################################################ |
| 2087 | #### Termination |
| 2088 | ################################################################ |
| 2089 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2090 | post_report () { |
| 2091 | msg "Done, cleaning up" |
| 2092 | cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2093 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2094 | final_report |
| 2095 | } |
| 2096 | |
| 2097 | |
| 2098 | |
| 2099 | ################################################################ |
| 2100 | #### Run all the things |
| 2101 | ################################################################ |
| 2102 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 2103 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2104 | run_component () { |
Gilles Peskine | 608953e | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 2105 | # Back up the configuration in case the component modifies it. |
| 2106 | # The cleanup function will restore it. |
| 2107 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 2108 | current_component="$1" |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 2109 | export MBEDTLS_TEST_CONFIGURATION="$current_component" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 2110 | |
| 2111 | # Unconditionally create a seedfile that's sufficiently long. |
| 2112 | # Do this before each component, because a previous component may |
| 2113 | # have messed it up or shortened it. |
Manuel Pégourié-Gonnard | f1f180a | 2020-06-08 10:46:35 +0200 | [diff] [blame] | 2114 | 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] | 2115 | |
| 2116 | # Run the component code. |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 2117 | if [ $QUIET -eq 1 ]; then |
| 2118 | # msg() is silenced, so just print the component name here |
| 2119 | echo "${current_component#component_}" |
| 2120 | fi |
| 2121 | redirect_out "$@" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 2122 | |
| 2123 | # Restore the build tree to a clean state. |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 2124 | cleanup |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 2125 | unset current_component |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2126 | } |
| 2127 | |
| 2128 | # Preliminary setup |
| 2129 | pre_check_environment |
| 2130 | pre_initialize_variables |
| 2131 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 2132 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2133 | pre_check_git |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 2134 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2135 | build_status=0 |
| 2136 | if [ $KEEP_GOING -eq 1 ]; then |
| 2137 | pre_setup_keep_going |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 2138 | else |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2139 | record_status () { |
| 2140 | "$@" |
| 2141 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2142 | fi |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 2143 | pre_setup_quiet_redirect |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 2144 | pre_prepare_outcome_file |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2145 | pre_print_configuration |
| 2146 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2147 | cleanup |
| 2148 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 2149 | # Run the requested tests. |
| 2150 | for component in $RUN_COMPONENTS; do |
| 2151 | run_component "component_$component" |
| 2152 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2153 | |
| 2154 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 2155 | post_report |