From 6bb65fa3713873b9e18a297426780b737cc2b0ce Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 1 Jun 2007 00:06:45 +0000 Subject: [PATCH] r13121@catbus: nickm | 2007-05-31 20:06:40 -0400 Oops. Different inet_ntop implementations seem to differ on whether, in an IPv6 address with a single "0" word, that word should be written as 0, or omitted. Fix the unit tests to account for that. svn:r10432 --- src/or/test.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/or/test.c b/src/or/test.c index 29b6d5c097..610a297f1a 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -1024,6 +1024,16 @@ _test_eq_ip6(struct in6_addr *a, struct in6_addr *b, const char *e1, test_eq_ip6(&a1, &a2); \ } while (0) +#define test_ntop6_reduces2(a,b,c) do { \ + r = tor_inet_pton(AF_INET6, a, &a1); \ + test_assert(r==1); \ + test_assert(tor_inet_ntop(AF_INET6, &a1, buf, sizeof(buf))); \ + test_assert(!strcmp(buf, b) || !strcmp(buf, c)); \ + r = tor_inet_pton(AF_INET6, b, &a2); \ + test_assert(r==1); \ + test_eq_ip6(&a1, &a2); \ + } while (0) + static void test_ip6_helpers(void) { @@ -1060,8 +1070,8 @@ test_ip6_helpers(void) /* === Test ntop: af_inet6 */ test_ntop6_reduces("0:0:0:0:0:0:0:0", "::"); - test_ntop6_reduces("0001:0099:BEEF:0000:0123:FFFF:0001:0001", - "1:99:beef:0:123:ffff:1:1"); + test_ntop6_reduces("0001:0099:BEEF:0006:0123:FFFF:0001:0001", + "1:99:beef:6:123:ffff:1:1"); test_ntop6_reduces("0:0:0:0:0:0:c0a8:0101", "::192.168.1.1"); test_ntop6_reduces("0:0:0:0:0:ffff:c0a8:0101", "::ffff:192.168.1.1");