This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: print BIG FAT ERROR message if osmo_fsm lacks event names ...................................................................... print BIG FAT ERROR message if osmo_fsm lacks event names Event names are displayed in VTY commands so all FSM should have them. Print an error message if an FSM is registered without event names. We could also return an error code, however at present no caller checks the return value of osmo_fsm_register() so this would be pointless. Add event names to the test FSM and update expected output accordingly. Change-Id: I08b100d62b5c50bf025ef87d31ea39072539cf37 Related: OS#3008 --- M src/fsm.c M tests/fsm/fsm_test.c M tests/fsm/fsm_test.err 3 files changed, 13 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/fsm.c b/src/fsm.c index 176aa8a..342542f 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -154,6 +154,8 @@ } if (osmo_fsm_find_by_name(fsm->name)) return -EEXIST; + if (fsm->event_names == NULL) + LOGP(DLGLOBAL, LOGL_ERROR, "FSM '%s' has no event names! Please fix!\n", fsm->name); llist_add_tail(&fsm->list, &osmo_g_fsms); INIT_LLIST_HEAD(&fsm->instances); diff --git a/tests/fsm/fsm_test.c b/tests/fsm/fsm_test.c index 3bcb7d4..f70b0b5 100644 --- a/tests/fsm/fsm_test.c +++ b/tests/fsm/fsm_test.c @@ -28,6 +28,12 @@ EV_B, }; +static const struct value_string test_fsm_event_names[] = { + OSMO_VALUE_STRING(EV_A), + OSMO_VALUE_STRING(EV_B), + { 0, NULL } +}; + static void test_fsm_null(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { @@ -88,6 +94,7 @@ .states = test_fsm_states, .num_states = ARRAY_SIZE(test_fsm_states), .log_subsys = DMAIN, + .event_names = test_fsm_event_names, }; static struct ctrl_handle *g_ctrl; diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err index 17a2f2e..153963f 100644 --- a/tests/fsm/fsm_test.err +++ b/tests/fsm/fsm_test.err @@ -1,10 +1,10 @@ Checking FSM allocation [0;mTest_FSM(my_id){NULL}: Allocated -[0;mTest_FSM(my_id){NULL}: Received Event 1 -[0;mTest_FSM(my_id){NULL}: Event 1 not permitted -[0;mTest_FSM(my_id){NULL}: Received Event 0 +[0;mTest_FSM(my_id){NULL}: Received Event EV_B +[0;mTest_FSM(my_id){NULL}: Event EV_B not permitted +[0;mTest_FSM(my_id){NULL}: Received Event EV_A [0;mTest_FSM(my_id){NULL}: state_chg to ONE -[0;mTest_FSM(my_id){ONE}: Received Event 1 +[0;mTest_FSM(my_id){ONE}: Received Event EV_B [0;mTest_FSM(my_id){ONE}: state_chg to TWO [0;mTest_FSM(my_id){TWO}: Timeout of T2342 [0;mTimer -- To view, visit https://gerrit.osmocom.org/6951 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I08b100d62b5c50bf025ef87d31ea39072539cf37 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder