git: f0c143b3565a - main - ktls_tests: Ignore spurious errors from shutdown(2).

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 20 Dec 2022 19:38:56 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=f0c143b3565abdc53ee387429473d2df7c7716f7

commit f0c143b3565abdc53ee387429473d2df7c7716f7
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-12-20 19:38:07 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-12-20 19:38:07 +0000

    ktls_tests: Ignore spurious errors from shutdown(2).
    
    For some of the "bad size" tests, the remote end can notice the error
    and drop the connection before the test program returns from write to
    call shutdown.  In that case, shutdown fails with ENOTCONN.  Permit
    these ENOTCONN errors without failing the test.
    
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D37693
---
 tests/sys/kern/ktls_test.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c
index 9488ac24f4cc..85998fcbdf80 100644
--- a/tests/sys/kern/ktls_test.c
+++ b/tests/sys/kern/ktls_test.c
@@ -1893,7 +1893,13 @@ test_ktls_receive_bad_size(const atf_tc_t *tc, struct tls_enable *en,
 	rv = write(sockets[1], outbuf, outbuf_len);
 	ATF_REQUIRE_INTEQ((ssize_t)outbuf_len, rv);
 
-	ATF_REQUIRE(shutdown(sockets[1], SHUT_WR) == 0);
+	/*
+	 * The other end may notice the error and drop the connection
+	 * before this executes resulting in shutdown() failing with
+	 * ENOTCONN.  Ignore this error if it occurs.
+	 */
+	if (shutdown(sockets[1], SHUT_WR) != 0)
+		ATF_REQUIRE_ERRNO(ENOTCONN, true);
 
 	ktls_receive_tls_error(sockets[0], EMSGSIZE);