mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-12 22:28:44 +00:00
Removed config reparsing from unrelated tests
This commit is contained in:
parent
47e4e97db4
commit
34aeafbf9e
@ -85,6 +85,5 @@ main(int argc, char *argv[])
|
|||||||
WALK_LIST(t, config->tests)
|
WALK_LIST(t, config->tests)
|
||||||
bt_test_suite_base(run_function, t->fn_name, t, 0, BT_TIMEOUT, "%s", t->dsc);
|
bt_test_suite_base(run_function, t->fn_name, t, 0, BT_TIMEOUT, "%s", t->dsc);
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
return bt_exit_value();
|
return bt_exit_value();
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,6 @@
|
|||||||
|
|
||||||
#define MAX_TREE_HEIGHT 13
|
#define MAX_TREE_HEIGHT 13
|
||||||
|
|
||||||
static void
|
|
||||||
start_conf_env(void)
|
|
||||||
{
|
|
||||||
bt_bird_init();
|
|
||||||
cfg_mem = tmp_linpool;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct f_tree *
|
static struct f_tree *
|
||||||
new_tree(uint id)
|
new_tree(uint id)
|
||||||
{
|
{
|
||||||
@ -153,8 +146,6 @@ get_balanced_tree_with_ranged_values(uint nodes_count)
|
|||||||
static int
|
static int
|
||||||
t_balancing(void)
|
t_balancing(void)
|
||||||
{
|
{
|
||||||
start_conf_env();
|
|
||||||
|
|
||||||
uint height;
|
uint height;
|
||||||
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
||||||
{
|
{
|
||||||
@ -181,8 +172,6 @@ t_balancing(void)
|
|||||||
static int
|
static int
|
||||||
t_balancing_random(void)
|
t_balancing_random(void)
|
||||||
{
|
{
|
||||||
start_conf_env();
|
|
||||||
|
|
||||||
uint height;
|
uint height;
|
||||||
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
||||||
{
|
{
|
||||||
@ -218,8 +207,6 @@ t_balancing_random(void)
|
|||||||
static int
|
static int
|
||||||
t_find(void)
|
t_find(void)
|
||||||
{
|
{
|
||||||
start_conf_env();
|
|
||||||
|
|
||||||
uint height;
|
uint height;
|
||||||
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
||||||
{
|
{
|
||||||
@ -266,8 +253,6 @@ get_max_value_in_unbalanced_tree(struct f_tree *node, uint max)
|
|||||||
static int
|
static int
|
||||||
t_find_ranges(void)
|
t_find_ranges(void)
|
||||||
{
|
{
|
||||||
start_conf_env();
|
|
||||||
|
|
||||||
uint height;
|
uint height;
|
||||||
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
for (height = 1; height < MAX_TREE_HEIGHT; height++)
|
||||||
{
|
{
|
||||||
@ -305,6 +290,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bt_init(argc, argv);
|
bt_init(argc, argv);
|
||||||
|
bt_bird_init();
|
||||||
|
cfg_mem = tmp_linpool;
|
||||||
|
|
||||||
bt_test_suite(t_balancing, "Balancing strong unbalanced trees");
|
bt_test_suite(t_balancing, "Balancing strong unbalanced trees");
|
||||||
bt_test_suite(t_balancing_random, "Balancing random unbalanced trees");
|
bt_test_suite(t_balancing_random, "Balancing random unbalanced trees");
|
||||||
|
@ -432,9 +432,6 @@ test_match_net(list *prefixes, struct f_trie *trie, const net_addr *net)
|
|||||||
static int
|
static int
|
||||||
t_match_random_net(void)
|
t_match_random_net(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
int v6 = 0;
|
int v6 = 0;
|
||||||
for (int round = 0; round < TESTS_NUM; round++)
|
for (int round = 0; round < TESTS_NUM; round++)
|
||||||
{
|
{
|
||||||
@ -452,16 +449,12 @@ t_match_random_net(void)
|
|||||||
tmp_flush();
|
tmp_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
t_match_inner_net(void)
|
t_match_inner_net(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
int v6 = 0;
|
int v6 = 0;
|
||||||
for (int round = 0; round < TESTS_NUM; round++)
|
for (int round = 0; round < TESTS_NUM; round++)
|
||||||
{
|
{
|
||||||
@ -482,16 +475,12 @@ t_match_inner_net(void)
|
|||||||
tmp_flush();
|
tmp_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
t_match_outer_net(void)
|
t_match_outer_net(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
int v6 = 0;
|
int v6 = 0;
|
||||||
for (int round = 0; round < TESTS_NUM; round++)
|
for (int round = 0; round < TESTS_NUM; round++)
|
||||||
{
|
{
|
||||||
@ -513,7 +502,6 @@ t_match_outer_net(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
v6 = !v6;
|
v6 = !v6;
|
||||||
bt_bird_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,34 +562,24 @@ benchmark_trie_dataset(const char *filename, int plus)
|
|||||||
static int UNUSED
|
static int UNUSED
|
||||||
t_bench_trie_datasets_subset(void)
|
t_bench_trie_datasets_subset(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
/* Specific datasets, not included */
|
/* Specific datasets, not included */
|
||||||
benchmark_trie_dataset("trie-data-bgp-1", 0);
|
benchmark_trie_dataset("trie-data-bgp-1", 0);
|
||||||
benchmark_trie_dataset("trie-data-bgp-10", 0);
|
benchmark_trie_dataset("trie-data-bgp-10", 0);
|
||||||
benchmark_trie_dataset("trie-data-bgp-100", 0);
|
benchmark_trie_dataset("trie-data-bgp-100", 0);
|
||||||
benchmark_trie_dataset("trie-data-bgp-1000", 0);
|
benchmark_trie_dataset("trie-data-bgp-1000", 0);
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int UNUSED
|
static int UNUSED
|
||||||
t_bench_trie_datasets_random(void)
|
t_bench_trie_datasets_random(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
/* Specific datasets, not included */
|
/* Specific datasets, not included */
|
||||||
benchmark_trie_dataset("trie-data-bgp-1", 1);
|
benchmark_trie_dataset("trie-data-bgp-1", 1);
|
||||||
benchmark_trie_dataset("trie-data-bgp-10", 1);
|
benchmark_trie_dataset("trie-data-bgp-10", 1);
|
||||||
benchmark_trie_dataset("trie-data-bgp-100", 1);
|
benchmark_trie_dataset("trie-data-bgp-100", 1);
|
||||||
benchmark_trie_dataset("trie-data-bgp-1000", 1);
|
benchmark_trie_dataset("trie-data-bgp-1000", 1);
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,9 +587,6 @@ t_bench_trie_datasets_random(void)
|
|||||||
static int
|
static int
|
||||||
t_trie_same(void)
|
t_trie_same(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
int v6 = 0;
|
int v6 = 0;
|
||||||
for (int round = 0; round < TESTS_NUM*4; round++)
|
for (int round = 0; round < TESTS_NUM*4; round++)
|
||||||
{
|
{
|
||||||
@ -632,7 +607,6 @@ t_trie_same(void)
|
|||||||
tmp_flush();
|
tmp_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,9 +626,6 @@ log_networks(const net_addr *a, const net_addr *b)
|
|||||||
static int
|
static int
|
||||||
t_trie_walk(void)
|
t_trie_walk(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
for (int round = 0; round < TESTS_NUM*8; round++)
|
for (int round = 0; round < TESTS_NUM*8; round++)
|
||||||
{
|
{
|
||||||
int level = round / TESTS_NUM;
|
int level = round / TESTS_NUM;
|
||||||
@ -763,7 +734,6 @@ t_trie_walk(void)
|
|||||||
tmp_flush();
|
tmp_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,9 +772,6 @@ find_covering_nets(struct f_prefix *prefixes, int num, const net_addr *net, net_
|
|||||||
static int
|
static int
|
||||||
t_trie_walk_to_root(void)
|
t_trie_walk_to_root(void)
|
||||||
{
|
{
|
||||||
bt_bird_init();
|
|
||||||
bt_config_parse(BT_CONFIG_SIMPLE);
|
|
||||||
|
|
||||||
for (int round = 0; round < TESTS_NUM * 4; round++)
|
for (int round = 0; round < TESTS_NUM * 4; round++)
|
||||||
{
|
{
|
||||||
int level = round / TESTS_NUM;
|
int level = round / TESTS_NUM;
|
||||||
@ -876,7 +843,6 @@ t_trie_walk_to_root(void)
|
|||||||
tmp_flush();
|
tmp_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_bird_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,6 +850,8 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bt_init(argc, argv);
|
bt_init(argc, argv);
|
||||||
|
bt_bird_init();
|
||||||
|
bt_config_parse(BT_CONFIG_SIMPLE);
|
||||||
|
|
||||||
bt_test_suite(t_match_random_net, "Testing random prefix matching");
|
bt_test_suite(t_match_random_net, "Testing random prefix matching");
|
||||||
bt_test_suite(t_match_inner_net, "Testing random inner prefix matching");
|
bt_test_suite(t_match_inner_net, "Testing random inner prefix matching");
|
||||||
|
@ -78,13 +78,13 @@ t_path_format(void)
|
|||||||
bt_debug("Prepending ASN: %10u \n", i);
|
bt_debug("Prepending ASN: %10u \n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUFFER_SIZE 120
|
#define T_BUFFER_SIZE 120
|
||||||
byte buf[BUFFER_SIZE] = {};
|
byte buf[T_BUFFER_SIZE] = {};
|
||||||
|
|
||||||
as_path_format(&empty_as_path, buf, BUFFER_SIZE);
|
as_path_format(&empty_as_path, buf, T_BUFFER_SIZE);
|
||||||
bt_assert_msg(strcmp(buf, "") == 0, "Buffer(%zu): '%s'", strlen(buf), buf);
|
bt_assert_msg(strcmp(buf, "") == 0, "Buffer(%zu): '%s'", strlen(buf), buf);
|
||||||
|
|
||||||
as_path_format(as_path, buf, BUFFER_SIZE);
|
as_path_format(as_path, buf, T_BUFFER_SIZE);
|
||||||
bt_assert_msg(strcmp(buf, "4294967294 4294967293 4294967292 4294967291 4294967290 4294967289 4294967288 4294967287 4294967286 4294967285") == 0, "Buffer(%zu): '%s'", strlen(buf), buf);
|
bt_assert_msg(strcmp(buf, "4294967294 4294967293 4294967292 4294967291 4294967290 4294967289 4294967288 4294967287 4294967286 4294967285") == 0, "Buffer(%zu): '%s'", strlen(buf), buf);
|
||||||
|
|
||||||
#define SMALL_BUFFER_SIZE 25
|
#define SMALL_BUFFER_SIZE 25
|
||||||
|
@ -20,8 +20,8 @@ static const struct adata *set_sequence_same; /* <0; SET_SIZE) */
|
|||||||
static const struct adata *set_sequence_higher; /* <SET_SIZE; 2*SET_SIZE) */
|
static const struct adata *set_sequence_higher; /* <SET_SIZE; 2*SET_SIZE) */
|
||||||
static const struct adata *set_random;
|
static const struct adata *set_random;
|
||||||
|
|
||||||
#define BUFFER_SIZE 1000
|
#define T_BUFFER_SIZE 1000
|
||||||
static byte buf[BUFFER_SIZE] = {};
|
static byte buf[T_BUFFER_SIZE] = {};
|
||||||
|
|
||||||
#define SET_SIZE_FOR_FORMAT_OUTPUT 10
|
#define SET_SIZE_FOR_FORMAT_OUTPUT 10
|
||||||
|
|
||||||
@ -92,11 +92,11 @@ t_set_int_union(void)
|
|||||||
const struct adata *set_union;
|
const struct adata *set_union;
|
||||||
set_union = int_set_union(tmp_linpool, set_sequence, set_sequence_same);
|
set_union = int_set_union(tmp_linpool, set_sequence, set_sequence_same);
|
||||||
bt_assert(int_set_get_size(set_union) == SET_SIZE);
|
bt_assert(int_set_get_size(set_union) == SET_SIZE);
|
||||||
bt_assert(int_set_format(set_union, 0, 2, buf, BUFFER_SIZE) == 0);
|
bt_assert(int_set_format(set_union, 0, 2, buf, T_BUFFER_SIZE) == 0);
|
||||||
|
|
||||||
set_union = int_set_union(tmp_linpool, set_sequence, set_sequence_higher);
|
set_union = int_set_union(tmp_linpool, set_sequence, set_sequence_higher);
|
||||||
bt_assert_msg(int_set_get_size(set_union) == SET_SIZE*2, "int_set_get_size(set_union) %d, SET_SIZE*2 %d", int_set_get_size(set_union), SET_SIZE*2);
|
bt_assert_msg(int_set_get_size(set_union) == SET_SIZE*2, "int_set_get_size(set_union) %d, SET_SIZE*2 %d", int_set_get_size(set_union), SET_SIZE*2);
|
||||||
bt_assert(int_set_format(set_union, 0, 2, buf, BUFFER_SIZE) == 0);
|
bt_assert(int_set_format(set_union, 0, 2, buf, T_BUFFER_SIZE) == 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -106,15 +106,15 @@ t_set_int_format(void)
|
|||||||
{
|
{
|
||||||
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, T_BUFFER_SIZE) == 0);
|
||||||
bt_assert(strcmp(buf, "0.0.0.0 0.0.0.1 0.0.0.2 0.0.0.3 0.0.0.4 0.0.0.5 0.0.0.6 0.0.0.7 0.0.0.8 0.0.0.9") == 0);
|
bt_assert(strcmp(buf, "0.0.0.0 0.0.0.1 0.0.0.2 0.0.0.3 0.0.0.4 0.0.0.5 0.0.0.6 0.0.0.7 0.0.0.8 0.0.0.9") == 0);
|
||||||
|
|
||||||
bzero(buf, BUFFER_SIZE);
|
bzero(buf, T_BUFFER_SIZE);
|
||||||
bt_assert(int_set_format(set_sequence, 0, 2, buf, BUFFER_SIZE) == 0);
|
bt_assert(int_set_format(set_sequence, 0, 2, buf, T_BUFFER_SIZE) == 0);
|
||||||
bt_assert(strcmp(buf, "0.0.0.2 0.0.0.3 0.0.0.4 0.0.0.5 0.0.0.6 0.0.0.7 0.0.0.8 0.0.0.9") == 0);
|
bt_assert(strcmp(buf, "0.0.0.2 0.0.0.3 0.0.0.4 0.0.0.5 0.0.0.6 0.0.0.7 0.0.0.8 0.0.0.9") == 0);
|
||||||
|
|
||||||
bzero(buf, BUFFER_SIZE);
|
bzero(buf, T_BUFFER_SIZE);
|
||||||
bt_assert(int_set_format(set_sequence, 1, 0, buf, BUFFER_SIZE) == 0);
|
bt_assert(int_set_format(set_sequence, 1, 0, buf, T_BUFFER_SIZE) == 0);
|
||||||
bt_assert(strcmp(buf, "(0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) (0,8) (0,9)") == 0);
|
bt_assert(strcmp(buf, "(0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) (0,8) (0,9)") == 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -174,11 +174,11 @@ t_set_ec_union(void)
|
|||||||
const struct adata *set_union;
|
const struct adata *set_union;
|
||||||
set_union = ec_set_union(tmp_linpool, set_sequence, set_sequence_same);
|
set_union = ec_set_union(tmp_linpool, set_sequence, set_sequence_same);
|
||||||
bt_assert(ec_set_get_size(set_union) == SET_SIZE);
|
bt_assert(ec_set_get_size(set_union) == SET_SIZE);
|
||||||
bt_assert(ec_set_format(set_union, 0, buf, BUFFER_SIZE) == 0);
|
bt_assert(ec_set_format(set_union, 0, buf, T_BUFFER_SIZE) == 0);
|
||||||
|
|
||||||
set_union = ec_set_union(tmp_linpool, set_sequence, set_sequence_higher);
|
set_union = ec_set_union(tmp_linpool, set_sequence, set_sequence_higher);
|
||||||
bt_assert_msg(ec_set_get_size(set_union) == SET_SIZE*2, "ec_set_get_size(set_union) %d, SET_SIZE*2 %d", ec_set_get_size(set_union), SET_SIZE*2);
|
bt_assert_msg(ec_set_get_size(set_union) == SET_SIZE*2, "ec_set_get_size(set_union) %d, SET_SIZE*2 %d", ec_set_get_size(set_union), SET_SIZE*2);
|
||||||
bt_assert(ec_set_format(set_union, 0, buf, BUFFER_SIZE) == 0);
|
bt_assert(ec_set_format(set_union, 0, buf, T_BUFFER_SIZE) == 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ t_set_ec_format(void)
|
|||||||
for (i = 1; i < SET_SIZE_FOR_FORMAT_OUTPUT; i++)
|
for (i = 1; i < SET_SIZE_FOR_FORMAT_OUTPUT; i++)
|
||||||
set_sequence = ec_set_add(tmp_linpool, set_sequence, i + ((i%2) ? ((u64)EC_RO << 48) : ((u64)EC_RT << 48)));
|
set_sequence = ec_set_add(tmp_linpool, set_sequence, i + ((i%2) ? ((u64)EC_RO << 48) : ((u64)EC_RT << 48)));
|
||||||
|
|
||||||
bt_assert(ec_set_format(set_sequence, 0, buf, BUFFER_SIZE) == 0);
|
bt_assert(ec_set_format(set_sequence, 0, buf, T_BUFFER_SIZE) == 0);
|
||||||
bt_assert_msg(strcmp(buf, "(unknown 0x0, 0, 0) (ro, 0, 1) (rt, 0, 2) (ro, 0, 3) (rt, 0, 4) (ro, 0, 5) (rt, 0, 6) (ro, 0, 7) (rt, 0, 8) (ro, 0, 9)") == 0,
|
bt_assert_msg(strcmp(buf, "(unknown 0x0, 0, 0) (ro, 0, 1) (rt, 0, 2) (ro, 0, 3) (rt, 0, 4) (ro, 0, 5) (rt, 0, 6) (ro, 0, 7) (rt, 0, 8) (ro, 0, 9)") == 0,
|
||||||
"ec_set_format() returns '%s'", buf);
|
"ec_set_format() returns '%s'", buf);
|
||||||
|
|
||||||
|
@ -71,12 +71,6 @@ bt_bird_init(void)
|
|||||||
protos_build();
|
protos_build();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_bird_cleanup(void)
|
|
||||||
{
|
|
||||||
config = new_config = NULL;
|
|
||||||
the_bird_unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
bt_load_file(const char *filename, int quiet)
|
bt_load_file(const char *filename, int quiet)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user