From 0d9bb6c4013b80c6979a1c9d179bec56a83c83ab Mon Sep 17 00:00:00 2001 From: Yanray Wang Date: Mon, 20 Feb 2023 16:10:55 +0800 Subject: [PATCH] compat.sh: support option --append-outcome By default, we record each test cases into a new file if MBEDTLS_TEST_OUTCOME_FILE is set. With --append-outcome, append records to the existing outcome file if it's set. Signed-off-by: Yanray Wang --- tests/compat.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 2583d1bf5fdb..89fc9eeb0d80 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,18 @@ 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 + if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then + MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE" + # Should we write to a new outcome file? + if [ "$append_outcome" -eq 0 ]; then + rm -f "$MBEDTLS_TEST_OUTCOME_FILE" + fi + fi +} + log() { if [ "X" != "X$VERBOSE" ]; then echo "" @@ -971,14 +989,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