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