1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

compat.sh: uniform test description

Test case description is printed by different block of code. This
causes code maintenance harder since we need to maintain two parts
of code with same functionality. print_test_title is used to
control test case description in compat.sh

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang
2023-02-24 17:07:47 +08:00
parent baced97929
commit 7e1c0c7f79
2 changed files with 15 additions and 15 deletions

View File

@ -40,6 +40,7 @@ TESTS=0
FAILED=0 FAILED=0
SKIPPED=0 SKIPPED=0
SRVMEM=0 SRVMEM=0
LIST_TEST_CASE=0
# default commands, can be overridden by the environment # default commands, can be overridden by the environment
: ${M_SRV:=../programs/ssl/ssl_server2} : ${M_SRV:=../programs/ssl/ssl_server2}
@ -133,14 +134,6 @@ print_usage() {
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n" printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
} }
# print_test_title <CLIENT> <SERVER> <STANDARD_CIPHER_SUITE>
print_test_title() {
for i in $3; do
TITLE="$1->$2 $MODE,$VERIF $i"
echo "$TITLE"
done
}
list_test_case() { list_test_case() {
reset_ciphersuites reset_ciphersuites
for TYPE in $TYPES; do for TYPE in $TYPES; do
@ -190,6 +183,7 @@ get_options() {
MEMCHECK=1 MEMCHECK=1
;; ;;
--list-test-case) --list-test-case)
LIST_TEST_CASE=1
list_test_case list_test_case
exit 0 exit 0
;; ;;
@ -1233,15 +1227,21 @@ report_fail() {
fi fi
} }
# 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
}
# run_client <name> <cipher> # run_client <name> <cipher>
run_client() { run_client() {
# announce what we're going to do # announce what we're going to do
TESTS=$(( $TESTS + 1 )) TESTS=$(( $TESTS + 1 ))
TITLE="`echo $1 | head -c1`->`echo $SERVER_NAME | head -c1`" print_test_title ${1%"${1#?}"} ${SERVER_NAME%"${SERVER_NAME#?}"} $2
TITLE="$TITLE $MODE,$VERIF $2"
printf "%s " "$TITLE"
LEN=$(( 72 - `echo "$TITLE" | wc -c` ))
for i in `seq 1 $LEN`; do printf '.'; done; printf ' '
# should we skip? # should we skip?
if [ "X$SKIP_NEXT" = "XYES" ]; then if [ "X$SKIP_NEXT" = "XYES" ]; then

View File

@ -123,8 +123,8 @@ state may override this method.
print(*compat_cmd, 'returned', str(result.returncode)) print(*compat_cmd, 'returned', str(result.returncode))
return return
else: else:
# Pattern: g->m dtls12,no TLS_DHE_PSK_WITH_AES_128_CBC_SHA\n # Pattern: g->m dtls12,no TLS_DHE_PSK_WITH_AES_128_CBC_SHA .......... \n
m = re.findall(br'[^ogm]*((?:[ogm]->[ogm]\s*\w*.\w*\s\w*)*)\n', m = re.findall(br'[^ogm]*((?:[ogm]->[ogm]\s*\w*.\w*\s\w*)*)\s*\.*\s*\n',
result.stdout) result.stdout)
if m: if m:
for i in m: for i in m: