summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fsm.c2
-rw-r--r--tests/fsm/fsm_test.c7
-rw-r--r--tests/fsm/fsm_test.err8
3 files changed, 13 insertions, 4 deletions
diff --git a/src/fsm.c b/src/fsm.c
index 176aa8ab..342542fb 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -154,6 +154,8 @@ int osmo_fsm_register(struct osmo_fsm *fsm)
}
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 3bcb7d49..f70b0b5c 100644
--- a/tests/fsm/fsm_test.c
+++ b/tests/fsm/fsm_test.c
@@ -28,6 +28,12 @@ enum test_fsm_evt {
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 @@ static struct osmo_fsm fsm = {
.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 17a2f2e0..153963fc 100644
--- a/tests/fsm/fsm_test.err
+++ b/tests/fsm/fsm_test.err
@@ -1,10 +1,10 @@
Checking FSM allocation
Test_FSM(my_id){NULL}: Allocated
-Test_FSM(my_id){NULL}: Received Event 1
-Test_FSM(my_id){NULL}: Event 1 not permitted
-Test_FSM(my_id){NULL}: Received Event 0
+Test_FSM(my_id){NULL}: Received Event EV_B
+Test_FSM(my_id){NULL}: Event EV_B not permitted
+Test_FSM(my_id){NULL}: Received Event EV_A
Test_FSM(my_id){NULL}: state_chg to ONE
-Test_FSM(my_id){ONE}: Received Event 1
+Test_FSM(my_id){ONE}: Received Event EV_B
Test_FSM(my_id){ONE}: state_chg to TWO
Test_FSM(my_id){TWO}: Timeout of T2342
Timer