Skip to content

Commit 7e23b3a

Browse files
committed
tests: Add negative version config tests.
tls1.3 and tls1.2 can not be enabled at same time before Mbed-TLS#4832 resolved. And the test won't run into `handshake` stage, add `skip_handshak_check` function to skip it. Change-Id: I13f3b06b2f33b9c9beb8cac90f5fda41a4ed53f3 Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
1 parent 2304065 commit 7e23b3a

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

tests/ssl-opt.sh

+32-11
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,11 @@ find_in_both() {
693693
fi
694694
}
695695

696+
SKIP_HANDSHAKE_CHECK="NO"
697+
skip_handshake_stage_check() {
698+
SKIP_HANDSHAKE_CHECK="YES"
699+
}
700+
696701
# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
697702
# Options: -s pattern pattern that must be present in server output
698703
# -c pattern pattern that must be present in client output
@@ -855,21 +860,25 @@ run_test() {
855860
# (useful to avoid tests with only negative assertions and non-zero
856861
# expected client exit to incorrectly succeed in case of catastrophic
857862
# failure)
858-
if is_polar "$SRV_CMD"; then
859-
if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
860-
else
861-
fail "server or client failed to reach handshake stage"
862-
return
863+
if [ "X$SKIP_HANDSHAKE_CHECK" != "XYES" ]
864+
then
865+
if is_polar "$SRV_CMD"; then
866+
if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
867+
else
868+
fail "server or client failed to reach handshake stage"
869+
return
870+
fi
863871
fi
864-
fi
865-
if is_polar "$CLI_CMD"; then
866-
if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
867-
else
868-
fail "server or client failed to reach handshake stage"
869-
return
872+
if is_polar "$CLI_CMD"; then
873+
if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
874+
else
875+
fail "server or client failed to reach handshake stage"
876+
return
877+
fi
870878
fi
871879
fi
872880

881+
SKIP_HANDSHAKE_CHECK="NO"
873882
# Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
874883
# exit with status 0 when interrupted by a signal, and we don't really
875884
# care anyway), in case e.g. the server reports a memory leak.
@@ -8478,6 +8487,18 @@ run_test "export keys functionality" \
84788487
-c "EAP-TLS IV is:" \
84798488
-s "EAP-TLS IV is:"
84808489

8490+
# TLS1.3 test cases
8491+
# TODO: remove or rewrite this test case if #4832 is resolved.
8492+
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8493+
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
8494+
skip_handshake_stage_check
8495+
run_test "TLS1.3: Not supported version check: tls1_2 and tls1_3" \
8496+
"$P_SRV debug_level=4 min_version=tls1_2 max_version=tls1_3" \
8497+
"$P_CLI debug_level=4 min_version=tls1_2 max_version=tls1_3" \
8498+
1 \
8499+
-s "SSL - Invalid value in SSL config" \
8500+
-c "SSL - Invalid value in SSL config"
8501+
84818502
# Test heap memory usage after handshake
84828503
requires_config_enabled MBEDTLS_MEMORY_DEBUG
84838504
requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C

0 commit comments

Comments
 (0)