Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Run all available tests (mostly). |
| 4 | # |
| 5 | # Warning: includes various build modes, so it will mess with the current |
| 6 | # CMake configuration. After this script is run, the CMake cache is lost and |
| 7 | # CMake is not initialised any more! |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 8 | # |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 9 | # Assumes gcc and clang (recent enough for using ASan with gcc and MemSen with |
| 10 | # clang) are available, as well as cmake and GNU find. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 11 | |
| 12 | # Abort on errors (and uninitiliased variables) |
| 13 | set -eu |
| 14 | |
| 15 | if [ -d library -a -d include -a -d tests ]; then :; else |
| 16 | echo "Must be run from PolarSSL root" >&2 |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 20 | CONFIG_H='include/polarssl/config.h' |
| 21 | CONFIG_BAK="$CONFIG_H.bak" |
| 22 | |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 23 | MEMORY=0 |
| 24 | |
| 25 | while [ $# -gt 0 ]; do |
| 26 | case "$1" in |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 27 | -m*) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 28 | MEMORY=1 |
| 29 | ;; |
| 30 | *) |
| 31 | echo "Unknown argument: '$1'" >&2 |
| 32 | echo "Use the source, Luke!" >&2 |
| 33 | exit 1 |
| 34 | ;; |
| 35 | esac |
| 36 | shift |
| 37 | done |
| 38 | |
| 39 | # remove built files as well as the cmake cache/config |
| 40 | cleanup() |
| 41 | { |
| 42 | make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 43 | |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 44 | find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ |
Manuel Pégourié-Gonnard | 897a595 | 2014-03-25 13:23:04 +0100 | [diff] [blame] | 45 | rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 46 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 47 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 48 | |
| 49 | if [ -f "$CONFIG_BAK" ]; then |
| 50 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 51 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 54 | trap cleanup INT TERM HUP |
| 55 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 56 | msg() |
| 57 | { |
| 58 | echo "" |
| 59 | echo "******************************************************************" |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 60 | echo "* $1 " |
| 61 | echo -n "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 62 | echo "******************************************************************" |
| 63 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 64 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 65 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 66 | # 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] | 67 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 68 | # time, so start with a GCC build). |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 69 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 70 | # |
| 71 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 72 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 73 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 74 | cleanup |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 75 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 76 | make |
| 77 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 78 | msg "test: main suites and selftest (ASan build)" # ~ 50s |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 79 | make test |
| 80 | programs/test/selftest |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 81 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 82 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 83 | cd tests |
| 84 | ./ssl-opt.sh |
| 85 | cd .. |
| 86 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 87 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 88 | tests/scripts/test-ref-configs.pl |
| 89 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 90 | # Most frequent issues are likely to be caught at this point |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 91 | |
| 92 | msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min |
| 93 | make |
| 94 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 95 | msg "test: compat.sh (ASan build)" # ~ 6 min |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 96 | cd tests |
| 97 | ./compat.sh |
| 98 | cd .. |
| 99 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 100 | msg "build: cmake, full config, clang" # ~ 50s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 101 | cleanup |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 102 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 103 | scripts/config.pl full |
| 104 | scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # too slow for tests |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 105 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check . |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 106 | make |
| 107 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 108 | msg "test: main suites (full config)" # ~ 5s |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 109 | make test |
| 110 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 111 | msg "test: ssl-opt.sh default (full config)" # ~ 1s |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 112 | cd tests |
| 113 | ./ssl-opt.sh -f Default |
| 114 | cd .. |
| 115 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 116 | msg "test: compat.sh DES & NULL (full config)" # ~ 2 min |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 117 | cd tests |
| 118 | ./compat.sh -e '^$' -f 'NULL\|3DES-EDE-CBC\|DES-CBC3' |
| 119 | cd .. |
| 120 | |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 121 | msg "test/build: curves.pl (gcc)" # ~ 5 min (?) |
| 122 | cleanup |
| 123 | cmake -D CMAKE_BUILD_TYPE:String=Debug . |
| 124 | tests/scripts/curves.pl |
| 125 | |
Manuel Pégourié-Gonnard | 61bc57a | 2014-08-14 11:29:06 +0200 | [diff] [blame] | 126 | msg "build: Unix make, -O2 (gcc)" # ~ 30s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 127 | cleanup |
Manuel Pégourié-Gonnard | 61bc57a | 2014-08-14 11:29:06 +0200 | [diff] [blame] | 128 | CC=gcc make |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 129 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 130 | msg "build: MSan (clang)" # ~ 1 min 20s |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 131 | cleanup |
| 132 | cp "$CONFIG_H" "$CONFIG_BAK" |
| 133 | scripts/config.pl unset POLARSSL_AESNI_C # memsan doesn't grok asm |
| 134 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 135 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 136 | |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame^] | 137 | msg "test: main suites (MSan)" # ~ 10s |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 138 | make test |
| 139 | |
| 140 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
| 141 | cd tests |
| 142 | ./ssl-opt.sh |
| 143 | cd .. |
| 144 | |
| 145 | # Optional part(s) |
| 146 | |
| 147 | if [ "$MEMORY" -gt 0 ]; then |
| 148 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 149 | cd tests |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 150 | ./compat.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 151 | cd .. |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 152 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 153 | |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 154 | msg "Done, cleaning up" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 155 | cleanup |
| 156 | |