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 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 5 | # This file is part of mbed TLS (https://tls.mbed.org) |
| 6 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 7 | # Copyright (c) 2014-2017, ARM Limited, All Rights Reserved |
| 8 | |
| 9 | |
| 10 | |
| 11 | ################################################################ |
| 12 | #### Documentation |
| 13 | ################################################################ |
| 14 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 15 | # Purpose |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 16 | # ------- |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 17 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 18 | # To run all tests possible or available on the platform. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 19 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 20 | # Notes for users |
| 21 | # --------------- |
| 22 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 23 | # Warning: the test is destructive. It includes various build modes and |
| 24 | # configurations, and can and will arbitrarily change the current CMake |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 25 | # configuration. The following files must be committed into git: |
| 26 | # * include/mbedtls/config.h |
Philippe Antoine | 1c582c3 | 2019-06-25 21:55:21 +0200 | [diff] [blame] | 27 | # * Makefile, library/Makefile, programs/Makefile, tests/Makefile, |
Philippe Antoine | 5dece6d | 2019-06-27 16:55:07 +0200 | [diff] [blame] | 28 | # programs/fuzz/Makefile |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 29 | # After running this script, the CMake cache will be lost and CMake |
| 30 | # will no longer be initialised. |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 31 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 32 | # The script assumes the presence of a number of tools: |
| 33 | # * Basic Unix tools (Windows users note: a Unix-style find must be before |
| 34 | # the Windows find in the PATH) |
| 35 | # * Perl |
| 36 | # * GNU Make |
| 37 | # * CMake |
| 38 | # * 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] | 39 | # * G++ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 40 | # * arm-gcc and mingw-gcc |
| 41 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 42 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
| 43 | # interoperability tests. If they don't support SSLv3 then a legacy |
| 44 | # version of these tools must be present as well (search for LEGACY |
| 45 | # below). |
| 46 | # See the invocation of check_tools below for details. |
| 47 | # |
| 48 | # This script must be invoked from the toplevel directory of a git |
| 49 | # working copy of Mbed TLS. |
| 50 | # |
| 51 | # Note that the output is not saved. You may want to run |
| 52 | # script -c tests/scripts/all.sh |
| 53 | # or |
| 54 | # tests/scripts/all.sh >all.log 2>&1 |
| 55 | # |
| 56 | # Notes for maintainers |
| 57 | # --------------------- |
| 58 | # |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 59 | # The bulk of the code is organized into functions that follow one of the |
| 60 | # following naming conventions: |
| 61 | # * pre_XXX: things to do before running the tests, in order. |
| 62 | # * component_XXX: independent components. They can be run in any order. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 63 | # * component_check_XXX: quick tests that aren't worth parallelizing. |
| 64 | # * component_build_XXX: build things but don't run them. |
| 65 | # * component_test_XXX: build and test. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 66 | # * support_XXX: if support_XXX exists and returns false then |
| 67 | # component_XXX is not run by default. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 68 | # * post_XXX: things to do after running the tests. |
| 69 | # * other: miscellaneous support functions. |
| 70 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 71 | # Each component must start by invoking `msg` with a short informative message. |
| 72 | # |
| 73 | # The framework performs some cleanup tasks after each component. This |
| 74 | # means that components can assume that the working directory is in a |
| 75 | # cleaned-up state, and don't need to perform the cleanup themselves. |
| 76 | # * Run `make clean`. |
| 77 | # * Restore `include/mbedtks/config.h` from a backup made before running |
| 78 | # the component. |
Philippe Antoine | 1c582c3 | 2019-06-25 21:55:21 +0200 | [diff] [blame] | 79 | # * Check out `Makefile`, `library/Makefile`, `programs/Makefile`, |
Philippe Antoine | 5dece6d | 2019-06-27 16:55:07 +0200 | [diff] [blame] | 80 | # `tests/Makefile` and `programs/fuzz/Makefile` from git. |
Philippe Antoine | 1c582c3 | 2019-06-25 21:55:21 +0200 | [diff] [blame] | 81 | # This cleans up after an in-tree use of CMake. |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 82 | # |
| 83 | # Any command that is expected to fail must be protected so that the |
| 84 | # script keeps running in --keep-going mode despite `set -e`. In keep-going |
| 85 | # mode, if a protected command fails, this is logged as a failure and the |
| 86 | # script will exit with a failure status once it has run all components. |
| 87 | # Commands can be protected in any of the following ways: |
| 88 | # * `make` is a function which runs the `make` command with protection. |
| 89 | # Note that you must write `make VAR=value`, not `VAR=value make`, |
| 90 | # because the `VAR=value make` syntax doesn't work with functions. |
| 91 | # * Put `report_status` before the command to protect it. |
| 92 | # * Put `if_build_successful` before a command. This protects it, and |
| 93 | # additionally skips it if a prior invocation of `make` in the same |
| 94 | # component failed. |
| 95 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 96 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 97 | # have to be exact, but in general you should add slower tests towards |
| 98 | # the end and fast checks near the beginning. |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 99 | |
| 100 | |
| 101 | |
| 102 | ################################################################ |
| 103 | #### Initialization and command line parsing |
| 104 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 105 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 106 | # Abort on errors (and uninitialised variables) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 107 | set -eu |
| 108 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 109 | pre_check_environment () { |
Gilles Peskine | a16c2b1 | 2019-01-06 19:58:02 +0000 | [diff] [blame] | 110 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 111 | echo "Must be run from mbed TLS root" >&2 |
| 112 | exit 1 |
| 113 | fi |
| 114 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 115 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 116 | pre_initialize_variables () { |
| 117 | CONFIG_H='include/mbedtls/config.h' |
| 118 | CONFIG_BAK="$CONFIG_H.bak" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 119 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 120 | MEMORY=0 |
| 121 | FORCE=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 122 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 123 | |
Jaeden Amero | c4cc251 | 2019-01-30 15:35:44 +0000 | [diff] [blame] | 124 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 125 | : ${OPENSSL:="openssl"} |
| 126 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 127 | : ${OPENSSL_NEXT:="$OPENSSL"} |
| 128 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 129 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 130 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 131 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 132 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 133 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 134 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 135 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 136 | # 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] | 137 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 138 | export MAKEFLAGS="-j" |
| 139 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 140 | |
| 141 | # Gather the list of available components. These are the functions |
| 142 | # defined in this script whose name starts with "component_". |
| 143 | # Parse the script with sed, because in sh there is no way to list |
| 144 | # defined functions. |
| 145 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 146 | |
| 147 | # Exclude components that are not supported on this platform. |
| 148 | SUPPORTED_COMPONENTS= |
| 149 | for component in $ALL_COMPONENTS; do |
| 150 | case $(type "support_$component" 2>&1) in |
| 151 | *' function'*) |
| 152 | if ! support_$component; then continue; fi;; |
| 153 | esac |
| 154 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 155 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 156 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 157 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 158 | # Test whether the component $1 is included in the command line patterns. |
| 159 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 160 | { |
| 161 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 162 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 163 | set +f |
| 164 | case ${1#component_} in $pattern) return 0;; esac |
| 165 | done |
| 166 | set +f |
| 167 | return 1 |
| 168 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 169 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 170 | usage() |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 171 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 172 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 173 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 174 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 175 | 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] | 176 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 177 | |
| 178 | Examples: |
| 179 | $0 "check_*" |
| 180 | Run all sanity checks. |
| 181 | $0 --no-armcc --except test_memsan |
| 182 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 183 | |
| 184 | Special options: |
| 185 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 186 | --list-all-components List all available test components and exit. |
| 187 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 188 | |
| 189 | General options: |
| 190 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 191 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 192 | -m|--memory Additional optional memory tests. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 193 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 194 | --except Exclude the COMPONENTs listed on the command line, |
| 195 | instead of running only those. |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 196 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 197 | --no-force Refuse to overwrite modified files (default). |
| 198 | --no-keep-going Stop at the first error (default). |
| 199 | --no-memory No additional memory tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 200 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 201 | --random-seed Use a random seed value for randomized tests (default). |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 202 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 203 | -s|--seed Integer seed value to use for this test run. |
| 204 | |
| 205 | Tool path options: |
| 206 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 207 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 208 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 209 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 210 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 211 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 212 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 213 | --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] | 214 | --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] | 215 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 216 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 217 | |
| 218 | # remove built files as well as the cmake cache/config |
| 219 | cleanup() |
| 220 | { |
Gilles Peskine | a71d64c | 2018-03-21 12:16:57 +0100 | [diff] [blame] | 221 | if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then |
| 222 | cd "$MBEDTLS_ROOT_DIR" |
| 223 | fi |
| 224 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 225 | command make clean |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 226 | cd crypto |
| 227 | command make clean |
| 228 | cd .. |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 229 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 230 | # Remove CMake artefacts |
Jaeden Amero | 2d0e00f | 2018-11-07 18:46:41 +0000 | [diff] [blame] | 231 | find . -name .git -prune -o \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 232 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 233 | \( -iname cmake_install.cmake -o \ |
| 234 | -iname CTestTestfile.cmake -o \ |
| 235 | -iname CMakeCache.txt \) -exec rm {} \+ |
| 236 | # Recover files overwritten by in-tree CMake builds |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 237 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Philippe Antoine | 5dece6d | 2019-06-27 16:55:07 +0200 | [diff] [blame] | 238 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 239 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 240 | cd crypto |
| 241 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
| 242 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 243 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
| 244 | cd .. |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 245 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 246 | # Remove any artifacts from the component_test_cmake_as_subdirectory test. |
| 247 | rm -rf programs/test/cmake_subproject/build |
| 248 | rm -f programs/test/cmake_subproject/Makefile |
| 249 | rm -f programs/test/cmake_subproject/cmake_subproject |
| 250 | |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 251 | if [ -f "$CONFIG_BAK" ]; then |
| 252 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 253 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 254 | } |
| 255 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 256 | # Executed on exit. May be redefined depending on command line options. |
| 257 | final_report () { |
| 258 | : |
| 259 | } |
| 260 | |
| 261 | fatal_signal () { |
| 262 | cleanup |
| 263 | final_report $1 |
| 264 | trap - $1 |
| 265 | kill -$1 $$ |
| 266 | } |
| 267 | |
| 268 | trap 'fatal_signal HUP' HUP |
| 269 | trap 'fatal_signal INT' INT |
| 270 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 271 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 272 | msg() |
| 273 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 274 | if [ -n "${current_component:-}" ]; then |
| 275 | current_section="${current_component#component_}: $1" |
| 276 | else |
| 277 | current_section="$1" |
| 278 | fi |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 279 | echo "" |
| 280 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 281 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 282 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 283 | echo "******************************************************************" |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 284 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 285 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 286 | armc6_build_test() |
| 287 | { |
| 288 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 289 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 290 | msg "build: ARM Compiler 6 ($FLAGS), make" |
| 291 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
| 292 | WARNING_CFLAGS='-xc -std=c99' make lib |
| 293 | make clean |
| 294 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 295 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 296 | err_msg() |
| 297 | { |
| 298 | echo "$1" >&2 |
| 299 | } |
| 300 | |
| 301 | check_tools() |
| 302 | { |
| 303 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 304 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 305 | err_msg "$TOOL not found!" |
| 306 | exit 1 |
| 307 | fi |
| 308 | done |
| 309 | } |
| 310 | |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 311 | check_headers_in_cpp () { |
Peter Kolbus | 1bc1a4c | 2019-02-01 17:19:08 -0600 | [diff] [blame] | 312 | ls include/mbedtls | grep "\.h$" >headers.txt |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 313 | <programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' | |
| 314 | sort | |
| 315 | diff headers.txt - |
| 316 | rm headers.txt |
| 317 | } |
| 318 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 319 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 320 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 321 | all_except=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 322 | no_armcc= |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 323 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 324 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 325 | case "$1" in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 326 | --armcc) no_armcc=;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 327 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 328 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 329 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 330 | --force|-f) FORCE=1;; |
| 331 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 332 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 333 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 334 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 335 | --help|-h) usage; exit;; |
| 336 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 337 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 338 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 339 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 340 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 341 | --no-force) FORCE=0;; |
| 342 | --no-keep-going) KEEP_GOING=0;; |
| 343 | --no-memory) MEMORY=0;; |
| 344 | --openssl) shift; OPENSSL="$1";; |
| 345 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 346 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
| 347 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
| 348 | --random-seed) unset SEED;; |
| 349 | --release-test|-r) SEED=1;; |
| 350 | --seed|-s) shift; SEED="$1";; |
| 351 | -*) |
| 352 | echo >&2 "Unknown option: $1" |
| 353 | echo >&2 "Run $0 --help for usage." |
| 354 | exit 120 |
| 355 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 356 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 357 | esac |
| 358 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 359 | done |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 360 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 361 | # With no list of components, run everything. |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 362 | if [ -z "$COMMAND_LINE_COMPONENTS" ]; then |
| 363 | all_except=1 |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 364 | fi |
| 365 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 366 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 367 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 368 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 369 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 370 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 371 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 372 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 373 | RUN_COMPONENTS= |
| 374 | for component in $SUPPORTED_COMPONENTS; do |
| 375 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 376 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 377 | fi |
| 378 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 379 | |
| 380 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 381 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 382 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 383 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 384 | pre_check_git () { |
| 385 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 386 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 387 | git checkout-index -f -q $CONFIG_H |
| 388 | cleanup |
| 389 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 390 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 391 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 392 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 393 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 394 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 395 | exit 1 |
| 396 | fi |
| 397 | |
Gilles Peskine | d1174cf | 2019-01-09 22:30:01 +0100 | [diff] [blame] | 398 | if ! git diff --quiet include/mbedtls/config.h; then |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 399 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 400 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 401 | echo "script as: $0 --force" |
| 402 | exit 1 |
| 403 | fi |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 404 | fi |
Andrzej Kurek | e9c3b81 | 2019-02-05 05:34:21 -0500 | [diff] [blame] | 405 | if ! [ -f crypto/Makefile ]; then |
| 406 | echo "Please initialize the crypto submodule" >&2 |
| 407 | exit 1 |
| 408 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 409 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 410 | |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 411 | pre_check_seedfile () { |
| 412 | if [ ! -f "./tests/seedfile" ]; then |
| 413 | dd if=/dev/urandom of=./tests/seedfile bs=32 count=1 |
| 414 | fi |
Jaeden Amero | 9714510 | 2019-03-18 16:31:21 +0000 | [diff] [blame] | 415 | if [ ! -f "./crypto/tests/seedfile" ]; then |
| 416 | dd if=/dev/urandom of=./crypto/tests/seedfile bs=32 count=1 |
| 417 | fi |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 418 | } |
| 419 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 420 | pre_setup_keep_going () { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 421 | failure_summary= |
| 422 | failure_count=0 |
| 423 | start_red= |
| 424 | end_color= |
| 425 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 426 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 427 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 428 | start_red=$(printf '\033[31m') |
| 429 | end_color=$(printf '\033[0m') |
| 430 | ;; |
| 431 | esac |
| 432 | fi |
| 433 | record_status () { |
| 434 | if "$@"; then |
| 435 | last_status=0 |
| 436 | else |
| 437 | last_status=$? |
| 438 | text="$current_section: $* -> $last_status" |
| 439 | failure_summary="$failure_summary |
| 440 | $text" |
| 441 | failure_count=$((failure_count + 1)) |
| 442 | echo "${start_red}^^^^$text^^^^${end_color}" |
| 443 | fi |
| 444 | } |
| 445 | make () { |
| 446 | case "$*" in |
| 447 | *test|*check) |
| 448 | if [ $build_status -eq 0 ]; then |
| 449 | record_status command make "$@" |
| 450 | else |
| 451 | echo "(skipped because the build failed)" |
| 452 | fi |
| 453 | ;; |
| 454 | *) |
| 455 | record_status command make "$@" |
| 456 | build_status=$last_status |
| 457 | ;; |
| 458 | esac |
| 459 | } |
| 460 | final_report () { |
| 461 | if [ $failure_count -gt 0 ]; then |
| 462 | echo |
| 463 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 464 | echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" |
| 465 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Jaeden Amero | 7c1258d | 2018-07-20 16:42:14 +0100 | [diff] [blame] | 466 | exit 1 |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 467 | elif [ -z "${1-}" ]; then |
| 468 | echo "SUCCESS :)" |
| 469 | fi |
| 470 | if [ -n "${1-}" ]; then |
| 471 | echo "Killed by SIG$1." |
| 472 | fi |
| 473 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 474 | } |
| 475 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 476 | if_build_succeeded () { |
| 477 | if [ $build_status -eq 0 ]; then |
| 478 | record_status "$@" |
| 479 | fi |
| 480 | } |
| 481 | |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 482 | # to be used instead of ! for commands run with |
| 483 | # record_status or if_build_succeeded |
| 484 | not() { |
| 485 | ! "$@" |
| 486 | } |
| 487 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 488 | pre_print_configuration () { |
| 489 | msg "info: $0 configuration" |
| 490 | echo "MEMORY: $MEMORY" |
| 491 | echo "FORCE: $FORCE" |
| 492 | echo "SEED: ${SEED-"UNSET"}" |
| 493 | echo "OPENSSL: $OPENSSL" |
| 494 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 495 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 496 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 497 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 498 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 499 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 500 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 501 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 502 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 503 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 504 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 505 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 506 | # Build the list of variables to pass to output_env.sh. |
| 507 | set env |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 508 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 509 | case " $RUN_COMPONENTS " in |
| 510 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 511 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 512 | # is a good enough approximation in practice. |
| 513 | *" test_"*) |
| 514 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 515 | # and ssl-opt.sh, we just export the variables they require. |
| 516 | export OPENSSL_CMD="$OPENSSL" |
| 517 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 518 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 519 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 520 | if [ -n "${SEED-}" ]; then |
| 521 | export SEED |
| 522 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 523 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 524 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 525 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 526 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 527 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 528 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 529 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 530 | ;; |
| 531 | esac |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 532 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 533 | case " $RUN_COMPONENTS " in |
| 534 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 535 | esac |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 536 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 537 | case " $RUN_COMPONENTS " in |
| 538 | *_arm_none_eabi_gcc[_\ ]*) check_tools "arm-none-eabi-gcc";; |
| 539 | esac |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 540 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 541 | case " $RUN_COMPONENTS " in |
| 542 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 543 | esac |
| 544 | |
| 545 | case " $RUN_COMPONENTS " in |
| 546 | *" test_zeroize "*) check_tools "gdb";; |
| 547 | esac |
| 548 | |
| 549 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 550 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 551 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 552 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
| 553 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 554 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 555 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR";; |
| 556 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 557 | |
| 558 | msg "info: output_env.sh" |
| 559 | case $RUN_COMPONENTS in |
| 560 | *_armcc*) |
| 561 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 562 | *) set "$@" RUN_ARMCC=0;; |
| 563 | esac |
| 564 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 565 | } |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 566 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 567 | |
| 568 | |
| 569 | ################################################################ |
| 570 | #### Basic checks |
| 571 | ################################################################ |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 572 | |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 573 | # |
| 574 | # Test Suites to be executed |
| 575 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 576 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 577 | # 1. Catch possible problems early, by running first tests that run quickly |
Manuel Pégourié-Gonnard | 61bc57a | 2014-08-14 11:29:06 +0200 | [diff] [blame] | 578 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 579 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 580 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 581 | # |
| 582 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 583 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 584 | component_check_recursion () { |
| 585 | msg "test: recursion.pl" # < 1s |
| 586 | record_status tests/scripts/recursion.pl library/*.c |
| 587 | } |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 588 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 589 | component_check_generated_files () { |
| 590 | msg "test: freshness of generated source files" # < 1s |
| 591 | record_status tests/scripts/check-generated-files.sh |
| 592 | } |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 593 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 594 | component_check_doxy_blocks () { |
| 595 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 596 | record_status tests/scripts/check-doxy-blocks.pl |
| 597 | } |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 598 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 599 | component_check_files () { |
| 600 | msg "test: check-files.py" # < 1s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 601 | record_status tests/scripts/check-files.py |
| 602 | } |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 603 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 604 | component_check_names () { |
| 605 | msg "test/build: declared and exported names" # < 3s |
Gilles Peskine | 13f97dc | 2019-05-15 17:52:22 +0200 | [diff] [blame] | 606 | record_status tests/scripts/check-names.sh -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 607 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 608 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 609 | component_check_doxygen_warnings () { |
| 610 | msg "test: doxygen warnings" # ~ 3s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 611 | record_status tests/scripts/doxygen.sh |
| 612 | } |
Manuel Pégourié-Gonnard | 1d552e7 | 2016-01-04 16:49:09 +0100 | [diff] [blame] | 613 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 614 | |
| 615 | |
| 616 | ################################################################ |
| 617 | #### Build and test many configurations and targets |
| 618 | ################################################################ |
| 619 | |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 620 | component_test_default_out_of_box () { |
| 621 | msg "build: make, default config (out-of-box)" # ~1min |
| 622 | make |
| 623 | |
| 624 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 625 | make test |
| 626 | |
| 627 | msg "selftest: make, default config (out-of-box)" # ~10s |
| 628 | programs/test/selftest |
| 629 | } |
| 630 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 631 | component_test_default_cmake_gcc_asan () { |
| 632 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 633 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 634 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 635 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 636 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 637 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 638 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 639 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
| 640 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 641 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 642 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 643 | if_build_succeeded tests/compat.sh |
| 644 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 645 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 646 | component_test_ref_configs () { |
| 647 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 648 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 649 | record_status tests/scripts/test-ref-configs.pl |
| 650 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 651 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 652 | component_test_sslv3 () { |
| 653 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 654 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 655 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 656 | make |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 657 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 658 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 659 | make test |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 660 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 661 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
| 662 | if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 663 | 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] | 664 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 665 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 666 | if_build_succeeded tests/ssl-opt.sh |
| 667 | } |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 668 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 669 | component_test_no_renegotiation () { |
| 670 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 671 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 672 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 673 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 674 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 675 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 676 | make test |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 677 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 678 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 679 | if_build_succeeded tests/ssl-opt.sh |
| 680 | } |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 681 | |
Hanno Becker | a545be2 | 2019-05-10 14:45:37 +0100 | [diff] [blame] | 682 | component_test_no_pem_no_fs () { |
| 683 | msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" |
| 684 | scripts/config.pl unset MBEDTLS_PEM_PARSE_C |
| 685 | scripts/config.pl unset MBEDTLS_FS_IO |
| 686 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 687 | make |
| 688 | |
| 689 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 690 | make test |
| 691 | |
| 692 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
| 693 | if_build_succeeded tests/ssl-opt.sh |
| 694 | } |
| 695 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 696 | component_test_rsa_no_crt () { |
| 697 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 698 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 699 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 700 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 701 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 702 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 703 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 704 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 705 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 706 | if_build_succeeded tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 707 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 708 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
| 709 | if_build_succeeded tests/compat.sh -t RSA |
| 710 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 711 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 712 | component_test_small_ssl_out_content_len () { |
| 713 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 714 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 715 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
| 716 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 717 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 718 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 719 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
| 720 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" |
| 721 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 722 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 723 | component_test_small_ssl_in_content_len () { |
| 724 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 725 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 726 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
| 727 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 728 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 729 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 730 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
| 731 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment" |
| 732 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 733 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 734 | component_test_small_ssl_dtls_max_buffering () { |
| 735 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 736 | scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
| 737 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 738 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 739 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 740 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
| 741 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
| 742 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 743 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 744 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 745 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 746 | scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240 |
| 747 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 748 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 749 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 750 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
| 751 | if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
| 752 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 753 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 754 | component_test_full_cmake_clang () { |
| 755 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 756 | scripts/config.pl full |
| 757 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 758 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 759 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 760 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 761 | msg "test: main suites (full config)" # ~ 5s |
| 762 | make test |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 763 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 764 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
| 765 | 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] | 766 | |
Andres Amaya Garcia | 2dadab7 | 2019-01-08 21:42:27 +0000 | [diff] [blame] | 767 | 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] | 768 | 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] | 769 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 770 | msg "test: compat.sh ARIA + ChachaPoly" |
| 771 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 772 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 773 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 774 | component_build_deprecated () { |
| 775 | msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 776 | scripts/config.pl full |
| 777 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
| 778 | # Build with -O -Wextra to catch a maximum of issues. |
| 779 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 780 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 781 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 782 | msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s |
| 783 | # No cleanup, just tweak the configuration and rebuild |
| 784 | make clean |
| 785 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 786 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
| 787 | # Build with -O -Wextra to catch a maximum of issues. |
| 788 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 789 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
| 790 | } |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 791 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 792 | component_test_depends_curves () { |
| 793 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 794 | record_status tests/scripts/curves.pl |
| 795 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 796 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 797 | component_test_depends_hashes () { |
| 798 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 799 | record_status tests/scripts/depends-hashes.pl |
| 800 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 801 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 802 | component_test_depends_pkalgs () { |
| 803 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 804 | record_status tests/scripts/depends-pkalgs.pl |
| 805 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 806 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 807 | component_build_key_exchanges () { |
| 808 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 809 | record_status tests/scripts/key-exchanges.pl |
| 810 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 811 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 812 | component_build_default_make_gcc_and_cxx () { |
| 813 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 814 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 815 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 816 | msg "test: verify header list in cpp_dummy_build.cpp" |
| 817 | record_status check_headers_in_cpp |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 818 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 819 | msg "build: Unix make, incremental g++" |
| 820 | make TEST_CPP=1 |
| 821 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 822 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 823 | component_test_no_use_psa_crypto_full_cmake_asan() { |
| 824 | # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 825 | msg "build: cmake, full config + MBEDTLS_USE_PSA_CRYPTO, ASan" |
| 826 | scripts/config.pl full |
| 827 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
Jaeden Amero | 0f220ec | 2019-07-05 15:03:40 +0100 | [diff] [blame] | 828 | scripts/config.pl set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 829 | scripts/config.pl set MBEDTLS_PSA_CRYPTO_C |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 830 | scripts/config.pl unset MBEDTLS_USE_PSA_CRYPTO |
| 831 | scripts/config.pl unset MBEDTLS_PSA_ITS_FILE_C |
Andrzej Kurek | 324b2f7 | 2019-04-18 08:59:12 -0400 | [diff] [blame] | 832 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Manuel Pégourié-Gonnard | d8167e8 | 2019-02-01 11:12:52 +0100 | [diff] [blame] | 833 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 834 | make |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 835 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 836 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 837 | make test |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 838 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 839 | msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 840 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 841 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 842 | msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 843 | if_build_succeeded tests/compat.sh |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 844 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 845 | msg "test: compat.sh ssl3 (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 846 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 847 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 848 | 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] | 849 | 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] | 850 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 851 | msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 852 | if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 853 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 854 | |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 855 | component_test_check_params_functionality () { |
| 856 | msg "build+test: MBEDTLS_CHECK_PARAMS functionality" |
| 857 | scripts/config.pl full # includes CHECK_PARAMS |
| 858 | # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed(). |
| 859 | scripts/config.pl unset MBEDTLS_CHECK_PARAMS_ASSERT |
| 860 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 861 | # Only build and run tests. Do not build sample programs, because |
| 862 | # they don't have a mbedtls_param_failed() function. |
| 863 | make CC=gcc CFLAGS='-Werror -O1' lib test |
| 864 | } |
| 865 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 866 | component_test_check_params_without_platform () { |
| 867 | msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" |
| 868 | scripts/config.pl full # includes CHECK_PARAMS |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 869 | # Keep MBEDTLS_PARAM_FAILED as assert. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 870 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 871 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 872 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 873 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 874 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 875 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 876 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 877 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 878 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 879 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 880 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 881 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 882 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 883 | component_test_check_params_silent () { |
| 884 | msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" |
| 885 | scripts/config.pl full # includes CHECK_PARAMS |
| 886 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
Gilles Peskine | adcde5e | 2019-06-12 16:05:50 +0200 | [diff] [blame] | 887 | # Set MBEDTLS_PARAM_FAILED to nothing. |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 888 | sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" |
| 889 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 890 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 891 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 892 | component_test_no_platform () { |
| 893 | # Full configuration build, without platform support, file IO and net sockets. |
| 894 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 895 | # IO, it should catch missing '#include <stdio.h>' |
| 896 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 897 | scripts/config.pl full |
| 898 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 899 | scripts/config.pl unset MBEDTLS_NET_C |
| 900 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 901 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 902 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 903 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 904 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 905 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 906 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 907 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 908 | scripts/config.pl unset MBEDTLS_FS_IO |
Andrzej Kurek | 7375708 | 2019-04-18 04:14:37 -0400 | [diff] [blame] | 909 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 910 | scripts/config.pl unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 911 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 912 | # to re-enable platform integration features otherwise disabled in C99 builds |
| 913 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs |
| 914 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test |
| 915 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 916 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 917 | component_build_no_std_function () { |
| 918 | # catch compile bugs in _uninit functions |
| 919 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 920 | scripts/config.pl full |
| 921 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 922 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 923 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
| 924 | } |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 925 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 926 | component_build_no_ssl_srv () { |
| 927 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 928 | scripts/config.pl full |
| 929 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
| 930 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
| 931 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 932 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 933 | component_build_no_ssl_cli () { |
| 934 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 935 | scripts/config.pl full |
| 936 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
| 937 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
| 938 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 939 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 940 | component_build_no_sockets () { |
| 941 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 942 | # as that requires a POSIX platform (which isn't the same as C99). |
| 943 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 944 | scripts/config.pl full |
| 945 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 946 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
| 947 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib |
| 948 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 949 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 950 | component_test_no_max_fragment_length () { |
| 951 | # Run max fragment length tests with MFL disabled |
| 952 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 953 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 954 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 955 | make |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 956 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 957 | msg "test: ssl-opt.sh, MFL-related tests" |
| 958 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" |
| 959 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 960 | |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 961 | component_test_asan_remove_peer_certificate () { |
| 962 | msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)" |
| 963 | scripts/config.pl unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE |
| 964 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 965 | make |
| 966 | |
| 967 | msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 968 | make test |
| 969 | |
| 970 | msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 971 | if_build_succeeded tests/ssl-opt.sh |
| 972 | |
| 973 | msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 974 | if_build_succeeded tests/compat.sh |
| 975 | } |
| 976 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 977 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 978 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 979 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 980 | scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 981 | scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
| 982 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 983 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 984 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 985 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
| 986 | if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer" |
| 987 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 988 | |
Jaeden Amero | 2de07f1 | 2019-06-05 13:32:08 +0100 | [diff] [blame] | 989 | component_test_when_no_ciphersuites_have_mac () { |
| 990 | msg "build: when no ciphersuites have MAC" |
| 991 | scripts/config.pl unset MBEDTLS_CIPHER_NULL_CIPHER |
| 992 | scripts/config.pl unset MBEDTLS_ARC4_C |
| 993 | scripts/config.pl unset MBEDTLS_CIPHER_MODE_CBC |
| 994 | make |
| 995 | |
| 996 | msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 997 | make test |
| 998 | |
| 999 | msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
Jaeden Amero | 6b1683d | 2019-06-05 14:42:50 +0100 | [diff] [blame] | 1000 | if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' |
Jaeden Amero | 2de07f1 | 2019-06-05 13:32:08 +0100 | [diff] [blame] | 1001 | } |
| 1002 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1003 | component_test_null_entropy () { |
| 1004 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1005 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
| 1006 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 1007 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 1008 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 1009 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 1010 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 5fa32a7 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 1011 | 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] | 1012 | make |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1013 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1014 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 1015 | make test |
| 1016 | } |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 1017 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1018 | component_test_platform_calloc_macro () { |
| 1019 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1020 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 1021 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 1022 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 1023 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1024 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1025 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1026 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 1027 | make test |
| 1028 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 1029 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1030 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1031 | msg "build/test: make shared" # ~ 40s |
Andrzej Kurek | 8761577 | 2019-04-19 15:03:58 -0400 | [diff] [blame] | 1032 | make SHARED=1 all check -j1 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1033 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 1034 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1035 | component_test_m32_o0 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1036 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 1037 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 1038 | scripts/config.pl full |
Philippe Antoine | cd2c127 | 2019-06-25 21:50:07 +0200 | [diff] [blame] | 1039 | make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 1040 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1041 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 1042 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1043 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1044 | support_test_m32_o0 () { |
| 1045 | case $(uname -m) in |
| 1046 | *64*) true;; |
| 1047 | *) false;; |
| 1048 | esac |
| 1049 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1050 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1051 | component_test_m32_o1 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1052 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 1053 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1054 | scripts/config.pl full |
Gilles Peskine | 4b31761 | 2019-04-08 16:58:02 +0200 | [diff] [blame] | 1055 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE |
| 1056 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1057 | scripts/config.pl unset MBEDTLS_MEMORY_DEBUG |
Philippe Antoine | cd2c127 | 2019-06-25 21:50:07 +0200 | [diff] [blame] | 1058 | make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address' |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 1059 | |
| 1060 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1061 | make test |
Gilles Peskine | 4b31761 | 2019-04-08 16:58:02 +0200 | [diff] [blame] | 1062 | |
| 1063 | msg "test ssl-opt.sh, i386, make, gcc-O1" |
| 1064 | if_build_succeeded tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1065 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1066 | support_test_m32_o1 () { |
| 1067 | support_test_m32_o0 "$@" |
| 1068 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1069 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1070 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1071 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 1072 | scripts/config.pl full |
Gilles Peskine | 5d26e7c | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 1073 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 1074 | |
| 1075 | msg "test: 64-bit ILP32, make, gcc" |
| 1076 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1077 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1078 | support_test_mx32 () { |
| 1079 | case $(uname -m) in |
| 1080 | amd64|x86_64) true;; |
| 1081 | *) false;; |
| 1082 | esac |
| 1083 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1084 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1085 | component_build_arm_none_eabi_gcc () { |
| 1086 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
Manuel Pégourié-Gonnard | df2bfcf | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1087 | scripts/config.pl baremetal |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1088 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 1089 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1090 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1091 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
| 1092 | msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Manuel Pégourié-Gonnard | df2bfcf | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1093 | scripts/config.pl baremetal |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1094 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
| 1095 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 1096 | echo "Checking that software 64-bit division is not required" |
| 1097 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
| 1098 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1099 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1100 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
| 1101 | msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Manuel Pégourié-Gonnard | df2bfcf | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1102 | scripts/config.pl baremetal |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1103 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 1104 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib |
| 1105 | echo "Checking that software 64-bit multiplication is not required" |
| 1106 | if_build_succeeded not grep __aeabi_lmul library/*.o |
| 1107 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 1108 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1109 | component_build_armcc () { |
| 1110 | msg "build: ARM Compiler 5, make" |
Manuel Pégourié-Gonnard | df2bfcf | 2019-04-29 12:44:12 +0200 | [diff] [blame] | 1111 | scripts/config.pl baremetal |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 1112 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1113 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 1114 | make clean |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 1115 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1116 | # ARM Compiler 6 - Target ARMv7-A |
| 1117 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1118 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1119 | # ARM Compiler 6 - Target ARMv7-M |
| 1120 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1121 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1122 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1123 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1124 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1125 | # ARM Compiler 6 - Target ARMv8-M |
| 1126 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 1127 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 1128 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 1129 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1130 | } |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 1131 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1132 | component_test_allow_sha1 () { |
| 1133 | msg "build: allow SHA1 in certificates by default" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1134 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
| 1135 | make CFLAGS='-Werror -Wall -Wextra' |
| 1136 | msg "test: allow SHA1 in certificates by default" |
| 1137 | make test |
| 1138 | if_build_succeeded tests/ssl-opt.sh -f SHA-1 |
| 1139 | } |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 1140 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1141 | component_build_mingw () { |
| 1142 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Andrzej Kurek | 62faadd | 2019-04-19 20:10:21 -0400 | [diff] [blame] | 1143 | 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 -j1 |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 1144 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1145 | # note Make tests only builds the tests, but doesn't run them |
Andrzej Kurek | 62faadd | 2019-04-19 20:10:21 -0400 | [diff] [blame] | 1146 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests -j1 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1147 | make WINDOWS_BUILD=1 clean |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 1148 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1149 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
Andrzej Kurek | 8761577 | 2019-04-19 15:03:58 -0400 | [diff] [blame] | 1150 | 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 -j1 |
| 1151 | 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 -j1 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1152 | make WINDOWS_BUILD=1 clean |
| 1153 | } |
Jaeden Amero | 117b8a4 | 2019-04-17 15:19:26 +0100 | [diff] [blame] | 1154 | support_build_mingw() { |
| 1155 | case $(i686-w64-mingw32-gcc -dumpversion) in |
| 1156 | [0-5]*) false;; |
| 1157 | *) true;; |
| 1158 | esac |
| 1159 | } |
Simon Butcher | 91aef33 | 2016-11-17 09:20:50 +0000 | [diff] [blame] | 1160 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1161 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1162 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1163 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1164 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1165 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 1166 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1167 | msg "test: main suites (MSan)" # ~ 10s |
| 1168 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1169 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1170 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1171 | if_build_succeeded tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1172 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1173 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 1174 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1175 | if [ "$MEMORY" -gt 0 ]; then |
| 1176 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1177 | if_build_succeeded tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1178 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1179 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1180 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 1181 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1182 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1183 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1184 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1185 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1186 | msg "test: main suites valgrind (Release)" |
| 1187 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1188 | |
Gilles Peskine | f1349e4 | 2019-04-08 17:00:56 +0200 | [diff] [blame] | 1189 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1190 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1191 | if [ "$MEMORY" -gt 0 ]; then |
| 1192 | msg "test: ssl-opt.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1193 | if_build_succeeded tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1194 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1195 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1196 | if [ "$MEMORY" -gt 1 ]; then |
| 1197 | msg "test: compat.sh --memcheck (Release)" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 1198 | if_build_succeeded tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 1199 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1200 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1201 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1202 | component_test_cmake_out_of_source () { |
| 1203 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1204 | MBEDTLS_ROOT_DIR="$PWD" |
| 1205 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1206 | cd "$OUT_OF_SOURCE_DIR" |
| 1207 | cmake "$MBEDTLS_ROOT_DIR" |
| 1208 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1209 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1210 | msg "test: cmake 'out-of-source' build" |
| 1211 | make test |
| 1212 | # Test an SSL option that requires an auxiliary script in test/scripts/. |
| 1213 | # Also ensure that there are no error messages such as |
| 1214 | # "No such file or directory", which would indicate that some required |
| 1215 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 1216 | # may exit with status 0 but emit errors). |
| 1217 | if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err |
| 1218 | if [ -s ssl-opt.err ]; then |
| 1219 | cat ssl-opt.err >&2 |
| 1220 | record_status [ ! -s ssl-opt.err ] |
| 1221 | rm ssl-opt.err |
| 1222 | fi |
| 1223 | cd "$MBEDTLS_ROOT_DIR" |
| 1224 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1225 | unset MBEDTLS_ROOT_DIR |
| 1226 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1227 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 1228 | component_test_cmake_as_subdirectory () { |
| 1229 | msg "build: cmake 'as-subdirectory' build" |
| 1230 | MBEDTLS_ROOT_DIR="$PWD" |
| 1231 | |
| 1232 | cd programs/test/cmake_subproject |
| 1233 | cmake . |
| 1234 | make |
| 1235 | if_build_succeeded ./cmake_subproject |
| 1236 | |
| 1237 | cd "$MBEDTLS_ROOT_DIR" |
| 1238 | unset MBEDTLS_ROOT_DIR |
| 1239 | } |
| 1240 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1241 | component_test_zeroize () { |
| 1242 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 1243 | # different combinations of compilers and optimization flags by using an |
| 1244 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 1245 | # system in all cases that the script fails, so we must manually search the |
| 1246 | # output to check whether the pass string is present and no failure strings |
| 1247 | # were printed. |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1248 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1249 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 1250 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 1251 | gdb_disable_aslr= |
| 1252 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 1253 | gdb_disable_aslr='set disable-randomization off' |
| 1254 | fi |
| 1255 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1256 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1257 | for compiler in clang gcc; do |
| 1258 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 1259 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1260 | 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] | 1261 | if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log |
| 1262 | if_build_succeeded not grep -i "error" test_zeroize.log |
| 1263 | rm -f test_zeroize.log |
| 1264 | make clean |
| 1265 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 1266 | done |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 1267 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1268 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1269 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1270 | |
Gilles Peskine | aad2ebd | 2019-02-25 20:26:06 +0100 | [diff] [blame] | 1271 | support_check_python_files () { |
| 1272 | type pylint3 >/dev/null 2>/dev/null |
| 1273 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1274 | component_check_python_files () { |
| 1275 | msg "Lint: Python scripts" |
| 1276 | record_status tests/scripts/check-python-files.sh |
| 1277 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1278 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1279 | component_check_generate_test_code () { |
| 1280 | msg "uint test: generate_test_code.py" |
| 1281 | record_status ./tests/scripts/test_generate_test_code.py |
| 1282 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1283 | |
| 1284 | ################################################################ |
| 1285 | #### Termination |
| 1286 | ################################################################ |
| 1287 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1288 | post_report () { |
| 1289 | msg "Done, cleaning up" |
| 1290 | cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1291 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1292 | final_report |
| 1293 | } |
| 1294 | |
| 1295 | |
| 1296 | |
| 1297 | ################################################################ |
| 1298 | #### Run all the things |
| 1299 | ################################################################ |
| 1300 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1301 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1302 | run_component () { |
Gilles Peskine | 608953e | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1303 | # Back up the configuration in case the component modifies it. |
| 1304 | # The cleanup function will restore it. |
| 1305 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1306 | current_component="$1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1307 | "$@" |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1308 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | # Preliminary setup |
| 1312 | pre_check_environment |
| 1313 | pre_initialize_variables |
| 1314 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 1315 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1316 | pre_check_git |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 1317 | pre_check_seedfile |
| 1318 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1319 | build_status=0 |
| 1320 | if [ $KEEP_GOING -eq 1 ]; then |
| 1321 | pre_setup_keep_going |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 1322 | else |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1323 | record_status () { |
| 1324 | "$@" |
| 1325 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1326 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1327 | pre_print_configuration |
| 1328 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1329 | cleanup |
| 1330 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 1331 | # Run the requested tests. |
| 1332 | for component in $RUN_COMPONENTS; do |
| 1333 | run_component "component_$component" |
| 1334 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1335 | |
| 1336 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1337 | post_report |