1 /* Test NSS query path for plugins that only implement gethostbyname2
3 Copyright The GNU Toolchain Authors.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
25 #include <support/check.h>
26 #include <support/xstdio.h>
27 #include "nss/tst-nss-gai-hv2-canonname.h"
29 #define PREPARE do_prepare
31 static void do_prepare (int a
, char **av
)
33 FILE *hosts
= xfopen ("/etc/hosts", "w");
34 for (unsigned i
= 2; i
< 255; i
++)
36 fprintf (hosts
, "ff01::ff02:ff03:%u:2\ttest.example.com\n", i
);
37 fprintf (hosts
, "192.168.0.%u\ttest.example.com\n", i
);
47 __nss_configure_lookup ("hosts", "test_gai_hv2_canonname");
49 struct addrinfo hints
= {};
50 struct addrinfo
*result
= NULL
;
52 hints
.ai_family
= AF_INET6
;
53 hints
.ai_flags
= AI_ALL
| AI_V4MAPPED
| AI_CANONNAME
;
55 int ret
= getaddrinfo (QUERYNAME
, NULL
, &hints
, &result
);
58 FAIL_EXIT1 ("getaddrinfo failed: %s\n", gai_strerror (ret
));
60 TEST_COMPARE_STRING (result
->ai_canonname
, QUERYNAME
);
66 #include <support/test-driver.c>