From 9509583f652b4774c580acba49386bbd87deafff Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Thu, 16 Jul 2026 01:03:10 +0200 Subject: [PATCH] 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). --- tests/api.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/api.c b/tests/api.c index db67f5ba3a..395cc94d28 100644 --- a/tests/api.c +++ b/tests/api.c @@ -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);