Date: Mon, 4 Feb 2019 19:12:45 +0000 (UTC) From: Enji Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343751 - head/lib/libc/tests/sys Message-ID: <201902041912.x14JCjBd020269@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Mon Feb 4 19:12:45 2019 New Revision: 343751 URL: https://svnweb.freebsd.org/changeset/base/343751 Log: Avoid the DNS lookup for "localhost" ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test VM), so in order for the test to pass on the host, it needs to avoid the DNS lookup by using the numeric host address representation. PR: 235200 Reviewed by: asomers, lwhsu Approved by: emaste (mentor) MFC after: 2 weeks MFC with: r343362, r343365, r343367-r343368, r343461 Differential Revision: https://reviews.freebsd.org/D19026 Modified: head/lib/libc/tests/sys/sendfile_test.c Modified: head/lib/libc/tests/sys/sendfile_test.c ============================================================================== --- head/lib/libc/tests/sys/sendfile_test.c Mon Feb 4 18:30:47 2019 (r343750) +++ head/lib/libc/tests/sys/sendfile_test.c Mon Feb 4 19:12:45 2019 (r343751) @@ -97,22 +97,31 @@ generate_random_port(int seed) static void resolve_localhost(struct addrinfo **res, int domain, int type, int port) { + const char *host; char *serv; struct addrinfo hints; int error; - ATF_REQUIRE_MSG(domain == AF_INET || domain == AF_INET6, - "unhandled domain: %d", domain); + switch (domain) { + case AF_INET: + host = "127.0.0.1"; + break; + case AF_INET6: + host = "::1"; + break; + default: + atf_tc_fail("unhandled domain: %d", domain); + } ATF_REQUIRE_MSG(asprintf(&serv, "%d", port) >= 0, "asprintf failed: %s", strerror(errno)); memset(&hints, 0, sizeof(hints)); hints.ai_family = domain; - hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV; + hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV|AI_NUMERICHOST; hints.ai_socktype = type; - error = getaddrinfo("localhost", serv, &hints, res); + error = getaddrinfo(host, serv, &hints, res); ATF_REQUIRE_EQ_MSG(error, 0, "getaddrinfo failed: %s", gai_strerror(error)); free(serv);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902041912.x14JCjBd020269>