Allow alternate openssl and gnutls in all.sh

Allow the user to specify alternative openssl, gnutls-cli and
gnutls-serv binaries to execute legacy tests in all.sh.
This commit is contained in:
Andres AG 2016-08-26 14:42:14 +01:00 committed by Simon Butcher
parent 669c635ec0
commit d9eba4ba3d

View file

@ -23,7 +23,7 @@
set -eu set -eu
if [ -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 err_msg "Must be run from mbed TLS root"
exit 1 exit 1
fi fi
@ -31,19 +31,30 @@ CONFIG_H='include/mbedtls/config.h'
CONFIG_BAK="$CONFIG_H.bak" CONFIG_BAK="$CONFIG_H.bak"
MEMORY=0 MEMORY=0
SHORT=0
FORCE=0 FORCE=0
# Default commands, can be overriden by the environment
: ${OPENSSL:="openssl"}
: ${OPENSSL_LEGACY:="$OPENSSL"}
: ${GNUTLS_CLI:="gnutls-cli"}
: ${GNUTLS_SERV:="gnutls-serv"}
: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
usage() usage()
{ {
echo "Usage: $0" printf "Usage: $0\n"
echo -e " -h|--help\t\tPrint this help." printf " -h|--help\t\tPrint this help.\n"
echo -e " -m|--memory\t\tAdditional optional memory tests." printf " -m|--memory\t\tAdditional optional memory tests.\n"
echo -e " -s|--short\t\tSubset of tests." printf " -f|--force\t\tForce the tests to overwrite any modified files.\n"
echo -e " -f|--force\t\tForce the tests to overwrite any modified files." printf " --out-of-source-dir\t\tDirectory used for CMake out-of-source build tests."
echo -e " --out-of-source-dir\t\tDirectory used for CMake out-of-source build tests." printf " --openssl=<OpenSSL_path>\t\tPath to OpenSSL executable to use for most tests.\n"
printf " --openssl-legacy=<OpenSSL_path>\t\tPath to OpenSSL executable to use for legacy tests e.g. SSLv3.\n"
printf " --gnutls-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for most tests.\n"
printf " --gnutls-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for most tests.\n"
printf " --gnutls-legacy-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for legacy tests.\n"
printf " --gnutls-legacy-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for legacy tests.\n"
} }
# remove built files as well as the cmake cache/config # remove built files as well as the cmake cache/config
@ -72,14 +83,26 @@ msg()
echo "******************************************************************" echo "******************************************************************"
} }
err_msg()
{
echo "$1" >&2
}
check_tools()
{
for TOOL in "$@"; do
if ! `hash "$TOOL" >/dev/null 2>&1`; then
err_msg "$TOOL not found!"
exit 1
fi
done
}
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
--memory|-m*) --memory|-m*)
MEMORY=${1#-m} MEMORY=${1#-m}
;; ;;
--short|-s)
SHORT=1
;;
--force|-f) --force|-f)
FORCE=1 FORCE=1
;; ;;
@ -87,8 +110,32 @@ while [ $# -gt 0 ]; do
shift shift
OUT_OF_SOURCE_DIR="$1" OUT_OF_SOURCE_DIR="$1"
;; ;;
--openssl)
shift
OPENSSL="$1"
;;
--openssl-legacy)
shift
OPENSSL_LEGACY="$1"
;;
--gnutls-cli)
shift
GNUTLS_CLI="$1"
;;
--gnutls-serv)
shift
GNUTLS_SERV="$1"
;;
--gnutls-legacy-cli)
shift
GNUTLS_LEGACY_CLI="$1"
;;
--gnutls-legacy-serv)
shift
GNUTLS_LEGACY_SERV="$1"
;;
--help|-h|*) --help|-h|*)
usage() usage
exit 1 exit 1
;; ;;
esac esac
@ -102,7 +149,7 @@ if [ $FORCE -eq 1 ]; then
else else
if [ -d yotta/module ]; then if [ -d yotta/module ]; then
echo "Warning - there is an existing yotta module in the directory 'yotta/module'" >&2 err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
echo "You can either delete your work and retry, or force the test to overwrite the" echo "You can either delete your work and retry, or force the test to overwrite the"
echo "test by rerunning the script as: $0 --force" echo "test by rerunning the script as: $0 --force"
exit 1 exit 1
@ -117,13 +164,28 @@ else
if ! git diff-files --quiet include/mbedtls/config.h; then if ! git diff-files --quiet include/mbedtls/config.h; then
echo $? echo $?
echo "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " >&2 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
echo "You can either delete or preserve your work, or force the test by rerunning the" echo "You can either delete or preserve your work, or force the test by rerunning the"
echo "script as: $0 --force" echo "script as: $0 --force"
exit 1 exit 1
fi fi
fi fi
msg "info: $0 configuration"
echo "MEMORY: $MEMORY"
echo "FORCE: $FORCE"
echo "OPENSSL: $OPENSSL"
echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
echo "GNUTLS_CLI: $GNUTLS_CLI"
echo "GNUTLS_SERV: $GNUTLS_SERV"
echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
# Make sure the tools we need are available.
check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
"$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
"arm-none-eabi-gcc" "armcc"
# #
# Test Suites to be executed # Test Suites to be executed
# #
@ -136,7 +198,9 @@ fi
# Indicative running times are given for reference. # Indicative running times are given for reference.
msg "info: output_env.sh" msg "info: output_env.sh"
scripts/output_env.sh OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" scripts/output_env.sh
msg "test: recursion.pl" # < 1s msg "test: recursion.pl" # < 1s
tests/scripts/recursion.pl library/*.c tests/scripts/recursion.pl library/*.c
@ -151,11 +215,9 @@ msg "test/build: declared and exported names" # < 3s
cleanup cleanup
tests/scripts/check-names.sh tests/scripts/check-names.sh
if which doxygen >/dev/null; then msg "test: doxygen warnings" # ~ 3s
msg "test: doxygen warnings" # ~ 3s cleanup
cleanup tests/scripts/doxygen.sh
tests/scripts/doxygen.sh
fi
msg "build: create and build yotta module" # ~ 30s msg "build: create and build yotta module" # ~ 30s
cleanup cleanup
@ -175,13 +237,6 @@ tests/ssl-opt.sh
msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
tests/scripts/test-ref-configs.pl tests/scripts/test-ref-configs.pl
# Most frequent issues are likely to be caught at this point
if [ $SHORT -eq 1 ]; then
msg "Done, cleaning up"
cleanup
exit 0
fi
msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
make make
@ -199,7 +254,8 @@ msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
make test make test
msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
tests/compat.sh -m 'ssl3 tls1 tls1_1 tls1_2 dtls1 dtls1_2' tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
tests/ssl-opt.sh tests/ssl-opt.sh
@ -219,7 +275,7 @@ msg "test: ssl-opt.sh default (full config)" # ~ 1s
tests/ssl-opt.sh -f Default tests/ssl-opt.sh -f Default
msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR' OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
msg "test/build: curves.pl (gcc)" # ~ 4 min msg "test/build: curves.pl (gcc)" # ~ 4 min
cleanup cleanup
@ -311,7 +367,6 @@ cleanup
CC=gcc CFLAGS='-Werror -m32' make CC=gcc CFLAGS='-Werror -m32' make
fi # x86_64 fi # x86_64
if which arm-none-eabi-gcc >/dev/null; then
msg "build: arm-none-eabi-gcc, make" # ~ 10s msg "build: arm-none-eabi-gcc, make" # ~ 10s
cleanup cleanup
cp "$CONFIG_H" "$CONFIG_BAK" cp "$CONFIG_H" "$CONFIG_BAK"
@ -328,9 +383,7 @@ scripts/config.pl unset MBEDTLS_THREADING_C
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror make lib CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror make lib
fi # arm-gcc
if which armcc >/dev/null && armcc --help >/dev/null 2>&1; then
msg "build: armcc, make" msg "build: armcc, make"
cleanup cleanup
cp "$CONFIG_H" "$CONFIG_BAK" cp "$CONFIG_H" "$CONFIG_BAK"
@ -351,7 +404,6 @@ scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
CC=armcc AR=armar WARNING_CFLAGS= make lib CC=armcc AR=armar WARNING_CFLAGS= make lib
fi # armcc
if which i686-w64-mingw32-gcc >/dev/null; then if which i686-w64-mingw32-gcc >/dev/null; then
msg "build: cross-mingw64, make" # ~ 30s msg "build: cross-mingw64, make" # ~ 30s