2014-03-19 17:29:01 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Run all available tests (mostly).
|
|
|
|
#
|
|
|
|
# Warning: includes various build modes, so it will mess with the current
|
|
|
|
# CMake configuration. After this script is run, the CMake cache is lost and
|
|
|
|
# CMake is not initialised any more!
|
2014-03-27 13:44:04 +00:00
|
|
|
#
|
|
|
|
# Assumes gcc, clang (recent enough for using ASan) are available, as weel as
|
|
|
|
# cmake. Also assumes valgrind is available if --memcheck is used.
|
2014-03-19 17:29:01 +00:00
|
|
|
|
|
|
|
# Abort on errors (and uninitiliased variables)
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
if [ -d library -a -d include -a -d tests ]; then :; else
|
|
|
|
echo "Must be run from PolarSSL root" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
MEMORY=0
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
-m|--memory)
|
|
|
|
MEMORY=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown argument: '$1'" >&2
|
|
|
|
echo "Use the source, Luke!" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# remove built files as well as the cmake cache/config
|
|
|
|
cleanup()
|
|
|
|
{
|
|
|
|
make clean
|
|
|
|
find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
|
2014-03-25 12:23:04 +00:00
|
|
|
rm -f include/Makefile include/polarssl/Makefile programs/*/Makefile
|
|
|
|
git update-index --no-skip-worktree {.,library,programs,tests}/Makefile
|
2014-03-19 17:29:01 +00:00
|
|
|
git checkout -- {.,library,programs,tests}/Makefile
|
|
|
|
}
|
|
|
|
|
2014-03-27 13:44:04 +00:00
|
|
|
msg()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
echo "******************************************************************"
|
|
|
|
echo "* $1"
|
|
|
|
echo "******************************************************************"
|
|
|
|
}
|
2014-03-19 17:29:01 +00:00
|
|
|
|
2014-03-27 13:44:04 +00:00
|
|
|
# Step 1: various build types
|
2014-03-19 17:29:01 +00:00
|
|
|
|
2014-03-27 13:44:04 +00:00
|
|
|
msg "Unix make, default compiler and flags"
|
|
|
|
cleanup
|
|
|
|
make
|
|
|
|
|
|
|
|
msg "cmake, gcc with lots of warnings"
|
|
|
|
cleanup
|
|
|
|
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
|
|
|
|
make
|
|
|
|
|
|
|
|
msg "cmake, clang with lots of warnings"
|
|
|
|
cleanup
|
|
|
|
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
|
|
|
|
make
|
2014-03-19 17:29:01 +00:00
|
|
|
|
2014-03-27 13:44:04 +00:00
|
|
|
# Step 2: Full tests, with ASan
|
2014-03-19 17:29:01 +00:00
|
|
|
|
2014-03-27 13:44:04 +00:00
|
|
|
msg "ASan build and full tests"
|
2014-03-19 17:29:01 +00:00
|
|
|
cleanup
|
2014-03-27 13:44:04 +00:00
|
|
|
cmake -D CMAKE_BUILD_TYPE:String=ASan .
|
2014-03-19 17:29:01 +00:00
|
|
|
make
|
2014-03-27 13:44:04 +00:00
|
|
|
make test
|
2014-03-19 17:29:01 +00:00
|
|
|
cd tests
|
|
|
|
./compat.sh
|
|
|
|
./ssl-opt.sh
|
|
|
|
cd ..
|
|
|
|
tests/scripts/test-ref-configs.pl
|
|
|
|
|
|
|
|
# Step 3: using valgrind's memcheck
|
|
|
|
|
|
|
|
if [ "$MEMORY" -gt 0 ] && which valgrind >/dev/null; then
|
2014-03-27 13:44:04 +00:00
|
|
|
msg "Release build, full tests with valgrind's memcheck"
|
2014-03-19 17:29:01 +00:00
|
|
|
cleanup
|
2014-03-27 13:44:04 +00:00
|
|
|
# optimized build to compensate a bit for valgrind slowdown
|
|
|
|
cmake -D CMAKE_BUILD_TYPE:String=Release .
|
2014-03-19 17:29:01 +00:00
|
|
|
make
|
|
|
|
make memcheck
|
|
|
|
cd tests
|
|
|
|
./compat.sh --memcheck
|
|
|
|
./ssl-opt.sh --memcheck
|
|
|
|
cd ..
|
|
|
|
# no test-ref-configs: doesn't have a memcheck option (yet?)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Done
|
|
|
|
|
2014-03-27 13:44:04 +00:00
|
|
|
echo "Done."
|
2014-03-19 17:29:01 +00:00
|
|
|
cleanup
|
|
|
|
|