mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
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
This commit is contained in:
parent
d8a1f31283
commit
6bb65fa371
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user