mirror of https://gerrit.osmocom.org/libosmocore
fsm_test: terminate the main loop instead of exit on timeout
In fsm_test.c, we have FSM instance cleanup after the select main loop, but we exit(0) in the timer cb; hence the final code is never called. Rather clean up the instance and hence also test that, by using a global flag to exit the main loop upon timeout. Adjust expected stderr output. BTW, in a subsequent commit, I want to move the fsm instance id testing to below the main loop, to more clearly group the tested bits. Change-Id: Ia47811ffcc1bd68d2630c86be7ab98fc1f338773
This commit is contained in:
parent
04eb56f146
commit
d8f175cd2a
|
@ -60,13 +60,17 @@ static void test_fsm_one(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
static bool main_loop_run = true;
|
||||
|
||||
static int test_fsm_tmr_cb(struct osmo_fsm_inst *fi)
|
||||
{
|
||||
OSMO_ASSERT(fi->T == 2342);
|
||||
OSMO_ASSERT(fi->state == ST_TWO);
|
||||
LOGP(DMAIN, LOGL_INFO, "Timer\n");
|
||||
|
||||
exit(0);
|
||||
main_loop_run = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct osmo_fsm_state test_fsm_states[] = {
|
||||
|
@ -201,7 +205,7 @@ int main(int argc, char **argv)
|
|||
OSMO_ASSERT(osmo_fsm_inst_find_by_name(&fsm, "Test_FSM(another_id)") == finst);
|
||||
OSMO_ASSERT(osmo_fsm_inst_update_id(finst, "my_id") == 0);
|
||||
|
||||
while (1) {
|
||||
while (main_loop_run) {
|
||||
osmo_select_main(0);
|
||||
}
|
||||
osmo_fsm_inst_free(finst);
|
||||
|
|
|
@ -8,4 +8,5 @@ Checking FSM allocation
|
|||
[0;mTest_FSM(my_id){ONE}: state_chg to TWO
|
||||
[0;mTest_FSM(my_id){TWO}: Timeout of T2342
|
||||
[0;mTimer
|
||||
[0;mTest_FSM(my_id){TWO}: Deallocated
|
||||
[0;m
|
Loading…
Reference in New Issue