From 1955ad42b3b71a2083bd6d2aec0d9a10dd78eb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 10 Mar 2023 13:25:00 +0000 Subject: [PATCH] tftpd: Gracefully skip tests if networking is not enabled. Sponsored by: Klara, Inc. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D39012 --- libexec/tftpd/tests/functional.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c index 8c35daf5cd65..36f22ea33294 100644 --- a/libexec/tftpd/tests/functional.c +++ b/libexec/tftpd/tests/functional.c @@ -319,7 +319,13 @@ setup(struct sockaddr_storage *to, uint16_t idx) ATF_REQUIRE_EQ(getcwd(pwd, sizeof(pwd)), pwd); /* Must bind(2) pre-fork so it happens before the client's send(2) */ - ATF_REQUIRE((server_s = socket(protocol, SOCK_DGRAM, 0)) > 0); + server_s = socket(protocol, SOCK_DGRAM, 0); + if (server_s < 0 && errno == EAFNOSUPPORT) { + atf_tc_skip("This test requires IPv%d support", + protocol == PF_INET ? 4 : 6); + } + ATF_REQUIRE_MSG(server_s >= 0, + "socket failed with error %s", strerror(errno)); ATF_REQUIRE_EQ_MSG(bind(server_s, server_addr, len), 0, "bind failed with error %s", strerror(errno));