From 9e60a1fbc3ef9ab93b414dcf451bbe741e2e8827 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Wed, 9 Mar 2022 10:30:03 +0100 Subject: [PATCH] Fixed resource initialization in unit tests --- lib/bitmap_test.c | 3 --- lib/buffer_test.c | 1 - lib/event_test.c | 1 - lib/flowspec_test.c | 3 --- lib/hash_test.c | 1 - nest/a-path_test.c | 8 -------- nest/a-set_test.c | 9 --------- sysdep/unix/alloc.c | 2 ++ test/birdtest.c | 2 ++ 9 files changed, 4 insertions(+), 26 deletions(-) diff --git a/lib/bitmap_test.c b/lib/bitmap_test.c index 0595a4d0..07860c94 100644 --- a/lib/bitmap_test.c +++ b/lib/bitmap_test.c @@ -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] = {}; diff --git a/lib/buffer_test.c b/lib/buffer_test.c index 5b7de330..0629e901 100644 --- a/lib/buffer_test.c +++ b/lib/buffer_test.c @@ -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); } diff --git a/lib/event_test.c b/lib/event_test.c index e1215bba..e1fbea8f 100644 --- a/lib/event_test.c +++ b/lib/event_test.c @@ -53,7 +53,6 @@ t_ev_run_list(void) { int i; - resource_init(); olock_init(); timer_init(); io_init(); diff --git a/lib/flowspec_test.c b/lib/flowspec_test.c index 115084a3..03649b99 100644 --- a/lib/flowspec_test.c +++ b/lib/flowspec_test.c @@ -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; diff --git a/lib/hash_test.c b/lib/hash_test.c index 59beb7c0..4bce7017 100644 --- a/lib/hash_test.c +++ b/lib/hash_test.c @@ -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); diff --git a/nest/a-path_test.c b/nest/a-path_test.c index abd2abbf..e007a450 100644 --- a/nest/a-path_test.c +++ b/nest/a-path_test.c @@ -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 diff --git a/nest/a-set_test.c b/nest/a-set_test.c index 669872e3..904e6764 100644 --- a/nest/a-set_test.c +++ b/nest/a-set_test.c @@ -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; diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index f96c0fcf..755b5fa5 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -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"); diff --git a/test/birdtest.c b/test/birdtest.c index 10d6d6de..ae05d1a5 100644 --- a/test/birdtest.c +++ b/test/birdtest.c @@ -20,6 +20,7 @@ #include "test/birdtest.h" #include "lib/string.h" +#include "lib/event.h" #ifdef HAVE_EXECINFO_H #include @@ -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;