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