diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-09-27 06:18:18 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2004-09-27 06:18:18 +0000 |
commit | f1750fb9c68854778e6e023ed490ff80e1c90167 (patch) | |
tree | 416f6a0fabb42abbdafde8965810adb5abcf0283 /posix | |
parent | efaf80c5d05102f75864847140bfb8b2bdbd4523 (diff) | |
download | glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.tar glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.tar.gz glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.tar.bz2 glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.zip |
Updated to fedora-glibc-20040927T0611cvs/fedora-glibc-2_3_3-59
Diffstat (limited to 'posix')
-rw-r--r-- | posix/Makefile | 3 | ||||
-rw-r--r-- | posix/tst-getaddrinfo2.c | 75 |
2 files changed, 77 insertions, 1 deletions
diff --git a/posix/Makefile b/posix/Makefile index 766c1dd7f7..82d35378d1 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -81,7 +81,8 @@ tests := tstgetopt testfnm runtests runptests \ bug-regex17 bug-regex18 bug-regex19 bug-regex20 \ bug-regex21 bug-regex22 bug-regex23 tst-nice tst-nanosleep \ transbug tst-rxspencer tst-pcre tst-boost \ - bug-ga1 tst-vfork1 tst-vfork2 tst-waitid + bug-ga1 tst-vfork1 tst-vfork2 tst-waitid \ + tst-getaddrinfo2 xtests := bug-ga2 ifeq (yes,$(build-shared)) test-srcs := globtest diff --git a/posix/tst-getaddrinfo2.c b/posix/tst-getaddrinfo2.c new file mode 100644 index 0000000000..b0bce5925c --- /dev/null +++ b/posix/tst-getaddrinfo2.c @@ -0,0 +1,75 @@ +/* Test by David L Stevens <dlstevens@us.ibm.com> [BZ #358] */ +#include <errno.h> +#include <netdb.h> +#include <unistd.h> +#include <sys/socket.h> + +static int +do_test (void) +{ + const char portstr[] = "583"; + int port = atoi (portstr); + struct addrinfo hints, *aires, *pai; + int rv; + int res = 1; + + memset (&hints, 0, sizeof (hints)); + hints.ai_family = AF_INET; + rv = getaddrinfo (NULL, portstr, &hints, &aires); + if (rv == 0) + { + struct sockaddr_in *psin = 0; + int got_tcp, got_udp; + int err = 0; + + got_tcp = got_udp = 0; + for (pai = aires; pai; pai = pai->ai_next) + { + printf ("ai_family=%d, ai_addrlen=%d, ai_socktype=%d", + (int) pai->ai_family, (int) pai->ai_addrlen, + (int) pai->ai_socktype); + if (pai->ai_family == AF_INET) + printf (", port=%d", + ntohs (((struct sockaddr_in *) pai->ai_addr)->sin_port)); + puts (""); + + err |= pai->ai_family != AF_INET; + err |= pai->ai_addrlen != sizeof (struct sockaddr_in); + err |= pai->ai_addr == 0; + if (pai->ai_family == AF_INET) + err |= + ntohs (((struct sockaddr_in *) pai->ai_addr)->sin_port) != port; + got_tcp |= pai->ai_socktype == SOCK_STREAM; + got_udp |= pai->ai_socktype == SOCK_DGRAM; + if (err) + break; + } + if (err) + { + printf ("FAIL getaddrinfo IPv4 socktype 0,513: " + "fam %d alen %d addr 0x%08X addr/fam %d " + "addr/port %d H[%d]\n", + pai->ai_family, pai->ai_addrlen, psin, + psin ? psin->sin_family : 0, + psin ? psin->sin_port : 0, + psin ? htons (psin->sin_port) : 0); + } + else if (got_tcp && got_udp) + { + printf ("SUCCESS getaddrinfo IPv4 socktype 0,513\n"); + res = 0; + } + else + printf ("FAIL getaddrinfo IPv4 socktype 0,513 TCP %d" + " UDP %d\n", got_tcp, got_udp); + freeaddrinfo (aires); + } + else + printf ("FAIL getaddrinfo IPv4 socktype 0,513 returns %d " + "(\"%s\")\n", rv, gai_strerror (rv)); + + return res; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |