blob: 8dba3ecab8d4bf1bd7cb9b081772b389b0eab4b6 [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é-Gonnard2be0b522014-03-27 20:16:07 +010077programs/test/selftest
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010078cd tests
79./compat.sh
80./ssl-opt.sh
81cd ..
82tests/scripts/test-ref-configs.pl
83
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010084# Step 3: using valgrind's memcheck
85
86if [ "$MEMORY" -gt 0 ] && which valgrind >/dev/null; then
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010087 msg "Release build, full tests with valgrind's memcheck"
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010088 cleanup
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010089 # optimized build to compensate a bit for valgrind slowdown
90 cmake -D CMAKE_BUILD_TYPE:String=Release .
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010091 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?)
98fi
99
100# Done
101
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100102echo "Done."
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100103cleanup
104