Merge pull request #2639 from mpg/use-all-sh-checks-for-pre-push

Use all.sh and its component list in pre-push hook
This commit is contained in:
Gilles Peskine 2020-06-23 14:37:16 +02:00 committed by GitHub
commit 04c6b61f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 20 deletions

View File

@ -45,18 +45,4 @@ echo "URL is $URL"
set -eu set -eu
run_test() tests/scripts/all.sh -q -k 'check_*'
{
TEST=$1
echo "running '$TEST'"
if ! `$TEST > /dev/null 2>&1`; then
echo "test '$TEST' failed"
return 1
fi
}
run_test ./tests/scripts/check-doxy-blocks.pl
run_test ./tests/scripts/check-names.sh
run_test ./tests/scripts/check-generated-files.sh
run_test ./tests/scripts/check-files.py
run_test ./tests/scripts/doxygen.sh

View File

@ -133,6 +133,7 @@ pre_initialize_variables () {
append_outcome=0 append_outcome=0
MEMORY=0 MEMORY=0
FORCE=0 FORCE=0
QUIET=0
KEEP_GOING=0 KEEP_GOING=0
# Seed value used with the --release-test option. # Seed value used with the --release-test option.
@ -221,6 +222,7 @@ Special options:
--list-components List components supported on this platform and exit. --list-components List components supported on this platform and exit.
General options: General options:
-q|--quiet Only output component names, and errors if any.
-f|--force Force the tests to overwrite any modified files. -f|--force Force the tests to overwrite any modified files.
-k|--keep-going Run all tests and report errors at the end. -k|--keep-going Run all tests and report errors at the end.
-m|--memory Additional optional memory tests. -m|--memory Additional optional memory tests.
@ -236,6 +238,7 @@ General options:
--no-force Refuse to overwrite modified files (default). --no-force Refuse to overwrite modified files (default).
--no-keep-going Stop at the first error (default). --no-keep-going Stop at the first error (default).
--no-memory No additional memory tests (default). --no-memory No additional memory tests (default).
--no-quiet Print full ouput from components.
--out-of-source-dir=<path> Directory used for CMake out-of-source build tests. --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
--outcome-file=<path> File where test outcomes are written (not done if --outcome-file=<path> File where test outcomes are written (not done if
empty; default: \$MBEDTLS_TEST_OUTCOME_FILE). empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
@ -309,6 +312,11 @@ msg()
else else
current_section="$1" current_section="$1"
fi fi
if [ $QUIET -eq 1 ]; then
return
fi
echo "" echo ""
echo "******************************************************************" echo "******************************************************************"
echo "* $current_section " echo "* $current_section "
@ -384,11 +392,13 @@ pre_parse_command_line () {
--no-force) FORCE=0;; --no-force) FORCE=0;;
--no-keep-going) KEEP_GOING=0;; --no-keep-going) KEEP_GOING=0;;
--no-memory) MEMORY=0;; --no-memory) MEMORY=0;;
--no-quiet) QUIET=0;;
--openssl) shift; OPENSSL="$1";; --openssl) shift; OPENSSL="$1";;
--openssl-legacy) shift; OPENSSL_LEGACY="$1";; --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
--openssl-next) shift; OPENSSL_NEXT="$1";; --openssl-next) shift; OPENSSL_NEXT="$1";;
--outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";; --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
--out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
--quiet|-q) QUIET=1;;
--random-seed) unset SEED;; --random-seed) unset SEED;;
--release-test|-r) SEED=$RELEASE_SEED;; --release-test|-r) SEED=$RELEASE_SEED;;
--seed|-s) shift; SEED="$1";; --seed|-s) shift; SEED="$1";;
@ -470,7 +480,7 @@ pre_setup_keep_going () {
failure_summary="$failure_summary failure_summary="$failure_summary
$text" $text"
failure_count=$((failure_count + 1)) failure_count=$((failure_count + 1))
echo "${start_red}^^^^$text^^^^${end_color}" echo "${start_red}^^^^$text^^^^${end_color}" >&2
fi fi
} }
make () { make () {
@ -516,6 +526,24 @@ not() {
! "$@" ! "$@"
} }
pre_setup_quiet_redirect () {
if [ $QUIET -ne 1 ]; then
redirect_out () {
"$@"
}
redirect_err () {
"$@"
}
else
redirect_out () {
"$@" >/dev/null
}
redirect_err () {
"$@" 2>/dev/null
}
fi
}
pre_prepare_outcome_file () { pre_prepare_outcome_file () {
case "$MBEDTLS_TEST_OUTCOME_FILE" in case "$MBEDTLS_TEST_OUTCOME_FILE" in
[!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
@ -526,6 +554,10 @@ pre_prepare_outcome_file () {
} }
pre_print_configuration () { pre_print_configuration () {
if [ $QUIET -eq 1 ]; then
return
fi
msg "info: $0 configuration" msg "info: $0 configuration"
echo "MEMORY: $MEMORY" echo "MEMORY: $MEMORY"
echo "FORCE: $FORCE" echo "FORCE: $FORCE"
@ -600,6 +632,11 @@ pre_check_tools () {
"$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
esac esac
# past this point, no call to check_tool, only printing output
if [ $QUIET -eq 1 ]; then
return
fi
msg "info: output_env.sh" msg "info: output_env.sh"
case $RUN_COMPONENTS in case $RUN_COMPONENTS in
*_armcc*) *_armcc*)
@ -665,7 +702,13 @@ component_check_names () {
component_check_test_cases () { component_check_test_cases () {
msg "Check: test case descriptions" # < 1s msg "Check: test case descriptions" # < 1s
record_status tests/scripts/check-test-cases.py if [ $QUIET -eq 1 ]; then
opt='--quiet'
else
opt=''
fi
record_status tests/scripts/check-test-cases.py $opt
unset opt
} }
component_check_doxygen_warnings () { component_check_doxygen_warnings () {
@ -1919,7 +1962,10 @@ component_check_python_files () {
component_check_generate_test_code () { component_check_generate_test_code () {
msg "uint test: generate_test_code.py" msg "uint test: generate_test_code.py"
record_status ./tests/scripts/test_generate_test_code.py # unittest writes out mundane stuff like number or tests run on stderr.
# Our convention is to reserve stderr for actual errors, and write
# harmless info on stdout so it can be suppress with --quiet.
record_status ./tests/scripts/test_generate_test_code.py 2>&1
} }
################################################################ ################################################################
@ -1950,13 +1996,18 @@ run_component () {
# Unconditionally create a seedfile that's sufficiently long. # Unconditionally create a seedfile that's sufficiently long.
# Do this before each component, because a previous component may # Do this before each component, because a previous component may
# have messed it up or shortened it. # have messed it up or shortened it.
dd if=/dev/urandom of=./tests/seedfile bs=64 count=1 redirect_err dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
# Run the component code. # Run the component code.
"$@" if [ $QUIET -eq 1 ]; then
# msg() is silenced, so just print the component name here
echo "${current_component#component_}"
fi
redirect_out "$@"
# Restore the build tree to a clean state. # Restore the build tree to a clean state.
cleanup cleanup
unset current_component
} }
# Preliminary setup # Preliminary setup
@ -1974,6 +2025,7 @@ else
"$@" "$@"
} }
fi fi
pre_setup_quiet_redirect
pre_prepare_outcome_file pre_prepare_outcome_file
pre_print_configuration pre_print_configuration
pre_check_tools pre_check_tools