From ab9a29bd2cc33ca22badc7cc4b0465cf30bf7865 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 24 Sep 2019 16:14:39 +0100 Subject: [PATCH] ssl-opt.sh: Reuse query config test program for requires_config_xxx This commit reimplements the helper functions - requires_config_enabled - requires_config_disabled in ssl-opt.sh in terms of the programs/test/query_config programs which allows to query the configuration in which Mbed TLS was built. This removes the dependency of ssl-opt.sh from the config that was used to build the library. --- tests/ssl-opt.sh | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 49d2d1fc4..38b1b69fd 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -71,8 +71,6 @@ TESTS=0 FAILS=0 SKIPS=0 -CONFIG_H='../include/mbedtls/config.h' - MEMCHECK=0 FILTER='.*' EXCLUDE='^$' @@ -154,20 +152,6 @@ skip_next_test() { SKIP_NEXT="YES" } -# skip next test if the flag is not enabled in config.h -requires_config_enabled() { - if grep "^#define $1" $CONFIG_H > /dev/null; then :; else - SKIP_NEXT="YES" - fi -} - -# skip next test if the flag is enabled in config.h -requires_config_disabled() { - if grep "^#define $1" $CONFIG_H > /dev/null; then - SKIP_NEXT="YES" - fi -} - requires_ciphersuite_enabled() { if [ -z "$($P_CLI --help | grep "$1")" ]; then SKIP_NEXT="YES" @@ -185,6 +169,19 @@ get_config_value_or_default() { ${P_SRV} "query_config=${1}" } +# skip next test if the flag is enabled in config.h +requires_config_disabled() { + if get_config_value_or_default $1; then + SKIP_NEXT="YES" + fi +} + +requires_config_enabled() { + if ! get_config_value_or_default $1; then + SKIP_NEXT="YES" + fi +} + requires_config_value_at_least() { VAL="$( get_config_value_or_default "$1" )" if [ -z "$VAL" ]; then @@ -2990,7 +2987,7 @@ run_test "Session resume using cache, DTLS: openssl server" \ # Tests for Max Fragment Length extension if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then - printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n" + printf "The configuration defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n" exit 1 fi @@ -3954,7 +3951,7 @@ MAX_IM_CA='8' MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA) if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then - printf "The ${CONFIG_H} file contains a value for the configuration of\n" + printf "The configuration file contains a value for the configuration of\n" printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n" printf "test value of ${MAX_IM_CA}. \n" printf "\n"