blob: c88757ce57b469e6e1b1ab3df02e5e2c163adf89 [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#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02009# Assumes gcc and clang (recent enough for using ASan) are available,
10# as well as cmake and valgrind.
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
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +020024 -m1)
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010025 MEMORY=1
26 ;;
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +020027 -m2)
28 MEMORY=2
29 ;;
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010030 *)
31 echo "Unknown argument: '$1'" >&2
32 echo "Use the source, Luke!" >&2
33 exit 1
34 ;;
35 esac
36 shift
37done
38
39# remove built files as well as the cmake cache/config
40cleanup()
41{
42 make clean
43 find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
Manuel Pégourié-Gonnard897a5952014-03-25 13:23:04 +010044 rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile
Paul Bakkerfe0984d2014-06-13 00:13:45 +020045 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é-Gonnard80955ee2014-03-19 18:29:01 +010047}
48
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010049msg()
50{
51 echo ""
52 echo "******************************************************************"
53 echo "* $1"
54 echo "******************************************************************"
55}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010056
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +020057# 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é-Gonnard80955ee2014-03-19 18:29:01 +010063
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +020064msg "build: cmake, gcc with lots of warnings" # ~ 1 min
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010065cleanup
66CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
67make
68
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +020069msg "test: main suites with valgrind" # ~ 2 min 10s
70make memcheck
71
72msg "build: with ASan" # ~ 1 min
73cleanup
74cmake -D CMAKE_BUILD_TYPE:String=ASan .
75make
76
77msg "test: ssl-opt.sh (ASan build)" # ~ 1 min 10s
78cd tests
79./ssl-opt.sh
80cd ..
81
82msg "test: main suites and selftest (ASan build)" # ~ 10s + 30s
83make test
84programs/test/selftest
85
86msg "test: ref-configs (ASan build)" # ~ 4 min 45 s
87tests/scripts/test-ref-configs.pl
88
89# Most issues are likely to be caught at this point
90
91msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
92make
93
94msg "test: compat.sh (ASan build)" # ~ 7 min 30s
95cd tests
96./compat.sh
97cd ..
98
99msg "build: cmake, clang with lots of warnings" # ~ 40s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100100cleanup
101CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
102make
103
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200104msg "build: Unix make, -O2" # ~ 30s
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100105cleanup
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100106make
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100107
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200108# Optional parts that take a long time to run
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +0200109
110if [ "$MEMORY" -gt 0 ]; then
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200111 msg "test: ssl-opt --memcheck (-02 build)" # ~ 8 min
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100112 cd tests
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100113 ./ssl-opt.sh --memcheck
114 cd ..
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100115
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200116 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
122fi
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100123
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100124echo "Done."
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100125cleanup
126