diff options
author | 2013-03-28 09:36:03 +0000 | |
---|---|---|
committer | 2013-03-28 09:36:03 +0000 | |
commit | f2033d2fa87cb38cd8d8382bb8e32deb69b9682e (patch) | |
tree | ed6bf91ded36e6f1887216816ce0ff7a81b26541 | |
parent | More tests for negative seeks, prodded by matthew@ (diff) | |
download | wireguard-openbsd-f2033d2fa87cb38cd8d8382bb8e32deb69b9682e.tar.xz wireguard-openbsd-f2033d2fa87cb38cd8d8382bb8e32deb69b9682e.zip |
add a test case for the icmpv6 issue spotted by naddy
-rw-r--r-- | regress/lib/libc/asr/bin/common.c | 17 | ||||
-rw-r--r-- | regress/lib/libc/asr/bin/getaddrinfo.c | 6 | ||||
-rw-r--r-- | regress/lib/libc/asr/regress.sh | 10 | ||||
-rw-r--r-- | regress/lib/libc/asr/regress.subr | 3 |
4 files changed, 26 insertions, 10 deletions
diff --git a/regress/lib/libc/asr/bin/common.c b/regress/lib/libc/asr/bin/common.c index 4402d083738..8f2f4515b3f 100644 --- a/regress/lib/libc/asr/bin/common.c +++ b/regress/lib/libc/asr/bin/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.1.1.1 2012/07/13 17:49:53 eric Exp $ */ +/* $OpenBSD: common.c,v 1.2 2013/03/28 09:36:03 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -69,18 +69,21 @@ struct kv kv_socktype[] = { struct kv kv_protocol[] = { { IPPROTO_UDP, "udp" }, { IPPROTO_TCP, "tcp" }, + { IPPROTO_ICMP, "icmp" }, + { IPPROTO_ICMPV6, "icmpv6" }, { 0, NULL, } }; static const char * -kv_lookup_name(struct kv *kv, int code) +kv_lookup_name(struct kv *kv, int code, char *buf, size_t sz) { while (kv->name) { if (kv->code == code) return (kv->name); kv++; } - return "???"; + snprintf(buf, sz, "%i", code); + return (buf); } struct keyval { @@ -243,12 +246,12 @@ print_netent(struct netent *e) void print_addrinfo(struct addrinfo *ai) { - char buf[256]; + char buf[256], bf[64], bt[64], bp[64]; printf("family=%s socktype=%s protocol=%s addr=%s canonname=%s\n", - kv_lookup_name(kv_family, ai->ai_family), - kv_lookup_name(kv_socktype, ai->ai_socktype), - kv_lookup_name(kv_protocol, ai->ai_protocol), + kv_lookup_name(kv_family, ai->ai_family, bf, sizeof bf), + kv_lookup_name(kv_socktype, ai->ai_socktype, bt, sizeof bt), + kv_lookup_name(kv_protocol, ai->ai_protocol, bp, sizeof bp), print_addr(ai->ai_addr, buf, sizeof buf), ai->ai_canonname); } diff --git a/regress/lib/libc/asr/bin/getaddrinfo.c b/regress/lib/libc/asr/bin/getaddrinfo.c index 8c4abf361e1..7b8674aea95 100644 --- a/regress/lib/libc/asr/bin/getaddrinfo.c +++ b/regress/lib/libc/asr/bin/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo.c,v 1.1.1.1 2012/07/13 17:49:54 eric Exp $ */ +/* $OpenBSD: getaddrinfo.c,v 1.2 2013/03/28 09:36:03 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -81,6 +81,10 @@ main(int argc, char *argv[]) hints.ai_protocol = IPPROTO_UDP; else if (!strcmp(optarg, "tcp")) hints.ai_protocol = IPPROTO_TCP; + else if (!strcmp(optarg, "icmp")) + hints.ai_protocol = IPPROTO_ICMP; + else if (!strcmp(optarg, "icmpv6")) + hints.ai_protocol = IPPROTO_ICMPV6; else usage(); break; diff --git a/regress/lib/libc/asr/regress.sh b/regress/lib/libc/asr/regress.sh index 6e41a90d122..b1bbabc1f8a 100644 --- a/regress/lib/libc/asr/regress.sh +++ b/regress/lib/libc/asr/regress.sh @@ -1,4 +1,4 @@ -# $OpenBSD: regress.sh,v 1.4 2012/12/17 21:15:33 eric Exp $ +# $OpenBSD: regress.sh,v 1.5 2013/03/28 09:36:03 eric Exp $ . regress.subr @@ -67,6 +67,13 @@ test_getaddrinfo() done } +test_getaddrinfo2() +{ + for i in $@; do + regress getaddrinfo -f inet6 -t raw -p icmpv6 $i + done +} + test_getnameinfo() { for i in $@; do @@ -98,6 +105,7 @@ for e in file bind local; do test_gethostbyname $WEIRD $BASIC $EXTRA test_gethostbyaddr $ADDRS test_getaddrinfo NULL $WEIRD $BASIC $EXTRA + test_getaddrinfo2 undeadly.org www.kame.net test_getnameinfo $ADDRS test_gethostbyname $ADDRS done diff --git a/regress/lib/libc/asr/regress.subr b/regress/lib/libc/asr/regress.subr index dafb7ddf758..3e8cc0ebd5a 100644 --- a/regress/lib/libc/asr/regress.subr +++ b/regress/lib/libc/asr/regress.subr @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: regress.subr,v 1.1.1.1 2012/07/13 17:49:53 eric Exp $ +# $OpenBSD: regress.subr,v 1.2 2013/03/28 09:36:03 eric Exp $ TOTAL=0 FAIL=0 @@ -109,6 +109,7 @@ test "$_RUNDIR" == / && fail RUNDIR is root dir: $RUNDIR OUT=$_RUNDIR/output.log REG=$_RUNDIR/regress.log +ETC=$_RUNDIR/etc echo -n > $REG echo -n > $OUT |