lwtest.c revision 611dc8876869036ab5e981e53ae7a446145d9354
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * Copyright (C) 2004, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * Copyright (C) 2000-2002 Internet Software Consortium.
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * Permission to use, copy, modify, and/or distribute this software for any
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * purpose with or without fee is hereby granted, provided that the above
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * copyright notice and this permission notice appear in all copies.
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * PERFORMANCE OF THIS SOFTWARE.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff/* $Id: lwtest.c,v 1.32 2008/04/02 02:37:42 marka Exp $ */
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff * XXX getnameinfo errors, which don't appear to be standard.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic int fails = 0;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic unsigned char TESTSTRING[] =
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff "This is a test. This is only a test. !!!";
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff lwres_nooprequest_t nooprequest, *nooprequest2;
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff lwres_noopresponse_t noopresponse, *noopresponse2;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff nooprequest.datalength = strlen((char *)TESTSTRING);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff ret = lwres_nooprequest_render(ctx, &nooprequest, &pkt, &b);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff * Now, parse it into a new structure.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff ret = lwres_nooprequest_parse(ctx, &b, &pkt2, &nooprequest2);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff assert(nooprequest.datalength == nooprequest2->datalength);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff assert(memcmp(nooprequest.data, nooprequest2->data,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff noopresponse.datalength = strlen((char *)TESTSTRING);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff ret = lwres_noopresponse_render(ctx, &noopresponse, &pkt, &b);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff * Now, parse it into a new structure.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff ret = lwres_noopresponse_parse(ctx, &b, &pkt2, &noopresponse2);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff assert(noopresponse.datalength == noopresponse2->datalength);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff assert(memcmp(noopresponse.data, noopresponse2->data,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftest_gabn(const char *target, lwres_result_t expected, const char *address,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff unsigned int len;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff printf("I:gabn(%s) failed: %d\n", target, ret);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff printf("I:gabn(%s) returned empty list\n", target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (addr->family != af || addr->length != len ||
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff printf("I:gabn(%s) returned %s, expected %s\n",
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftest_gnba(const char *target, lwres_uint32_t af, lwres_result_t expected,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff unsigned int len;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff ret = lwres_getnamebyaddr(ctx, af, len, addrbuf, &res);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff printf("I:gnba(%s) failed: %d\n", target, ret);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (ret == LWRES_R_SUCCESS && strcasecmp(res->realname, name) != 0) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff printf("I:gnba(%s) returned %s, expected %s\n",
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftest_gethostbyname(const char *name, const char *address) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (address == NULL && h_errno == HOST_NOT_FOUND)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff printf("I:gethostbyname(%s) returned not found\n",
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (memcmp(hp->h_addr_list[0], addrbuf, hp->h_length) != 0) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftest_gethostbyname2(const char *name, const char *address, int af) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (address == NULL && h_errno == HOST_NOT_FOUND)
fails++;
name);
fails++;
name);
fails++;
fails++;
int error_num;
int flags = 0;
if (v4map)
if (all)
fails++;
name);
fails++;
name);
fails++;
fails++;
fails++;
address);
fails++;
fails++;
int error_num;
fails++;
address);
fails++;
fails++;
const char *address)
unsigned int len;
int ret;
if (v4ok)
if (ret != 0) {
fails++;
fails++;
name);
fails++;
fails++;
fails++;
fails++;
int ret;
int salen;
#ifdef LWRES_PLATFORM_HAVESALEN
#ifdef LWRES_PLATFORM_HAVESALEN
if (ret != 0) {
fails++;
address);
fails++;
fails++;
fails++;
int should_pass)
int ret;
fails++;
fails++;
} else if (ret != 0)
fails++;
fails++;
main(void) {
test_noop();
NULL);
AF_INET6);
AF_INET6, 0, 0);
if (fails == 0)
return (fails);