localedata: fy_DE: make this "Western Frisian" to agree with the language code "fy"
[glibc.git] / nss / tst-nss-gai-hv2-canonname.c
blob7db53cf09da8dcb6ba0186391ac9c273de81aca4
1 /* Test NSS query path for plugins that only implement gethostbyname2
2 (#30843).
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/>. */
20 #include <nss.h>
21 #include <netdb.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <mcheck.h>
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);
39 xfclose (hosts);
42 static int
43 do_test (void)
45 mtrace ();
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);
57 if (ret != 0)
58 FAIL_EXIT1 ("getaddrinfo failed: %s\n", gai_strerror (ret));
60 TEST_COMPARE_STRING (result->ai_canonname, QUERYNAME);
62 freeaddrinfo(result);
63 return 0;
66 #include <support/test-driver.c>