compat.sh: add support to record outcome of test cases
If the environment variable MBEDTLS_TEST_OUTCOME_FILE is set, the test outcome file records each test case in a single line with the format of PLATFORM;CONFIGURATION;compat;TEST CASE DESCRIPTION;RESULT;[CAUSE] - CONFIGURATION comes from MBEDTLS_TEST_CONFIGURATION to record configuration of each test case - PLATFORM is either set by users or calculated from test platform - RESULT is one of PASS, FAIL or SKIP. If test case fails, srv_out/cli_out follows as FAILURE CAUSE. Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
f45a8eae3b
commit
ad47063002
1 changed files with 51 additions and 10 deletions
|
@ -30,6 +30,11 @@ set -u
|
|||
# where it may output seemingly unlimited length error logs.
|
||||
ulimit -f 20971520
|
||||
|
||||
ORIGINAL_PWD=$PWD
|
||||
if ! cd "$(dirname "$0")"; then
|
||||
exit 125
|
||||
fi
|
||||
|
||||
# initialise counters
|
||||
TESTS=0
|
||||
FAILED=0
|
||||
|
@ -77,6 +82,17 @@ else
|
|||
PEER_GNUTLS=""
|
||||
fi
|
||||
|
||||
guess_config_name() {
|
||||
if git diff --quiet ../include/mbedtls/mbedtls_config.h 2>/dev/null; then
|
||||
echo "default"
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
: ${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 _)"}
|
||||
|
||||
# default values for options
|
||||
# /!\ keep this synchronised with:
|
||||
# - basic-build-test.sh
|
||||
|
@ -110,6 +126,8 @@ print_usage() {
|
|||
printf " \tAlso available: GnuTLS (needs v3.2.15 or higher)\n"
|
||||
printf " -M|--memcheck\tCheck memory leaks and errors.\n"
|
||||
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"
|
||||
}
|
||||
|
||||
get_options() {
|
||||
|
@ -139,6 +157,9 @@ get_options() {
|
|||
-M|--memcheck)
|
||||
MEMCHECK=1
|
||||
;;
|
||||
--outcome-file)
|
||||
shift; MBEDTLS_TEST_OUTCOME_FILE=$1
|
||||
;;
|
||||
-h|--help)
|
||||
print_usage
|
||||
exit 0
|
||||
|
@ -790,12 +811,29 @@ wait_client_done() {
|
|||
echo "EXIT: $EXIT" >> $CLI_OUT
|
||||
}
|
||||
|
||||
# record_outcome <outcome> [<failure-reason>]
|
||||
record_outcome() {
|
||||
echo "$1"
|
||||
if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
|
||||
# The test outcome file has the format (in single line):
|
||||
# platform;configuration;
|
||||
# test suite name;test case description;
|
||||
# PASS/FAIL/SKIP;[failure cause]
|
||||
printf '%s;%s;%s;%s;%s;%s\n' \
|
||||
"$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
|
||||
"compat" "$TITLE" \
|
||||
"$1" "${2-}" \
|
||||
>> "$MBEDTLS_TEST_OUTCOME_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
# display additional information if test case fails
|
||||
report_fail() {
|
||||
echo "FAIL"
|
||||
FAIL_PROMPT="outputs saved to c-srv-${TESTS}.log, c-cli-${TESTS}.log"
|
||||
record_outcome "FAIL" "$FAIL_PROMPT"
|
||||
cp $SRV_OUT c-srv-${TESTS}.log
|
||||
cp $CLI_OUT c-cli-${TESTS}.log
|
||||
echo " ! outputs saved to c-srv-${TESTS}.log, c-cli-${TESTS}.log"
|
||||
echo " ! $FAIL_PROMPT"
|
||||
|
||||
if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
|
||||
echo " ! server output:"
|
||||
|
@ -818,7 +856,7 @@ run_client() {
|
|||
# should we skip?
|
||||
if [ "X$SKIP_NEXT" = "XYES" ]; then
|
||||
SKIP_NEXT="NO"
|
||||
echo "SKIP"
|
||||
record_outcome "SKIP"
|
||||
SKIPPED=$(( $SKIPPED + 1 ))
|
||||
return
|
||||
fi
|
||||
|
@ -912,10 +950,10 @@ run_client() {
|
|||
# report and count result
|
||||
case $RESULT in
|
||||
"0")
|
||||
echo PASS
|
||||
record_outcome "PASS"
|
||||
;;
|
||||
"1")
|
||||
echo SKIP
|
||||
record_outcome "SKIP"
|
||||
SKIPPED=$(( $SKIPPED + 1 ))
|
||||
;;
|
||||
"2")
|
||||
|
@ -931,13 +969,16 @@ run_client() {
|
|||
# MAIN
|
||||
#
|
||||
|
||||
if cd $( dirname $0 ); then :; else
|
||||
echo "cd $( dirname $0 ) failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
# sanity checks, avoid an avalanche of errors
|
||||
if [ ! -x "$M_SRV" ]; then
|
||||
echo "Command '$M_SRV' is not an executable file" >&2
|
||||
|
|
Loading…
Reference in a new issue