From e53cb61cf7346c1f345423cff0a153867f9f8733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 14 Aug 2024 10:01:33 +0200 Subject: [PATCH] Ignore ISC_R_CONNECTIONRESET in the TCP tests On FreeBSD, the TCP connection callback could spuriously receive ISC_R_CONNECTIONRESET even when connection to the loopback interface. Skip the other checks in such case and graciously shutdown the TCP connection. --- tests/dns/dispatch_test.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/dns/dispatch_test.c b/tests/dns/dispatch_test.c index 8352ca0913..8a94582c4d 100644 --- a/tests/dns/dispatch_test.c +++ b/tests/dns/dispatch_test.c @@ -467,7 +467,14 @@ connected(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED, void *arg) { test_dispatch_t *test = arg; - REQUIRE(eresult == ISC_R_SUCCESS); + switch (eresult) { + case ISC_R_CONNECTIONRESET: + /* Don't send any data if the connection failed */ + test_dispatch_shutdown(test); + return; + default: + assert_int_equal(eresult, ISC_R_SUCCESS); + } dns_dispatch_send(test->dispentry, &testdata.region); } @@ -477,7 +484,13 @@ connected_shutdown(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED, void *arg) { test_dispatch_t *test = arg; - REQUIRE(eresult == ISC_R_SUCCESS); + switch (eresult) { + case ISC_R_CONNECTIONRESET: + /* Skip */ + break; + default: + assert_int_equal(eresult, ISC_R_SUCCESS); + } test_dispatch_shutdown(test); } @@ -551,9 +564,12 @@ timeout_connected(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED, void *arg) { test_dispatch_t *test = arg; - if (eresult == ISC_R_ADDRNOTAVAIL || eresult == ISC_R_CONNREFUSED) { - /* FIXME: Skip */ - } else { + switch (eresult) { + case ISC_R_ADDRNOTAVAIL: + case ISC_R_CONNREFUSED: + /* Skip */ + break; + default: assert_int_equal(eresult, ISC_R_TIMEDOUT); }