Skip unnecessary logic when -l option is used

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
This commit is contained in:
Tomás González 2023-08-23 15:46:20 +01:00
parent f162b4f497
commit 06956a12aa

View file

@ -223,6 +223,9 @@ skip_next_test() {
# Check if the required configuration ($1) is enabled # Check if the required configuration ($1) is enabled
is_config_enabled() is_config_enabled()
{ {
if [ "$LIST_TESTS" -gt 0 ];then
return 0;
fi
case $CONFIGS_ENABLED in case $CONFIGS_ENABLED in
*" $1"[\ =]*) return 0;; *" $1"[\ =]*) return 0;;
*) return 1;; *) return 1;;
@ -231,6 +234,9 @@ is_config_enabled()
# skip next test if the flag is not enabled in mbedtls_config.h # skip next test if the flag is not enabled in mbedtls_config.h
requires_config_enabled() { requires_config_enabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
case $CONFIGS_ENABLED in case $CONFIGS_ENABLED in
*" $1"[\ =]*) :;; *" $1"[\ =]*) :;;
*) SKIP_NEXT="YES";; *) SKIP_NEXT="YES";;
@ -239,12 +245,18 @@ requires_config_enabled() {
# skip next test if the flag is enabled in mbedtls_config.h # skip next test if the flag is enabled in mbedtls_config.h
requires_config_disabled() { requires_config_disabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
case $CONFIGS_ENABLED in case $CONFIGS_ENABLED in
*" $1"[\ =]*) SKIP_NEXT="YES";; *" $1"[\ =]*) SKIP_NEXT="YES";;
esac esac
} }
requires_all_configs_enabled() { requires_all_configs_enabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
if ! $P_QUERY -all $* if ! $P_QUERY -all $*
then then
SKIP_NEXT="YES" SKIP_NEXT="YES"
@ -252,6 +264,9 @@ requires_all_configs_enabled() {
} }
requires_all_configs_disabled() { requires_all_configs_disabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
if $P_QUERY -any $* if $P_QUERY -any $*
then then
SKIP_NEXT="YES" SKIP_NEXT="YES"
@ -259,6 +274,9 @@ requires_all_configs_disabled() {
} }
requires_any_configs_enabled() { requires_any_configs_enabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
if ! $P_QUERY -any $* if ! $P_QUERY -any $*
then then
SKIP_NEXT="YES" SKIP_NEXT="YES"
@ -266,6 +284,9 @@ requires_any_configs_enabled() {
} }
requires_any_configs_disabled() { requires_any_configs_disabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
if $P_QUERY -all $* if $P_QUERY -all $*
then then
SKIP_NEXT="YES" SKIP_NEXT="YES"
@ -290,6 +311,9 @@ TLS1_2_KEY_EXCHANGES_WITH_CERT_WO_ECDH="MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \
MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED" MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED"
requires_key_exchange_with_cert_in_tls12_or_tls13_enabled() { requires_key_exchange_with_cert_in_tls12_or_tls13_enabled() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
if $P_QUERY -all MBEDTLS_SSL_PROTO_TLS1_2 if $P_QUERY -all MBEDTLS_SSL_PROTO_TLS1_2
then then
requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT
@ -307,10 +331,18 @@ get_config_value_or_default() {
# #
# Note that if the configuration is not defined or is defined to nothing, # Note that if the configuration is not defined or is defined to nothing,
# the output of this function will be an empty string. # the output of this function will be an empty string.
if [ "$LIST_TESTS" -eq 0 ];then
${P_SRV} "query_config=${1}" ${P_SRV} "query_config=${1}"
else
echo "1"
fi
} }
requires_config_value_at_least() { requires_config_value_at_least() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
VAL="$( get_config_value_or_default "$1" )" VAL="$( get_config_value_or_default "$1" )"
if [ -z "$VAL" ]; then if [ -z "$VAL" ]; then
# Should never happen # Should never happen
@ -322,6 +354,9 @@ requires_config_value_at_least() {
} }
requires_config_value_at_most() { requires_config_value_at_most() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
VAL=$( get_config_value_or_default "$1" ) VAL=$( get_config_value_or_default "$1" )
if [ -z "$VAL" ]; then if [ -z "$VAL" ]; then
# Should never happen # Should never happen
@ -333,6 +368,9 @@ requires_config_value_at_most() {
} }
requires_config_value_equals() { requires_config_value_equals() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
VAL=$( get_config_value_or_default "$1" ) VAL=$( get_config_value_or_default "$1" )
if [ -z "$VAL" ]; then if [ -z "$VAL" ]; then
# Should never happen # Should never happen
@ -348,6 +386,9 @@ requires_config_value_equals() {
# Inputs: # Inputs:
# * $1: protocol version in mbedtls syntax (argument to force_version=) # * $1: protocol version in mbedtls syntax (argument to force_version=)
requires_protocol_version() { requires_protocol_version() {
if [ "$LIST_TESTS" -gt 0 ];then
return;
fi
# Support for DTLS is detected separately in detect_dtls(). # Support for DTLS is detected separately in detect_dtls().
case "$1" in case "$1" in
tls12|dtls12) requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2;; tls12|dtls12) requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2;;
@ -818,10 +859,11 @@ requires_not_i686() {
fi fi
} }
# Calculate the input & output maximum content lengths set in the config
MAX_CONTENT_LEN=16384 MAX_CONTENT_LEN=16384
MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" ) MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" ) MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
if [ "$LIST_TESTS" -eq 0 ];then
# Calculate the input & output maximum content lengths set in the config
# Calculate the maximum content length that fits both # Calculate the maximum content length that fits both
if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
@ -830,7 +872,7 @@ fi
if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
MAX_CONTENT_LEN="$MAX_OUT_LEN" MAX_CONTENT_LEN="$MAX_OUT_LEN"
fi fi
fi
# skip the next test if the SSL output buffer is less than 16KB # skip the next test if the SSL output buffer is less than 16KB
requires_full_size_output_buffer() { requires_full_size_output_buffer() {
if [ "$MAX_OUT_LEN" -ne 16384 ]; then if [ "$MAX_OUT_LEN" -ne 16384 ]; then
@ -1844,6 +1886,8 @@ else
} }
fi fi
if [ "$LIST_TESTS" -eq 0 ];then
# sanity checks, avoid an avalanche of errors # sanity checks, avoid an avalanche of errors
P_SRV_BIN="${P_SRV%%[ ]*}" P_SRV_BIN="${P_SRV%%[ ]*}"
P_CLI_BIN="${P_CLI%%[ ]*}" P_CLI_BIN="${P_CLI%%[ ]*}"
@ -1947,6 +1991,7 @@ fi
P_SRV="$P_SRV allow_sha1=1" P_SRV="$P_SRV allow_sha1=1"
P_CLI="$P_CLI allow_sha1=1" P_CLI="$P_CLI allow_sha1=1"
fi
# Also pick a unique name for intermediate files # Also pick a unique name for intermediate files
SRV_OUT="srv_out.$$" SRV_OUT="srv_out.$$"
CLI_OUT="cli_out.$$" CLI_OUT="cli_out.$$"