Merge miscellaneous fixes into development

This commit is contained in:
Paul Bakker 2015-01-13 16:04:38 +01:00
commit d7e2483bfc
57 changed files with 1292 additions and 369 deletions

View file

@ -6,8 +6,8 @@
# CMake configuration. After this script is run, the CMake cache is lost and
# CMake is not initialised any more!
#
# Assumes gcc and clang (recent enough for using ASan) are available,
# as well as cmake and valgrind.
# Assumes gcc and clang (recent enough for using ASan with gcc and MemSen with
# clang) are available, as well as cmake and GNU find.
# Abort on errors (and uninitiliased variables)
set -eu
@ -24,12 +24,9 @@ MEMORY=0
while [ $# -gt 0 ]; do
case "$1" in
-m1)
-m*)
MEMORY=1
;;
-m2)
MEMORY=2
;;
*)
echo "Unknown argument: '$1'" >&2
echo "Use the source, Luke!" >&2
@ -60,94 +57,103 @@ msg()
{
echo ""
echo "******************************************************************"
echo "* $1"
echo "* $1 "
echo -n "* "; date
echo "******************************************************************"
}
# The test ordering tries to optimize for the following criteria:
# 1. Catch possible problems early, by running first test that run quickly
# 1. Catch possible problems early, by running first tests that run quickly
# and/or are more likely to fail than others (eg I use Clang most of the
# time, so start with a GCC build).
# 2. Minimize total running time, by avoiding useless rebuilds
#
# Indicative running times are given for reference.
msg "build: cmake, -Werror (gcc)" # ~ 1 min
msg "test: recursion.pl" # < 1s
scripts/recursion.pl library/*.c
msg "build: cmake, gcc, ASan" # ~ 1 min 50s
cleanup
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
make
msg "test: main suites with valgrind" # ~ 2 min 10s
make memcheck
msg "test: main suites and selftest (ASan build)" # ~ 50s
make test
programs/test/selftest
msg "build: with ASan (clang)" # ~ 1 min
cleanup
CC=clang cmake -D CMAKE_BUILD_TYPE:String=ASan .
make
msg "test: ssl-opt.sh (ASan build)" # ~ 1 min 10s
msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
cd tests
./ssl-opt.sh
cd ..
msg "test: main suites and selftest (ASan build)" # ~ 10s + 30s
make test
programs/test/selftest
msg "test: ref-configs (ASan build)" # ~ 4 min 45 s
msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
tests/scripts/test-ref-configs.pl
# Most issues are likely to be caught at this point
# Most frequent issues are likely to be caught at this point
msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
make
msg "test: compat.sh (ASan build)" # ~ 7 min 30s
msg "test: compat.sh (ASan build)" # ~ 6 min
cd tests
./compat.sh
cd ..
msg "build: cmake, full config" # ~ 40s
msg "build: cmake, full config, clang" # ~ 50s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset POLARSSL_MEMORY_BACKTRACE # too slow for tests
cmake -D CMAKE_BUILD_TYPE:String=Check .
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
make
msg "test: main suites (full config)"
msg "test: main suites (full config)" # ~ 5s
make test
msg "test: ssl-opt.sh default (full config)"
msg "test: ssl-opt.sh default (full config)" # ~ 1s
cd tests
./ssl-opt.sh -f Default
cd ..
msg "test: compat.sh 3DES & NULL (full config)"
msg "test: compat.sh DES & NULL (full config)" # ~ 2 min
cd tests
./compat.sh -e '^$' -f 'NULL\|3DES-EDE-CBC\|DES-CBC3'
cd ..
msg "test/build: curves.pl (gcc)" # ~ 5 min (?)
cleanup
cmake -D CMAKE_BUILD_TYPE:String=Debug .
tests/scripts/curves.pl
msg "build: Unix make, -O2 (gcc)" # ~ 30s
cleanup
CC=gcc make
# Optional parts that take a long time to run
msg "build: MSan (clang)" # ~ 1 min 20s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl unset POLARSSL_AESNI_C # memsan doesn't grok asm
CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
make
if [ "$MEMORY" -ge 1 ]; then
msg "test: ssl-opt --memcheck (-02 build)" # ~ 8 min
msg "test: main suites (MSan)" # ~ 10s
make test
msg "test: ssl-opt.sh (MSan)" # ~ 1 min
cd tests
./ssl-opt.sh
cd ..
# Optional part(s)
if [ "$MEMORY" -gt 0 ]; then
msg "test: compat.sh (MSan)" # ~ 6 min 20s
cd tests
./ssl-opt.sh --memcheck
./compat.sh
cd ..
if [ "$MEMORY" -ge 2 ]; then
msg "test: compat --memcheck (-02 build)" # ~ 42 min
cd tests
./compat.sh --memcheck
cd ..
fi
fi
echo "Done."
msg "Done, cleaning up"
cleanup

45
tests/scripts/curves.pl Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/perl
# test dependencies on individual curves in tests
# - build
# - run test suite
#
# Usage: tests/scripts/curves.pl
use warnings;
use strict;
-d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
my $sed_cmd = 's/^#define \(POLARSSL_ECP_DP.*_ENABLED\)/\1/p';
my $config_h = 'include/polarssl/config.h';
my @curves = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` );
my $test = system( "grep -i cmake Makefile >/dev/null" ) ? 'check' : 'test';
system( "cp $config_h $config_h.bak" ) and die;
sub abort {
system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
die $_[0];
}
for my $curve (@curves) {
system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
system( "make clean" ) and die;
print "\n******************************************\n";
print "* Testing without curve: $curve\n";
print "******************************************\n";
system( "scripts/config.pl unset $curve" )
and abort "Failed to disable $curve\n";
system( "make polarssl" ) and abort "Failed to build lib: $curve\n";
system( "cd tests && make" ) and abort "Failed to build tests: $curve\n";
system( "make $test" ) and abort "Failed test suite: $curve\n";
}
system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
system( "make clean" ) and die;
exit 0;