summaryrefslogtreecommitdiffstats
path: root/src/tests/resolve
diff options
context:
space:
mode:
authorTom Yu <tlyu@mit.edu>2009-11-30 23:09:36 +0000
committerTom Yu <tlyu@mit.edu>2009-11-30 23:09:36 +0000
commitb6a2bb106c67280824362a64b1b04e62aabf3646 (patch)
tree768c0ace37786a9613245c98633181a37e145c4d /src/tests/resolve
parentbbb952ae5f5b7b8803de125b35dda3395155ddbb (diff)
downloadkrb5-b6a2bb106c67280824362a64b1b04e62aabf3646.tar.gz
krb5-b6a2bb106c67280824362a64b1b04e62aabf3646.tar.xz
krb5-b6a2bb106c67280824362a64b1b04e62aabf3646.zip
Mark and reindent tests, with some exclusions
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23394 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/tests/resolve')
-rw-r--r--src/tests/resolve/addrinfo-test.c267
-rw-r--r--src/tests/resolve/fake-addrinfo-test.c1
-rw-r--r--src/tests/resolve/resolve.c181
3 files changed, 226 insertions, 223 deletions
diff --git a/src/tests/resolve/addrinfo-test.c b/src/tests/resolve/addrinfo-test.c
index f011b6ad4..218f350bf 100644
--- a/src/tests/resolve/addrinfo-test.c
+++ b/src/tests/resolve/addrinfo-test.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test/resolve/addrinfo-test.c
*
@@ -92,31 +93,31 @@ static char *whoami;
static void usage () {
fprintf(stderr,
- "usage:\n"
- "\t%s [ options ] [host]\n"
- "options:\n"
- "\t-t\tspecify protocol IPPROTO_TCP\n"
- "\t-u\tspecify protocol IPPROTO_UDP\n"
- "\t-R\tspecify protocol IPPROTO_RAW\n"
- "\t-I\tspecify protocol IPPROTO_ICMP\n"
- "\n"
- "\t-d\tspecify socket type SOCK_DGRAM\n"
- "\t-s\tspecify socket type SOCK_STREAM\n"
- "\t-r\tspecify socket type SOCK_RAW\n"
- "\n"
- "\t-4\tspecify address family AF_INET\n"
+ "usage:\n"
+ "\t%s [ options ] [host]\n"
+ "options:\n"
+ "\t-t\tspecify protocol IPPROTO_TCP\n"
+ "\t-u\tspecify protocol IPPROTO_UDP\n"
+ "\t-R\tspecify protocol IPPROTO_RAW\n"
+ "\t-I\tspecify protocol IPPROTO_ICMP\n"
+ "\n"
+ "\t-d\tspecify socket type SOCK_DGRAM\n"
+ "\t-s\tspecify socket type SOCK_STREAM\n"
+ "\t-r\tspecify socket type SOCK_RAW\n"
+ "\n"
+ "\t-4\tspecify address family AF_INET\n"
#ifdef AF_INET6
- "\t-6\tspecify address family AF_INET6\n"
+ "\t-6\tspecify address family AF_INET6\n"
#endif
- "\n"
- "\t-p P\tspecify port P (service name or port number)\n"
- "\t-N\thostname is numeric, skip DNS query\n"
- "\t-n\tservice/port is numeric (sets AI_NUMERICSERV)\n"
- "\t-P\tset AI_PASSIVE\n"
- "\n"
- "default: protocol 0, socket type 0, address family 0, null port\n"
- ,
- whoami);
+ "\n"
+ "\t-p P\tspecify port P (service name or port number)\n"
+ "\t-N\thostname is numeric, skip DNS query\n"
+ "\t-n\tservice/port is numeric (sets AI_NUMERICSERV)\n"
+ "\t-P\tset AI_PASSIVE\n"
+ "\n"
+ "default: protocol 0, socket type 0, address family 0, null port\n"
+ ,
+ whoami);
/* [ -t | -u | -R | -I ] [ -d | -s | -r ] [ -p port ] */
exit (1);
}
@@ -125,8 +126,8 @@ static const char *familyname (int f) {
static char buf[30];
switch (f) {
default:
- snprintf(buf, sizeof(buf), "AF %d", f);
- return buf;
+ snprintf(buf, sizeof(buf), "AF %d", f);
+ return buf;
case AF_INET: return "AF_INET";
#ifdef AF_INET6
case AF_INET6: return "AF_INET6";
@@ -145,9 +146,9 @@ int main (int argc, char *argv[])
whoami = strrchr(argv[0], '/');
if (whoami == 0)
- whoami = argv[0];
+ whoami = argv[0];
else
- whoami = whoami+1;
+ whoami = whoami+1;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = 0;
@@ -157,89 +158,89 @@ int main (int argc, char *argv[])
hints.ai_family = 0;
if (argc == 1)
- usage ();
+ usage ();
while (++argv, --argc > 0) {
- char *arg;
- arg = *argv;
+ char *arg;
+ arg = *argv;
- if (*arg != '-')
- hname = arg;
- else if (arg[1] == 0 || arg[2] != 0)
- usage ();
- else
- switch (arg[1]) {
- case 'u':
- hints.ai_protocol = IPPROTO_UDP;
- break;
- case 't':
- hints.ai_protocol = IPPROTO_TCP;
- break;
- case 'R':
- hints.ai_protocol = IPPROTO_RAW;
- break;
- case 'I':
- hints.ai_protocol = IPPROTO_ICMP;
- break;
- case 'd':
- hints.ai_socktype = SOCK_DGRAM;
- break;
- case 's':
- hints.ai_socktype = SOCK_STREAM;
- break;
- case 'r':
- hints.ai_socktype = SOCK_RAW;
- break;
- case 'p':
- if (argv[1] == 0 || argv[1][0] == 0 || argv[1][0] == '-')
- usage ();
- port = argv[1];
- argc--, argv++;
- break;
- case '4':
- hints.ai_family = AF_INET;
- break;
+ if (*arg != '-')
+ hname = arg;
+ else if (arg[1] == 0 || arg[2] != 0)
+ usage ();
+ else
+ switch (arg[1]) {
+ case 'u':
+ hints.ai_protocol = IPPROTO_UDP;
+ break;
+ case 't':
+ hints.ai_protocol = IPPROTO_TCP;
+ break;
+ case 'R':
+ hints.ai_protocol = IPPROTO_RAW;
+ break;
+ case 'I':
+ hints.ai_protocol = IPPROTO_ICMP;
+ break;
+ case 'd':
+ hints.ai_socktype = SOCK_DGRAM;
+ break;
+ case 's':
+ hints.ai_socktype = SOCK_STREAM;
+ break;
+ case 'r':
+ hints.ai_socktype = SOCK_RAW;
+ break;
+ case 'p':
+ if (argv[1] == 0 || argv[1][0] == 0 || argv[1][0] == '-')
+ usage ();
+ port = argv[1];
+ argc--, argv++;
+ break;
+ case '4':
+ hints.ai_family = AF_INET;
+ break;
#ifdef AF_INET6
- case '6':
- hints.ai_family = AF_INET6;
- break;
+ case '6':
+ hints.ai_family = AF_INET6;
+ break;
#endif
- case 'N':
- numerichost = 1;
- break;
- case 'n':
- numericserv = 1;
- break;
- case 'P':
- hints.ai_flags |= AI_PASSIVE;
- break;
- default:
- usage ();
- }
+ case 'N':
+ numerichost = 1;
+ break;
+ case 'n':
+ numericserv = 1;
+ break;
+ case 'P':
+ hints.ai_flags |= AI_PASSIVE;
+ break;
+ default:
+ usage ();
+ }
}
if (hname && !numerichost)
- hints.ai_flags |= AI_CANONNAME;
+ hints.ai_flags |= AI_CANONNAME;
if (numerichost) {
#ifdef AI_NUMERICHOST
- hints.ai_flags |= AI_NUMERICHOST;
+ hints.ai_flags |= AI_NUMERICHOST;
#else
- fprintf(stderr, "AI_NUMERICHOST not defined on this platform\n");
- exit(1);
+ fprintf(stderr, "AI_NUMERICHOST not defined on this platform\n");
+ exit(1);
#endif
}
if (numericserv) {
#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
+ hints.ai_flags |= AI_NUMERICSERV;
#else
- fprintf(stderr, "AI_NUMERICSERV not defined on this platform\n");
- exit(1);
+ fprintf(stderr, "AI_NUMERICSERV not defined on this platform\n");
+ exit(1);
#endif
}
printf("getaddrinfo(hostname %s, service %s,\n"
- " hints { ",
- hname ? hname : "(null)", port ? port : "(null)");
+ " hints { ",
+ hname ? hname : "(null)", port ? port : "(null)");
sep = "";
#define Z(FLAG) if (hints.ai_flags & AI_##FLAG) printf("%s%s", sep, #FLAG), sep = "|"
Z(CANONNAME);
@@ -251,65 +252,65 @@ int main (int argc, char *argv[])
Z(NUMERICSERV);
#endif
if (sep[0] == 0)
- printf ("no-flags");
+ printf ("no-flags");
if (hints.ai_family)
- printf(" %s", familyname(hints.ai_family));
+ printf(" %s", familyname(hints.ai_family));
if (hints.ai_socktype)
- printf(" SOCK_%s", socktypename(hints.ai_socktype));
+ printf(" SOCK_%s", socktypename(hints.ai_socktype));
if (hints.ai_protocol)
- printf(" IPPROTO_%s", protoname(hints.ai_protocol));
+ printf(" IPPROTO_%s", protoname(hints.ai_protocol));
printf(" }):\n");
err = getaddrinfo(hname, port, &hints, &ap);
if (err) {
- printf("\terror => %s\n", eaistr(err));
- return 1;
+ printf("\terror => %s\n", eaistr(err));
+ return 1;
}
#if defined(SIN6_LEN)
if (ap->ai_addr->sa_len == 0)
- printf ("BAD: sa_len not set!\n");
+ printf ("BAD: sa_len not set!\n");
#endif
for (ap2 = ap; ap2; ap2 = ap2->ai_next) {
- char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
- /* If we don't do this, even AIX's own getnameinfo will reject
- the sockaddr structures. The sa_len field doesn't get set
- either, on AIX, but getnameinfo won't complain. */
- if (ap2->ai_addr->sa_family == 0) {
- printf("BAD: sa_family zero! fixing...\n");
- ap2->ai_addr->sa_family = ap2->ai_family;
- } else if (ap2->ai_addr->sa_family != ap2->ai_family) {
- printf("BAD: sa_family != ai_family! fixing...\n");
- ap2->ai_addr->sa_family = ap2->ai_family;
- }
- if (getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof(hbuf),
- pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
- strlcpy(hbuf, "...", sizeof(hbuf));
- strlcpy(pbuf, "...", sizeof(pbuf));
- }
- printf("%p:\n"
- "\tfamily = %s\tproto = %-4s\tsocktype = %s\n",
- ap2, familyname(ap2->ai_family),
- protoname (ap2->ai_protocol),
- socktypename (ap2->ai_socktype));
- if (ap2->ai_canonname) {
- if (ap2->ai_canonname[0])
- printf("\tcanonname = %s\n", ap2->ai_canonname);
- else
- printf("BAD: ai_canonname is set but empty!\n");
- } else if (ap2 == ap && (hints.ai_flags & AI_CANONNAME)) {
- printf("BAD: first ai_canonname is null!\n");
- }
- printf("\taddr = %-28s\tport = %s\n", hbuf, pbuf);
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+ /* If we don't do this, even AIX's own getnameinfo will reject
+ the sockaddr structures. The sa_len field doesn't get set
+ either, on AIX, but getnameinfo won't complain. */
+ if (ap2->ai_addr->sa_family == 0) {
+ printf("BAD: sa_family zero! fixing...\n");
+ ap2->ai_addr->sa_family = ap2->ai_family;
+ } else if (ap2->ai_addr->sa_family != ap2->ai_family) {
+ printf("BAD: sa_family != ai_family! fixing...\n");
+ ap2->ai_addr->sa_family = ap2->ai_family;
+ }
+ if (getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof(hbuf),
+ pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
+ strlcpy(hbuf, "...", sizeof(hbuf));
+ strlcpy(pbuf, "...", sizeof(pbuf));
+ }
+ printf("%p:\n"
+ "\tfamily = %s\tproto = %-4s\tsocktype = %s\n",
+ ap2, familyname(ap2->ai_family),
+ protoname (ap2->ai_protocol),
+ socktypename (ap2->ai_socktype));
+ if (ap2->ai_canonname) {
+ if (ap2->ai_canonname[0])
+ printf("\tcanonname = %s\n", ap2->ai_canonname);
+ else
+ printf("BAD: ai_canonname is set but empty!\n");
+ } else if (ap2 == ap && (hints.ai_flags & AI_CANONNAME)) {
+ printf("BAD: first ai_canonname is null!\n");
+ }
+ printf("\taddr = %-28s\tport = %s\n", hbuf, pbuf);
- err = getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof (hbuf),
- pbuf, sizeof(pbuf), NI_NAMEREQD);
- if (err)
- printf("\tgetnameinfo(NI_NAMEREQD): %s\n", eaistr(err));
- else
- printf("\tgetnameinfo => %s, %s\n", hbuf, pbuf);
+ err = getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof (hbuf),
+ pbuf, sizeof(pbuf), NI_NAMEREQD);
+ if (err)
+ printf("\tgetnameinfo(NI_NAMEREQD): %s\n", eaistr(err));
+ else
+ printf("\tgetnameinfo => %s, %s\n", hbuf, pbuf);
}
freeaddrinfo(ap);
return 0;
diff --git a/src/tests/resolve/fake-addrinfo-test.c b/src/tests/resolve/fake-addrinfo-test.c
index f04024d73..86365a5ba 100644
--- a/src/tests/resolve/fake-addrinfo-test.c
+++ b/src/tests/resolve/fake-addrinfo-test.c
@@ -1,2 +1,3 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#define USE_FAKE_ADDRINFO
#include "addrinfo-test.c"
diff --git a/src/tests/resolve/resolve.c b/src/tests/resolve/resolve.c
index 09be1486e..6efd09786 100644
--- a/src/tests/resolve/resolve.c
+++ b/src/tests/resolve/resolve.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test/resolve/resolve.c
*
@@ -74,97 +75,97 @@ char *strchr();
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- char myname[MAXHOSTNAMELEN+1];
- char *ptr;
- struct in_addr addrcopy;
- struct hostent *host;
- int quiet = 0;
-
- argc--; argv++;
- while (argc) {
- if ((strcmp(*argv, "--quiet") == 0) ||
- (strcmp(*argv, "-q") == 0)) {
- quiet++;
- } else
- break;
- argc--; argv++;
- }
-
- if (argc >= 1) {
- strncpy(myname, *argv, MAXHOSTNAMELEN);
- } else {
- if(gethostname(myname, MAXHOSTNAMELEN)) {
- perror("gethostname failure");
- exit(1);
- }
- }
-
- myname[MAXHOSTNAMELEN] = '\0'; /* for safety */
-
- /* Look up the address... */
- if (!quiet)
- printf("Hostname: %s\n", myname);
-
-
- /* Set the hosts db to close each time - effectively rewinding file */
- sethostent(0);
-
- if((host = gethostbyname (myname)) == NULL) {
- fprintf(stderr,
- "Could not look up address for hostname '%s' - fatal\n",
- myname);
- exit(2);
- }
-
- ptr = host->h_addr_list[0];
+ char myname[MAXHOSTNAMELEN+1];
+ char *ptr;
+ struct in_addr addrcopy;
+ struct hostent *host;
+ int quiet = 0;
+
+ argc--; argv++;
+ while (argc) {
+ if ((strcmp(*argv, "--quiet") == 0) ||
+ (strcmp(*argv, "-q") == 0)) {
+ quiet++;
+ } else
+ break;
+ argc--; argv++;
+ }
+
+ if (argc >= 1) {
+ strncpy(myname, *argv, MAXHOSTNAMELEN);
+ } else {
+ if(gethostname(myname, MAXHOSTNAMELEN)) {
+ perror("gethostname failure");
+ exit(1);
+ }
+ }
+
+ myname[MAXHOSTNAMELEN] = '\0'; /* for safety */
+
+ /* Look up the address... */
+ if (!quiet)
+ printf("Hostname: %s\n", myname);
+
+
+ /* Set the hosts db to close each time - effectively rewinding file */
+ sethostent(0);
+
+ if((host = gethostbyname (myname)) == NULL) {
+ fprintf(stderr,
+ "Could not look up address for hostname '%s' - fatal\n",
+ myname);
+ exit(2);
+ }
+
+ ptr = host->h_addr_list[0];
#define UC(a) (((int)a)&0xff)
- if (!quiet)
- printf("Host address: %d.%d.%d.%d\n",
- UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
-
- memcpy(&addrcopy.s_addr, ptr, 4);
-
- /* Convert back to full name */
- if((host = gethostbyaddr(&addrcopy.s_addr, 4, AF_INET)) == NULL) {
- fprintf(stderr, "Error looking up IP address - fatal\n");
- exit(2);
- }
-
- if (quiet)
- printf("%s\n", host->h_name);
- else
- printf("FQDN: %s\n", host->h_name);
-
- /*
- * The host name must have at least one '.' in the name, and
- * if there is only one '.', it must not be at the end of the
- * string. (i.e., "foo." is not a FQDN)
- */
- ptr = strchr(host->h_name, '.');
- if (ptr == NULL || ptr[1] == '\0') {
- fprintf(stderr,
- "\nResolve library did not return a "
- "fully qualified domain name.\n\n"
- "If you are using /etc/hosts before DNS, "
- "e.g. \"files\" is listed first\n"
- "for \"hosts:\" in nsswitch.conf, ensure that "
- "you have listed the FQDN\n"
- "as the first name for the local host.\n\n"
- "If this does not correct the problem, "
- "you may have to reconfigure the kerberos\n"
- "distribution to select a "
- "different set of libraries using \n"
- "--with-netlib[=libs]\n");
- exit(3);
- }
-
- if (!quiet)
- printf("Resolve library appears to have passed the test\n");
-
- /* All ok */
- exit(0);
+ if (!quiet)
+ printf("Host address: %d.%d.%d.%d\n",
+ UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
+
+ memcpy(&addrcopy.s_addr, ptr, 4);
+
+ /* Convert back to full name */
+ if((host = gethostbyaddr(&addrcopy.s_addr, 4, AF_INET)) == NULL) {
+ fprintf(stderr, "Error looking up IP address - fatal\n");
+ exit(2);
+ }
+
+ if (quiet)
+ printf("%s\n", host->h_name);
+ else
+ printf("FQDN: %s\n", host->h_name);
+
+ /*
+ * The host name must have at least one '.' in the name, and
+ * if there is only one '.', it must not be at the end of the
+ * string. (i.e., "foo." is not a FQDN)
+ */
+ ptr = strchr(host->h_name, '.');
+ if (ptr == NULL || ptr[1] == '\0') {
+ fprintf(stderr,
+ "\nResolve library did not return a "
+ "fully qualified domain name.\n\n"
+ "If you are using /etc/hosts before DNS, "
+ "e.g. \"files\" is listed first\n"
+ "for \"hosts:\" in nsswitch.conf, ensure that "
+ "you have listed the FQDN\n"
+ "as the first name for the local host.\n\n"
+ "If this does not correct the problem, "
+ "you may have to reconfigure the kerberos\n"
+ "distribution to select a "
+ "different set of libraries using \n"
+ "--with-netlib[=libs]\n");
+ exit(3);
+ }
+
+ if (!quiet)
+ printf("Resolve library appears to have passed the test\n");
+
+ /* All ok */
+ exit(0);
}