Re: test-getaddrinfo: skip on EAI_NONAME when DNS is unavailable

Simon Josefsson via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
I've installed your patch to gnulib fixing this.

/Simon

Zineb Zaadoud via GNU gettext discussion list
<bug-gettext-mXXj517/[email protected]> writes:

> Hi,
>
> Ubuntu hit a build failure in gettext 1.0-1 caused by test-getaddrinfo.
>
> The test tries to resolve external hostnames with getaddrinfo(). In the
> Ubuntu build environment, where DNS resolution may be unavailable,
> getaddrinfo() returned EAI_NONAME (-2). The test expected success and
> failed.
>
> The test already treats EAI_AGAIN as a no-network case and skips instead of
> failing. The attached patch treats EAI_NONAME the same way, since this can
> also be returned when DNS resolution is unavailable in sandboxed build
> environments.
>
> PPA validation:
> https://launchpad.net/~zineb/+archive/ubuntu/gettext-ftbfs
>
> Thanks,
> Zineb
> diff --git a/gettext-tools/gnulib-tests/test-getaddrinfo.c b/gettext-tools/gnulib-tests/test-getaddrinfo.c
> index 83e52d10..4070cc26 100644
> --- a/gettext-tools/gnulib-tests/test-getaddrinfo.c
> +++ b/gettext-tools/gnulib-tests/test-getaddrinfo.c
> @@ -120,6 +120,16 @@ simple (int pass, char const *host, char const *service)
>            fprintf (stderr, "skipping getaddrinfo test: no network?\n");
>            return 77;
>          }
> +
> +      /* EAI_NONAME can be returned in sandboxed build environments where
> +         DNS resolution is unavailable. Treat it like EAI_AGAIN and skip.  */
> +      if (res == EAI_NONAME)
> +        {
> +          skip++;
> +          fprintf (stderr, "skipping getaddrinfo test: no DNS resolver?\n");
> +          return 77;
> +        }
> +
>        /* Solaris reports EAI_SERVICE for "http" and "https".  Don't
>           fail the test merely because of this.  */
>        if (res == EAI_SERVICE)
>
0001-getaddrinfo-tests-Skip-when-DNS-resolution-is-unavai.patch (text/x-diff, 1.7 KB)
From 48c984ad10f8dc4a6470389fc99b906406dfcd19 Mon Sep 17 00:00:00 2001
From: Zineb Zaadoud <[email protected]>
Date: Tue, 30 Jun 2026 18:10:59 +0200
Subject: [PATCH] getaddrinfo tests: Skip when DNS resolution is unavailable

* tests/test-getaddrinfo.c (simple): Skip tests for unavailable DNS.

Signed-off-by: Simon Josefsson <[email protected]>
---
 ChangeLog                |  5 +++++
 tests/test-getaddrinfo.c | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 1164db433b..4a0e91ef9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2026-06-30  Zineb Zaadoud <[email protected]>  (tiny change)
+
+	getaddrinfo: Skip when DNS resolution is unavailable
+	* tests/test-getaddrinfo.c (simple): Skip tests for unavailable DNS.
+
 2026-06-26  Paul Eggert  <[email protected]>
 
 	strfmon_l: be consistent about unsigned vs size_t
diff --git a/tests/test-getaddrinfo.c b/tests/test-getaddrinfo.c
index 83e52d1091..4070cc2685 100644
--- a/tests/test-getaddrinfo.c
+++ b/tests/test-getaddrinfo.c
@@ -120,6 +120,16 @@ simple (int pass, char const *host, char const *service)
           fprintf (stderr, "skipping getaddrinfo test: no network?\n");
           return 77;
         }
+
+      /* EAI_NONAME can be returned in sandboxed build environments where
+         DNS resolution is unavailable. Treat it like EAI_AGAIN and skip.  */
+      if (res == EAI_NONAME)
+        {
+          skip++;
+          fprintf (stderr, "skipping getaddrinfo test: no DNS resolver?\n");
+          return 77;
+        }
+
       /* Solaris reports EAI_SERVICE for "http" and "https".  Don't
          fail the test merely because of this.  */
       if (res == EAI_SERVICE)
-- 
2.54.0
signature.asc (application/pgp-signature, 1.2 KB)
-----BEGIN PGP SIGNATURE-----

iQNoBAEWCgMQFiEEo8ychwudMQq61M8vUXIrCP5HRaIFAmpD7W4UHHNpbW9uQGpv
c2Vmc3Nvbi5vcmfCHCYAmDMEXJLOtBYJKwYBBAHaRw8BAQdACIcrZIvhrxDBkK9f
V+QlTmXxo2naObDuGtw58YaxlOu0JVNpbW9uIEpvc2Vmc3NvbiA8c2ltb25Aam9z
ZWZzc29uLm9yZz6IlgQTFggAPgIbAwULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgBYh
BLHSvRN1vst4TPT4xNc89jjFPAa+BQJp4fWRBQkOa+rdAAoJENc89jjFPAa+hWIA
/1lQvrJeGlQq50lP6tm99D1zDy7J1tQ3ha4x0Jx7rkFTAP9hpUKuTvm6m1fXyiZV
YZlu2+Id/Dq3CIAZvNF+XEr2BLgzBFySz4EWCSsGAQQB2kcPAQEHQOxTCIOaeXAx
I2hIX4HK9bQTpNVei708oNr1Klm8qCGKiPUEGBYIACYCGwIWIQSx0r0Tdb7LeEz0
+MTXPPY4xTwGvgUCaeCW1wUJDmqLVgCBdiAEGRYIAB0WIQSjzJyHC50xCrrUzy9R
cisI/kdFogUCXJLPgQAKCRBRcisI/kdFoqdMAQCgH45aseZgIrwKOvUOA9QfsmeE
8GZHYNuFHmM9FEQS6AD6A4x5aYvoY6lo98pgtw2HPDhmcCXFItjXCrV4A0GmJA4J
ENc89jjFPAa+s7AA+gIIHpBApDpcDj1sKhzDngmpvwQf0VkHme6s+EG7qSgpAQDe
/XMrU0c0Pa3ji85cMqZhvzJOFI/soe662lzL0QY3Bbg4BFySz2oSCisGAQQBl1UB
BQEBB0AxlRumDW6nZY7A+VCfek9VpEx6PJmdJyYPt3lNHMd6HAMBCAeIfgQYFggA
JgIbDBYhBLHSvRN1vst4TPT4xNc89jjFPAa+BQJp4JbXBQkOaottAAoJENc89jjF
PAa+RNUA/2faQO/nFT06E+MlhlQdo/0chlQXC5TZMPTVvVBFwoLOAP9xLJK0ow5E
jTzYJB4K810AL/Iv6PEOAEgA4cPTHVlbCQAKCRBRcisI/kdFom2OAP40FiLYicOv
+3twgSFa8QoDG91M8AUB9FHhwcOxWmAy+QEA4JHd+1jmaC5pHw8JN5P4/DdCEW5F
33qPiOOfulx2DQQ=
=ywY9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.