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! |
| 8 | |
| 9 | # Abort on errors (and uninitiliased variables) |
| 10 | set -eu |
| 11 | |
| 12 | if [ -d library -a -d include -a -d tests ]; then :; else |
| 13 | echo "Must be run from PolarSSL root" >&2 |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | MEMORY=0 |
| 18 | |
| 19 | while [ $# -gt 0 ]; do |
| 20 | case "$1" in |
| 21 | -m|--memory) |
| 22 | MEMORY=1 |
| 23 | ;; |
| 24 | *) |
| 25 | echo "Unknown argument: '$1'" >&2 |
| 26 | echo "Use the source, Luke!" >&2 |
| 27 | exit 1 |
| 28 | ;; |
| 29 | esac |
| 30 | shift |
| 31 | done |
| 32 | |
| 33 | # remove built files as well as the cmake cache/config |
| 34 | cleanup() |
| 35 | { |
| 36 | make clean |
| 37 | find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ |
| 38 | git checkout -- {.,library,programs,tests}/Makefile |
| 39 | } |
| 40 | |
| 41 | # Step 0: compile with max warnings, with GCC and Clang |
| 42 | |
| 43 | if which gcc > /dev/null; then |
| 44 | cleanup |
| 45 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 46 | make |
| 47 | fi |
| 48 | |
| 49 | if which clang > /dev/null; then |
| 50 | cleanup |
| 51 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 52 | make |
| 53 | fi |
| 54 | |
| 55 | # Step 1: Unix Make, default compiler, all test suites/scripts |
| 56 | |
| 57 | cleanup |
| 58 | make |
| 59 | make check |
| 60 | cd tests |
| 61 | ./compat.sh |
| 62 | ./ssl-opt.sh |
| 63 | cd .. |
| 64 | tests/scripts/test-ref-configs.pl |
| 65 | |
| 66 | # Step 2: using ASan |
| 67 | |
| 68 | if [ "$MEMORY" -gt 0 ]; then |
| 69 | cleanup |
| 70 | cmake -D CMAKE_BUILD_TYPE:String=ASan . |
| 71 | make |
| 72 | make test |
| 73 | cd tests |
| 74 | ./compat.sh |
| 75 | ./ssl-opt.sh |
| 76 | cd .. |
| 77 | tests/scripts/test-ref-configs.pl |
| 78 | fi |
| 79 | |
| 80 | # Step 3: using valgrind's memcheck |
| 81 | |
| 82 | if [ "$MEMORY" -gt 0 ] && which valgrind >/dev/null; then |
| 83 | cleanup |
| 84 | cmake -D CMAKE_BUILD_TYPE:String=Debug . |
| 85 | make |
| 86 | make memcheck |
| 87 | cd tests |
| 88 | ./compat.sh --memcheck |
| 89 | ./ssl-opt.sh --memcheck |
| 90 | cd .. |
| 91 | # no test-ref-configs: doesn't have a memcheck option (yet?) |
| 92 | fi |
| 93 | |
| 94 | # Done |
| 95 | |
| 96 | cleanup |
| 97 | |