mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
fix(fsm): refuse all transitions in the Error state
- The Error state is a terminate state: the state machine ignores all events in it and calls no action, so ChangeState() returned the result of the previous transition (ErrorFound: true) - Return false for each transition in the Error state, except for ErrorFound: the device is already in the Error state, so callers such as ChangeStateOrThrow(ErrorFound) in Device::RunWrapper() or in user code do not throw - Enable StateMachine.RefusesTransitionsInError - Update the documentation pages that described the defect, and the source line links into the changed files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -230,17 +230,14 @@ TEST(StateMachine, ErrorFoundFromEachState)
|
||||
}
|
||||
}
|
||||
|
||||
// Known defect: Error is a terminate state, so the state machine ignores all
|
||||
// events in it. ChangeState() then returns the result of the previous
|
||||
// transition (ErrorFound: true) instead of false. Device::RunWrapper() relies
|
||||
// on ChangeStateOrThrow(ErrorFound) not throwing in Error, so a fix must
|
||||
// change both. Enable this test with the fix.
|
||||
TEST(StateMachine, DISABLED_RefusesTransitionsInError)
|
||||
// Error is a terminate state: the state machine refuses all transitions in it.
|
||||
// ErrorFound succeeds, because the device is already in the Error state.
|
||||
TEST(StateMachine, RefusesTransitionsInError)
|
||||
{
|
||||
Machine m;
|
||||
ASSERT_TRUE(m.Change(Transition::ErrorFound, State::Error));
|
||||
for (auto const transition : AllTransitions()) {
|
||||
EXPECT_FALSE(m.fFsm.ChangeState(transition)) << transition << " in Error";
|
||||
EXPECT_EQ(m.fFsm.ChangeState(transition), transition == Transition::ErrorFound) << transition << " in Error";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user