all.sh: don't insist on Linux; always run Valgrind

Don't bail out of all.sh if the OS isn't Linux. We only expect
everything to pass on a recent Linux x86_64, but it's useful to call
all.sh to run some components on any platform.

In all.sh, always run both MemorySanitizer and Valgrind. Valgrind is
slower than ASan and MSan but finds some things that they don't.

Run MSan unconditionally, not just on Linux/x86_64. MSan is supported
on some other OSes and CPUs these days.

Use `all.sh --except test_memsan` if you want to omit MSan because it
isn't supported on your platform. Use `all.sh --except test_memcheck`
if you want to omit Valgrind because it's too slow.

Make the test scripts more portable (tested on FreeBSD): don't insist
on GNU sed, and recognize amd64 as well as x86_64 for `uname -m`. The
`make` utility must still be GNU make.
This commit is contained in:
Gilles Peskine 2019-01-06 19:58:02 +00:00
parent 4976e82a9e
commit a16c2b1ff1
2 changed files with 12 additions and 19 deletions

View file

@ -91,10 +91,7 @@
set -eu
pre_check_environment () {
if [ "$( uname )" != "Linux" ]; then
echo "This script only works in Linux" >&2
exit 1
elif [ -d library -a -d include -a -d tests ]; then :; else
if [ -d library -a -d include -a -d tests ]; then :; else
echo "Must be run from mbed TLS root" >&2
exit 1
fi
@ -1207,14 +1204,14 @@ run_all_components () {
run_component component_test_aes_fewer_tables
run_component component_test_aes_rom_tables
run_component component_test_aes_fewer_tables_and_rom_tables
if uname -a | grep -F Linux >/dev/null; then
run_component component_test_make_shared
fi
if uname -a | grep -F x86_64 >/dev/null; then
run_component component_test_m32_o0
run_component component_test_m32_o1
run_component component_test_mx32
fi
run_component component_test_make_shared
case $(uname -m) in
amd64|x86_64)
run_component component_test_m32_o0
run_component component_test_m32_o1
run_component component_test_mx32
;;
esac
run_component component_test_have_int32
run_component component_test_have_int64
run_component component_test_no_udbl_division
@ -1225,12 +1222,8 @@ run_all_components () {
run_component component_build_armcc
run_component component_test_allow_sha1
run_component component_build_mingw
# MemSan currently only available on Linux 64 bits
if uname -a | grep 'Linux.*x86_64' >/dev/null; then
run_component component_test_memsan
else # no MemSan
run_component component_test_memcheck
fi
run_component component_test_memsan
run_component component_test_memcheck
run_component component_test_cmake_out_of_source
# More small things

View file

@ -167,7 +167,7 @@ requires_config_disabled() {
get_config_value_or_default() {
NAME="$1"
DEF_VAL=$( grep ".*#define.*${NAME}" ../include/mbedtls/config.h |
sed 's/^.*\s\([0-9]*\)$/\1/' )
sed 's/^.* \([0-9]*\)$/\1/' )
../scripts/config.pl get $NAME || echo "$DEF_VAL"
}