tests: drive read_write_ex shutdown to completion instead of fixed sequence

test_wolfSSL_read_write_ex hard-coded the close-notify exchange as
NOT_DONE/NOT_DONE/SUCCESS/SUCCESS, which is protocol-version/config dependent
and fails under the cmake old-TLS build. Loop wolfSSL_shutdown on each side
until WOLFSSL_SUCCESS (pre-existing flake, not from this PR's new tests).
This commit is contained in:
Daniele Lacamera
2026-07-17 08:56:03 +02:00
parent 92975dd9c8
commit 9509583f65
+19 -4
View File
@@ -7528,10 +7528,25 @@ static int test_wolfSSL_read_write_ex(void)
ExpectIntEQ(XSTRCMP((char*)buf, test_str), 0);
ExpectIntEQ(wolfSSL_shutdown(ssl_c), WOLFSSL_SHUTDOWN_NOT_DONE);
ExpectIntEQ(wolfSSL_shutdown(ssl_s), WOLFSSL_SHUTDOWN_NOT_DONE);
ExpectIntEQ(wolfSSL_shutdown(ssl_c), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_shutdown(ssl_s), WOLFSSL_SUCCESS);
/* Drive the bidirectional close-notify exchange to completion instead of
* asserting a fixed NOT_DONE/SUCCESS sequence: the number of shutdown
* round-trips is protocol-version/config dependent, so a hard-coded
* sequence is fragile (fails e.g. under the cmake old-TLS build). */
{
int shutC = WOLFSSL_SHUTDOWN_NOT_DONE;
int shutS = WOLFSSL_SHUTDOWN_NOT_DONE;
int shutIt;
for (shutIt = 0; shutIt < 10 &&
(shutC != WOLFSSL_SUCCESS || shutS != WOLFSSL_SUCCESS);
shutIt++) {
if (shutC != WOLFSSL_SUCCESS)
shutC = wolfSSL_shutdown(ssl_c);
if (shutS != WOLFSSL_SUCCESS)
shutS = wolfSSL_shutdown(ssl_s);
}
ExpectIntEQ(shutC, WOLFSSL_SUCCESS);
ExpectIntEQ(shutS, WOLFSSL_SUCCESS);
}
wolfSSL_free(ssl_c);
wolfSSL_free(ssl_s);