[or-cvs] r10432: Oops. Different inet_ntop implementations seem to differ on (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Jun 1 00:06:45 UTC 2007


Author: nickm
Date: 2007-05-31 20:06:45 -0400 (Thu, 31 May 2007)
New Revision: 10432

Modified:
   tor/trunk/
   tor/trunk/src/or/test.c
Log:
 r13121 at 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13121] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-05-31 23:58:54 UTC (rev 10431)
+++ tor/trunk/src/or/test.c	2007-06-01 00:06:45 UTC (rev 10432)
@@ -1024,6 +1024,16 @@
     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 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");



More information about the tor-commits mailing list