2 * Copyright (c) 2006 Michael Bushkov <bushman@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/socket.h>
33 #include <arpa/inet.h>
34 #include <netinet/in.h>
41 #include <stringlist.h>
46 #include "freebsd_test_suite/macros.h"
52 TEST_GETHOSTBYNAME2_GETADDRINFO,
53 TEST_GETHOSTBYADDR_GETNAMEINFO,
55 TEST_BUILD_ADDR_SNAPSHOT
58 static int ipnode_flags = 0;
59 static int af_type = AF_INET;
60 static bool use_ipnode_functions;
62 DECLARE_TEST_DATA(hostent)
63 DECLARE_TEST_FILE_SNAPSHOT(hostent)
64 DECLARE_1PASS_TEST(hostent)
65 DECLARE_2PASS_TEST(hostent)
67 /* These stubs will use gethostby***() or getipnodeby***() functions,
68 * depending on the use_ipnode_functions global variable value */
69 static struct hostent *__gethostbyname2(const char *, int);
70 static struct hostent *__gethostbyaddr(const void *, socklen_t, int);
71 static void __freehostent(struct hostent *);
73 static void clone_hostent(struct hostent *, struct hostent const *);
74 static int compare_hostent(struct hostent *, struct hostent *, void *);
75 static void dump_hostent(struct hostent *);
76 static void free_hostent(struct hostent *);
78 static int is_hostent_equal(struct hostent *, struct addrinfo *);
80 static void sdump_hostent(struct hostent *, char *, size_t);
81 static int hostent_read_hostlist_func(struct hostent *, char *);
82 static int hostent_read_snapshot_addr(char *, unsigned char *, size_t);
83 static int hostent_read_snapshot_func(struct hostent *, char *);
85 static int hostent_test_correctness(struct hostent *, void *);
86 static int hostent_test_gethostbyaddr(struct hostent *, void *);
87 static int hostent_test_getaddrinfo_eq(struct hostent *, void *);
88 static int hostent_test_getnameinfo_eq(struct hostent *, void *);
90 IMPLEMENT_TEST_DATA(hostent)
91 IMPLEMENT_TEST_FILE_SNAPSHOT(hostent)
92 IMPLEMENT_1PASS_TEST(hostent)
93 IMPLEMENT_2PASS_TEST(hostent)
95 static struct hostent *
96 __gethostbyname2(const char *name, int af)
101 if (use_ipnode_functions) {
103 he = getipnodebyname(name, af, ipnode_flags, &error);
107 he = gethostbyname2(name, af);
112 static struct hostent *
113 __gethostbyaddr(const void *addr, socklen_t len, int af)
118 if (use_ipnode_functions) {
120 he = getipnodebyaddr(addr, len, af, &error);
124 he = gethostbyaddr(addr, len, af);
130 __freehostent(struct hostent *he)
133 /* NOTE: checking for he != NULL - just in case */
134 if (use_ipnode_functions && he != NULL)
139 clone_hostent(struct hostent *dest, struct hostent const *src)
141 ATF_REQUIRE(dest != NULL);
142 ATF_REQUIRE(src != NULL);
149 memset(dest, 0, sizeof(struct hostent));
151 if (src->h_name != NULL) {
152 dest->h_name = strdup(src->h_name);
153 ATF_REQUIRE(dest->h_name != NULL);
156 dest->h_addrtype = src->h_addrtype;
157 dest->h_length = src->h_length;
159 if (src->h_aliases != NULL) {
161 for (cp = src->h_aliases; *cp; ++cp)
164 dest->h_aliases = calloc(aliases_num + 1, sizeof(char *));
165 ATF_REQUIRE(dest->h_aliases != NULL);
167 for (cp = src->h_aliases; *cp; ++cp) {
168 dest->h_aliases[cp - src->h_aliases] = strdup(*cp);
169 ATF_REQUIRE(dest->h_aliases[cp - src->h_aliases] != NULL);
173 if (src->h_addr_list != NULL) {
175 for (cp = src->h_addr_list; *cp; ++cp)
178 dest->h_addr_list = calloc(addrs_num + 1, sizeof(char *));
179 ATF_REQUIRE(dest->h_addr_list != NULL);
181 for (cp = src->h_addr_list; *cp; ++cp) {
182 offset = cp - src->h_addr_list;
183 dest->h_addr_list[offset] = malloc(src->h_length);
184 ATF_REQUIRE(dest->h_addr_list[offset] != NULL);
185 memcpy(dest->h_addr_list[offset],
186 src->h_addr_list[offset], src->h_length);
192 free_hostent(struct hostent *ht)
196 ATF_REQUIRE(ht != NULL);
200 if (ht->h_aliases != NULL) {
201 for (cp = ht->h_aliases; *cp; ++cp)
206 if (ht->h_addr_list != NULL) {
207 for (cp = ht->h_addr_list; *cp; ++cp)
209 free(ht->h_addr_list);
214 compare_hostent(struct hostent *ht1, struct hostent *ht2, void *mdata)
216 char **c1, **c2, **ct, **cb;
222 if (ht1 == NULL || ht2 == NULL)
225 if (ht1->h_name == NULL || ht2->h_name == NULL)
228 if (ht1->h_addrtype != ht2->h_addrtype ||
229 ht1->h_length != ht2->h_length ||
230 strcmp(ht1->h_name, ht2->h_name) != 0)
236 if ((ht1->h_aliases == NULL || ht2->h_aliases == NULL) &&
237 ht1->h_aliases != ht2->h_aliases)
240 if (c1 != NULL && c2 != NULL) {
244 for (ct = c2; *ct; ++ct) {
245 if (strcmp(*c1, *ct) == 0) {
251 printf("h1 aliases item can't be found in h2 "
260 for (ct = c1; *ct; ++ct) {
261 if (strcmp(*c2, *ct) == 0) {
267 printf("h2 aliases item can't be found in h1 "
274 c1 = ht1->h_addr_list;
275 c2 = ht2->h_addr_list;
277 if ((ht1->h_addr_list == NULL || ht2->h_addr_list== NULL) &&
278 ht1->h_addr_list != ht2->h_addr_list)
281 if (c1 != NULL && c2 != NULL) {
285 for (ct = c2; *ct; ++ct) {
286 if (memcmp(*c1, *ct, ht1->h_length) == 0) {
292 printf("h1 addresses item can't be found in "
301 for (ct = c1; *ct; ++ct) {
302 if (memcmp(*c2, *ct, ht1->h_length) == 0) {
308 printf("h2 addresses item can't be found in "
319 printf("following structures are not equal:\n");
328 check_addrinfo_for_name(struct addrinfo *ai, char const *name)
330 struct addrinfo *ai2;
332 for (ai2 = ai; ai2 != NULL; ai2 = ai2->ai_next) {
333 if (strcmp(ai2->ai_canonname, name) == 0)
341 check_addrinfo_for_addr(struct addrinfo *ai, char const *addr,
342 socklen_t addrlen, int af)
344 struct addrinfo *ai2;
346 for (ai2 = ai; ai2 != NULL; ai2 = ai2->ai_next) {
347 if (af != ai2->ai_family)
353 (void *)&((struct sockaddr_in *)ai2->ai_addr)->sin_addr,
354 MIN(addrlen, ai2->ai_addrlen)) == 0)
359 (void *)&((struct sockaddr_in6 *)ai2->ai_addr)->sin6_addr,
360 MIN(addrlen, ai2->ai_addrlen)) == 0)
372 is_hostent_equal(struct hostent *he, struct addrinfo *ai)
378 printf("checking equality of he and ai\n");
381 rv = check_addrinfo_for_name(ai, he->h_name);
383 printf("not equal - he->h_name couldn't be found\n");
387 for (cp = he->h_addr_list; *cp; ++cp) {
388 rv = check_addrinfo_for_addr(ai, *cp, he->h_length,
391 printf("not equal - one of he->h_addr_list couldn't be found\n");
404 sdump_hostent(struct hostent *ht, char *buffer, size_t buflen)
410 written = snprintf(buffer, buflen, "%s %d %d",
411 ht->h_name, ht->h_addrtype, ht->h_length);
413 if (written > (int)buflen)
417 if (ht->h_aliases != NULL) {
418 if (*(ht->h_aliases) != NULL) {
419 for (cp = ht->h_aliases; *cp; ++cp) {
420 written = snprintf(buffer, buflen, " %s",*cp);
422 if (written > (int)buflen)
430 written = snprintf(buffer, buflen, " noaliases");
432 if (written > (int)buflen)
437 written = snprintf(buffer, buflen, " (null)");
439 if (written > (int)buflen)
444 written = snprintf(buffer, buflen, " : ");
446 if (written > (int)buflen)
450 if (ht->h_addr_list != NULL) {
451 if (*(ht->h_addr_list) != NULL) {
452 for (cp = ht->h_addr_list; *cp; ++cp) {
453 for (i = 0; i < (size_t)ht->h_length; ++i) {
454 written = snprintf(buffer, buflen,
455 i + 1 != (size_t)ht->h_length ?
457 (unsigned char)(*cp)[i]);
459 if (written > (int)buflen)
468 written = snprintf(buffer, buflen,
471 if (written > (int)buflen)
477 written = snprintf(buffer, buflen, " noaddrs");
479 if (written > (int)buflen)
484 written = snprintf(buffer, buflen, " (null)");
486 if (written > (int)buflen)
493 hostent_read_hostlist_func(struct hostent *he, char *line)
495 struct hostent *result;
499 printf("resolving %s: ", line);
501 result = __gethostbyname2(line, af_type);
502 if (result != NULL) {
507 rv = hostent_test_correctness(result, NULL);
509 __freehostent(result);
513 clone_hostent(he, result);
514 __freehostent(result);
517 printf("not found\n");
519 memset(he, 0, sizeof(struct hostent));
520 he->h_name = strdup(line);
521 ATF_REQUIRE(he->h_name != NULL);
527 hostent_read_snapshot_addr(char *addr, unsigned char *result, size_t len)
532 while ( (s = strsep(&ps, ".")) != NULL) {
536 *result = (unsigned char)strtol(s, &ts, 10);
550 hostent_read_snapshot_func(struct hostent *ht, char *line)
552 StringList *sl1, *sl2;
557 printf("1 line read from snapshot:\n%s\n", line);
564 memset(ht, 0, sizeof(struct hostent));
565 while ((s = strsep(&ps, " ")) != NULL) {
568 ht->h_name = strdup(s);
569 ATF_REQUIRE(ht->h_name != NULL);
573 ht->h_addrtype = (int)strtol(s, &ts, 10);
579 ht->h_length = (int)strtol(s, &ts, 10);
586 if (strcmp(s, "(null)") == 0)
590 ATF_REQUIRE(sl1 != NULL);
592 if (strcmp(s, "noaliases") != 0) {
594 ATF_REQUIRE(ts != NULL);
598 if (strcmp(s, ":") == 0)
602 ATF_REQUIRE(ts != NULL);
610 if (strcmp(s, "(null)") == 0)
614 ATF_REQUIRE(sl2 != NULL);
616 if (strcmp(s, "noaddrs") != 0) {
617 ts = calloc(1, ht->h_length);
618 ATF_REQUIRE(ts != NULL);
619 rv = hostent_read_snapshot_addr(s,
627 ts = calloc(1, ht->h_length);
628 ATF_REQUIRE(ts != NULL);
629 rv = hostent_read_snapshot_addr(s,
630 (unsigned char *)ts, ht->h_length);
640 if (i != 3 && i != 4)
647 ht->h_aliases = sl1->sl_str;
651 ht->h_addr_list = sl2->sl_str;
654 if ((i != 4) || (rv != 0)) {
656 memset(ht, 0, sizeof(struct hostent));
660 /* NOTE: is it a dirty hack or not? */
667 dump_hostent(struct hostent *result)
669 if (result != NULL) {
671 sdump_hostent(result, buffer, sizeof(buffer));
672 printf("%s\n", buffer);
678 hostent_test_correctness(struct hostent *ht, void *mdata __unused)
682 printf("testing correctness with the following data:\n");
689 if (ht->h_name == NULL)
692 if (!((ht->h_addrtype >= 0) && (ht->h_addrtype < AF_MAX)))
695 if ((ht->h_length != sizeof(struct in_addr)) &&
696 (ht->h_length != sizeof(struct in6_addr)))
699 if (ht->h_aliases == NULL)
702 if (ht->h_addr_list == NULL)
711 printf("incorrect\n");
717 hostent_test_gethostbyaddr(struct hostent *he, void *mdata)
719 struct hostent *result;
720 struct hostent_test_data *addr_test_data;
723 addr_test_data = (struct hostent_test_data *)mdata;
725 /* We should omit unresolved hostents */
726 if (he->h_addr_list != NULL) {
728 for (cp = he->h_addr_list; *cp; ++cp) {
730 printf("doing reverse lookup for %s\n", he->h_name);
733 result = __gethostbyaddr(*cp, he->h_length,
735 if (result == NULL) {
737 printf("%s: warning: reverse lookup failed "
738 "for %s: %s\n", __func__, he->h_name,
743 rv = hostent_test_correctness(result, NULL);
745 __freehostent(result);
749 if (addr_test_data != NULL)
750 TEST_DATA_APPEND(hostent, addr_test_data,
753 __freehostent(result);
761 hostent_test_getaddrinfo_eq(struct hostent *he, void *mdata __unused)
763 struct addrinfo *ai, hints;
767 memset(&hints, 0, sizeof(struct addrinfo));
768 hints.ai_family = af_type;
769 hints.ai_flags = AI_CANONNAME;
771 printf("using getaddrinfo() to resolve %s\n", he->h_name);
773 /* struct hostent *he was not resolved */
774 if (he->h_addr_list == NULL) {
775 /* We can be sure that he->h_name is not NULL */
776 rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
778 printf("not ok - shouldn't have been resolved\n");
783 rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
785 printf("not ok - should have been resolved\n");
789 rv = is_hostent_equal(he, ai);
791 printf("not ok - addrinfo and hostent are not equal\n");
802 hostent_test_getnameinfo_eq(struct hostent *he, void *mdata __unused)
805 char buffer[NI_MAXHOST];
806 struct sockaddr_in sin;
807 struct sockaddr_in6 sin6;
808 struct sockaddr *saddr;
809 struct hostent *result;
812 if (he->h_addr_list == NULL)
815 for (cp = he->h_addr_list; *cp; ++cp) {
817 printf("doing reverse lookup for %s\n", he->h_name);
819 result = __gethostbyaddr(*cp, he->h_length,
821 if (result != NULL) {
822 rv = hostent_test_correctness(result, NULL);
824 __freehostent(result);
828 printf("%s: warning: reverse lookup failed "
829 "for %s: %s\n", __func__, he->h_name,
832 switch (he->h_addrtype) {
834 memset(&sin, 0, sizeof(struct sockaddr_in));
835 sin.sin_len = sizeof(struct sockaddr_in);
836 sin.sin_family = AF_INET;
837 memcpy(&sin.sin_addr, *cp, he->h_length);
839 saddr = (struct sockaddr *)&sin;
842 memset(&sin6, 0, sizeof(struct sockaddr_in6));
843 sin6.sin6_len = sizeof(struct sockaddr_in6);
844 sin6.sin6_family = AF_INET6;
845 memcpy(&sin6.sin6_addr, *cp, he->h_length);
847 saddr = (struct sockaddr *)&sin6;
850 printf("warning: %d family is unsupported\n",
855 ATF_REQUIRE(saddr != NULL);
856 rv = getnameinfo(saddr, saddr->sa_len, buffer,
857 sizeof(buffer), NULL, 0, NI_NAMEREQD);
859 if (rv != 0 && result != NULL) {
860 printf("getnameinfo() didn't make the reverse "
861 "lookup, when it should have (%s)\n",
866 if (rv == 0 && result == NULL) {
867 printf("getnameinfo() made the "
868 "reverse lookup, when it shouldn't have\n");
872 if (rv != 0 && result == NULL) {
874 printf("both getnameinfo() and ***byaddr() failed as "
881 printf("comparing %s with %s\n", result->h_name,
886 * An address might reverse resolve to hostname alias or the
887 * official hostname, e.g. moon.vub.ac.be.
889 bool found_a_match = false;
891 if (strcmp(result->h_name, buffer) == 0) {
892 found_a_match = true;
894 printf("matched official hostname\n");
897 for (i = 0; result->h_aliases[i] != NULL; i++) {
898 printf("[%d] resolved: %s\n", i,
899 result->h_aliases[i]);
900 if (strcmp(result->h_aliases[i],
902 printf("matched hostname alias\n");
903 found_a_match = true;
908 __freehostent(result);
912 printf("getnameinfo() and ***byaddr() results are "
916 printf("getnameinfo() and ***byaddr() results are not "
917 "equal for %s\n", he->h_name);
926 run_tests(const char *hostlist_file, const char *snapshot_file, int _af_type,
927 enum test_methods method, bool use_ipv6_mapping)
929 char *snapshot_file_copy;
930 struct hostent_test_data td, td_addr, td_snap;
934 if (snapshot_file == NULL)
935 snapshot_file_copy = NULL;
937 snapshot_file_copy = strdup(snapshot_file);
938 ATF_REQUIRE(snapshot_file_copy != NULL);
940 snapshot_file = snapshot_file_copy;
944 ATF_REQUIRE_FEATURE("inet");
945 ATF_REQUIRE(!use_ipv6_mapping);
948 ATF_REQUIRE_FEATURE("inet6");
951 atf_tc_fail("unhandled address family: %d", _af_type);
955 if (!use_ipnode_functions) {
956 statp = __res_state();
957 if (statp == NULL || ((statp->options & RES_INIT) == 0 &&
958 res_ninit(statp) == -1)) {
959 printf("error: can't init res_state\n");
964 if (use_ipv6_mapping)
965 statp->options |= RES_USE_INET6;
967 statp->options &= ~RES_USE_INET6;
970 TEST_DATA_INIT(hostent, &td, clone_hostent, free_hostent);
971 TEST_DATA_INIT(hostent, &td_addr, clone_hostent, free_hostent);
972 TEST_DATA_INIT(hostent, &td_snap, clone_hostent, free_hostent);
974 if (access(hostlist_file, R_OK) != 0) {
975 printf("can't access the hostlist file %s\n", hostlist_file);
981 printf("building host lists from %s\n", hostlist_file);
984 rv = TEST_SNAPSHOT_FILE_READ(hostent, hostlist_file, &td,
985 hostent_read_hostlist_func);
987 printf("failed to read the host list file: %s\n",
992 if (snapshot_file != NULL) {
993 if (access(snapshot_file, W_OK | R_OK) != 0) {
994 if (errno == ENOENT) {
995 if (method != TEST_GETHOSTBYADDR)
996 method = TEST_BUILD_SNAPSHOT;
998 method = TEST_BUILD_ADDR_SNAPSHOT;
1000 printf("can't access the snapshot file %s\n",
1006 rv = TEST_SNAPSHOT_FILE_READ(hostent, snapshot_file,
1007 &td_snap, hostent_read_snapshot_func);
1009 printf("error reading snapshot file\n");
1016 case TEST_GETHOSTBYNAME2:
1017 if (snapshot_file != NULL)
1018 rv = DO_2PASS_TEST(hostent, &td, &td_snap,
1019 compare_hostent, NULL);
1021 case TEST_GETHOSTBYADDR:
1022 rv = DO_1PASS_TEST(hostent, &td,
1023 hostent_test_gethostbyaddr, (void *)&td_addr);
1027 if (snapshot_file != NULL)
1028 rv = DO_2PASS_TEST(hostent, &td_addr, &td_snap,
1029 compare_hostent, NULL);
1031 case TEST_GETHOSTBYNAME2_GETADDRINFO:
1032 rv = DO_1PASS_TEST(hostent, &td,
1033 hostent_test_getaddrinfo_eq, NULL);
1035 case TEST_GETHOSTBYADDR_GETNAMEINFO:
1036 rv = DO_1PASS_TEST(hostent, &td,
1037 hostent_test_getnameinfo_eq, NULL);
1039 case TEST_BUILD_SNAPSHOT:
1040 if (snapshot_file != NULL) {
1041 rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file,
1042 &td, sdump_hostent);
1045 case TEST_BUILD_ADDR_SNAPSHOT:
1046 if (snapshot_file != NULL) {
1047 rv = DO_1PASS_TEST(hostent, &td,
1048 hostent_test_gethostbyaddr, (void *)&td_addr);
1051 rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file,
1052 &td_addr, sdump_hostent);
1061 TEST_DATA_DESTROY(hostent, &td_snap);
1062 TEST_DATA_DESTROY(hostent, &td_addr);
1063 TEST_DATA_DESTROY(hostent, &td);
1066 free(snapshot_file_copy);
1071 #define HOSTLIST_FILE "mach"
1073 #define _RUN_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping) \
1075 char *_hostlist_file; \
1076 ATF_REQUIRE(0 < asprintf(&_hostlist_file, "%s/%s", \
1077 atf_tc_get_config_var(tc, "srcdir"), HOSTLIST_FILE)); \
1078 ATF_REQUIRE(run_tests(_hostlist_file, snapshot_file, af_type, \
1079 method, use_ipv6_mapping) == 0); \
1080 free(_hostlist_file); \
1083 #define RUN_HOST_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping) \
1085 use_ipnode_functions = false; \
1086 _RUN_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping); \
1089 #define RUN_IPNODE_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping) \
1091 use_ipnode_functions = true; \
1092 _RUN_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping); \
1095 ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv4);
1096 ATF_TC_BODY(gethostbyaddr_ipv4, tc)
1099 RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR, false);
1102 ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv4_with_snapshot);
1103 ATF_TC_BODY(gethostbyaddr_ipv4_with_snapshot, tc)
1106 RUN_HOST_TESTS(tc, "snapshot_htaddr4", AF_INET, TEST_GETHOSTBYADDR, false);
1109 ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6);
1110 ATF_TC_BODY(gethostbyaddr_ipv6, tc)
1113 RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, false);
1116 ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6_AI_V4MAPPED);
1117 ATF_TC_BODY(gethostbyaddr_ipv6_AI_V4MAPPED, tc)
1120 ipnode_flags = AI_V4MAPPED;
1121 RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);
1124 ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6_with_snapshot);
1125 ATF_TC_BODY(gethostbyaddr_ipv6_with_snapshot, tc)
1128 RUN_HOST_TESTS(tc, "snapshot_htaddr6", AF_INET6, TEST_GETHOSTBYADDR, false);
1131 ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6_with_snapshot_AI_V4MAPPED);
1132 ATF_TC_BODY(gethostbyaddr_ipv6_with_snapshot_AI_V4MAPPED, tc)
1135 ipnode_flags = AI_V4MAPPED;
1136 RUN_HOST_TESTS(tc, "snapshot_htaddr6map", AF_INET6, TEST_GETHOSTBYADDR, true);
1139 ATF_TC_WITHOUT_HEAD(gethostbyname2_getaddrinfo_ipv4);
1140 ATF_TC_BODY(gethostbyname2_getaddrinfo_ipv4, tc)
1143 RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2_GETADDRINFO, false);
1146 ATF_TC_WITHOUT_HEAD(gethostbyname2_getaddrinfo_ipv6);
1147 ATF_TC_BODY(gethostbyname2_getaddrinfo_ipv6, tc)
1150 RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2_GETADDRINFO, false);
1153 ATF_TC_WITHOUT_HEAD(gethostbyaddr_getnameinfo_ipv4);
1154 ATF_TC_BODY(gethostbyaddr_getnameinfo_ipv4, tc)
1157 RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR_GETNAMEINFO, false);
1160 ATF_TC_WITHOUT_HEAD(gethostbyaddr_getnameinfo_ipv6);
1161 ATF_TC_BODY(gethostbyaddr_getnameinfo_ipv6, tc)
1164 RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR_GETNAMEINFO, false);
1167 ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv4);
1168 ATF_TC_BODY(gethostbyname2_ipv4, tc)
1171 RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2, false);
1174 ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv4_with_snapshot);
1175 ATF_TC_BODY(gethostbyname2_ipv4_with_snapshot, tc)
1178 RUN_HOST_TESTS(tc, "snapshot_htname4", AF_INET, TEST_GETHOSTBYNAME2, false);
1181 ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6);
1182 ATF_TC_BODY(gethostbyname2_ipv6, tc)
1185 RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);
1188 ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6_AI_V4MAPPED);
1189 ATF_TC_BODY(gethostbyname2_ipv6_AI_V4MAPPED, tc)
1192 ipnode_flags = AI_V4MAPPED;
1193 RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);
1196 ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6_with_snapshot);
1197 ATF_TC_BODY(gethostbyname2_ipv6_with_snapshot, tc)
1200 RUN_HOST_TESTS(tc, "snapshot_htname6", AF_INET6, TEST_GETHOSTBYNAME2, false);
1203 ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6_with_snapshot_AI_V4MAPPED);
1204 ATF_TC_BODY(gethostbyname2_ipv6_with_snapshot_AI_V4MAPPED, tc)
1207 ipnode_flags = AI_V4MAPPED;
1208 RUN_HOST_TESTS(tc, "snapshot_htname6map", AF_INET6, TEST_GETHOSTBYNAME2, true);
1211 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv4);
1212 ATF_TC_BODY(getipnodebyaddr_ipv4, tc)
1215 RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR, false);
1218 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv4_with_snapshot);
1219 ATF_TC_BODY(getipnodebyaddr_ipv4_with_snapshot, tc)
1222 RUN_IPNODE_TESTS(tc, "snapshot_ipnodeaddr4", AF_INET, TEST_GETHOSTBYADDR, false);
1225 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_getnameinfo_ipv4);
1226 ATF_TC_BODY(getipnodebyaddr_getnameinfo_ipv4, tc)
1229 RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR_GETNAMEINFO, false);
1232 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6);
1233 ATF_TC_BODY(getipnodebyaddr_ipv6, tc)
1236 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, false);
1239 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_AI_V4MAPPED);
1240 ATF_TC_BODY(getipnodebyaddr_ipv6_AI_V4MAPPED, tc)
1243 ipnode_flags = AI_V4MAPPED;
1244 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);
1247 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG);
1248 ATF_TC_BODY(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG, tc)
1251 ipnode_flags = AI_V4MAPPED_CFG;
1252 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);
1255 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG_AI_ALL);
1256 ATF_TC_BODY(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG_AI_ALL, tc)
1259 ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;
1260 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);
1263 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot);
1264 ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot, tc)
1267 RUN_IPNODE_TESTS(tc, "snapshot_ipnodeaddr6", AF_INET6, TEST_GETHOSTBYADDR, false);
1270 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED);
1271 ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED, tc)
1274 ipnode_flags = AI_V4MAPPED;
1275 RUN_IPNODE_TESTS(tc,
1276 "snapshot_ipnodeaddr6_AI_V4MAPPED", AF_INET6,
1277 TEST_GETHOSTBYADDR, true);
1280 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG);
1281 ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG, tc)
1284 ipnode_flags = AI_V4MAPPED_CFG;
1285 RUN_IPNODE_TESTS(tc,
1286 "snapshot_ipnodeaddr6_AI_V4MAPPED_CFG", AF_INET6,
1287 TEST_GETHOSTBYADDR, true);
1290 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);
1291 ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL, tc)
1294 ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;
1295 RUN_IPNODE_TESTS(tc,
1296 "snapshot_ipnodeaddr6_AI_V4MAPPED_CFG_AI_ALL", AF_INET6,
1297 TEST_GETHOSTBYADDR, true);
1300 ATF_TC_WITHOUT_HEAD(getipnodebyaddr_getnameinfo_ipv6);
1301 ATF_TC_BODY(getipnodebyaddr_getnameinfo_ipv6, tc)
1304 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR_GETNAMEINFO, false);
1307 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4);
1308 ATF_TC_BODY(getipnodebyname_ipv4, tc)
1311 RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2, false);
1314 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4_with_snapshot);
1315 ATF_TC_BODY(getipnodebyname_ipv4_with_snapshot, tc)
1318 RUN_IPNODE_TESTS(tc, "snapshot_ipnodename4", AF_INET, TEST_GETHOSTBYNAME2, false);
1321 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4_AI_ADDRCONFIG);
1322 ATF_TC_BODY(getipnodebyname_ipv4_AI_ADDRCONFIG, tc)
1325 ipnode_flags = AI_ADDRCONFIG;
1326 RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2, false);
1329 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4_with_snapshot_AI_ADDRCONFIG);
1330 ATF_TC_BODY(getipnodebyname_ipv4_with_snapshot_AI_ADDRCONFIG, tc)
1333 ipnode_flags = AI_ADDRCONFIG;
1334 RUN_IPNODE_TESTS(tc, "snapshot_ipnodename4_AI_ADDRCONFIG", AF_INET,
1335 TEST_GETHOSTBYNAME2, false);
1338 ATF_TC_WITHOUT_HEAD(getipnodebyname_getaddrinfo_ipv4);
1339 ATF_TC_BODY(getipnodebyname_getaddrinfo_ipv4, tc)
1342 RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2_GETADDRINFO, false);
1345 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6);
1346 ATF_TC_BODY(getipnodebyname_ipv6, tc)
1349 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);
1352 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot);
1353 ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot, tc)
1356 RUN_IPNODE_TESTS(tc, "snapshot_ipnodename6", AF_INET6, TEST_GETHOSTBYNAME2, false);
1359 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_ADDRCONFIG);
1360 ATF_TC_BODY(getipnodebyname_ipv6_AI_ADDRCONFIG, tc)
1363 ipnode_flags = AI_ADDRCONFIG;
1364 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);
1367 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED);
1368 ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED, tc)
1371 ipnode_flags = AI_V4MAPPED;
1372 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);
1375 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED_CFG);
1376 ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED_CFG, tc)
1379 ipnode_flags = AI_V4MAPPED_CFG;
1380 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);
1383 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ADDRCONFIG);
1384 ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ADDRCONFIG, tc)
1387 ipnode_flags = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
1388 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);
1391 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ALL);
1392 ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ALL, tc)
1395 ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;
1396 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);
1399 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED);
1400 ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED, tc)
1403 ipnode_flags = AI_V4MAPPED;
1404 RUN_IPNODE_TESTS(tc,
1405 "snapshot_ipnodename6_AI_V4MAPPED", AF_INET6,
1406 TEST_GETHOSTBYNAME2, true);
1409 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG);
1410 ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG, tc)
1413 ipnode_flags = AI_V4MAPPED_CFG;
1414 RUN_IPNODE_TESTS(tc,
1415 "snapshot_ipnodename6_AI_V4MAPPED_CFG", AF_INET6,
1416 TEST_GETHOSTBYNAME2, true);
1419 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ADDRCONFIG);
1420 ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ADDRCONFIG, tc)
1423 ipnode_flags = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
1424 RUN_IPNODE_TESTS(tc,
1425 "snapshot_ipnodename6_AI_V4MAPPED_CFG_AI_ADDRCONFIG", AF_INET6,
1426 TEST_GETHOSTBYNAME2, false);
1429 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);
1430 ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL, tc)
1433 ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;
1434 RUN_IPNODE_TESTS(tc,
1435 "snapshot_ipnodename6_AI_V4MAPPED_CFG_AI_ALL", AF_INET6,
1436 TEST_GETHOSTBYNAME2, true);
1439 ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_ADDRCONFIG);
1440 ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_ADDRCONFIG, tc)
1443 ipnode_flags = AI_ADDRCONFIG;
1444 RUN_IPNODE_TESTS(tc, "snapshot_ipnodename6_AI_ADDRCONFIG", AF_INET6,
1445 TEST_GETHOSTBYNAME2, false);
1448 ATF_TC_WITHOUT_HEAD(getipnodebyname_getaddrinfo_ipv6);
1449 ATF_TC_BODY(getipnodebyname_getaddrinfo_ipv6, tc)
1452 RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2_GETADDRINFO, false);
1459 ATF_TP_ADD_TC(tp, gethostbyaddr_ipv4);
1460 ATF_TP_ADD_TC(tp, gethostbyaddr_ipv4_with_snapshot);
1461 ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6);
1462 ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6_AI_V4MAPPED); /* XXX */
1463 ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6_with_snapshot);
1464 ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6_with_snapshot_AI_V4MAPPED);
1465 ATF_TP_ADD_TC(tp, gethostbyaddr_getnameinfo_ipv4);
1466 ATF_TP_ADD_TC(tp, gethostbyaddr_getnameinfo_ipv6);
1468 /* gethostbyname2 */
1469 ATF_TP_ADD_TC(tp, gethostbyname2_getaddrinfo_ipv4);
1470 ATF_TP_ADD_TC(tp, gethostbyname2_getaddrinfo_ipv6);
1471 ATF_TP_ADD_TC(tp, gethostbyname2_ipv4);
1472 ATF_TP_ADD_TC(tp, gethostbyname2_ipv4_with_snapshot);
1473 ATF_TP_ADD_TC(tp, gethostbyname2_ipv6);
1474 ATF_TP_ADD_TC(tp, gethostbyname2_ipv6_AI_V4MAPPED);
1475 ATF_TP_ADD_TC(tp, gethostbyname2_ipv6_with_snapshot);
1476 ATF_TP_ADD_TC(tp, gethostbyname2_ipv6_with_snapshot_AI_V4MAPPED);
1478 /* getipnodebyaddr */
1479 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv4);
1480 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv4_with_snapshot);
1481 ATF_TP_ADD_TC(tp, getipnodebyaddr_getnameinfo_ipv4);
1482 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6);
1483 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_AI_V4MAPPED);
1484 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_AI_V4MAPPED_CFG);
1485 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_AI_V4MAPPED_CFG_AI_ALL);
1486 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot);
1487 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED);
1488 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG);
1489 ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);
1490 ATF_TP_ADD_TC(tp, getipnodebyaddr_getnameinfo_ipv6);
1492 /* getipnodebyname */
1493 ATF_TP_ADD_TC(tp, getipnodebyname_ipv4);
1494 ATF_TP_ADD_TC(tp, getipnodebyname_ipv4_with_snapshot);
1495 ATF_TP_ADD_TC(tp, getipnodebyname_ipv4_AI_ADDRCONFIG);
1496 ATF_TP_ADD_TC(tp, getipnodebyname_ipv4_with_snapshot_AI_ADDRCONFIG);
1497 ATF_TP_ADD_TC(tp, getipnodebyname_getaddrinfo_ipv4);
1498 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6);
1499 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot);
1500 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_ADDRCONFIG);
1501 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED);
1502 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED_CFG);
1503 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ADDRCONFIG);
1504 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ALL);
1505 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED);
1506 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG);
1507 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ADDRCONFIG);
1508 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);
1509 ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_ADDRCONFIG);
1510 ATF_TP_ADD_TC(tp, getipnodebyname_getaddrinfo_ipv6);
1512 return (atf_no_error());