mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-17 11:43:37 +00:00
ssl-opt.sh, compat.sh: Error out if not executing any tests
Alert if all tests are filtered out or skipped: that probably indicates a test script that set up an unintended configuration or an overly strict filter. You can pass `--min 0` to bypass this check. You can pass `--min` with a larger value to require that many test cases to run. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
f5473a0260
commit
39c5207d79
@ -96,6 +96,7 @@ FILTER=""
|
|||||||
EXCLUDE='NULL\|ARIA\|CHACHA20_POLY1305'
|
EXCLUDE='NULL\|ARIA\|CHACHA20_POLY1305'
|
||||||
VERBOSE=""
|
VERBOSE=""
|
||||||
MEMCHECK=0
|
MEMCHECK=0
|
||||||
|
MIN_TESTS=1
|
||||||
PRESERVE_LOGS=0
|
PRESERVE_LOGS=0
|
||||||
PEERS="OpenSSL$PEER_GNUTLS mbedTLS"
|
PEERS="OpenSSL$PEER_GNUTLS mbedTLS"
|
||||||
|
|
||||||
@ -116,6 +117,7 @@ print_usage() {
|
|||||||
printf " -M|--memcheck\tCheck memory leaks and errors.\n"
|
printf " -M|--memcheck\tCheck memory leaks and errors.\n"
|
||||||
printf " -v|--verbose\tSet verbose output.\n"
|
printf " -v|--verbose\tSet verbose output.\n"
|
||||||
printf " --list-test-cases\tList all potential test cases (No Execution)\n"
|
printf " --list-test-cases\tList all potential test cases (No Execution)\n"
|
||||||
|
printf " --min \tMinimum number of non-skipped tests (default 1)\n"
|
||||||
printf " --outcome-file\tFile where test outcomes are written\n"
|
printf " --outcome-file\tFile where test outcomes are written\n"
|
||||||
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
|
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
|
||||||
printf " --preserve-logs\tPreserve logs of successful tests as well\n"
|
printf " --preserve-logs\tPreserve logs of successful tests as well\n"
|
||||||
@ -190,6 +192,9 @@ get_options() {
|
|||||||
list_test_cases
|
list_test_cases
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
|
--min)
|
||||||
|
shift; MIN_TESTS=$1
|
||||||
|
;;
|
||||||
--outcome-file)
|
--outcome-file)
|
||||||
shift; MBEDTLS_TEST_OUTCOME_FILE=$1
|
shift; MBEDTLS_TEST_OUTCOME_FILE=$1
|
||||||
;;
|
;;
|
||||||
@ -1238,6 +1243,16 @@ fi
|
|||||||
PASSED=$(( $TESTS - $FAILED ))
|
PASSED=$(( $TESTS - $FAILED ))
|
||||||
echo " ($PASSED / $TESTS tests ($SKIPPED skipped$MEMREPORT))"
|
echo " ($PASSED / $TESTS tests ($SKIPPED skipped$MEMREPORT))"
|
||||||
|
|
||||||
|
if [ $((TESTS - SKIPPED)) -lt $MIN_TESTS ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Error: Expected to run at least $MIN_TESTS, but only ran $((TESTS - SKIPPED)).
|
||||||
|
Maybe a bad filter ('$FILTER' excluding '$EXCLUDE') or a bad configuration?
|
||||||
|
EOF
|
||||||
|
if [ $FAILED -eq 0 ]; then
|
||||||
|
FAILED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
FAILED=$(( $FAILED + $SRVMEM ))
|
FAILED=$(( $FAILED + $SRVMEM ))
|
||||||
if [ $FAILED -gt 255 ]; then
|
if [ $FAILED -gt 255 ]; then
|
||||||
# Clamp at 255 as caller gets exit code & 0xFF
|
# Clamp at 255 as caller gets exit code & 0xFF
|
||||||
|
@ -141,6 +141,7 @@ LIST_TESTS=0
|
|||||||
RUN_TEST_NUMBER=''
|
RUN_TEST_NUMBER=''
|
||||||
RUN_TEST_SUITE=''
|
RUN_TEST_SUITE=''
|
||||||
|
|
||||||
|
MIN_TESTS=1
|
||||||
PRESERVE_LOGS=0
|
PRESERVE_LOGS=0
|
||||||
|
|
||||||
# Pick a "unique" server port in the range 10000-19999, and a proxy
|
# Pick a "unique" server port in the range 10000-19999, and a proxy
|
||||||
@ -159,6 +160,7 @@ print_usage() {
|
|||||||
printf " -s|--show-numbers\tShow test numbers in front of test names\n"
|
printf " -s|--show-numbers\tShow test numbers in front of test names\n"
|
||||||
printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
|
printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
|
||||||
printf " --list-test-cases\tList all potential test cases (No Execution)\n"
|
printf " --list-test-cases\tList all potential test cases (No Execution)\n"
|
||||||
|
printf " --min \tMinimum number of non-skipped tests (default 1)\n"
|
||||||
printf " --outcome-file\tFile where test outcomes are written\n"
|
printf " --outcome-file\tFile where test outcomes are written\n"
|
||||||
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
|
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
|
||||||
printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
|
printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
|
||||||
@ -192,6 +194,9 @@ get_options() {
|
|||||||
-p|--preserve-logs)
|
-p|--preserve-logs)
|
||||||
PRESERVE_LOGS=1
|
PRESERVE_LOGS=1
|
||||||
;;
|
;;
|
||||||
|
--min)
|
||||||
|
shift; MIN_TESTS=$1
|
||||||
|
;;
|
||||||
--outcome-file)
|
--outcome-file)
|
||||||
shift; MBEDTLS_TEST_OUTCOME_FILE=$1
|
shift; MBEDTLS_TEST_OUTCOME_FILE=$1
|
||||||
;;
|
;;
|
||||||
@ -14152,6 +14157,15 @@ if [ "$LIST_TESTS" -eq 0 ]; then
|
|||||||
PASSES=$(( $TESTS - $FAILS ))
|
PASSES=$(( $TESTS - $FAILS ))
|
||||||
echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
|
echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
|
||||||
|
|
||||||
|
if [ $((TESTS - SKIPS)) -lt $MIN_TESTS ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Error: Expected to run at least $MIN_TESTS, but only ran $((TESTS - SKIPS)).
|
||||||
|
Maybe a bad filter ('$FILTER') or a bad configuration?
|
||||||
|
EOF
|
||||||
|
if [ $FAILS -eq 0 ]; then
|
||||||
|
FAILS=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $FAILS -gt 255 ]; then
|
if [ $FAILS -gt 255 ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user