Fixed resource initialization in unit tests

This commit is contained in:
Maria Matejka 2022-03-09 10:30:03 +01:00
parent b90c9b164f
commit 9e60a1fbc3
9 changed files with 4 additions and 26 deletions

View file

@ -24,7 +24,6 @@ t_bmap_set_clear_random(void)
{ {
struct bmap b; struct bmap b;
resource_init();
bmap_init(&b, &root_pool, 1024); bmap_init(&b, &root_pool, 1024);
char expected[MAX_NUM] = {}; char expected[MAX_NUM] = {};
@ -60,7 +59,6 @@ t_hmap_set_clear_random(void)
{ {
struct hmap b; struct hmap b;
resource_init();
hmap_init(&b, &root_pool, 1024); hmap_init(&b, &root_pool, 1024);
char expected[MAX_NUM] = {}; char expected[MAX_NUM] = {};
@ -119,7 +117,6 @@ t_hmap_set_clear_fill(void)
{ {
struct hmap b; struct hmap b;
resource_init();
hmap_init(&b, &root_pool, 1024); hmap_init(&b, &root_pool, 1024);
char expected[MAX_NUM] = {}; char expected[MAX_NUM] = {};

View file

@ -41,7 +41,6 @@ fill_expected_array(void)
static void static void
init_buffer(void) init_buffer(void)
{ {
resource_init();
buffer_pool = &root_pool; buffer_pool = &root_pool;
BUFFER_INIT(buf, buffer_pool, MAX_NUM); BUFFER_INIT(buf, buffer_pool, MAX_NUM);
} }

View file

@ -53,7 +53,6 @@ t_ev_run_list(void)
{ {
int i; int i;
resource_init();
olock_init(); olock_init();
timer_init(); timer_init();
io_init(); io_init();

View file

@ -446,8 +446,6 @@ t_validation6(void)
static int static int
t_builder4(void) t_builder4(void)
{ {
resource_init();
struct flow_builder *fb = flow_builder_init(&root_pool); struct flow_builder *fb = flow_builder_init(&root_pool);
/* Expectation */ /* Expectation */
@ -528,7 +526,6 @@ t_builder6(void)
{ {
net_addr_ip6 ip; net_addr_ip6 ip;
resource_init();
struct flow_builder *fb = flow_builder_init(&root_pool); struct flow_builder *fb = flow_builder_init(&root_pool);
fb->ipv6 = 1; fb->ipv6 = 1;

View file

@ -61,7 +61,6 @@ dump_nodes(void)
static void static void
init_hash_(uint order) init_hash_(uint order)
{ {
resource_init();
my_pool = rp_new(&root_pool, "Test pool"); my_pool = rp_new(&root_pool, "Test pool");
HASH_INIT(hash, my_pool, order); HASH_INIT(hash, my_pool, order);

View file

@ -23,8 +23,6 @@
static int static int
t_as_path_match(void) t_as_path_match(void)
{ {
resource_init();
int round; int round;
for (round = 0; round < TESTS_NUM; round++) for (round = 0; round < TESTS_NUM; round++)
{ {
@ -69,8 +67,6 @@ t_as_path_match(void)
static int static int
t_path_format(void) t_path_format(void)
{ {
resource_init();
struct adata empty_as_path = {}; struct adata empty_as_path = {};
struct adata *as_path = &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 static int
t_path_include(void) t_path_include(void)
{ {
resource_init();
struct adata empty_as_path = {}; struct adata empty_as_path = {};
struct adata *as_path = &empty_as_path; struct adata *as_path = &empty_as_path;
@ -158,8 +152,6 @@ t_path_include(void)
static int static int
t_as_path_converting(void) t_as_path_converting(void)
{ {
resource_init();
struct adata empty_as_path = {}; struct adata empty_as_path = {};
struct adata *as_path = &empty_as_path; struct adata *as_path = &empty_as_path;
#define AS_PATH_LENGTH_FOR_CONVERTING_TEST 10 #define AS_PATH_LENGTH_FOR_CONVERTING_TEST 10

View file

@ -68,7 +68,6 @@ t_set_int_contains(void)
{ {
int i; int i;
resource_init();
generate_set_sequence(SET_TYPE_INT, SET_SIZE); generate_set_sequence(SET_TYPE_INT, SET_SIZE);
bt_assert(int_set_get_size(set_sequence) == SET_SIZE); bt_assert(int_set_get_size(set_sequence) == SET_SIZE);
@ -88,7 +87,6 @@ t_set_int_contains(void)
static int static int
t_set_int_union(void) t_set_int_union(void)
{ {
resource_init();
generate_set_sequence(SET_TYPE_INT, SET_SIZE); generate_set_sequence(SET_TYPE_INT, SET_SIZE);
const struct adata *set_union; const struct adata *set_union;
@ -106,7 +104,6 @@ t_set_int_union(void)
static int static int
t_set_int_format(void) t_set_int_format(void)
{ {
resource_init();
generate_set_sequence(SET_TYPE_INT, SET_SIZE_FOR_FORMAT_OUTPUT); generate_set_sequence(SET_TYPE_INT, SET_SIZE_FOR_FORMAT_OUTPUT);
bt_assert(int_set_format(set_sequence, 0, 0, buf, BUFFER_SIZE) == 0); bt_assert(int_set_format(set_sequence, 0, 0, buf, BUFFER_SIZE) == 0);
@ -126,7 +123,6 @@ t_set_int_format(void)
static int static int
t_set_int_delete(void) t_set_int_delete(void)
{ {
resource_init();
generate_set_sequence(SET_TYPE_INT, SET_SIZE); generate_set_sequence(SET_TYPE_INT, SET_SIZE);
const struct adata *deleting_sequence = set_sequence; const struct adata *deleting_sequence = set_sequence;
@ -154,7 +150,6 @@ t_set_ec_contains(void)
{ {
u32 i; u32 i;
resource_init();
generate_set_sequence(SET_TYPE_EC, SET_SIZE); generate_set_sequence(SET_TYPE_EC, SET_SIZE);
bt_assert(ec_set_get_size(set_sequence) == SET_SIZE); bt_assert(ec_set_get_size(set_sequence) == SET_SIZE);
@ -174,7 +169,6 @@ t_set_ec_contains(void)
static int static int
t_set_ec_union(void) t_set_ec_union(void)
{ {
resource_init();
generate_set_sequence(SET_TYPE_EC, SET_SIZE); generate_set_sequence(SET_TYPE_EC, SET_SIZE);
const struct adata *set_union; const struct adata *set_union;
@ -192,8 +186,6 @@ t_set_ec_union(void)
static int static int
t_set_ec_format(void) t_set_ec_format(void)
{ {
resource_init();
const struct adata empty_as_path = {}; const struct adata empty_as_path = {};
set_sequence = set_sequence_same = set_sequence_higher = set_random = &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 static int
t_set_ec_delete(void) t_set_ec_delete(void)
{ {
resource_init();
generate_set_sequence(SET_TYPE_EC, SET_SIZE); generate_set_sequence(SET_TYPE_EC, SET_SIZE);
const struct adata *deleting_sequence = set_sequence; const struct adata *deleting_sequence = set_sequence;

View file

@ -164,6 +164,8 @@ void
resource_sys_init(void) resource_sys_init(void)
{ {
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
ASSERT_DIE(global_free_pages.cnt == 0);
if (!(page_size = sysconf(_SC_PAGESIZE))) if (!(page_size = sysconf(_SC_PAGESIZE)))
die("System page size must be non-zero"); die("System page size must be non-zero");

View file

@ -20,6 +20,7 @@
#include "test/birdtest.h" #include "test/birdtest.h"
#include "lib/string.h" #include "lib/string.h"
#include "lib/event.h"
#ifdef HAVE_EXECINFO_H #ifdef HAVE_EXECINFO_H
#include <execinfo.h> #include <execinfo.h>
@ -120,6 +121,7 @@ bt_init(int argc, char *argv[])
bt_suite_case_begin = bt_suite_begin = bt_begin; bt_suite_case_begin = bt_suite_begin = bt_begin;
resource_init(); resource_init();
ev_init_list(&global_event_list);
return; return;