blob: 249be3b500f48e1cb26e7c4f1af5ff0e57f67a17 [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!
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01008#
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é-Gonnard80955ee2014-03-19 18:29:01 +010011
12# Abort on errors (and uninitiliased variables)
13set -eu
14
15if [ -d library -a -d include -a -d tests ]; then :; else
16 echo "Must be run from PolarSSL root" >&2
17 exit 1
18fi
19
20MEMORY=0
21
22while [ $# -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
34done
35
36# remove built files as well as the cmake cache/config
37cleanup()
38{
39 make clean
40 find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard897a5952014-03-25 13:23:04 +010041 rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile
42 git update-index --no-skip-worktree {.,library,programs,tests}/Makefile
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010043 git checkout -- {.,library,programs,tests}/Makefile
44}
45
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010046msg()
47{
48 echo ""
49 echo "******************************************************************"
50 echo "* $1"
51 echo "******************************************************************"
52}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010053
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010054# Step 1: various build types
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010055
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010056msg "Unix make, default compiler and flags"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010057cleanup
58make
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010059
60msg "cmake, gcc with lots of warnings"
61cleanup
62CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
63make
64
65msg "cmake, clang with lots of warnings"
66cleanup
67CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
68make
69
70# Step 2: Full tests, with ASan
71
72msg "ASan build and full tests"
73cleanup
74cmake -D CMAKE_BUILD_TYPE:String=ASan .
75make
76make test
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010077cd tests
78./compat.sh
79./ssl-opt.sh
80cd ..
81tests/scripts/test-ref-configs.pl
82
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010083# Step 3: using valgrind's memcheck
84
85if [ "$MEMORY" -gt 0 ] && which valgrind >/dev/null; then
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010086 msg "Release build, full tests with valgrind's memcheck"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010087 cleanup
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010088 # optimized build to compensate a bit for valgrind slowdown
89 cmake -D CMAKE_BUILD_TYPE:String=Release .
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010090 make
91 make memcheck
92 cd tests
93 ./compat.sh --memcheck
94 ./ssl-opt.sh --memcheck
95 cd ..
96 # no test-ref-configs: doesn't have a memcheck option (yet?)
97fi
98
99# Done
100
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100101echo "Done."
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100102cleanup
103