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