Make mbedtls_ssl_get_bytes_avail tests more independent

Don't depend on the default sizes in the test programs: pass explicit
request and buffer sizes.

Don't depend on MAX_CONTENT_LEN (other than it not being extremely small:
this commit assumes that it will never be less than 101).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2022-04-06 23:35:56 +02:00
parent a30439a7f9
commit 5a1b3bdc44

View File

@ -6411,18 +6411,31 @@ run_test "ClientHello without extensions" \
# Tests for mbedtls_ssl_get_bytes_avail()
# The server first reads buffer_size-1 bytes, then reads the remainder.
run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
"$P_SRV" \
"$P_SRV buffer_size=100" \
"$P_CLI request_size=100" \
0 \
-s "Read from client: 100 bytes read$"
requires_max_content_len 474
run_test "mbedtls_ssl_get_bytes_avail: extra data" \
"$P_SRV" \
"$P_CLI request_size=450" \
run_test "mbedtls_ssl_get_bytes_avail: extra data (+1)" \
"$P_SRV buffer_size=100" \
"$P_CLI request_size=101" \
0 \
-s "Read from client: 450 bytes read (.*+.*)"
-s "Read from client: 101 bytes read (100 + 1)"
requires_max_content_len 200
run_test "mbedtls_ssl_get_bytes_avail: extra data (*2)" \
"$P_SRV buffer_size=100" \
"$P_CLI request_size=200" \
0 \
-s "Read from client: 200 bytes read (100 + 100)"
run_test "mbedtls_ssl_get_bytes_avail: extra data (max)" \
"$P_SRV buffer_size=100" \
"$P_CLI request_size=$MAX_CONTENT_LEN" \
0 \
-s "Read from client: $MAX_CONTENT_LEN bytes read (100 + $((MAX_CONTENT_LEN - 100)))"
# Tests for small client packets