mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-05 19:35:48 +03:00
ssl-opt: Introduce --list-test-cases option
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
This commit is contained in:
@@ -112,6 +112,7 @@ FILTER='.*'
|
||||
EXCLUDE='^$'
|
||||
|
||||
SHOW_TEST_NUMBER=0
|
||||
LIST_TESTS=0
|
||||
RUN_TEST_NUMBER=''
|
||||
|
||||
PRESERVE_LOGS=0
|
||||
@@ -131,6 +132,7 @@ print_usage() {
|
||||
printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
|
||||
printf " -s|--show-numbers\tShow test numbers in front of test names\n"
|
||||
printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
|
||||
printf " --list-test-cases\tList all potential test cases (No Execution)\n"
|
||||
printf " --outcome-file\tFile where test outcomes are written\n"
|
||||
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
|
||||
printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
|
||||
@@ -156,6 +158,9 @@ get_options() {
|
||||
-s|--show-numbers)
|
||||
SHOW_TEST_NUMBER=1
|
||||
;;
|
||||
-l|--list-test-cases)
|
||||
LIST_TESTS=1
|
||||
;;
|
||||
-p|--preserve-logs)
|
||||
PRESERVE_LOGS=1
|
||||
;;
|
||||
@@ -185,11 +190,18 @@ get_options() {
|
||||
done
|
||||
}
|
||||
|
||||
get_options "$@"
|
||||
|
||||
# Read boolean configuration options from config.h for easy and quick
|
||||
# testing. Skip non-boolean options (with something other than spaces
|
||||
# and a comment after "#define SYMBOL"). The variable contains a
|
||||
# space-separated list of symbols.
|
||||
if [ "$LIST_TESTS" -eq 0 ];then
|
||||
CONFIGS_ENABLED=" $(echo `$P_QUERY -l` )"
|
||||
else
|
||||
P_QUERY=":"
|
||||
CONFIGS_ENABLED=""
|
||||
fi
|
||||
# Skip next test; use this macro to skip tests which are legitimate
|
||||
# in theory and expected to be re-introduced at some point, but
|
||||
# aren't expected to succeed at the moment due to problems outside
|
||||
@@ -221,7 +233,12 @@ get_config_value_or_default() {
|
||||
#
|
||||
# Note that if the configuration is not defined or is defined to nothing,
|
||||
# the output of this function will be an empty string.
|
||||
if [ "$LIST_TESTS" -eq 0 ];then
|
||||
${P_SRV} "query_config=${1}"
|
||||
else
|
||||
echo "1"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
requires_config_value_at_least() {
|
||||
@@ -496,19 +513,18 @@ requires_not_i686() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Calculate the input & output maximum content lengths set in the config
|
||||
MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_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" )
|
||||
|
||||
# Calculate the maximum content length that fits both
|
||||
if [ "$LIST_TESTS" -eq 0 ];then
|
||||
# Calculate the input & output maximum content lengths set in the config
|
||||
if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
|
||||
MAX_CONTENT_LEN="$MAX_IN_LEN"
|
||||
fi
|
||||
if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
|
||||
MAX_CONTENT_LEN="$MAX_OUT_LEN"
|
||||
fi
|
||||
|
||||
fi
|
||||
# skip the next test if the SSL output buffer is less than 16KB
|
||||
requires_full_size_output_buffer() {
|
||||
if [ "$MAX_OUT_LEN" -ne 16384 ]; then
|
||||
@@ -550,6 +566,7 @@ print_name() {
|
||||
fi
|
||||
|
||||
LINE="$LINE$1"
|
||||
|
||||
printf "%s " "$LINE"
|
||||
LEN=$(( 72 - `echo "$LINE" | wc -c` ))
|
||||
for i in `seq 1 $LEN`; do printf '.'; done
|
||||
@@ -1164,6 +1181,11 @@ run_test() {
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$LIST_TESTS" -gt 0 ]; then
|
||||
printf "%s\n" "$NAME"
|
||||
return
|
||||
fi
|
||||
|
||||
print_name "$NAME"
|
||||
|
||||
# Do we only run numbered tests?
|
||||
@@ -1363,8 +1385,6 @@ cleanup() {
|
||||
# MAIN
|
||||
#
|
||||
|
||||
get_options "$@"
|
||||
|
||||
# Make the outcome file path relative to the original directory, not
|
||||
# to .../tests
|
||||
case "$MBEDTLS_TEST_OUTCOME_FILE" in
|
||||
@@ -1413,6 +1433,8 @@ else
|
||||
}
|
||||
fi
|
||||
|
||||
if [ "$LIST_TESTS" -eq 0 ];then
|
||||
|
||||
# sanity checks, avoid an avalanche of errors
|
||||
P_SRV_BIN="${P_SRV%%[ ]*}"
|
||||
P_CLI_BIN="${P_CLI%%[ ]*}"
|
||||
@@ -1510,7 +1532,7 @@ fi
|
||||
# Allow SHA-1, because many of our test certificates use it
|
||||
P_SRV="$P_SRV allow_sha1=1"
|
||||
P_CLI="$P_CLI allow_sha1=1"
|
||||
|
||||
fi
|
||||
# Also pick a unique name for intermediate files
|
||||
SRV_OUT="srv_out.$$"
|
||||
CLI_OUT="cli_out.$$"
|
||||
@@ -10540,6 +10562,7 @@ requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
|
||||
requires_max_content_len 16384
|
||||
run_tests_memory_after_hanshake
|
||||
|
||||
if [ "$LIST_TESTS" -eq 0 ]; then
|
||||
# Final report
|
||||
|
||||
echo "------------------------------------------------------------------------"
|
||||
@@ -10551,6 +10574,7 @@ else
|
||||
fi
|
||||
PASSES=$(( $TESTS - $FAILS ))
|
||||
echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
|
||||
fi
|
||||
|
||||
if [ $FAILS -gt 255 ]; then
|
||||
# Clamp at 255 as caller gets exit code & 0xFF
|
||||
|
Reference in New Issue
Block a user