]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed main birdloop init in unit tests
authorMaria Matejka <mq@ucw.cz>
Mon, 1 Aug 2022 13:17:41 +0000 (15:17 +0200)
committerMaria Matejka <mq@ucw.cz>
Mon, 1 Aug 2022 13:17:41 +0000 (15:17 +0200)
Some unit tests weren't initializing the birdloop, trying to write the
birdloop ping into stdin. Fixed this and also forced stdin close on
startup of every test just to be sure that CI and local build behave the
same in this. (CI was failing on this while local build not.)

lib/event_test.c
test/birdtest.c
test/bt-utils.c

index 5385011a826d880ab2dc70e4ea2690d8ab66effe..612deb25c4877c8ec226e9ae9bcad9258e308611 100644 (file)
@@ -54,7 +54,6 @@ t_ev_run_list(void)
   int i;
 
   olock_init();
-  birdloop_init();
   rt_init();
   io_init();
   if_init();
@@ -81,9 +80,7 @@ main(int argc, char *argv[])
 {
   bt_init(argc, argv);
 
-  the_bird_lock();
   bt_test_suite(t_ev_run_list, "Schedule and run 3 events in right order.");
-  the_bird_unlock();
 
   return bt_exit_value();
 }
index 2ae7b51e51a724088f5e039539356f0f84bb152d..5e3de1c560a80a4cb8b79e32b49c811b9c1ac56b 100644 (file)
@@ -65,6 +65,9 @@ bt_init(int argc, char *argv[])
 {
   int c;
 
+  /* We have no interest in stdin */
+  close(0);
+
   initstate(BT_RANDOM_SEED, (char *) bt_random_state, sizeof(bt_random_state));
 
   bt_verbose = 0;
@@ -121,9 +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:
index 3d56292ee4cabb79900304fe9b719e797d588320..36e44da4e567070d5fd415300ad373167d7881e2 100644 (file)
@@ -62,9 +62,7 @@ bt_bird_init(void)
     log_init_debug("");
   log_switch(bt_verbose != 0, NULL, NULL);
 
-  the_bird_lock();
   olock_init();
-  birdloop_init();
   rt_init();
   io_init();
   if_init();