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 | # |
| 9 | # Assumes gcc, clang (recent enough for using ASan) are available, as weel as |
| 10 | # cmake. Also assumes valgrind is available if --memcheck is used. |
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 | |
| 20 | MEMORY=0 |
| 21 | |
| 22 | while [ $# -gt 0 ]; do |
| 23 | case "$1" in |
| 24 | -m|--memory) |
| 25 | MEMORY=1 |
| 26 | ;; |
| 27 | *) |
| 28 | echo "Unknown argument: '$1'" >&2 |
| 29 | echo "Use the source, Luke!" >&2 |
| 30 | exit 1 |
| 31 | ;; |
| 32 | esac |
| 33 | shift |
| 34 | done |
| 35 | |
| 36 | # remove built files as well as the cmake cache/config |
| 37 | cleanup() |
| 38 | { |
| 39 | make clean |
| 40 | find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ |
Manuel Pégourié-Gonnard | 897a595 | 2014-03-25 13:23:04 +0100 | [diff] [blame] | 41 | rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile |
| 42 | git update-index --no-skip-worktree {.,library,programs,tests}/Makefile |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 43 | git checkout -- {.,library,programs,tests}/Makefile |
| 44 | } |
| 45 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 46 | msg() |
| 47 | { |
| 48 | echo "" |
| 49 | echo "******************************************************************" |
| 50 | echo "* $1" |
| 51 | echo "******************************************************************" |
| 52 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 53 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 54 | # Step 1: various build types |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 55 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 56 | msg "Unix make, default compiler and flags" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 57 | cleanup |
| 58 | make |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 59 | |
| 60 | msg "cmake, gcc with lots of warnings" |
| 61 | cleanup |
| 62 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 63 | make |
| 64 | |
| 65 | msg "cmake, clang with lots of warnings" |
| 66 | cleanup |
| 67 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 68 | make |
| 69 | |
| 70 | # Step 2: Full tests, with ASan |
| 71 | |
| 72 | msg "ASan build and full tests" |
| 73 | cleanup |
| 74 | cmake -D CMAKE_BUILD_TYPE:String=ASan . |
| 75 | make |
| 76 | make test |
Manuel Pégourié-Gonnard | 2be0b52 | 2014-03-27 20:16:07 +0100 | [diff] [blame] | 77 | programs/test/selftest |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 78 | cd tests |
| 79 | ./compat.sh |
| 80 | ./ssl-opt.sh |
| 81 | cd .. |
| 82 | tests/scripts/test-ref-configs.pl |
| 83 | |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 84 | # Step 3: using valgrind's memcheck |
| 85 | |
| 86 | if [ "$MEMORY" -gt 0 ] && which valgrind >/dev/null; then |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 87 | msg "Release build, full tests with valgrind's memcheck" |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 88 | cleanup |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 89 | # optimized build to compensate a bit for valgrind slowdown |
| 90 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 91 | make |
| 92 | make memcheck |
| 93 | cd tests |
| 94 | ./compat.sh --memcheck |
| 95 | ./ssl-opt.sh --memcheck |
| 96 | cd .. |
| 97 | # no test-ref-configs: doesn't have a memcheck option (yet?) |
| 98 | fi |
| 99 | |
| 100 | # Done |
| 101 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 102 | echo "Done." |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 103 | cleanup |
| 104 | |