]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed resource initialization in unit tests
authorMaria Matejka <mq@ucw.cz>
Wed, 9 Mar 2022 09:30:03 +0000 (10:30 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 9 Mar 2022 09:30:42 +0000 (10:30 +0100)
lib/bitmap_test.c
lib/buffer_test.c
lib/event_test.c
lib/flowspec_test.c
lib/hash_test.c
nest/a-path_test.c
nest/a-set_test.c
sysdep/unix/alloc.c
test/birdtest.c

index 0595a4d0d6349ecd8753de48971f8323c14331b5..07860c94394dc968aeb1c99958a02af7b0d31cbe 100644 (file)
@@ -24,7 +24,6 @@ t_bmap_set_clear_random(void)
 {
   struct bmap b;
 
-  resource_init();
   bmap_init(&b, &root_pool, 1024);
 
   char expected[MAX_NUM] = {};
@@ -60,7 +59,6 @@ t_hmap_set_clear_random(void)
 {
   struct hmap b;
 
-  resource_init();
   hmap_init(&b, &root_pool, 1024);
 
   char expected[MAX_NUM] = {};
@@ -119,7 +117,6 @@ t_hmap_set_clear_fill(void)
 {
   struct hmap b;
 
-  resource_init();
   hmap_init(&b, &root_pool, 1024);
 
   char expected[MAX_NUM] = {};
index 5b7de33072d1d69d5b4a816ecc88dd625da7a400..0629e90134f06062d8008b52b68736ed6c2c13cf 100644 (file)
@@ -41,7 +41,6 @@ fill_expected_array(void)
 static void
 init_buffer(void)
 {
-  resource_init();
   buffer_pool = &root_pool;
   BUFFER_INIT(buf, buffer_pool, MAX_NUM);
 }
index e1215bbab6ac401b8b367f02702b28dc9b1c11bf..e1fbea8fc7421e720ef819ac4a99c226e7aa244b 100644 (file)
@@ -53,7 +53,6 @@ t_ev_run_list(void)
 {
   int i;
 
-  resource_init();
   olock_init();
   timer_init();
   io_init();
index 115084a386435e6074473ca6e44868fbcfd2407a..03649b99808fc2009184d477447fe639f7569b4f 100644 (file)
@@ -446,8 +446,6 @@ t_validation6(void)
 static int
 t_builder4(void)
 {
-  resource_init();
-
   struct flow_builder *fb = flow_builder_init(&root_pool);
 
   /* Expectation */
@@ -528,7 +526,6 @@ t_builder6(void)
 {
   net_addr_ip6 ip;
 
-  resource_init();
   struct flow_builder *fb = flow_builder_init(&root_pool);
   fb->ipv6 = 1;
 
index 59beb7c0c70e4f44249c4a0a48d281d1e159dfac..4bce70179e0fcdf0416421018e1d8ec86de97100 100644 (file)
@@ -61,7 +61,6 @@ dump_nodes(void)
 static void
 init_hash_(uint order)
 {
-  resource_init();
   my_pool = rp_new(&root_pool, "Test pool");
 
   HASH_INIT(hash, my_pool, order);
index abd2abbf425c12179d9b88102e9ce58fcf8b2068..e007a45040f47c55ff954cbc60d720bce718c1ac 100644 (file)
@@ -23,8 +23,6 @@
 static int
 t_as_path_match(void)
 {
-  resource_init();
-
   int round;
   for (round = 0; round < TESTS_NUM; round++)
   {
@@ -69,8 +67,6 @@ t_as_path_match(void)
 static int
 t_path_format(void)
 {
-  resource_init();
-
   struct adata empty_as_path = {};
   struct adata *as_path = &empty_as_path;
 
@@ -114,8 +110,6 @@ count_asn_in_array(const u32 *array, u32 asn)
 static int
 t_path_include(void)
 {
-  resource_init();
-
   struct adata empty_as_path = {};
   struct adata *as_path = &empty_as_path;
 
@@ -158,8 +152,6 @@ t_path_include(void)
 static int
 t_as_path_converting(void)
 {
-  resource_init();
-
   struct adata empty_as_path = {};
   struct adata *as_path = &empty_as_path;
 #define AS_PATH_LENGTH_FOR_CONVERTING_TEST 10
index 669872e3ac84bc0c303ec51c5b550ad8c782a664..904e676408d735ed9fbdf613c17d07812de19b11 100644 (file)
@@ -68,7 +68,6 @@ t_set_int_contains(void)
 {
   int i;
 
-  resource_init();
   generate_set_sequence(SET_TYPE_INT, SET_SIZE);
 
   bt_assert(int_set_get_size(set_sequence) == SET_SIZE);
@@ -88,7 +87,6 @@ t_set_int_contains(void)
 static int
 t_set_int_union(void)
 {
-  resource_init();
   generate_set_sequence(SET_TYPE_INT, SET_SIZE);
 
   const struct adata *set_union;
@@ -106,7 +104,6 @@ t_set_int_union(void)
 static int
 t_set_int_format(void)
 {
-  resource_init();
   generate_set_sequence(SET_TYPE_INT, SET_SIZE_FOR_FORMAT_OUTPUT);
 
   bt_assert(int_set_format(set_sequence, 0, 0, buf, BUFFER_SIZE) == 0);
@@ -126,7 +123,6 @@ t_set_int_format(void)
 static int
 t_set_int_delete(void)
 {
-  resource_init();
   generate_set_sequence(SET_TYPE_INT, SET_SIZE);
 
   const struct adata *deleting_sequence = set_sequence;
@@ -154,7 +150,6 @@ t_set_ec_contains(void)
 {
   u32 i;
 
-  resource_init();
   generate_set_sequence(SET_TYPE_EC, SET_SIZE);
 
   bt_assert(ec_set_get_size(set_sequence) == SET_SIZE);
@@ -174,7 +169,6 @@ t_set_ec_contains(void)
 static int
 t_set_ec_union(void)
 {
-  resource_init();
   generate_set_sequence(SET_TYPE_EC, SET_SIZE);
 
   const struct adata *set_union;
@@ -192,8 +186,6 @@ t_set_ec_union(void)
 static int
 t_set_ec_format(void)
 {
-  resource_init();
-
   const struct adata empty_as_path = {};
   set_sequence = set_sequence_same = set_sequence_higher = set_random = &empty_as_path;
 
@@ -212,7 +204,6 @@ t_set_ec_format(void)
 static int
 t_set_ec_delete(void)
 {
-  resource_init();
   generate_set_sequence(SET_TYPE_EC, SET_SIZE);
 
   const struct adata *deleting_sequence = set_sequence;
index f96c0fcf0a7bb3b65963b0d282ad41e58e7dc730..755b5fa54d877c0014f69e3a82ac5280021104a0 100644 (file)
@@ -164,6 +164,8 @@ void
 resource_sys_init(void)
 {
 #ifdef HAVE_MMAP
+  ASSERT_DIE(global_free_pages.cnt == 0);
+
   if (!(page_size = sysconf(_SC_PAGESIZE)))
     die("System page size must be non-zero");
 
index 10d6d6ded4fcecc1d655f58a6664e77bb099c38b..ae05d1a530dc759967338bba2b699c051a4e63f5 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "test/birdtest.h"
 #include "lib/string.h"
+#include "lib/event.h"
 
 #ifdef HAVE_EXECINFO_H
 #include <execinfo.h>
@@ -120,6 +121,7 @@ bt_init(int argc, char *argv[])
   bt_suite_case_begin = bt_suite_begin = bt_begin;
 
   resource_init();
+  ev_init_list(&global_event_list);
 
   return;