diff --git a/tests/compat.sh b/tests/compat.sh index 2583d1bf5fdb..6895d6592eed 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -93,6 +93,8 @@ guess_config_name() { : ${MBEDTLS_TEST_OUTCOME_FILE=} : ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"} : ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} +# By default, we record the outcome to a new file +append_outcome=0 # default values for options # /!\ keep this synchronised with: @@ -129,6 +131,7 @@ print_usage() { printf " -v|--verbose\tSet verbose output.\n" printf " --outcome-file\tFile where test outcomes are written\n" printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n" + printf " --append-outcome\tAppend records to the outcome file (if used)\n" } get_options() { @@ -161,6 +164,9 @@ get_options() { --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE=$1 ;; + --append-outcome) + append_outcome=1 + ;; -h|--help) print_usage exit 0 @@ -179,6 +185,20 @@ get_options() { TYPES="$( echo $TYPES | tr [a-z] [A-Z] )" } +prepare_outcome_file() { + # Make the outcome file path relative to the original directory, not + # to .../tests + case "$MBEDTLS_TEST_OUTCOME_FILE" in + [!/]*) + MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE" + ;; + esac + # Should we write to a new outcome file? + if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then + rm -f "$MBEDTLS_TEST_OUTCOME_FILE" + fi +} + log() { if [ "X" != "X$VERBOSE" ]; then echo "" @@ -971,14 +991,7 @@ run_client() { # get_options "$@" - -# Make the outcome file path relative to the original directory, not -# to .../tests -case "$MBEDTLS_TEST_OUTCOME_FILE" in - [!/]*) - MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE" - ;; -esac +prepare_outcome_file # sanity checks, avoid an avalanche of errors if [ ! -x "$M_SRV" ]; then