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 | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 552 | component_test_default_cmake_gcc_asan () { |
| 553 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 554 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 555 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 556 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 557 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 558 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 559 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 560 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 561 | component_test_ref_configs () { |
| 562 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 563 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 564 | record_status tests/scripts/test-ref-configs.pl |
| 565 | } |
| 566 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 567 | component_test_rsa_no_crt () { |
| 568 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 569 | scripts/config.pl set MBEDTLS_RSA_NO_CRT |
| 570 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 571 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 572 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 573 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 574 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 575 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 576 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 577 | component_test_full_cmake_clang () { |
| 578 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 579 | scripts/config.pl full |
| 580 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 581 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . |
| 582 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 583 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 584 | msg "test: main suites (full config)" # ~ 5s |
| 585 | make test |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 586 | |
Darryl Green | 45010a3 | 2019-02-06 13:43:58 +0000 | [diff] [blame] | 587 | msg "test: psa_constant_names (full config)" # ~ 1s |
| 588 | record_status tests/scripts/test_psa_constant_names.py |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 589 | } |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 590 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 591 | component_build_deprecated () { |
| 592 | msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 593 | scripts/config.pl full |
| 594 | scripts/config.pl set MBEDTLS_DEPRECATED_WARNING |
| 595 | # Build with -O -Wextra to catch a maximum of issues. |
| 596 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 597 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
Gilles Peskine | b4ef45b | 2018-03-01 22:23:50 +0100 | [diff] [blame] | 598 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 599 | msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s |
| 600 | # No cleanup, just tweak the configuration and rebuild |
| 601 | make clean |
| 602 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 603 | scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED |
| 604 | # Build with -O -Wextra to catch a maximum of issues. |
| 605 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs |
| 606 | make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests |
| 607 | } |
Gilles Peskine | 0afe624 | 2018-02-21 19:28:12 +0100 | [diff] [blame] | 608 | |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 609 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 610 | component_test_depends_curves () { |
| 611 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 612 | record_status tests/scripts/curves.pl |
| 613 | } |
Manuel Pégourié-Gonnard | 1fe6bb9 | 2017-06-06 11:36:16 +0200 | [diff] [blame] | 614 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 615 | component_test_depends_hashes () { |
| 616 | msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 617 | record_status tests/scripts/depends-hashes.pl |
| 618 | } |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 619 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 620 | component_test_depends_pkalgs () { |
| 621 | msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 622 | record_status tests/scripts/depends-pkalgs.pl |
| 623 | } |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 624 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 625 | component_build_default_make_gcc_and_cxx () { |
| 626 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 627 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 628 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 629 | msg "test: verify header list in cpp_dummy_build.cpp" |
| 630 | record_status check_headers_in_cpp |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 631 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 632 | msg "build: Unix make, incremental g++" |
| 633 | make TEST_CPP=1 |
| 634 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 635 | |
Andrzej Kurek | fd0381a | 2019-02-05 05:00:02 -0500 | [diff] [blame] | 636 | component_test_use_psa_crypto_full_cmake_asan() { |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 637 | # MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh |
| 638 | msg "build: cmake, full config + MBEDTLS_USE_PSA_CRYPTO, ASan" |
| 639 | scripts/config.pl full |
| 640 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
Hanno Becker | 241b524 | 2019-02-22 10:26:18 +0000 | [diff] [blame] | 641 | 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] | 642 | scripts/config.pl set MBEDTLS_PSA_CRYPTO_C |
| 643 | scripts/config.pl set MBEDTLS_USE_PSA_CRYPTO |
Jaeden Amero | 67ea2c5 | 2019-02-11 12:05:54 +0000 | [diff] [blame] | 644 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 645 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 646 | |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 647 | msg "test: main suites (MBEDTLS_USE_PSA_CRYPTO)" |
| 648 | make test |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 649 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 650 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 651 | component_test_check_params_without_platform () { |
| 652 | msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" |
| 653 | scripts/config.pl full # includes CHECK_PARAMS |
| 654 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 655 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 656 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 657 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 658 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 659 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 660 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 661 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 662 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 663 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 664 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 665 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 666 | |
Gilles Peskine | b28636b | 2019-01-02 19:06:24 +0100 | [diff] [blame] | 667 | component_test_check_params_silent () { |
| 668 | msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" |
| 669 | scripts/config.pl full # includes CHECK_PARAMS |
| 670 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 671 | sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" |
| 672 | make CC=gcc CFLAGS='-Werror -O1' all test |
| 673 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 674 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 675 | component_test_no_platform () { |
| 676 | # Full configuration build, without platform support, file IO and net sockets. |
| 677 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 678 | # IO, it should catch missing '#include <stdio.h>' |
| 679 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 680 | scripts/config.pl full |
| 681 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 682 | scripts/config.pl unset MBEDTLS_NET_C |
| 683 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
| 684 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 685 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 686 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 687 | scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT |
| 688 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
| 689 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 690 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 691 | scripts/config.pl unset MBEDTLS_FS_IO |
Gilles Peskine | 5158538 | 2019-01-05 10:27:47 +0100 | [diff] [blame] | 692 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C |
| 693 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 694 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 695 | # to re-enable platform integration features otherwise disabled in C99 builds |
| 696 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs |
| 697 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test |
| 698 | } |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 699 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 700 | component_build_no_std_function () { |
| 701 | # catch compile bugs in _uninit functions |
| 702 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 703 | scripts/config.pl full |
| 704 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 705 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 706 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' |
| 707 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 708 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 709 | component_test_null_entropy () { |
| 710 | msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 711 | scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY |
| 712 | scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
| 713 | scripts/config.pl set MBEDTLS_ENTROPY_C |
| 714 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 715 | scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT |
| 716 | scripts/config.pl unset MBEDTLS_HAVEGE_C |
Gilles Peskine | 1927565 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 717 | 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] | 718 | make |
Janos Follath | 06c5400 | 2016-06-09 13:57:40 +0100 | [diff] [blame] | 719 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 720 | msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" |
| 721 | make test |
| 722 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 723 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 724 | component_test_platform_calloc_macro () { |
| 725 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 726 | scripts/config.pl set MBEDTLS_PLATFORM_MEMORY |
| 727 | scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 728 | scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free |
| 729 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 730 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 731 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 732 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 733 | make test |
| 734 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 735 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 736 | component_test_aes_fewer_tables () { |
| 737 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 738 | scripts/config.pl set MBEDTLS_AES_FEWER_TABLES |
| 739 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 740 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 741 | msg "test: AES_FEWER_TABLES" |
| 742 | make test |
| 743 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 744 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 745 | component_test_aes_rom_tables () { |
| 746 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 747 | scripts/config.pl set MBEDTLS_AES_ROM_TABLES |
| 748 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 749 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 750 | msg "test: AES_ROM_TABLES" |
| 751 | make test |
| 752 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 753 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 754 | component_test_aes_fewer_tables_and_rom_tables () { |
| 755 | 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] | 756 | scripts/config.pl set MBEDTLS_AES_FEWER_TABLES |
| 757 | scripts/config.pl set MBEDTLS_AES_ROM_TABLES |
| 758 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 759 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 760 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 761 | make test |
| 762 | } |
| 763 | |
| 764 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 765 | msg "build/test: make shared" # ~ 40s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 766 | make SHARED=1 all check |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 767 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 768 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 769 | component_test_m32_o0 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 770 | # Build once with -O0, to compile out the i386 specific inline assembly |
| 771 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 772 | scripts/config.pl full |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 773 | make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 774 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 775 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 776 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 777 | } |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 778 | support_test_m32_o0 () { |
| 779 | case $(uname -m) in |
| 780 | *64*) true;; |
| 781 | *) false;; |
| 782 | esac |
| 783 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 784 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 785 | component_test_m32_o1 () { |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 786 | # Build again with -O1, to compile in the i386 specific inline assembly |
| 787 | msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 788 | scripts/config.pl full |
| 789 | make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' |
| 790 | |
| 791 | msg "test: i386, make, gcc -O1 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 792 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 793 | } |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 794 | support_test_m32_o1 () { |
| 795 | support_test_m32_o0 "$@" |
| 796 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 797 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 798 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 799 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Simon Butcher | 7a6da6e | 2018-06-27 21:52:54 +0100 | [diff] [blame] | 800 | scripts/config.pl full |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 801 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' |
| 802 | |
| 803 | msg "test: 64-bit ILP32, make, gcc" |
| 804 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 805 | } |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 806 | support_test_mx32 () { |
| 807 | case $(uname -m) in |
| 808 | amd64|x86_64) true;; |
| 809 | *) false;; |
| 810 | esac |
| 811 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 812 | |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 813 | component_test_min_mpi_window_size () { |
| 814 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
| 815 | scripts/config.pl set MBEDTLS_MPI_WINDOW_SIZE 1 |
| 816 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 817 | make |
| 818 | |
| 819 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 820 | make test |
| 821 | } |
| 822 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 823 | component_test_have_int32 () { |
| 824 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 825 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 826 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 827 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 828 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 829 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 830 | msg "test: gcc, force 32-bit bignum limbs" |
| 831 | make test |
| 832 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 833 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 834 | component_test_have_int64 () { |
| 835 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 836 | scripts/config.pl unset MBEDTLS_HAVE_ASM |
| 837 | scripts/config.pl unset MBEDTLS_AESNI_C |
| 838 | scripts/config.pl unset MBEDTLS_PADLOCK_C |
| 839 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 840 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 841 | msg "test: gcc, force 64-bit bignum limbs" |
| 842 | make test |
| 843 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 844 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 845 | component_test_no_udbl_division () { |
| 846 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 847 | scripts/config.pl full |
| 848 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 849 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
| 850 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 851 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 852 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 853 | make test |
| 854 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 855 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 856 | component_test_no_64bit_multiplication () { |
| 857 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 858 | scripts/config.pl full |
| 859 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 860 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 861 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 862 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 863 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 864 | make test |
| 865 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 866 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 867 | component_build_arm_none_eabi_gcc () { |
| 868 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 869 | scripts/config.pl full |
| 870 | scripts/config.pl unset MBEDTLS_NET_C |
| 871 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 872 | scripts/config.pl unset MBEDTLS_FS_IO |
Gilles Peskine | 5158538 | 2019-01-05 10:27:47 +0100 | [diff] [blame] | 873 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C |
| 874 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 875 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 876 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
| 877 | # following things are not in the default config |
| 878 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 879 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 880 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 881 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 882 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
| 883 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 884 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 885 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 886 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
| 887 | msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 888 | scripts/config.pl full |
| 889 | scripts/config.pl unset MBEDTLS_NET_C |
| 890 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 891 | scripts/config.pl unset MBEDTLS_FS_IO |
Gilles Peskine | 5158538 | 2019-01-05 10:27:47 +0100 | [diff] [blame] | 892 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C |
| 893 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 894 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 895 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
| 896 | # following things are not in the default config |
| 897 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 898 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 899 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 900 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 901 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
| 902 | scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION |
| 903 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib |
| 904 | echo "Checking that software 64-bit division is not required" |
| 905 | if_build_succeeded not grep __aeabi_uldiv library/*.o |
| 906 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 907 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 908 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
| 909 | msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 910 | scripts/config.pl full |
| 911 | scripts/config.pl unset MBEDTLS_NET_C |
| 912 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 913 | scripts/config.pl unset MBEDTLS_FS_IO |
Gilles Peskine | 5158538 | 2019-01-05 10:27:47 +0100 | [diff] [blame] | 914 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C |
| 915 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 916 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 917 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
| 918 | # following things are not in the default config |
| 919 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 920 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 921 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 922 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 923 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
| 924 | scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 925 | make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib |
| 926 | echo "Checking that software 64-bit multiplication is not required" |
| 927 | if_build_succeeded not grep __aeabi_lmul library/*.o |
| 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_armcc () { |
| 931 | msg "build: ARM Compiler 5, make" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 932 | scripts/config.pl full |
| 933 | scripts/config.pl unset MBEDTLS_NET_C |
| 934 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 935 | scripts/config.pl unset MBEDTLS_FS_IO |
Gilles Peskine | 5158538 | 2019-01-05 10:27:47 +0100 | [diff] [blame] | 936 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C |
| 937 | scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 938 | scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED |
| 939 | scripts/config.pl unset MBEDTLS_HAVE_TIME |
| 940 | scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE |
| 941 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
| 942 | # following things are not in the default config |
| 943 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 944 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 945 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 946 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 947 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 948 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
| 949 | 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] | 950 | |
Gilles Peskine | e26ab18 | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 951 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 952 | make clean |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 953 | |
Gilles Peskine | e26ab18 | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 954 | # ARM Compiler 6 - Target ARMv7-A |
| 955 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a" |
Gilles Peskine | ed942f8 | 2017-06-08 15:19:20 +0200 | [diff] [blame] | 956 | |
Gilles Peskine | e26ab18 | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 957 | # ARM Compiler 6 - Target ARMv7-M |
| 958 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 959 | |
Gilles Peskine | e26ab18 | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 960 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 961 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a" |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 962 | |
Gilles Peskine | e26ab18 | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 963 | # ARM Compiler 6 - Target ARMv8-M |
| 964 | armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 965 | |
Gilles Peskine | e26ab18 | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 966 | # ARM Compiler 6 - Target ARMv8-A - AArch64 |
| 967 | armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 968 | } |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 969 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 970 | component_build_mingw () { |
| 971 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 972 | 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] | 973 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 974 | # note Make tests only builds the tests, but doesn't run them |
| 975 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
| 976 | make WINDOWS_BUILD=1 clean |
Hanno Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 977 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 978 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
| 979 | 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 |
| 980 | 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 |
| 981 | make WINDOWS_BUILD=1 clean |
| 982 | } |
Simon Butcher | 002bc62 | 2016-11-17 09:27:45 +0000 | [diff] [blame] | 983 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 984 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 985 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 986 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 987 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 988 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 989 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 990 | msg "test: main suites (MSan)" # ~ 10s |
| 991 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 992 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 993 | |
Gilles Peskine | e878987 | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 994 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 995 | msg "build: Release (clang)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 996 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 997 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 998 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 999 | msg "test: main suites valgrind (Release)" |
| 1000 | make memcheck |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1001 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1002 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1003 | component_test_cmake_out_of_source () { |
| 1004 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1005 | MBEDTLS_ROOT_DIR="$PWD" |
| 1006 | mkdir "$OUT_OF_SOURCE_DIR" |
| 1007 | cd "$OUT_OF_SOURCE_DIR" |
| 1008 | cmake "$MBEDTLS_ROOT_DIR" |
| 1009 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 1010 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1011 | msg "test: cmake 'out-of-source' build" |
| 1012 | make test |
Jaeden Amero | 9b90f2e | 2018-11-02 18:34:17 +0000 | [diff] [blame] | 1013 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1014 | cd "$MBEDTLS_ROOT_DIR" |
| 1015 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 1016 | unset MBEDTLS_ROOT_DIR |
| 1017 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 1018 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1019 | component_test_zeroize () { |
| 1020 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 1021 | # different combinations of compilers and optimization flags by using an |
| 1022 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 1023 | # system in all cases that the script fails, so we must manually search the |
| 1024 | # output to check whether the pass string is present and no failure strings |
| 1025 | # were printed. |
Gilles Peskine | 74851d8 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1026 | |
| 1027 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 1028 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 1029 | gdb_disable_aslr= |
| 1030 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 1031 | gdb_disable_aslr='set disable-randomization off' |
| 1032 | fi |
| 1033 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1034 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 06b385f | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 1035 | for compiler in clang gcc; do |
| 1036 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 1037 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 74851d8 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1038 | 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] | 1039 | if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log |
| 1040 | if_build_succeeded not grep -i "error" test_zeroize.log |
| 1041 | rm -f test_zeroize.log |
| 1042 | make clean |
| 1043 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 1044 | done |
Gilles Peskine | 74851d8 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 1045 | |
| 1046 | unset gdb_disable_aslr |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1047 | } |
Andres Amaya Garcia | d0d7bf6 | 2017-10-25 09:01:31 +0100 | [diff] [blame] | 1048 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1049 | component_check_python_files () { |
| 1050 | msg "Lint: Python scripts" |
| 1051 | record_status tests/scripts/check-python-files.sh |
| 1052 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1053 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1054 | component_check_generate_test_code () { |
| 1055 | msg "uint test: generate_test_code.py" |
| 1056 | record_status ./tests/scripts/test_generate_test_code.py |
| 1057 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 1058 | |
| 1059 | ################################################################ |
| 1060 | #### Termination |
| 1061 | ################################################################ |
| 1062 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1063 | post_report () { |
| 1064 | msg "Done, cleaning up" |
| 1065 | cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1066 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1067 | final_report |
| 1068 | } |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | ################################################################ |
| 1073 | #### Run all the things |
| 1074 | ################################################################ |
| 1075 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1076 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1077 | run_component () { |
Gilles Peskine | 8ae15dd | 2019-01-02 18:57:02 +0100 | [diff] [blame] | 1078 | # Back up the configuration in case the component modifies it. |
| 1079 | # The cleanup function will restore it. |
| 1080 | cp -p "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 1081 | current_component="$1" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1082 | "$@" |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 1083 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | # Preliminary setup |
| 1087 | pre_check_environment |
| 1088 | pre_initialize_variables |
| 1089 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 1090 | |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1091 | pre_check_git |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 1092 | pre_check_seedfile |
| 1093 | |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1094 | build_status=0 |
| 1095 | if [ $KEEP_GOING -eq 1 ]; then |
| 1096 | pre_setup_keep_going |
| 1097 | else |
| 1098 | record_status () { |
| 1099 | "$@" |
| 1100 | } |
| 1101 | fi |
| 1102 | pre_print_configuration |
| 1103 | pre_check_tools |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1104 | cleanup |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1105 | |
Gilles Peskine | 1bcb1c8 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 1106 | # Run the requested tests. |
| 1107 | for component in $RUN_COMPONENTS; do |
| 1108 | run_component "component_$component" |
| 1109 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1110 | |
| 1111 | # We're done. |
Gilles Peskine | 1072610 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 1112 | post_report |