From 34aeafbf9ea98c8644f6403b3810ff0490350465 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Wed, 18 Jan 2023 14:31:11 +0100 Subject: Removed config reparsing from unrelated tests --- filter/filter_test.c | 1 - filter/tree_test.c | 17 ++--------------- filter/trie_test.c | 36 ++---------------------------------- lib/a-path_test.c | 8 ++++---- lib/a-set_test.c | 24 ++++++++++++------------ test/bt-utils.c | 6 ------ 6 files changed, 20 insertions(+), 72 deletions(-) diff --git a/filter/filter_test.c b/filter/filter_test.c index 671dba94..aa325aef 100644 --- a/filter/filter_test.c +++ b/filter/filter_test.c @@ -85,6 +85,5 @@ main(int argc, char *argv[]) WALK_LIST(t, config->tests) bt_test_suite_base(run_function, t->fn_name, t, 0, BT_TIMEOUT, "%s", t->dsc); - bt_bird_cleanup(); return bt_exit_value(); } diff --git a/filter/tree_test.c b/filter/tree_test.c index d180efbc..655205c2 100644 --- a/filter/tree_test.c +++ b/filter/tree_test.c @@ -15,13 +15,6 @@ #define MAX_TREE_HEIGHT 13 -static void -start_conf_env(void) -{ - bt_bird_init(); - cfg_mem = tmp_linpool; -} - static struct f_tree * new_tree(uint id) { @@ -153,8 +146,6 @@ get_balanced_tree_with_ranged_values(uint nodes_count) static int t_balancing(void) { - start_conf_env(); - uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { @@ -181,8 +172,6 @@ t_balancing(void) static int t_balancing_random(void) { - start_conf_env(); - uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { @@ -218,8 +207,6 @@ t_balancing_random(void) static int t_find(void) { - start_conf_env(); - uint 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 t_find_ranges(void) { - start_conf_env(); - uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { @@ -305,6 +290,8 @@ int main(int argc, char *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_random, "Balancing random unbalanced trees"); diff --git a/filter/trie_test.c b/filter/trie_test.c index ddce2daa..81f38db9 100644 --- a/filter/trie_test.c +++ b/filter/trie_test.c @@ -432,9 +432,6 @@ test_match_net(list *prefixes, struct f_trie *trie, const net_addr *net) static int t_match_random_net(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - int v6 = 0; for (int round = 0; round < TESTS_NUM; round++) { @@ -452,16 +449,12 @@ t_match_random_net(void) tmp_flush(); } - bt_bird_cleanup(); return 1; } static int t_match_inner_net(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - int v6 = 0; for (int round = 0; round < TESTS_NUM; round++) { @@ -482,16 +475,12 @@ t_match_inner_net(void) tmp_flush(); } - bt_bird_cleanup(); return 1; } static int t_match_outer_net(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - int v6 = 0; for (int round = 0; round < TESTS_NUM; round++) { @@ -513,7 +502,6 @@ t_match_outer_net(void) } v6 = !v6; - bt_bird_cleanup(); return 1; } @@ -574,34 +562,24 @@ benchmark_trie_dataset(const char *filename, int plus) static int UNUSED t_bench_trie_datasets_subset(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - /* Specific datasets, not included */ benchmark_trie_dataset("trie-data-bgp-1", 0); benchmark_trie_dataset("trie-data-bgp-10", 0); benchmark_trie_dataset("trie-data-bgp-100", 0); benchmark_trie_dataset("trie-data-bgp-1000", 0); - bt_bird_cleanup(); - return 1; } static int UNUSED t_bench_trie_datasets_random(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - /* Specific datasets, not included */ benchmark_trie_dataset("trie-data-bgp-1", 1); benchmark_trie_dataset("trie-data-bgp-10", 1); benchmark_trie_dataset("trie-data-bgp-100", 1); benchmark_trie_dataset("trie-data-bgp-1000", 1); - bt_bird_cleanup(); - return 1; } @@ -609,9 +587,6 @@ t_bench_trie_datasets_random(void) static int t_trie_same(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - int v6 = 0; for (int round = 0; round < TESTS_NUM*4; round++) { @@ -632,7 +607,6 @@ t_trie_same(void) tmp_flush(); } - bt_bird_cleanup(); return 1; } @@ -652,9 +626,6 @@ log_networks(const net_addr *a, const net_addr *b) static int t_trie_walk(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - for (int round = 0; round < TESTS_NUM*8; round++) { int level = round / TESTS_NUM; @@ -763,7 +734,6 @@ t_trie_walk(void) tmp_flush(); } - bt_bird_cleanup(); return 1; } @@ -802,9 +772,6 @@ find_covering_nets(struct f_prefix *prefixes, int num, const net_addr *net, net_ static int t_trie_walk_to_root(void) { - bt_bird_init(); - bt_config_parse(BT_CONFIG_SIMPLE); - for (int round = 0; round < TESTS_NUM * 4; round++) { int level = round / TESTS_NUM; @@ -876,7 +843,6 @@ t_trie_walk_to_root(void) tmp_flush(); } - bt_bird_cleanup(); return 1; } @@ -884,6 +850,8 @@ int main(int argc, char *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_inner_net, "Testing random inner prefix matching"); diff --git a/lib/a-path_test.c b/lib/a-path_test.c index c6f8ce8b..08c6c96c 100644 --- a/lib/a-path_test.c +++ b/lib/a-path_test.c @@ -78,13 +78,13 @@ t_path_format(void) bt_debug("Prepending ASN: %10u \n", i); } -#define BUFFER_SIZE 120 - byte buf[BUFFER_SIZE] = {}; +#define T_BUFFER_SIZE 120 + 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); - 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); #define SMALL_BUFFER_SIZE 25 diff --git a/lib/a-set_test.c b/lib/a-set_test.c index 693b8f08..79b5cf9a 100644 --- a/lib/a-set_test.c +++ b/lib/a-set_test.c @@ -20,8 +20,8 @@ static const struct adata *set_sequence_same; /* <0; SET_SIZE) */ static const struct adata *set_sequence_higher; /*