compat.sh: uniform TITLE format for --list-test-case and run_client

uniform_title is used to print identical format of $TITLE between
--list-test-case and run_client. In such way, no matter how $TITLE
is developed, --list-test-case will in the same format of test case
description as stored in OUTCOME.CSV.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2023-03-02 11:55:55 +08:00
parent 7b394da738
commit fb784b26d2

View File

@ -35,7 +35,6 @@ TESTS=0
FAILED=0
SKIPPED=0
SRVMEM=0
LIST_TEST_CASE=0
# default commands, can be overridden by the environment
: ${M_SRV:=../programs/ssl/ssl_server2}
@ -114,6 +113,14 @@ print_usage() {
printf " --list-test-case\tList all potential test cases (No Execution)\n"
}
# print_test_case <CLIENT> <SERVER> <STANDARD_CIPHER_SUITE>
print_test_case() {
for i in $3; do
uniform_title $1 $2 $i
echo $TITLE
done
}
list_test_case() {
reset_ciphersuites
for TYPE in $TYPES; do
@ -126,11 +133,11 @@ list_test_case() {
for VERIFY in $VERIFIES; do
VERIF=$(echo $VERIFY | tr '[:upper:]' '[:lower:]')
for MODE in $MODES; do
print_test_title m O "$O_CIPHERS"
print_test_title O m "$O_CIPHERS"
print_test_title m G "$G_CIPHERS"
print_test_title G m "$G_CIPHERS"
print_test_title m m "$M_CIPHERS"
print_test_case m O "$O_CIPHERS"
print_test_case O m "$O_CIPHERS"
print_test_case m G "$G_CIPHERS"
print_test_case G m "$G_CIPHERS"
print_test_case m m "$M_CIPHERS"
done
done
}
@ -163,7 +170,6 @@ get_options() {
MEMCHECK=1
;;
--list-test-case)
LIST_TEST_CASE=1
list_test_case
exit 0
;;
@ -818,21 +824,21 @@ wait_client_done() {
echo "EXIT: $EXIT" >> $CLI_OUT
}
# print_test_title <CLIENT> <SERVER> <STANDARD_CIPHER_SUITE>
print_test_title() {
for i in $3; do
TITLE="$1->$2 $MODE,$VERIF $i"
DOTS72="........................................................................"
printf "%s %.*s " "$TITLE" "$((71 - ${#TITLE}))" "$DOTS72"
[ $LIST_TEST_CASE -eq 1 ] && printf "\n"
done
# uniform_title <CLIENT> <SERVER> <STANDARD_CIPHER_SUITE>
# $TITLE is considered as test case description for both --list-test-case and
# MBEDTLS_TEST_OUTCOME_FILE. This function aims to control the format of
# each test case description.
uniform_title() {
TITLE="$1->$2 $MODE,$VERIF $3"
}
# run_client PROGRAM_NAME STANDARD_CIPHER_SUITE PROGRAM_CIPHER_SUITE
run_client() {
# announce what we're going to do
TESTS=$(( $TESTS + 1 ))
print_test_title "${1%"${1#?}"}" "${SERVER_NAME%"${SERVER_NAME#?}"}" $2
uniform_title "${1%"${1#?}"}" "${SERVER_NAME%"${SERVER_NAME#?}"}" $2
DOTS72="........................................................................"
printf "%s %.*s " "$TITLE" "$((71 - ${#TITLE}))" "$DOTS72"
# should we skip?
if [ "X$SKIP_NEXT" = "XYES" ]; then