]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/event_test.c
2 * BIRD Library -- Event Processing Tests
4 * (c) 2015 CZ.NIC z.s.p.o.
6 * Can be freely distributed and used under the terms of the GNU GPL.
10 #include "test/birdtest.h"
13 #include "lib/event.h"
14 #include "conf/conf.h"
15 #include "nest/locks.h"
16 #include "sysdep/unix/unix.h"
17 #include "nest/iface.h"
18 #include "nest/route.h"
22 int event_check_points
[MAX_NUM
];
24 #define event_hook_body(num) \
26 bt_debug("Event Hook " #num "\n"); \
27 event_check_points[num] = 1; \
28 bt_assert_msg(event_check_points[num-1], "Events should be run in right order"); \
31 static void event_hook_1(void *data UNUSED
) { event_hook_body(1); }
32 static void event_hook_2(void *data UNUSED
) { event_hook_body(2); }
33 static void event_hook_3(void *data UNUSED
) { event_hook_body(3); }
35 #define schedule_event(num) \
37 struct event *event_##num = ev_new(&root_pool); \
38 event_##num->hook = event_hook_##num; \
39 ev_schedule(event_##num); \
43 init_event_check_points(void)
46 event_check_points
[0] = 1;
47 for (i
= 1; i
< MAX_NUM
; i
++)
48 event_check_points
[i
] = 0;
64 config
= config_alloc("");
66 init_event_check_points();
72 ev_run_list(&global_event_list
);
74 for (i
= 1; i
< MAX_NUM
; i
++)
75 bt_assert(event_check_points
[i
]);
81 main(int argc
, char *argv
[])
85 bt_test_suite(t_ev_run_list
, "Schedule and run 3 events in right order.");
87 return bt_exit_value();