]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Birdtest: Tunning IP tests, Hash tests
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Tue, 4 Aug 2015 08:25:47 +0000 (10:25 +0200)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Tue, 4 Aug 2015 08:26:33 +0000 (10:26 +0200)
lib/hash_test.c
lib/ip_test.c

index b325f96708ad599ee9d6d414202fb1b2e3a36e60..e6412431e456786fc5be8eb26d0e217b7cad47c0 100644 (file)
@@ -6,6 +6,8 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
+#undef LOCAL_DEBUG
+
 #include "test/birdtest.h"
 #include "test/birdtest_support.h"     /* REMOVE ME */
 
@@ -47,6 +49,7 @@ print_rate_of_fulfilment(void)
   bt_debug("%d (%.2f %%) chained of %d hashes \n", num_stacked_items, percent_stacked_items, MAX_NUM);
 }
 
+#ifdef LOCAL_DEBUG
 static void
 dump_nodes(void)
 {
@@ -54,6 +57,7 @@ dump_nodes(void)
   for (i = 0; i < MAX_NUM; i++)
     bt_debug("nodes[%3d] is at address %14p has .key %3d, .next %14p \n", i, &nodes[i], nodes[i].key, nodes[i].next);
 }
+#endif
 
 static void
 init_hash_(uint order)
index 8bab9eaf6d4679d00af3684c7d0b2f82deb76272..90ce3adeadae667e09691785817e2bfbbada9135 100644 (file)
 
 #define IP4_MAX_LEN    16
 
-static u32
-ip4_pton_(char *s)
-{
-  ip4_addr ip;
-  ip4_pton(s,&ip);
-  return ip4_to_u32(ip);
-}
-
 static int
 t_ip4_pton(void)
 {
   struct in_out {
     char in[IP4_MAX_LEN];
-    u32 out;
+    ip4_addr out;
   } in_out[] = {
       {
          .in  = "192.168.1.128",
-         .out = ip4_to_u32(ip4_build(192, 168, 1, 128)),
+         .out = ip4_build(192, 168, 1, 128),
       },
       {
          .in  = "255.255.255.255",
-         .out = ip4_to_u32(ip4_build(255, 255, 255, 255)),
+         .out = ip4_build(255, 255, 255, 255),
       },
       {
          .in  = "0.0.0.0",
-         .out = ip4_to_u32(ip4_build(0, 0, 0, 0)),
+         .out = ip4_build(0, 0, 0, 0),
       },
   };
 
-  bt_assert_out_fn_in(ip4_pton_, in_out, "'%s'", NULL);
+  bt_assert_fn_in_out(ip4_pton, in_out, "'%s'", NULL);
 
   return bt_test_suite_success;
 }
 
-static void
-ip6_pton_(char *s, u32 (*addr)[4])
-{
-  static ip6_addr ip;
-  ip6_pton(s, &ip);
-  int i;
-  for (i = 0; i < 4; i++)
-    (*addr)[i] = ip.addr[i];
-}
-
 static int
 t_ip6_pton(void)
 {
   struct in_out {
     char *in;
-    u32 out[4];
+    ip6_addr out;
   } in_out[] = {
       {
          .in  = "2001:0db8:0000:0000:0000:0000:1428:57ab",
-         .out = {0x20010DB8, 0x00000000, 0x00000000, 0x142857AB},
+         .out = ip6_build(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB),
       },
       {
          .in  = "2001:0db8:0000:0000:0000::1428:57ab",
-         .out = {0x20010DB8, 0x00000000, 0x00000000, 0x142857AB},
+         .out = ip6_build(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB),
       },
       {
          .in  = "2001:0db8::1428:57ab",
-         .out = {0x20010DB8, 0x00000000, 0x00000000, 0x142857AB},
+         .out = ip6_build(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB),
       },
       {
          .in  = "2001:db8::1428:57ab",
-         .out = {0x20010DB8, 0x00000000, 0x00000000, 0x142857AB},
+         .out = ip6_build(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB),
       },
       {
          .in  = "::1",
-         .out = {0x00000000, 0x00000000, 0x00000000, 0x00000001},
+         .out = ip6_build(0x00000000, 0x00000000, 0x00000000, 0x00000001),
       },
       {
          .in  = "::",
-         .out = {0x00000000, 0x00000000, 0x00000000, 0x00000000},
+         .out = ip6_build(0x00000000, 0x00000000, 0x00000000, 0x00000000),
       },
       {
          .in  = "2605:2700:0:3::4713:93e3",
-         .out = {0x26052700, 0x00000003, 0x00000000, 0x471393E3},
+         .out = ip6_build(0x26052700, 0x00000003, 0x00000000, 0x471393E3),
       },
   };
 
-  bt_assert_fn_in_out(ip6_pton_, in_out, "'%s'", NULL);
+  bt_assert_fn_in_out(ip6_pton, in_out, "'%s'", NULL);
 
   return bt_test_suite_success;
 }
@@ -146,11 +128,11 @@ t_ip6_ntop(void)
     char out[INET6_ADDRSTRLEN];
   } in_out[] = {
       {
-         .in  = { .addr = {0x20010DB8, 0x00000000, 0x00000000, 0x142857AB}},
+         .in  = ip6_build(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB),
          .out = "2001:db8::1428:57ab",
       },
       {
-         .in  = { .addr = {0x26052700, 0x00000003, 0x00000000, 0x471393E3}},
+         .in  = ip6_build(0x26052700, 0x00000003, 0x00000000, 0x471393E3),
          .out = "2605:2700:0:3::4713:93e3",
       },
   };