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 | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 9 | # Assumes gcc and clang (recent enough for using ASan) are available, |
| 10 | # as well as cmake and valgrind. |
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 |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 24 | -m1) |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 25 | MEMORY=1 |
| 26 | ;; |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 27 | -m2) |
| 28 | MEMORY=2 |
| 29 | ;; |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 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 |
| 43 | find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ |
Manuel Pégourié-Gonnard | 897a595 | 2014-03-25 13:23:04 +0100 | [diff] [blame] | 44 | rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile |
Paul Bakker | fe0984d | 2014-06-13 00:13:45 +0200 | [diff] [blame] | 45 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile |
| 46 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 47 | } |
| 48 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 49 | msg() |
| 50 | { |
| 51 | echo "" |
| 52 | echo "******************************************************************" |
| 53 | echo "* $1" |
| 54 | echo "******************************************************************" |
| 55 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 56 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 57 | # The test ordering tries to optimize for the following criteria: |
| 58 | # 1. Catch possible problems early, by running first test that run quickly |
| 59 | # and/or are more likely to fail than others. |
| 60 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 61 | # |
| 62 | # Indicative running times are given for reference. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 63 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 64 | msg "build: cmake, gcc with lots of warnings" # ~ 1 min |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 65 | cleanup |
| 66 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 67 | make |
| 68 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 69 | msg "test: main suites with valgrind" # ~ 2 min 10s |
| 70 | make memcheck |
| 71 | |
| 72 | msg "build: with ASan" # ~ 1 min |
| 73 | cleanup |
| 74 | cmake -D CMAKE_BUILD_TYPE:String=ASan . |
| 75 | make |
| 76 | |
| 77 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min 10s |
| 78 | cd tests |
| 79 | ./ssl-opt.sh |
| 80 | cd .. |
| 81 | |
| 82 | msg "test: main suites and selftest (ASan build)" # ~ 10s + 30s |
| 83 | make test |
| 84 | programs/test/selftest |
| 85 | |
| 86 | msg "test: ref-configs (ASan build)" # ~ 4 min 45 s |
| 87 | tests/scripts/test-ref-configs.pl |
| 88 | |
| 89 | # Most issues are likely to be caught at this point |
| 90 | |
| 91 | msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min |
| 92 | make |
| 93 | |
| 94 | msg "test: compat.sh (ASan build)" # ~ 7 min 30s |
| 95 | cd tests |
| 96 | ./compat.sh |
| 97 | cd .. |
| 98 | |
| 99 | msg "build: cmake, clang with lots of warnings" # ~ 40s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 100 | cleanup |
| 101 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check . |
| 102 | make |
| 103 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 104 | msg "build: Unix make, -O2" # ~ 30s |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 105 | cleanup |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 106 | make |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 107 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 108 | # Optional parts that take a long time to run |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 109 | |
| 110 | if [ "$MEMORY" -gt 0 ]; then |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 111 | msg "test: ssl-opt --memcheck (-02 build)" # ~ 8 min |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 112 | cd tests |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 113 | ./ssl-opt.sh --memcheck |
| 114 | cd .. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 115 | |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 116 | if [ "$MEMORY" -gt 1 ]; then |
| 117 | msg "test: compat --memcheck (-02 build)" # ~ 42 min |
| 118 | cd tests |
| 119 | ./compat.sh --memcheck |
| 120 | cd .. |
| 121 | fi |
| 122 | fi |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 123 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 124 | echo "Done." |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 125 | cleanup |
| 126 | |