]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/bgpd/test_bgp_table.c
bgpd: fix bgp_table range lookup
[mirror_frr.git] / tests / bgpd / test_bgp_table.c
index 01ce7480d751ac48a09aac9813b7869b1d6aa91f..819c2d728269b6e95ee593bf5d2e7cb660aae5c5 100644 (file)
@@ -28,6 +28,8 @@
 #include "bgpd/bgp_table.h"
 #include "linklist.h"
 
+/* Satisfy link requirements from including bgpd.h */
+struct zebra_privs_t bgpd_privs = {0};
 /*
  * test_node_t
  *
@@ -116,8 +118,8 @@ static void check_lookup_result(struct list *list, va_list arglist)
        assert(prefix_count == listcount(list));
 }
 
-static void do_test(struct bgp_table *table, const char *prefix, uint8_t maxlen,
-                   ...)
+static void do_test(struct bgp_table *table, const char *prefix,
+                   uint32_t maxlen, ...)
 {
        va_list arglist;
        struct list *list = list_new();
@@ -134,7 +136,7 @@ static void do_test(struct bgp_table *table, const char *prefix, uint8_t maxlen,
 
        check_lookup_result(list, arglist);
 
-       list_delete_and_null(&list);
+       list_delete(&list);
 
        va_end(arglist);
 
@@ -156,7 +158,7 @@ static void test_range_lookup(void)
                                  "1.16.160.0/19", "1.16.32.0/20",
                                  "1.16.32.0/21",  "16.0.0.0/16"};
 
-       int num_prefixes = sizeof(prefixes) / sizeof(prefixes[0]);
+       int num_prefixes = array_size(prefixes);
 
        for (int i = 0; i < num_prefixes; i++)
                add_node(table, prefixes[i]);
@@ -181,7 +183,7 @@ static void test_range_lookup(void)
 
        do_test(table, "16.0.0.0/8", 16, "16.0.0.0/16", NULL);
 
-       do_test(table, "0.0.0.0/3", 21, "1.16.0.0/16", "1.16.128.0/18",
+       do_test(table, "0.0.0.0/2", 21, "1.16.0.0/16", "1.16.128.0/18",
                "1.16.192.0/18", "1.16.64.0/19", "1.16.160.0/19",
                "1.16.32.0/20", "1.16.32.0/21", "16.0.0.0/16", NULL);
 }