summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-03-25 01:03:26 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2018-03-26 13:03:19 +0000
commitfcf79926e5e5d296efc4d53b1c50849e4fff7908 (patch)
tree38edf1067d0e4df0f98088a7451ab37727c64170 /contrib
parentbb22df3db915f2141ce3c2477e7417781c5961f4 (diff)
contrib/fsm-to-dot: warn and draw unallowed state transitions
Hacked as it is, fsm-to-dot is capable of detecting action functions transitioning to states that are not allowed according to the FSM definition struct. Draw those in red and output a warning. Found these osmo-bsc gscon errors with this patch: ERROR: gscon_fsm_active() triggers a transition to ST_WAIT_HO_COMPL, but this is not allowed by the FSM definition ERROR: gscon_fsm_wait_ho_compl() triggers a transition to ST_WAIT_MDCX_BTS_HO, but this is not allowed by the FSM definition Related: OS#3109 Change-Id: Ic6319a958b3c7247510c1930bac8b02b95f9dcf2
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/fsm-to-dot.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/fsm-to-dot.py b/contrib/fsm-to-dot.py
index ce94a4eb..7a4694e7 100755
--- a/contrib/fsm-to-dot.py
+++ b/contrib/fsm-to-dot.py
@@ -137,9 +137,10 @@ class Event:
return cmp(event.name, other.name)
class Edge:
- def __init__(edge, to_state, event_name=None, style=None, action=None):
+ def __init__(edge, to_state, event_name=None, style=None, action=None, color=None):
edge.to_state = to_state
edge.style = style
+ edge.color = color
edge.events = []
edge.actions = []
edge.add_event_name(event_name)
@@ -379,9 +380,17 @@ class Fsm:
for to_state_name, event_name in transitions:
if not event_name:
continue
+ found = False
for out_edge in state.out_edges:
if out_edge.to_state.name == to_state_name:
out_edge.add_event_name(event_name)
+ found = True
+ if not found:
+ sys.stderr.write(
+ "ERROR: %s() triggers a transition to %s, but this is not allowed by the FSM definition\n"
+ % (state.action, to_state_name))
+ state.add_out_edge(Edge(fsm.find_state_by_name(to_state_name, True), event_name,
+ color='red'))
additional_states = []
@@ -526,6 +535,8 @@ class Fsm:
attrs.append('label="%s"' % (r'\n'.join(labels)))
if out_edge.style:
attrs.append('style=%s'% out_edge.style)
+ if out_edge.color:
+ attrs.append('color=%s'% out_edge.color)
attrs_str = ''
if attrs:
attrs_str = ' [%s]' % (','.join(attrs))