blob: e9aa1ba00e409e1d2f96fba569c29d0a4c9e6801 [file] [log] [blame]
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001#!/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)
10set -eu
11
12if [ -d library -a -d include -a -d tests ]; then :; else
13 echo "Must be run from PolarSSL root" >&2
14 exit 1
15fi
16
17MEMORY=0
18
19while [ $# -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
31done
32
33# remove built files as well as the cmake cache/config
34cleanup()
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
43if which gcc > /dev/null; then
44 cleanup
45 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
46 make
47fi
48
49if which clang > /dev/null; then
50 cleanup
51 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
52 make
53fi
54
55# Step 1: Unix Make, default compiler, all test suites/scripts
56
57cleanup
58make
59make check
60cd tests
61./compat.sh
62./ssl-opt.sh
63cd ..
64tests/scripts/test-ref-configs.pl
65
66# Step 2: using ASan
67
68if [ "$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
78fi
79
80# Step 3: using valgrind's memcheck
81
82if [ "$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?)
92fi
93
94# Done
95
96cleanup
97