Skip to content

Commit fc9dc8c

Browse files
committed
tests: Update state machine verification script
- Update the state machine verification prompt to allow for more complex state machine that use shallow history and conditional initial transitions. - Addressing pre-existing compliance issues Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
1 parent 843e890 commit fc9dc8c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/state_machines/verify_machine.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ def compare_state_machines(c_code, plantuml):
6464
6565
Guidance:
6666
– Only consider states, transitions, and hierarchy. Ignore entry/running/exit functions.
67+
– Consider PlantUML deep history (`[H*]` inside a composite state, with transitions targeting that
68+
alias) as semantically equivalent to the C implementation resuming the last active leaf state
69+
within that composite state.
70+
– Consider a PlantUML choice pseudostate used for initial routing (e.g., `CHOOSE_INITIAL` with
71+
guards that point to alternative initial children) as semantically equivalent to a C setup where
72+
the initial child is decided conditionally (e.g., at build time via configuration or runtime).
73+
If either of the guarded targets matches a valid initial child in C, treat the initial alignment
74+
as satisfied.
6775
– If any ambiguity arises, default `match` to `true` and document the ambiguity in `details`.
6876
"""
6977

@@ -113,7 +121,8 @@ def compare_state_machines(c_code, plantuml):
113121

114122
def main():
115123
parser = argparse.ArgumentParser(
116-
description="Compare C state machine vs PlantUML definition using OpenAI API"
124+
description="Compare C state machine vs PlantUML definition using OpenAI API",
125+
allow_abbrev=False,
117126
)
118127
parser.add_argument("--c-file", required=True, help="Path to the C source file")
119128
parser.add_argument("--uml-file", required=True, help="Path to the PlantUML file")
@@ -124,7 +133,7 @@ def main():
124133

125134
result = compare_state_machines(c_code, plantuml)
126135

127-
if result.get("match") == True:
136+
if result.get("match") is True:
128137
print("✅ State machines match.")
129138
print(result.get("details", "No details provided."))
130139
sys.exit(0)

0 commit comments

Comments
 (0)