blob: 205966eb6c45e4f1e98b59bb3e7c8e3cdeee404f [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 {} \+
Manuel Pégourié-Gonnard897a5952014-03-25 13:23:04 +010038 rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile
39 git update-index --no-skip-worktree {.,library,programs,tests}/Makefile
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010040 git checkout -- {.,library,programs,tests}/Makefile
41}
42
43# Step 0: compile with max warnings, with GCC and Clang
44
45if which gcc > /dev/null; then
46 cleanup
47 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
48 make
49fi
50
51if which clang > /dev/null; then
52 cleanup
53 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
54 make
55fi
56
57# Step 1: Unix Make, default compiler, all test suites/scripts
58
59cleanup
60make
61make check
62cd tests
63./compat.sh
64./ssl-opt.sh
65cd ..
66tests/scripts/test-ref-configs.pl
67
68# Step 2: using ASan
69
70if [ "$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
80fi
81
82# Step 3: using valgrind's memcheck
83
84if [ "$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?)
94fi
95
96# Done
97
98cleanup
99