mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-05-05 23:52:13 +00:00
Move the code into functions. No behavior change.
Move almost all the code of this script into functions. There is no intended behavior change. The goal of this commit is to make subsequent improvements easier to follow. A very large number of lines have been reintended. To see what's going on, ignore whitespace differences (e.g. diff -w). I followed the following rules: * Minimize the amount of code that gets moved. * Don't change anything to what gets executed or displayed. * Almost all the code must end up in a function. This commit is in preparation for breaking up the sequence of tests into individual components that can run independently.
This commit is contained in:
parent
3187e7ca98
commit
57db6ff938
|
@ -80,6 +80,7 @@
|
|||
# Abort on errors (and uninitialised variables)
|
||||
set -eu
|
||||
|
||||
pre_check_environment () {
|
||||
if [ "$( uname )" != "Linux" ]; then
|
||||
echo "This script only works in Linux" >&2
|
||||
exit 1
|
||||
|
@ -87,7 +88,9 @@ elif [ -d library -a -d include -a -d tests ]; then :; else
|
|||
echo "Must be run from mbed TLS root" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
pre_initialize_variables () {
|
||||
CONFIG_H='include/mbedtls/config.h'
|
||||
CONFIG_BAK="$CONFIG_H.bak"
|
||||
|
||||
|
@ -112,6 +115,7 @@ YOTTA=1
|
|||
if [ -n "${MAKEFLAGS+set}" ]; then
|
||||
export MAKEFLAGS="-j"
|
||||
fi
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
|
@ -198,7 +202,6 @@ msg()
|
|||
current_section=$1
|
||||
}
|
||||
|
||||
if [ $RUN_ARMCC -ne 0 ]; then
|
||||
armc6_build_test()
|
||||
{
|
||||
FLAGS="$1"
|
||||
|
@ -208,7 +211,6 @@ if [ $RUN_ARMCC -ne 0 ]; then
|
|||
WARNING_CFLAGS='-xc -std=c99' make lib
|
||||
make clean
|
||||
}
|
||||
fi
|
||||
|
||||
err_msg()
|
||||
{
|
||||
|
@ -225,6 +227,7 @@ check_tools()
|
|||
done
|
||||
}
|
||||
|
||||
pre_parse_command_line () {
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--armcc) RUN_ARMCC=1;;
|
||||
|
@ -258,7 +261,9 @@ while [ $# -gt 0 ]; do
|
|||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
pre_check_git () {
|
||||
if [ $FORCE -eq 1 ]; then
|
||||
if [ $YOTTA -eq 1 ]; then
|
||||
rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
|
||||
|
@ -288,9 +293,9 @@ else
|
|||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
build_status=0
|
||||
if [ $KEEP_GOING -eq 1 ]; then
|
||||
pre_setup_keep_going () {
|
||||
failure_summary=
|
||||
failure_count=0
|
||||
start_red=
|
||||
|
@ -344,17 +349,15 @@ $text"
|
|||
echo "Killed by SIG$1."
|
||||
fi
|
||||
}
|
||||
else
|
||||
record_status () {
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
|
||||
if_build_succeeded () {
|
||||
if [ $build_status -eq 0 ]; then
|
||||
record_status "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
pre_print_configuration () {
|
||||
msg "info: $0 configuration"
|
||||
echo "MEMORY: $MEMORY"
|
||||
echo "FORCE: $FORCE"
|
||||
|
@ -367,7 +370,10 @@ echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
|
|||
echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
|
||||
echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
|
||||
echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
|
||||
}
|
||||
|
||||
# Make sure the tools we need are available.
|
||||
pre_check_tools () {
|
||||
ARMC5_CC="$ARMC5_BIN_DIR/armcc"
|
||||
ARMC5_AR="$ARMC5_BIN_DIR/armar"
|
||||
ARMC6_CC="$ARMC6_BIN_DIR/armclang"
|
||||
|
@ -384,7 +390,6 @@ if [ -n "${SEED-}" ]; then
|
|||
export SEED
|
||||
fi
|
||||
|
||||
# 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" "i686-w64-mingw32-gcc"
|
||||
|
@ -392,6 +397,13 @@ if [ $RUN_ARMCC -ne 0 ]; then
|
|||
check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
|
||||
fi
|
||||
|
||||
msg "info: 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" ARMC5_CC="$ARMC5_CC" \
|
||||
ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
|
||||
}
|
||||
|
||||
|
||||
|
||||
################################################################
|
||||
|
@ -409,11 +421,7 @@ fi
|
|||
#
|
||||
# Indicative running times are given for reference.
|
||||
|
||||
msg "info: 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" ARMC5_CC="$ARMC5_CC" \
|
||||
ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh
|
||||
run_all_the_tests () {
|
||||
|
||||
msg "test: recursion.pl" # < 1s
|
||||
record_status tests/scripts/recursion.pl library/*.c
|
||||
|
@ -905,6 +913,7 @@ fi
|
|||
cd "$MBEDTLS_ROOT_DIR"
|
||||
rm -rf "$OUT_OF_SOURCE_DIR"
|
||||
unset MBEDTLS_ROOT_DIR
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -912,7 +921,38 @@ unset MBEDTLS_ROOT_DIR
|
|||
#### Termination
|
||||
################################################################
|
||||
|
||||
post_report () {
|
||||
msg "Done, cleaning up"
|
||||
cleanup
|
||||
|
||||
final_report
|
||||
}
|
||||
|
||||
|
||||
|
||||
################################################################
|
||||
#### Run all the things
|
||||
################################################################
|
||||
|
||||
# Preliminary setup
|
||||
pre_check_environment
|
||||
pre_initialize_variables
|
||||
pre_parse_command_line "$@"
|
||||
|
||||
pre_check_git
|
||||
build_status=0
|
||||
if [ $KEEP_GOING -eq 1 ]; then
|
||||
pre_setup_keep_going
|
||||
else
|
||||
record_status () {
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
pre_print_configuration
|
||||
pre_check_tools
|
||||
cleanup
|
||||
|
||||
run_all_the_tests
|
||||
|
||||
# We're done.
|
||||
post_report
|
||||
|
|
Loading…
Reference in a new issue