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);