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 {} \+ |
Manuel Pégourié-Gonnard | 897a595 | 2014-03-25 13:23:04 +0100 | [diff] [blame] | 38 | rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile |
| 39 | git update-index --no-skip-worktree {.,library,programs,tests}/Makefile |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 40 | git checkout -- {.,library,programs,tests}/Makefile |
| 41 | } |
| 42 | |
| 43 | # Step 0: compile with max warnings, with GCC and Clang |
| 44 | |
| 45 | if which gcc > /dev/null; then |
| 46 | cleanup |
| 47 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 48 | make |
| 49 | fi |
| 50 | |
| 51 | if which clang > /dev/null; then |
| 52 | cleanup |
| 53 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 54 | make |
| 55 | fi |
| 56 | |
| 57 | # Step 1: Unix Make, default compiler, all test suites/scripts |
| 58 | |
| 59 | cleanup |
| 60 | make |
| 61 | make check |
| 62 | cd tests |
| 63 | ./compat.sh |
| 64 | ./ssl-opt.sh |
| 65 | cd .. |
| 66 | tests/scripts/test-ref-configs.pl |
| 67 | |
| 68 | # Step 2: using ASan |
| 69 | |
| 70 | if [ "$MEMORY" -gt 0 ]; then |
| 71 | cleanup |
| 72 | cmake -D CMAKE_BUILD_TYPE:String=ASan . |
| 73 | make |
| 74 | make test |
| 75 | cd tests |
| 76 | ./compat.sh |
| 77 | ./ssl-opt.sh |
| 78 | cd .. |
| 79 | tests/scripts/test-ref-configs.pl |
| 80 | fi |
| 81 | |
| 82 | # Step 3: using valgrind's memcheck |
| 83 | |
| 84 | if [ "$MEMORY" -gt 0 ] && which valgrind >/dev/null; then |
| 85 | cleanup |
| 86 | cmake -D CMAKE_BUILD_TYPE:String=Debug . |
| 87 | make |
| 88 | make memcheck |
| 89 | cd tests |
| 90 | ./compat.sh --memcheck |
| 91 | ./ssl-opt.sh --memcheck |
| 92 | cd .. |
| 93 | # no test-ref-configs: doesn't have a memcheck option (yet?) |
| 94 | fi |
| 95 | |
| 96 | # Done |
| 97 | |
| 98 | cleanup |
| 99 | |