summaryrefslogtreecommitdiff
path: root/test/birdtest.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-08-02 17:58:14 +0200
committerMaria Matejka <mq@ucw.cz>2022-08-02 17:58:14 +0200
commit0072d11f3431165240656edf6ade473554b8747e (patch)
tree6c53bbbf0d3a4a3ad70846aae50995dc184cc5a5 /test/birdtest.c
parent2e95d269d6bd42372d3273264e14775242b0744d (diff)
parentdb9153e216b6f1847ac9cdf170b1d14c04552e41 (diff)
Merge branch 'ballygarvan' into HEAD
Replacing the old 3.0-alpha0 cork mechanism with another one inside the routing table. This version should be simpler and also quite clear what it does, why and when.
Diffstat (limited to 'test/birdtest.c')
-rw-r--r--test/birdtest.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/test/birdtest.c b/test/birdtest.c
index c6a09684..5e3de1c5 100644
--- a/test/birdtest.c
+++ b/test/birdtest.c
@@ -20,6 +20,8 @@
#include "test/birdtest.h"
#include "lib/string.h"
+#include "lib/event.h"
+#include "lib/io-loop.h"
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
@@ -58,14 +60,14 @@ u64 bt_random_state[] = {
0x53d9772877c1b647, 0xab8ce3eb466de6c5, 0xad02844c8a8e865f, 0xe8cc78080295065d
};
-void resource_sys_init(void);
-
void
bt_init(int argc, char *argv[])
{
int c;
- resource_sys_init();
+ /* We have no interest in stdin */
+ close(0);
+
initstate(BT_RANDOM_SEED, (char *) bt_random_state, sizeof(bt_random_state));
bt_verbose = 0;
@@ -122,6 +124,11 @@ bt_init(int argc, char *argv[])
clock_gettime(CLOCK_MONOTONIC, &bt_begin);
bt_suite_case_begin = bt_suite_begin = bt_begin;
+ the_bird_lock();
+ resource_init();
+ ev_init_list(&global_event_list, &main_birdloop, "Global event list in unit tests");
+ ev_init_list(&global_work_list, &main_birdloop, "Global work list in unit tests");
+ birdloop_init();
return;
usage:
@@ -175,6 +182,8 @@ int bt_run_test_fn(int (*fn)(const void *), const void *fn_arg, int timeout)
if (!bt_suite_result)
result = 0;
+ tmp_flush();
+
return result;
}
@@ -312,6 +321,12 @@ bt_log_suite_case_result(int result, const char *fmt, ...)
}
}
+void
+bt_reset_suite_case_timer(void)
+{
+ clock_gettime(CLOCK_MONOTONIC, &bt_suite_case_begin);
+}
+
int
bt_test_suite_base(int (*fn)(const void *), const char *id, const void *fn_arg, int forked, int timeout, const char *dsc, ...)
{
@@ -504,6 +519,15 @@ bt_fmt_ipa(char *buf, size_t size, const void *data)
bsnprintf(buf, size, "(null)");
}
+void
+bt_format_net(char *buf, size_t size, const void *data)
+{
+ if (data)
+ bsnprintf(buf, size, "%N", (const net_addr *) data);
+ else
+ bsnprintf(buf, size, "(null)");
+}
+
int
bt_is_char(byte c)
{