Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 3 | # all.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 4 | # |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 5 | # This file is part of mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 6 | # |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 7 | # Copyright (c) 2014-2016, ARM Limited, All Rights Reserved |
| 8 | # |
| 9 | # Purpose |
| 10 | # |
| 11 | # To run all tests possible or available on the platform. |
| 12 | # |
| 13 | # Warning: the test is destructive. It includes various build modes and |
| 14 | # configurations, and can and will arbitrarily change the current CMake |
| 15 | # configuration. After this script has been run, the CMake cache will be lost |
| 16 | # and CMake will no longer be initialised. |
| 17 | # |
| 18 | # The script assumes the presence of gcc and clang (recent enough for using |
| 19 | # ASan with gcc and MemSan with clang, or valgrind) are available, as well as |
| 20 | # cmake and a "good" find. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 21 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 22 | # Abort on errors (and uninitialised variables) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 23 | set -eu |
| 24 | |
| 25 | if [ -d library -a -d include -a -d tests ]; then :; else |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 26 | err_msg "Must be run from mbed TLS root" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 27 | exit 1 |
| 28 | fi |
| 29 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 30 | CONFIG_H='include/mbedtls/config.h' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 31 | CONFIG_BAK="$CONFIG_H.bak" |
| 32 | |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 33 | MEMORY=0 |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 34 | FORCE=0 |
| 35 | RELEASE=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 36 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 37 | # Default commands, can be overriden by the environment |
| 38 | : ${OPENSSL:="openssl"} |
| 39 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 40 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 41 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 42 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 43 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 44 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 45 | |
| 46 | usage() |
| 47 | { |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame^] | 48 | cat <<EOF |
| 49 | Usage: $0 [OPTION]... |
| 50 | -h|--help Print this help. |
| 51 | |
| 52 | General options: |
| 53 | -f|--force Force the tests to overwrite any modified files. |
| 54 | -m|--memory Additional optional memory tests. |
| 55 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
| 56 | -r|--release-test Run this script in release mode. This fixes the seed value to 1. |
| 57 | -s|--seed Integer seed value to use for this test run. |
| 58 | |
| 59 | Tool path options: |
| 60 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 61 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 62 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 63 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 64 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
| 65 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3. |
| 66 | EOF |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 67 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 68 | |
| 69 | # remove built files as well as the cmake cache/config |
| 70 | cleanup() |
| 71 | { |
| 72 | make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 73 | |
Manuel Pégourié-Gonnard | 77d56bb | 2015-07-28 15:00:37 +0200 | [diff] [blame] | 74 | find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 75 | rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 76 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 77 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 78 | |
| 79 | if [ -f "$CONFIG_BAK" ]; then |
| 80 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 81 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 82 | } |
| 83 | |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 84 | trap cleanup INT TERM HUP |
| 85 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 86 | msg() |
| 87 | { |
| 88 | echo "" |
| 89 | echo "******************************************************************" |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 90 | echo "* $1 " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 91 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 92 | echo "******************************************************************" |
| 93 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 94 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 95 | err_msg() |
| 96 | { |
| 97 | echo "$1" >&2 |
| 98 | } |
| 99 | |
| 100 | check_tools() |
| 101 | { |
| 102 | for TOOL in "$@"; do |
| 103 | if ! `hash "$TOOL" >/dev/null 2>&1`; then |
| 104 | err_msg "$TOOL not found!" |
| 105 | exit 1 |
| 106 | fi |
| 107 | done |
| 108 | } |
| 109 | |
| 110 | while [ $# -gt 0 ]; do |
| 111 | case "$1" in |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 112 | --force|-f) |
| 113 | FORCE=1 |
| 114 | ;; |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 115 | --gnutls-cli) |
| 116 | shift |
| 117 | GNUTLS_CLI="$1" |
| 118 | ;; |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 119 | --gnutls-legacy-cli) |
| 120 | shift |
| 121 | GNUTLS_LEGACY_CLI="$1" |
| 122 | ;; |
| 123 | --gnutls-legacy-serv) |
| 124 | shift |
| 125 | GNUTLS_LEGACY_SERV="$1" |
| 126 | ;; |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame^] | 127 | --gnutls-serv) |
| 128 | shift |
| 129 | GNUTLS_SERV="$1" |
| 130 | ;; |
| 131 | --help|-h) |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 132 | usage |
Gilles Peskine | a6901f4 | 2017-12-10 23:43:39 +0100 | [diff] [blame^] | 133 | exit |
| 134 | ;; |
| 135 | --memory|-m) |
| 136 | MEMORY=1 |
| 137 | ;; |
| 138 | --openssl) |
| 139 | shift |
| 140 | OPENSSL="$1" |
| 141 | ;; |
| 142 | --openssl-legacy) |
| 143 | shift |
| 144 | OPENSSL_LEGACY="$1" |
| 145 | ;; |
| 146 | --out-of-source-dir) |
| 147 | shift |
| 148 | OUT_OF_SOURCE_DIR="$1" |
| 149 | ;; |
| 150 | --release-test|-r) |
| 151 | RELEASE=1 |
| 152 | ;; |
| 153 | --seed|-s) |
| 154 | shift |
| 155 | SEED="$1" |
| 156 | ;; |
| 157 | *) |
| 158 | echo >&2 "Unknown option: $1" |
| 159 | echo >&2 "Run $0 --help for usage." |
| 160 | exit 120 |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 161 | ;; |
| 162 | esac |
| 163 | shift |
| 164 | done |
| 165 | |
| 166 | if [ $FORCE -eq 1 ]; then |
| 167 | rm -rf yotta/module "$OUT_OF_SOURCE_DIR" |
| 168 | git checkout-index -f -q $CONFIG_H |
| 169 | cleanup |
| 170 | else |
| 171 | |
| 172 | if [ -d yotta/module ]; then |
| 173 | err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'" |
| 174 | echo "You can either delete your work and retry, or force the test to overwrite the" |
| 175 | echo "test by rerunning the script as: $0 --force" |
| 176 | exit 1 |
| 177 | fi |
| 178 | |
| 179 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 180 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 181 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 182 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 183 | exit 1 |
| 184 | fi |
| 185 | |
| 186 | if ! git diff-files --quiet include/mbedtls/config.h; then |
| 187 | echo $? |
| 188 | err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " |
| 189 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 190 | echo "script as: $0 --force" |
| 191 | exit 1 |
| 192 | fi |
| 193 | fi |
| 194 | |
| 195 | if [ $RELEASE -eq 1 ]; then |
| 196 | # Fix the seed value to 1 to ensure that the tests are deterministic. |
| 197 | SEED=1 |
| 198 | fi |
| 199 | |
| 200 | msg "info: $0 configuration" |
| 201 | echo "MEMORY: $MEMORY" |
| 202 | echo "FORCE: $FORCE" |
| 203 | echo "SEED: ${SEED-"UNSET"}" |
| 204 | echo "OPENSSL: $OPENSSL" |
| 205 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 206 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 207 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 208 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 209 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 210 | |
| 211 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh |
| 212 | # we just export the variables they require |
| 213 | export OPENSSL_CMD="$OPENSSL" |
| 214 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 215 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 216 | |
| 217 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 218 | [ ! -z ${SEED+set} ] && export SEED |
| 219 | |
| 220 | # Make sure the tools we need are available. |
| 221 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 222 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \ |
| 223 | "arm-none-eabi-gcc" "armcc" |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 224 | |
| 225 | # |
| 226 | # Test Suites to be executed |
| 227 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 228 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 229 | # 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] | 230 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 231 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 232 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 233 | # |
| 234 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 235 | |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 236 | msg "test: recursion.pl" # < 1s |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 237 | tests/scripts/recursion.pl library/*.c |
Manuel Pégourié-Gonnard | ea29d15 | 2014-11-20 17:32:33 +0100 | [diff] [blame] | 238 | |
Manuel Pégourié-Gonnard | b3b8e43 | 2015-02-13 14:52:19 +0000 | [diff] [blame] | 239 | msg "test: freshness of generated source files" # < 1s |
| 240 | tests/scripts/check-generated-files.sh |
| 241 | |
Manuel Pégourié-Gonnard | d09a6b5 | 2015-04-09 17:19:23 +0200 | [diff] [blame] | 242 | msg "test: doxygen markup outside doxygen blocks" # < 1s |
| 243 | tests/scripts/check-doxy-blocks.pl |
| 244 | |
Manuel Pégourié-Gonnard | a687baf | 2015-04-09 11:09:03 +0200 | [diff] [blame] | 245 | msg "test/build: declared and exported names" # < 3s |
| 246 | cleanup |
| 247 | tests/scripts/check-names.sh |
| 248 | |
Simon Butcher | 7315635 | 2015-11-04 00:36:30 +0000 | [diff] [blame] | 249 | # Yotta not supported in 2.1 branch |
| 250 | #msg "build: create and build yotta module" # ~ 30s |
| 251 | #cleanup |
| 252 | #tests/scripts/yotta-build.sh |
Manuel Pégourié-Gonnard | 77d56bb | 2015-07-28 15:00:37 +0200 | [diff] [blame] | 253 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 254 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 255 | cleanup |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 256 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 257 | make |
| 258 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 259 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 260 | make test |
| 261 | programs/test/selftest |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 262 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 263 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame] | 264 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 265 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 266 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 267 | tests/scripts/test-ref-configs.pl |
| 268 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 269 | msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min |
| 270 | make |
| 271 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 272 | msg "test: compat.sh (ASan build)" # ~ 6 min |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame] | 273 | tests/compat.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 274 | |
Hanno Becker | 797c084 | 2017-10-19 15:49:21 +0100 | [diff] [blame] | 275 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
| 276 | cleanup |
| 277 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 278 | scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 279 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 280 | make |
| 281 | |
| 282 | msg "test: ssl-opt.sh, MFL-related tests" |
| 283 | tests/ssl-opt.sh -f "Max fragment length" |
| 284 | |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 285 | msg "build: Default + SSLv3 (ASan build)" # ~ 6 min |
| 286 | cleanup |
| 287 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 288 | scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 |
| 289 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 290 | make |
| 291 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 292 | msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 293 | make test |
| 294 | programs/test/selftest |
| 295 | |
| 296 | msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 297 | tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' |
| 298 | OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' |
Simon Butcher | 02b8d48 | 2016-03-15 20:39:52 +0000 | [diff] [blame] | 299 | |
| 300 | msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min |
| 301 | tests/ssl-opt.sh |
| 302 | |
Hanno Becker | 4f9973e | 2017-10-24 11:56:28 +0100 | [diff] [blame] | 303 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
| 304 | cleanup |
| 305 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 306 | scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION |
| 307 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 308 | make |
| 309 | |
| 310 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 311 | make test |
| 312 | |
| 313 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
| 314 | tests/ssl-opt.sh |
| 315 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 316 | msg "build: cmake, full config, clang" # ~ 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 317 | cleanup |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 318 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 319 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 320 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 321 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 322 | make |
| 323 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 324 | msg "test: main suites (full config)" # ~ 5s |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 325 | make test |
| 326 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 327 | msg "test: ssl-opt.sh default (full config)" # ~ 1s |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame] | 328 | tests/ssl-opt.sh -f Default |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 329 | |
Manuel Pégourié-Gonnard | ea0920f | 2015-03-24 09:50:15 +0100 | [diff] [blame] | 330 | msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 331 | OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 332 | |
Manuel Pégourié-Gonnard | 134ca18 | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 333 | msg "test/build: curves.pl (gcc)" # ~ 4 min |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 334 | cleanup |
| 335 | cmake -D CMAKE_BUILD_TYPE:String=Debug . |
| 336 | tests/scripts/curves.pl |
| 337 | |
Manuel Pégourié-Gonnard | 134ca18 | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 338 | msg "test/build: key-exchanges (gcc)" # ~ 1 min |
| 339 | cleanup |
| 340 | cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 341 | tests/scripts/key-exchanges.pl |
| 342 | |
Manuel Pégourié-Gonnard | 61fe8b0 | 2015-03-13 14:33:16 +0000 | [diff] [blame] | 343 | msg "build: Unix make, -Os (gcc)" # ~ 30s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 344 | cleanup |
Manuel Pégourié-Gonnard | 61fe8b0 | 2015-03-13 14:33:16 +0000 | [diff] [blame] | 345 | CC=gcc CFLAGS='-Werror -Os' make |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 346 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 347 | # this is meant to cath missing #define mbedtls_printf etc |
Manuel Pégourié-Gonnard | 981732b | 2015-02-17 15:46:45 +0000 | [diff] [blame] | 348 | # disable fsio to catch some more missing #include <stdio.h> |
Manuel Pégourié-Gonnard | 757ca00 | 2015-03-23 15:24:07 +0100 | [diff] [blame] | 349 | msg "build: full config except platform/fsio, make, gcc" # ~ 30s |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 350 | cleanup |
| 351 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 352 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 353 | scripts/config.pl unset MBEDTLS_PLATFORM_C |
| 354 | scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY |
Manuel Pégourié-Gonnard | 3d4755b | 2015-06-03 14:03:17 +0100 | [diff] [blame] | 355 | scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 356 | scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 357 | scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
| 358 | scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 359 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 360 | scripts/config.pl unset MBEDTLS_FS_IO |
Manuel Pégourié-Gonnard | 61fe8b0 | 2015-03-13 14:33:16 +0000 | [diff] [blame] | 361 | CC=gcc CFLAGS='-Werror -O0' make |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 362 | |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 363 | # catch compile bugs in _uninit functions |
| 364 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
| 365 | cleanup |
| 366 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 367 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 7ee5ddd | 2015-06-03 10:33:55 +0100 | [diff] [blame] | 368 | scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 369 | CC=gcc CFLAGS='-Werror -O0' make |
| 370 | |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 371 | msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s |
| 372 | cleanup |
| 373 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 374 | scripts/config.pl full |
| 375 | scripts/config.pl unset MBEDTLS_SSL_SRV_C |
| 376 | CC=gcc CFLAGS='-Werror -O0' make |
| 377 | |
| 378 | msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s |
| 379 | cleanup |
| 380 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 381 | scripts/config.pl full |
| 382 | scripts/config.pl unset MBEDTLS_SSL_CLI_C |
| 383 | CC=gcc CFLAGS='-Werror -O0' make |
| 384 | |
Manuel Pégourié-Gonnard | f78e4de | 2015-05-29 10:52:14 +0200 | [diff] [blame] | 385 | msg "build: full config except net.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 386 | cleanup |
| 387 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 388 | scripts/config.pl full |
Manuel Pégourié-Gonnard | f78e4de | 2015-05-29 10:52:14 +0200 | [diff] [blame] | 389 | scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 390 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Manuel Pégourié-Gonnard | 7185936 | 2015-06-02 16:39:22 +0100 | [diff] [blame] | 391 | CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 392 | |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 393 | if uname -a | grep -F Linux >/dev/null; then |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 394 | msg "build/test: make shared" # ~ 40s |
| 395 | cleanup |
| 396 | make SHARED=1 all check |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 397 | fi |
| 398 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 399 | if uname -a | grep -F x86_64 >/dev/null; then |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 400 | msg "build: i386, make, gcc" # ~ 30s |
| 401 | cleanup |
| 402 | CC=gcc CFLAGS='-Werror -m32' make |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 403 | fi # x86_64 |
| 404 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 405 | msg "build: arm-none-eabi-gcc, make" # ~ 10s |
| 406 | cleanup |
| 407 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 408 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 409 | scripts/config.pl unset MBEDTLS_NET_C |
| 410 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 411 | scripts/config.pl unset MBEDTLS_FS_IO |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 412 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 413 | # following things are not in the default config |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 414 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 415 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 416 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 417 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 418 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Manuel Pégourié-Gonnard | e058ea2 | 2015-06-25 09:04:13 +0200 | [diff] [blame] | 419 | CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror make lib |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 420 | |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 421 | msg "build: armcc, make" |
| 422 | cleanup |
| 423 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 424 | scripts/config.pl full |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 425 | scripts/config.pl unset MBEDTLS_NET_C |
| 426 | scripts/config.pl unset MBEDTLS_TIMING_C |
| 427 | scripts/config.pl unset MBEDTLS_FS_IO |
| 428 | scripts/config.pl unset MBEDTLS_HAVE_TIME |
Manuel Pégourié-Gonnard | bbc60db | 2015-06-22 14:31:50 +0200 | [diff] [blame] | 429 | scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 430 | scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 431 | # following things are not in the default config |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 432 | scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING |
| 433 | scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c |
| 434 | scripts/config.pl unset MBEDTLS_THREADING_PTHREAD |
| 435 | scripts/config.pl unset MBEDTLS_THREADING_C |
| 436 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h |
| 437 | scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 438 | CC=armcc AR=armar WARNING_CFLAGS= make lib |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 439 | |
Gilles Peskine | b49351d | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 440 | msg "build: allow SHA1 in certificates by default" |
| 441 | cleanup |
| 442 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 443 | scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES |
| 444 | CFLAGS='-Werror -Wall -Wextra' make |
| 445 | msg "test: allow SHA1 in certificates by default" |
| 446 | make test |
| 447 | tests/ssl-opt.sh -f SHA-1 |
| 448 | |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 449 | if which i686-w64-mingw32-gcc >/dev/null; then |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 450 | msg "build: cross-mingw64, make" # ~ 30s |
| 451 | cleanup |
| 452 | CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 make |
| 453 | WINDOWS_BUILD=1 make clean |
| 454 | CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make |
| 455 | WINDOWS_BUILD=1 make clean |
Manuel Pégourié-Gonnard | 6448bce | 2015-02-16 17:18:36 +0100 | [diff] [blame] | 456 | fi |
| 457 | |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 458 | # MemSan currently only available on Linux 64 bits |
| 459 | if uname -a | grep 'Linux.*x86_64' >/dev/null; then |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 460 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 461 | msg "build: MSan (clang)" # ~ 1 min 20s |
| 462 | cleanup |
| 463 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 464 | scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 465 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 466 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 467 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 468 | msg "test: main suites (MSan)" # ~ 10s |
| 469 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 470 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 471 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
| 472 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 473 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 474 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 475 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 476 | if [ "$MEMORY" -gt 0 ]; then |
| 477 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
| 478 | tests/compat.sh |
| 479 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 480 | |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 481 | else # no MemSan |
| 482 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 483 | msg "build: Release (clang)" |
| 484 | cleanup |
| 485 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 486 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 487 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 488 | msg "test: main suites valgrind (Release)" |
| 489 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 490 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 491 | # Optional part(s) |
| 492 | # Currently broken, programs don't seem to receive signals |
| 493 | # under valgrind on OS X |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 494 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 495 | if [ "$MEMORY" -gt 0 ]; then |
| 496 | msg "test: ssl-opt.sh --memcheck (Release)" |
| 497 | tests/ssl-opt.sh --memcheck |
| 498 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 499 | |
Gilles Peskine | 30dfbaf | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 500 | if [ "$MEMORY" -gt 1 ]; then |
| 501 | msg "test: compat.sh --memcheck (Release)" |
| 502 | tests/compat.sh --memcheck |
| 503 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 504 | |
| 505 | fi # MemSan |
| 506 | |
Simon Butcher | d7f1902 | 2016-10-14 09:49:48 +0100 | [diff] [blame] | 507 | msg "build: cmake 'out-of-source' build" |
| 508 | cleanup |
| 509 | MBEDTLS_ROOT_DIR="$PWD" |
| 510 | mkdir "$OUT_OF_SOURCE_DIR" |
| 511 | cd "$OUT_OF_SOURCE_DIR" |
| 512 | cmake "$MBEDTLS_ROOT_DIR" |
| 513 | make |
| 514 | |
| 515 | msg "test: cmake 'out-of-source' build" |
| 516 | make test |
| 517 | cd "$MBEDTLS_ROOT_DIR" |
| 518 | rm -rf "$OUT_OF_SOURCE_DIR" |
| 519 | |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 520 | msg "Done, cleaning up" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 521 | cleanup |