Path: blob/main/lib/libc/tests/nss/gethostby_test.c
39491 views
/*-1* Copyright (c) 2006 Michael Bushkov <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*25*/2627#include <sys/param.h>28#include <sys/socket.h>29#include <arpa/inet.h>30#include <netinet/in.h>31#include <errno.h>32#include <netdb.h>33#include <resolv.h>34#include <stdio.h>35#include <stdlib.h>36#include <string.h>37#include <stringlist.h>38#include <unistd.h>3940#include <atf-c.h>4142#include "freebsd_test_suite/macros.h"43#include "testutil.h"4445enum test_methods {46TEST_GETHOSTBYNAME2,47TEST_GETHOSTBYADDR,48TEST_GETHOSTBYNAME2_GETADDRINFO,49TEST_GETHOSTBYADDR_GETNAMEINFO,50TEST_BUILD_SNAPSHOT,51TEST_BUILD_ADDR_SNAPSHOT52};5354static int ipnode_flags = 0;55static int af_type = AF_INET;56static bool use_ipnode_functions;5758DECLARE_TEST_DATA(hostent)59DECLARE_TEST_FILE_SNAPSHOT(hostent)60DECLARE_1PASS_TEST(hostent)61DECLARE_2PASS_TEST(hostent)6263/* These stubs will use gethostby***() or getipnodeby***() functions,64* depending on the use_ipnode_functions global variable value */65static struct hostent *__gethostbyname2(const char *, int);66static struct hostent *__gethostbyaddr(const void *, socklen_t, int);67static void __freehostent(struct hostent *);6869static void clone_hostent(struct hostent *, struct hostent const *);70static int compare_hostent(struct hostent *, struct hostent *, void *);71static void dump_hostent(struct hostent *);72static void free_hostent(struct hostent *);7374static int is_hostent_equal(struct hostent *, struct addrinfo *);7576static void sdump_hostent(struct hostent *, char *, size_t);77static int hostent_read_hostlist_func(struct hostent *, char *);78static int hostent_read_snapshot_addr(char *, unsigned char *, size_t);79static int hostent_read_snapshot_func(struct hostent *, char *);8081static int hostent_test_correctness(struct hostent *, void *);82static int hostent_test_gethostbyaddr(struct hostent *, void *);83static int hostent_test_getaddrinfo_eq(struct hostent *, void *);84static int hostent_test_getnameinfo_eq(struct hostent *, void *);8586IMPLEMENT_TEST_DATA(hostent)87IMPLEMENT_TEST_FILE_SNAPSHOT(hostent)88IMPLEMENT_1PASS_TEST(hostent)89IMPLEMENT_2PASS_TEST(hostent)9091static struct hostent *92__gethostbyname2(const char *name, int af)93{94struct hostent *he;95int error;9697if (use_ipnode_functions) {98error = 0;99he = getipnodebyname(name, af, ipnode_flags, &error);100if (he == NULL)101errno = error;102} else103he = gethostbyname2(name, af);104105return (he);106}107108static struct hostent *109__gethostbyaddr(const void *addr, socklen_t len, int af)110{111struct hostent *he;112int error;113114if (use_ipnode_functions) {115error = 0;116he = getipnodebyaddr(addr, len, af, &error);117if (he == NULL)118errno = error;119} else120he = gethostbyaddr(addr, len, af);121122return (he);123}124125static void126__freehostent(struct hostent *he)127{128129/* NOTE: checking for he != NULL - just in case */130if (use_ipnode_functions && he != NULL)131freehostent(he);132}133134static void135clone_hostent(struct hostent *dest, struct hostent const *src)136{137ATF_REQUIRE(dest != NULL);138ATF_REQUIRE(src != NULL);139140char **cp;141int aliases_num;142int addrs_num;143size_t offset;144145memset(dest, 0, sizeof(struct hostent));146147if (src->h_name != NULL) {148dest->h_name = strdup(src->h_name);149ATF_REQUIRE(dest->h_name != NULL);150}151152dest->h_addrtype = src->h_addrtype;153dest->h_length = src->h_length;154155if (src->h_aliases != NULL) {156aliases_num = 0;157for (cp = src->h_aliases; *cp; ++cp)158++aliases_num;159160dest->h_aliases = calloc(aliases_num + 1, sizeof(char *));161ATF_REQUIRE(dest->h_aliases != NULL);162163for (cp = src->h_aliases; *cp; ++cp) {164dest->h_aliases[cp - src->h_aliases] = strdup(*cp);165ATF_REQUIRE(dest->h_aliases[cp - src->h_aliases] != NULL);166}167}168169if (src->h_addr_list != NULL) {170addrs_num = 0;171for (cp = src->h_addr_list; *cp; ++cp)172++addrs_num;173174dest->h_addr_list = calloc(addrs_num + 1, sizeof(char *));175ATF_REQUIRE(dest->h_addr_list != NULL);176177for (cp = src->h_addr_list; *cp; ++cp) {178offset = cp - src->h_addr_list;179dest->h_addr_list[offset] = malloc(src->h_length);180ATF_REQUIRE(dest->h_addr_list[offset] != NULL);181memcpy(dest->h_addr_list[offset],182src->h_addr_list[offset], src->h_length);183}184}185}186187static void188free_hostent(struct hostent *ht)189{190char **cp;191192ATF_REQUIRE(ht != NULL);193194free(ht->h_name);195196if (ht->h_aliases != NULL) {197for (cp = ht->h_aliases; *cp; ++cp)198free(*cp);199free(ht->h_aliases);200}201202if (ht->h_addr_list != NULL) {203for (cp = ht->h_addr_list; *cp; ++cp)204free(*cp);205free(ht->h_addr_list);206}207}208209static int210compare_hostent(struct hostent *ht1, struct hostent *ht2, void *mdata)211{212char **c1, **c2, **ct, **cb;213int b;214215if (ht1 == ht2)216return 0;217218if (ht1 == NULL || ht2 == NULL)219goto errfin;220221if (ht1->h_name == NULL || ht2->h_name == NULL)222goto errfin;223224if (ht1->h_addrtype != ht2->h_addrtype ||225ht1->h_length != ht2->h_length ||226strcmp(ht1->h_name, ht2->h_name) != 0)227goto errfin;228229c1 = ht1->h_aliases;230c2 = ht2->h_aliases;231232if ((ht1->h_aliases == NULL || ht2->h_aliases == NULL) &&233ht1->h_aliases != ht2->h_aliases)234goto errfin;235236if (c1 != NULL && c2 != NULL) {237cb = c1;238for (;*c1; ++c1) {239b = 0;240for (ct = c2; *ct; ++ct) {241if (strcmp(*c1, *ct) == 0) {242b = 1;243break;244}245}246if (b == 0) {247printf("h1 aliases item can't be found in h2 "248"aliases\n");249goto errfin;250}251}252253c1 = cb;254for (;*c2; ++c2) {255b = 0;256for (ct = c1; *ct; ++ct) {257if (strcmp(*c2, *ct) == 0) {258b = 1;259break;260}261}262if (b == 0) {263printf("h2 aliases item can't be found in h1 "264"aliases\n");265goto errfin;266}267}268}269270c1 = ht1->h_addr_list;271c2 = ht2->h_addr_list;272273if ((ht1->h_addr_list == NULL || ht2->h_addr_list== NULL) &&274ht1->h_addr_list != ht2->h_addr_list)275goto errfin;276277if (c1 != NULL && c2 != NULL) {278cb = c1;279for (; *c1; ++c1) {280b = 0;281for (ct = c2; *ct; ++ct) {282if (memcmp(*c1, *ct, ht1->h_length) == 0) {283b = 1;284break;285}286}287if (b == 0) {288printf("h1 addresses item can't be found in "289"h2 addresses\n");290goto errfin;291}292}293294c1 = cb;295for (; *c2; ++c2) {296b = 0;297for (ct = c1; *ct; ++ct) {298if (memcmp(*c2, *ct, ht1->h_length) == 0) {299b = 1;300break;301}302}303if (b == 0) {304printf("h2 addresses item can't be found in "305"h1 addresses\n");306goto errfin;307}308}309}310311return 0;312313errfin:314if (mdata == NULL) {315printf("following structures are not equal:\n");316dump_hostent(ht1);317dump_hostent(ht2);318}319320return (-1);321}322323static int324check_addrinfo_for_name(struct addrinfo *ai, char const *name)325{326struct addrinfo *ai2;327328for (ai2 = ai; ai2 != NULL; ai2 = ai2->ai_next) {329if (strcmp(ai2->ai_canonname, name) == 0)330return (0);331}332333return (-1);334}335336static int337check_addrinfo_for_addr(struct addrinfo *ai, char const *addr,338socklen_t addrlen, int af)339{340struct addrinfo *ai2;341342for (ai2 = ai; ai2 != NULL; ai2 = ai2->ai_next) {343if (af != ai2->ai_family)344continue;345346switch (af) {347case AF_INET:348if (memcmp(addr,349(void *)&((struct sockaddr_in *)ai2->ai_addr)->sin_addr,350MIN(addrlen, ai2->ai_addrlen)) == 0)351return (0);352break;353case AF_INET6:354if (memcmp(addr,355(void *)&((struct sockaddr_in6 *)ai2->ai_addr)->sin6_addr,356MIN(addrlen, ai2->ai_addrlen)) == 0)357return (0);358break;359default:360break;361}362}363364return (-1);365}366367static int368is_hostent_equal(struct hostent *he, struct addrinfo *ai)369{370char **cp;371int rv;372373#ifdef DEBUG374printf("checking equality of he and ai\n");375#endif376377rv = check_addrinfo_for_name(ai, he->h_name);378if (rv != 0) {379printf("not equal - he->h_name couldn't be found\n");380return (rv);381}382383for (cp = he->h_addr_list; *cp; ++cp) {384rv = check_addrinfo_for_addr(ai, *cp, he->h_length,385he->h_addrtype);386if (rv != 0) {387printf("not equal - one of he->h_addr_list couldn't be found\n");388return (rv);389}390}391392#ifdef DEBUG393printf("equal\n");394#endif395396return (0);397}398399static void400sdump_hostent(struct hostent *ht, char *buffer, size_t buflen)401{402char **cp;403size_t i;404int written;405406written = snprintf(buffer, buflen, "%s %d %d",407ht->h_name, ht->h_addrtype, ht->h_length);408buffer += written;409if (written > (int)buflen)410return;411buflen -= written;412413if (ht->h_aliases != NULL) {414if (*(ht->h_aliases) != NULL) {415for (cp = ht->h_aliases; *cp; ++cp) {416written = snprintf(buffer, buflen, " %s",*cp);417buffer += written;418if (written > (int)buflen)419return;420buflen -= written;421422if (buflen == 0)423return;424}425} else {426written = snprintf(buffer, buflen, " noaliases");427buffer += written;428if (written > (int)buflen)429return;430buflen -= written;431}432} else {433written = snprintf(buffer, buflen, " (null)");434buffer += written;435if (written > (int)buflen)436return;437buflen -= written;438}439440written = snprintf(buffer, buflen, " : ");441buffer += written;442if (written > (int)buflen)443return;444buflen -= written;445446if (ht->h_addr_list != NULL) {447if (*(ht->h_addr_list) != NULL) {448for (cp = ht->h_addr_list; *cp; ++cp) {449for (i = 0; i < (size_t)ht->h_length; ++i) {450written = snprintf(buffer, buflen,451i + 1 != (size_t)ht->h_length ?452"%d." : "%d",453(unsigned char)(*cp)[i]);454buffer += written;455if (written > (int)buflen)456return;457buflen -= written;458459if (buflen == 0)460return;461}462463if (*(cp + 1)) {464written = snprintf(buffer, buflen,465" ");466buffer += written;467if (written > (int)buflen)468return;469buflen -= written;470}471}472} else {473written = snprintf(buffer, buflen, " noaddrs");474buffer += written;475if (written > (int)buflen)476return;477buflen -= written;478}479} else {480written = snprintf(buffer, buflen, " (null)");481buffer += written;482if (written > (int)buflen)483return;484buflen -= written;485}486}487488static int489hostent_read_hostlist_func(struct hostent *he, char *line)490{491struct hostent *result;492int rv;493494#ifdef DEBUG495printf("resolving %s: ", line);496#endif497result = __gethostbyname2(line, af_type);498if (result != NULL) {499#ifdef DEBUG500printf("found\n");501#endif502503rv = hostent_test_correctness(result, NULL);504if (rv != 0) {505__freehostent(result);506return (rv);507}508509clone_hostent(he, result);510__freehostent(result);511} else {512#ifdef DEBUG513printf("not found\n");514#endif515memset(he, 0, sizeof(struct hostent));516he->h_name = strdup(line);517ATF_REQUIRE(he->h_name != NULL);518}519return (0);520}521522static int523hostent_read_snapshot_addr(char *addr, unsigned char *result, size_t len)524{525char *s, *ps, *ts;526527ps = addr;528while ( (s = strsep(&ps, ".")) != NULL) {529if (len == 0)530return (-1);531532*result = (unsigned char)strtol(s, &ts, 10);533++result;534if (*ts != '\0')535return (-1);536537--len;538}539if (len != 0)540return (-1);541else542return (0);543}544545static int546hostent_read_snapshot_func(struct hostent *ht, char *line)547{548StringList *sl1, *sl2;549char *s, *ps, *ts;550int i, rv;551552#ifdef DEBUG553printf("1 line read from snapshot:\n%s\n", line);554#endif555556rv = 0;557i = 0;558sl1 = sl2 = NULL;559ps = line;560memset(ht, 0, sizeof(struct hostent));561while ((s = strsep(&ps, " ")) != NULL) {562switch (i) {563case 0:564ht->h_name = strdup(s);565ATF_REQUIRE(ht->h_name != NULL);566break;567568case 1:569ht->h_addrtype = (int)strtol(s, &ts, 10);570if (*ts != '\0')571goto fin;572break;573574case 2:575ht->h_length = (int)strtol(s, &ts, 10);576if (*ts != '\0')577goto fin;578break;579580case 3:581if (sl1 == NULL) {582if (strcmp(s, "(null)") == 0)583return (0);584585sl1 = sl_init();586ATF_REQUIRE(sl1 != NULL);587588if (strcmp(s, "noaliases") != 0) {589ts = strdup(s);590ATF_REQUIRE(ts != NULL);591sl_add(sl1, ts);592}593} else {594if (strcmp(s, ":") == 0)595++i;596else {597ts = strdup(s);598ATF_REQUIRE(ts != NULL);599sl_add(sl1, ts);600}601}602break;603604case 4:605if (sl2 == NULL) {606if (strcmp(s, "(null)") == 0)607return (0);608609sl2 = sl_init();610ATF_REQUIRE(sl2 != NULL);611612if (strcmp(s, "noaddrs") != 0) {613ts = calloc(1, ht->h_length);614ATF_REQUIRE(ts != NULL);615rv = hostent_read_snapshot_addr(s,616(unsigned char *)ts,617ht->h_length);618sl_add(sl2, ts);619if (rv != 0)620goto fin;621}622} else {623ts = calloc(1, ht->h_length);624ATF_REQUIRE(ts != NULL);625rv = hostent_read_snapshot_addr(s,626(unsigned char *)ts, ht->h_length);627sl_add(sl2, ts);628if (rv != 0)629goto fin;630}631break;632default:633break;634}635636if (i != 3 && i != 4)637++i;638}639640fin:641if (sl1 != NULL) {642sl_add(sl1, NULL);643ht->h_aliases = sl1->sl_str;644}645if (sl2 != NULL) {646sl_add(sl2, NULL);647ht->h_addr_list = sl2->sl_str;648}649650if ((i != 4) || (rv != 0)) {651free_hostent(ht);652memset(ht, 0, sizeof(struct hostent));653return (-1);654}655656/* NOTE: is it a dirty hack or not? */657free(sl1);658free(sl2);659return (0);660}661662static void663dump_hostent(struct hostent *result)664{665if (result != NULL) {666char buffer[1024];667sdump_hostent(result, buffer, sizeof(buffer));668printf("%s\n", buffer);669} else670printf("(null)\n");671}672673static int674hostent_test_correctness(struct hostent *ht, void *mdata __unused)675{676677#ifdef DEBUG678printf("testing correctness with the following data:\n");679dump_hostent(ht);680#endif681682if (ht == NULL)683goto errfin;684685if (ht->h_name == NULL)686goto errfin;687688if (!((ht->h_addrtype >= 0) && (ht->h_addrtype < AF_MAX)))689goto errfin;690691if ((ht->h_length != sizeof(struct in_addr)) &&692(ht->h_length != sizeof(struct in6_addr)))693goto errfin;694695if (ht->h_aliases == NULL)696goto errfin;697698if (ht->h_addr_list == NULL)699goto errfin;700701#ifdef DEBUG702printf("correct\n");703#endif704705return (0);706errfin:707printf("incorrect\n");708709return (-1);710}711712static int713hostent_test_gethostbyaddr(struct hostent *he, void *mdata)714{715struct hostent *result;716struct hostent_test_data *addr_test_data;717int rv;718719addr_test_data = (struct hostent_test_data *)mdata;720721/* We should omit unresolved hostents */722if (he->h_addr_list != NULL) {723char **cp;724for (cp = he->h_addr_list; *cp; ++cp) {725#ifdef DEBUG726printf("doing reverse lookup for %s\n", he->h_name);727#endif728729result = __gethostbyaddr(*cp, he->h_length,730he->h_addrtype);731if (result == NULL) {732#ifdef DEBUG733printf("%s: warning: reverse lookup failed "734"for %s: %s\n", __func__, he->h_name,735strerror(errno));736#endif737continue;738}739rv = hostent_test_correctness(result, NULL);740if (rv != 0) {741__freehostent(result);742return (rv);743}744745if (addr_test_data != NULL)746TEST_DATA_APPEND(hostent, addr_test_data,747result);748749__freehostent(result);750}751}752753return (0);754}755756static int757hostent_test_getaddrinfo_eq(struct hostent *he, void *mdata __unused)758{759struct addrinfo *ai, hints;760int rv;761762ai = NULL;763memset(&hints, 0, sizeof(struct addrinfo));764hints.ai_family = af_type;765hints.ai_flags = AI_CANONNAME;766767printf("using getaddrinfo() to resolve %s\n", he->h_name);768769/* struct hostent *he was not resolved */770if (he->h_addr_list == NULL) {771/* We can be sure that he->h_name is not NULL */772rv = getaddrinfo(he->h_name, NULL, &hints, &ai);773if (rv == 0) {774printf("not ok - shouldn't have been resolved\n");775rv = -1;776} else777rv = 0;778} else {779rv = getaddrinfo(he->h_name, NULL, &hints, &ai);780if (rv != 0) {781printf("not ok - should have been resolved\n");782rv = -1;783goto done;784}785rv = is_hostent_equal(he, ai);786if (rv != 0) {787printf("not ok - addrinfo and hostent are not equal\n");788rv = -1;789}790}791done:792if (ai != NULL)793freeaddrinfo(ai);794return (rv);795}796797static int798hostent_test_getnameinfo_eq(struct hostent *he, void *mdata __unused)799{800char **cp;801char buffer[NI_MAXHOST];802struct sockaddr_in sin;803struct sockaddr_in6 sin6;804struct sockaddr *saddr;805struct hostent *result;806int i, rv;807808if (he->h_addr_list == NULL)809return (0);810811for (cp = he->h_addr_list; *cp; ++cp) {812#ifdef DEBUG813printf("doing reverse lookup for %s\n", he->h_name);814#endif815result = __gethostbyaddr(*cp, he->h_length,816he->h_addrtype);817if (result != NULL) {818rv = hostent_test_correctness(result, NULL);819if (rv != 0) {820__freehostent(result);821return (rv);822}823} else824printf("%s: warning: reverse lookup failed "825"for %s: %s\n", __func__, he->h_name,826strerror(errno));827828switch (he->h_addrtype) {829case AF_INET:830memset(&sin, 0, sizeof(struct sockaddr_in));831sin.sin_len = sizeof(struct sockaddr_in);832sin.sin_family = AF_INET;833memcpy(&sin.sin_addr, *cp, he->h_length);834835saddr = (struct sockaddr *)&sin;836break;837case AF_INET6:838memset(&sin6, 0, sizeof(struct sockaddr_in6));839sin6.sin6_len = sizeof(struct sockaddr_in6);840sin6.sin6_family = AF_INET6;841memcpy(&sin6.sin6_addr, *cp, he->h_length);842843saddr = (struct sockaddr *)&sin6;844break;845default:846printf("warning: %d family is unsupported\n",847he->h_addrtype);848continue;849}850851ATF_REQUIRE(saddr != NULL);852rv = getnameinfo(saddr, saddr->sa_len, buffer,853sizeof(buffer), NULL, 0, NI_NAMEREQD);854855if (rv != 0 && result != NULL) {856printf("getnameinfo() didn't make the reverse "857"lookup, when it should have (%s)\n",858gai_strerror(rv));859return (rv);860}861862if (rv == 0 && result == NULL) {863printf("getnameinfo() made the "864"reverse lookup, when it shouldn't have\n");865return (rv);866}867868if (rv != 0 && result == NULL) {869#ifdef DEBUG870printf("both getnameinfo() and ***byaddr() failed as "871"expected\n");872#endif873continue;874}875876#ifdef DEBUG877printf("comparing %s with %s\n", result->h_name,878buffer);879#endif880881/*882* An address might reverse resolve to hostname alias or the883* official hostname, e.g. moon.vub.ac.be.884*/885bool found_a_match = false;886887if (strcmp(result->h_name, buffer) == 0) {888found_a_match = true;889#ifdef DEBUG890printf("matched official hostname\n");891#endif892} else {893for (i = 0; result->h_aliases[i] != NULL; i++) {894printf("[%d] resolved: %s\n", i,895result->h_aliases[i]);896if (strcmp(result->h_aliases[i],897buffer) == 0) {898printf("matched hostname alias\n");899found_a_match = true;900break;901}902}903}904__freehostent(result);905906if (found_a_match) {907#ifdef DEBUG908printf("getnameinfo() and ***byaddr() results are "909"equal\n");910#endif911} else {912printf("getnameinfo() and ***byaddr() results are not "913"equal for %s\n", he->h_name);914return (-1);915}916}917918return (0);919}920921static int922run_tests(const char *hostlist_file, const char *snapshot_file, int _af_type,923enum test_methods method, bool use_ipv6_mapping)924{925char *snapshot_file_copy;926struct hostent_test_data td, td_addr, td_snap;927res_state statp;928int rv = -2;929930if (snapshot_file == NULL)931snapshot_file_copy = NULL;932else {933snapshot_file_copy = strdup(snapshot_file);934ATF_REQUIRE(snapshot_file_copy != NULL);935}936snapshot_file = snapshot_file_copy;937938switch (_af_type) {939case AF_INET:940ATF_REQUIRE_FEATURE("inet");941ATF_REQUIRE(!use_ipv6_mapping);942break;943case AF_INET6:944ATF_REQUIRE_FEATURE("inet6");945break;946default:947atf_tc_fail("unhandled address family: %d", _af_type);948break;949}950951if (!use_ipnode_functions) {952statp = __res_state();953if (statp == NULL || ((statp->options & RES_INIT) == 0 &&954res_ninit(statp) == -1)) {955printf("error: can't init res_state\n");956rv = -1;957goto fin2;958}959960if (use_ipv6_mapping)961statp->options |= RES_USE_INET6;962else963statp->options &= ~RES_USE_INET6;964}965966TEST_DATA_INIT(hostent, &td, clone_hostent, free_hostent);967TEST_DATA_INIT(hostent, &td_addr, clone_hostent, free_hostent);968TEST_DATA_INIT(hostent, &td_snap, clone_hostent, free_hostent);969970if (access(hostlist_file, R_OK) != 0) {971printf("can't access the hostlist file %s\n", hostlist_file);972rv = -1;973goto fin;974}975976#ifdef DEBUG977printf("building host lists from %s\n", hostlist_file);978#endif979980rv = TEST_SNAPSHOT_FILE_READ(hostent, hostlist_file, &td,981hostent_read_hostlist_func);982if (rv != 0) {983printf("failed to read the host list file: %s\n",984hostlist_file);985goto fin;986}987988if (snapshot_file != NULL) {989if (access(snapshot_file, W_OK | R_OK) != 0) {990if (errno == ENOENT) {991if (method != TEST_GETHOSTBYADDR)992method = TEST_BUILD_SNAPSHOT;993else994method = TEST_BUILD_ADDR_SNAPSHOT;995} else {996printf("can't access the snapshot file %s\n",997snapshot_file);998rv = -1;999goto fin;1000}1001} else {1002rv = TEST_SNAPSHOT_FILE_READ(hostent, snapshot_file,1003&td_snap, hostent_read_snapshot_func);1004if (rv != 0) {1005printf("error reading snapshot file\n");1006goto fin;1007}1008}1009}10101011switch (method) {1012case TEST_GETHOSTBYNAME2:1013if (snapshot_file != NULL)1014rv = DO_2PASS_TEST(hostent, &td, &td_snap,1015compare_hostent, NULL);1016break;1017case TEST_GETHOSTBYADDR:1018rv = DO_1PASS_TEST(hostent, &td,1019hostent_test_gethostbyaddr, (void *)&td_addr);1020if (rv != 0)1021goto fin;10221023if (snapshot_file != NULL)1024rv = DO_2PASS_TEST(hostent, &td_addr, &td_snap,1025compare_hostent, NULL);1026break;1027case TEST_GETHOSTBYNAME2_GETADDRINFO:1028rv = DO_1PASS_TEST(hostent, &td,1029hostent_test_getaddrinfo_eq, NULL);1030break;1031case TEST_GETHOSTBYADDR_GETNAMEINFO:1032rv = DO_1PASS_TEST(hostent, &td,1033hostent_test_getnameinfo_eq, NULL);1034break;1035case TEST_BUILD_SNAPSHOT:1036if (snapshot_file != NULL) {1037rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file,1038&td, sdump_hostent);1039}1040break;1041case TEST_BUILD_ADDR_SNAPSHOT:1042if (snapshot_file != NULL) {1043rv = DO_1PASS_TEST(hostent, &td,1044hostent_test_gethostbyaddr, (void *)&td_addr);1045if (rv != 0)1046goto fin;1047rv = TEST_SNAPSHOT_FILE_WRITE(hostent, snapshot_file,1048&td_addr, sdump_hostent);1049}1050break;1051default:1052rv = 0;1053break;1054}10551056fin:1057TEST_DATA_DESTROY(hostent, &td_snap);1058TEST_DATA_DESTROY(hostent, &td_addr);1059TEST_DATA_DESTROY(hostent, &td);10601061fin2:1062free(snapshot_file_copy);10631064return (rv);1065}10661067#define HOSTLIST_FILE "mach"10681069#define _RUN_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping) \1070do { \1071char *_hostlist_file; \1072ATF_REQUIRE(0 < asprintf(&_hostlist_file, "%s/%s", \1073atf_tc_get_config_var(tc, "srcdir"), HOSTLIST_FILE)); \1074ATF_REQUIRE(run_tests(_hostlist_file, snapshot_file, af_type, \1075method, use_ipv6_mapping) == 0); \1076free(_hostlist_file); \1077} while (0)10781079#define RUN_HOST_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping) \1080do { \1081use_ipnode_functions = false; \1082_RUN_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping); \1083} while (0)10841085#define RUN_IPNODE_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping) \1086do { \1087use_ipnode_functions = true; \1088_RUN_TESTS(tc, snapshot_file, af_type, method, use_ipv6_mapping); \1089} while (0)10901091ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv4);1092ATF_TC_BODY(gethostbyaddr_ipv4, tc)1093{10941095RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR, false);1096}10971098ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv4_with_snapshot);1099ATF_TC_BODY(gethostbyaddr_ipv4_with_snapshot, tc)1100{11011102RUN_HOST_TESTS(tc, "snapshot_htaddr4", AF_INET, TEST_GETHOSTBYADDR, false);1103}11041105ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6);1106ATF_TC_BODY(gethostbyaddr_ipv6, tc)1107{11081109RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, false);1110}11111112ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6_AI_V4MAPPED);1113ATF_TC_BODY(gethostbyaddr_ipv6_AI_V4MAPPED, tc)1114{11151116ipnode_flags = AI_V4MAPPED;1117RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);1118}11191120ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6_with_snapshot);1121ATF_TC_BODY(gethostbyaddr_ipv6_with_snapshot, tc)1122{11231124RUN_HOST_TESTS(tc, "snapshot_htaddr6", AF_INET6, TEST_GETHOSTBYADDR, false);1125}11261127ATF_TC_WITHOUT_HEAD(gethostbyaddr_ipv6_with_snapshot_AI_V4MAPPED);1128ATF_TC_BODY(gethostbyaddr_ipv6_with_snapshot_AI_V4MAPPED, tc)1129{11301131ipnode_flags = AI_V4MAPPED;1132RUN_HOST_TESTS(tc, "snapshot_htaddr6map", AF_INET6, TEST_GETHOSTBYADDR, true);1133}11341135ATF_TC_WITHOUT_HEAD(gethostbyname2_getaddrinfo_ipv4);1136ATF_TC_BODY(gethostbyname2_getaddrinfo_ipv4, tc)1137{11381139RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2_GETADDRINFO, false);1140}11411142ATF_TC_WITHOUT_HEAD(gethostbyname2_getaddrinfo_ipv6);1143ATF_TC_BODY(gethostbyname2_getaddrinfo_ipv6, tc)1144{11451146RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2_GETADDRINFO, false);1147}11481149ATF_TC_WITHOUT_HEAD(gethostbyaddr_getnameinfo_ipv4);1150ATF_TC_BODY(gethostbyaddr_getnameinfo_ipv4, tc)1151{11521153RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR_GETNAMEINFO, false);1154}11551156ATF_TC_WITHOUT_HEAD(gethostbyaddr_getnameinfo_ipv6);1157ATF_TC_BODY(gethostbyaddr_getnameinfo_ipv6, tc)1158{11591160RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR_GETNAMEINFO, false);1161}11621163ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv4);1164ATF_TC_BODY(gethostbyname2_ipv4, tc)1165{11661167RUN_HOST_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2, false);1168}11691170ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv4_with_snapshot);1171ATF_TC_BODY(gethostbyname2_ipv4_with_snapshot, tc)1172{11731174RUN_HOST_TESTS(tc, "snapshot_htname4", AF_INET, TEST_GETHOSTBYNAME2, false);1175}11761177ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6);1178ATF_TC_BODY(gethostbyname2_ipv6, tc)1179{11801181RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);1182}11831184ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6_AI_V4MAPPED);1185ATF_TC_BODY(gethostbyname2_ipv6_AI_V4MAPPED, tc)1186{11871188ipnode_flags = AI_V4MAPPED;1189RUN_HOST_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);1190}11911192ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6_with_snapshot);1193ATF_TC_BODY(gethostbyname2_ipv6_with_snapshot, tc)1194{11951196RUN_HOST_TESTS(tc, "snapshot_htname6", AF_INET6, TEST_GETHOSTBYNAME2, false);1197}11981199ATF_TC_WITHOUT_HEAD(gethostbyname2_ipv6_with_snapshot_AI_V4MAPPED);1200ATF_TC_BODY(gethostbyname2_ipv6_with_snapshot_AI_V4MAPPED, tc)1201{12021203ipnode_flags = AI_V4MAPPED;1204RUN_HOST_TESTS(tc, "snapshot_htname6map", AF_INET6, TEST_GETHOSTBYNAME2, true);1205}12061207ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv4);1208ATF_TC_BODY(getipnodebyaddr_ipv4, tc)1209{12101211RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR, false);1212}12131214ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv4_with_snapshot);1215ATF_TC_BODY(getipnodebyaddr_ipv4_with_snapshot, tc)1216{12171218RUN_IPNODE_TESTS(tc, "snapshot_ipnodeaddr4", AF_INET, TEST_GETHOSTBYADDR, false);1219}12201221ATF_TC_WITHOUT_HEAD(getipnodebyaddr_getnameinfo_ipv4);1222ATF_TC_BODY(getipnodebyaddr_getnameinfo_ipv4, tc)1223{12241225RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYADDR_GETNAMEINFO, false);1226}12271228ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6);1229ATF_TC_BODY(getipnodebyaddr_ipv6, tc)1230{12311232RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, false);1233}12341235ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_AI_V4MAPPED);1236ATF_TC_BODY(getipnodebyaddr_ipv6_AI_V4MAPPED, tc)1237{12381239ipnode_flags = AI_V4MAPPED;1240RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);1241}12421243ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG);1244ATF_TC_BODY(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG, tc)1245{12461247ipnode_flags = AI_V4MAPPED_CFG;1248RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);1249}12501251ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG_AI_ALL);1252ATF_TC_BODY(getipnodebyaddr_ipv6_AI_V4MAPPED_CFG_AI_ALL, tc)1253{12541255ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;1256RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR, true);1257}12581259ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot);1260ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot, tc)1261{12621263RUN_IPNODE_TESTS(tc, "snapshot_ipnodeaddr6", AF_INET6, TEST_GETHOSTBYADDR, false);1264}12651266ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED);1267ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED, tc)1268{12691270ipnode_flags = AI_V4MAPPED;1271RUN_IPNODE_TESTS(tc,1272"snapshot_ipnodeaddr6_AI_V4MAPPED", AF_INET6,1273TEST_GETHOSTBYADDR, true);1274}12751276ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG);1277ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG, tc)1278{12791280ipnode_flags = AI_V4MAPPED_CFG;1281RUN_IPNODE_TESTS(tc,1282"snapshot_ipnodeaddr6_AI_V4MAPPED_CFG", AF_INET6,1283TEST_GETHOSTBYADDR, true);1284}12851286ATF_TC_WITHOUT_HEAD(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);1287ATF_TC_BODY(getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL, tc)1288{12891290ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;1291RUN_IPNODE_TESTS(tc,1292"snapshot_ipnodeaddr6_AI_V4MAPPED_CFG_AI_ALL", AF_INET6,1293TEST_GETHOSTBYADDR, true);1294}12951296ATF_TC_WITHOUT_HEAD(getipnodebyaddr_getnameinfo_ipv6);1297ATF_TC_BODY(getipnodebyaddr_getnameinfo_ipv6, tc)1298{12991300RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYADDR_GETNAMEINFO, false);1301}13021303ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4);1304ATF_TC_BODY(getipnodebyname_ipv4, tc)1305{13061307RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2, false);1308}13091310ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4_with_snapshot);1311ATF_TC_BODY(getipnodebyname_ipv4_with_snapshot, tc)1312{13131314RUN_IPNODE_TESTS(tc, "snapshot_ipnodename4", AF_INET, TEST_GETHOSTBYNAME2, false);1315}13161317ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4_AI_ADDRCONFIG);1318ATF_TC_BODY(getipnodebyname_ipv4_AI_ADDRCONFIG, tc)1319{13201321ipnode_flags = AI_ADDRCONFIG;1322RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2, false);1323}13241325ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv4_with_snapshot_AI_ADDRCONFIG);1326ATF_TC_BODY(getipnodebyname_ipv4_with_snapshot_AI_ADDRCONFIG, tc)1327{13281329ipnode_flags = AI_ADDRCONFIG;1330RUN_IPNODE_TESTS(tc, "snapshot_ipnodename4_AI_ADDRCONFIG", AF_INET,1331TEST_GETHOSTBYNAME2, false);1332}13331334ATF_TC_WITHOUT_HEAD(getipnodebyname_getaddrinfo_ipv4);1335ATF_TC_BODY(getipnodebyname_getaddrinfo_ipv4, tc)1336{13371338RUN_IPNODE_TESTS(tc, NULL, AF_INET, TEST_GETHOSTBYNAME2_GETADDRINFO, false);1339}13401341ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6);1342ATF_TC_BODY(getipnodebyname_ipv6, tc)1343{13441345RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);1346}13471348ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot);1349ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot, tc)1350{13511352RUN_IPNODE_TESTS(tc, "snapshot_ipnodename6", AF_INET6, TEST_GETHOSTBYNAME2, false);1353}13541355ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_ADDRCONFIG);1356ATF_TC_BODY(getipnodebyname_ipv6_AI_ADDRCONFIG, tc)1357{13581359ipnode_flags = AI_ADDRCONFIG;1360RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);1361}13621363ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED);1364ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED, tc)1365{13661367ipnode_flags = AI_V4MAPPED;1368RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);1369}13701371ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED_CFG);1372ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED_CFG, tc)1373{13741375ipnode_flags = AI_V4MAPPED_CFG;1376RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);1377}13781379ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ADDRCONFIG);1380ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ADDRCONFIG, tc)1381{13821383ipnode_flags = AI_V4MAPPED_CFG | AI_ADDRCONFIG;1384RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, false);1385}13861387ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ALL);1388ATF_TC_BODY(getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ALL, tc)1389{13901391ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;1392RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2, true);1393}13941395ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED);1396ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED, tc)1397{13981399ipnode_flags = AI_V4MAPPED;1400RUN_IPNODE_TESTS(tc,1401"snapshot_ipnodename6_AI_V4MAPPED", AF_INET6,1402TEST_GETHOSTBYNAME2, true);1403}14041405ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG);1406ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG, tc)1407{14081409ipnode_flags = AI_V4MAPPED_CFG;1410RUN_IPNODE_TESTS(tc,1411"snapshot_ipnodename6_AI_V4MAPPED_CFG", AF_INET6,1412TEST_GETHOSTBYNAME2, true);1413}14141415ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ADDRCONFIG);1416ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ADDRCONFIG, tc)1417{14181419ipnode_flags = AI_V4MAPPED_CFG | AI_ADDRCONFIG;1420RUN_IPNODE_TESTS(tc,1421"snapshot_ipnodename6_AI_V4MAPPED_CFG_AI_ADDRCONFIG", AF_INET6,1422TEST_GETHOSTBYNAME2, false);1423}14241425ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);1426ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL, tc)1427{14281429ipnode_flags = AI_V4MAPPED_CFG | AI_ALL;1430RUN_IPNODE_TESTS(tc,1431"snapshot_ipnodename6_AI_V4MAPPED_CFG_AI_ALL", AF_INET6,1432TEST_GETHOSTBYNAME2, true);1433}14341435ATF_TC_WITHOUT_HEAD(getipnodebyname_ipv6_with_snapshot_AI_ADDRCONFIG);1436ATF_TC_BODY(getipnodebyname_ipv6_with_snapshot_AI_ADDRCONFIG, tc)1437{14381439ipnode_flags = AI_ADDRCONFIG;1440RUN_IPNODE_TESTS(tc, "snapshot_ipnodename6_AI_ADDRCONFIG", AF_INET6,1441TEST_GETHOSTBYNAME2, false);1442}14431444ATF_TC_WITHOUT_HEAD(getipnodebyname_getaddrinfo_ipv6);1445ATF_TC_BODY(getipnodebyname_getaddrinfo_ipv6, tc)1446{14471448RUN_IPNODE_TESTS(tc, NULL, AF_INET6, TEST_GETHOSTBYNAME2_GETADDRINFO, false);1449}14501451ATF_TP_ADD_TCS(tp)1452{14531454/* gethostbyaddr */1455ATF_TP_ADD_TC(tp, gethostbyaddr_ipv4);1456ATF_TP_ADD_TC(tp, gethostbyaddr_ipv4_with_snapshot);1457ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6);1458ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6_AI_V4MAPPED); /* XXX */1459ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6_with_snapshot);1460ATF_TP_ADD_TC(tp, gethostbyaddr_ipv6_with_snapshot_AI_V4MAPPED);1461ATF_TP_ADD_TC(tp, gethostbyaddr_getnameinfo_ipv4);1462ATF_TP_ADD_TC(tp, gethostbyaddr_getnameinfo_ipv6);14631464/* gethostbyname2 */1465ATF_TP_ADD_TC(tp, gethostbyname2_getaddrinfo_ipv4);1466ATF_TP_ADD_TC(tp, gethostbyname2_getaddrinfo_ipv6);1467ATF_TP_ADD_TC(tp, gethostbyname2_ipv4);1468ATF_TP_ADD_TC(tp, gethostbyname2_ipv4_with_snapshot);1469ATF_TP_ADD_TC(tp, gethostbyname2_ipv6);1470ATF_TP_ADD_TC(tp, gethostbyname2_ipv6_AI_V4MAPPED);1471ATF_TP_ADD_TC(tp, gethostbyname2_ipv6_with_snapshot);1472ATF_TP_ADD_TC(tp, gethostbyname2_ipv6_with_snapshot_AI_V4MAPPED);14731474/* getipnodebyaddr */1475ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv4);1476ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv4_with_snapshot);1477ATF_TP_ADD_TC(tp, getipnodebyaddr_getnameinfo_ipv4);1478ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6);1479ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_AI_V4MAPPED);1480ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_AI_V4MAPPED_CFG);1481ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_AI_V4MAPPED_CFG_AI_ALL);1482ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot);1483ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED);1484ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG);1485ATF_TP_ADD_TC(tp, getipnodebyaddr_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);1486ATF_TP_ADD_TC(tp, getipnodebyaddr_getnameinfo_ipv6);14871488/* getipnodebyname */1489ATF_TP_ADD_TC(tp, getipnodebyname_ipv4);1490ATF_TP_ADD_TC(tp, getipnodebyname_ipv4_with_snapshot);1491ATF_TP_ADD_TC(tp, getipnodebyname_ipv4_AI_ADDRCONFIG);1492ATF_TP_ADD_TC(tp, getipnodebyname_ipv4_with_snapshot_AI_ADDRCONFIG);1493ATF_TP_ADD_TC(tp, getipnodebyname_getaddrinfo_ipv4);1494ATF_TP_ADD_TC(tp, getipnodebyname_ipv6);1495ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot);1496ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_ADDRCONFIG);1497ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED);1498ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED_CFG);1499ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ADDRCONFIG);1500ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_AI_V4MAPPED_CFG_AI_ALL);1501ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED);1502ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG);1503ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ADDRCONFIG);1504ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_V4MAPPED_CFG_AI_ALL);1505ATF_TP_ADD_TC(tp, getipnodebyname_ipv6_with_snapshot_AI_ADDRCONFIG);1506ATF_TP_ADD_TC(tp, getipnodebyname_getaddrinfo_ipv6);15071508return (atf_no_error());1509}151015111512