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