Add common infrastructure for Rule-Based Testing#4977
Merged
thomas-bc merged 16 commits intonasa:develfrom Apr 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds shared infrastructure to simplify Rule-Based Testing (RBT) rules in F Prime unit tests, then refactors the Svc::Ccsds::ApidManager unit tests to use the new approach (shadow state + grouped rules implemented as tester methods).
Changes:
- Introduces
FW_RBT_DEFINE_RULEinTestUtilsto generate rule structs that delegate to tester member functions (enabling existingASSERT_*macros inside rule bodies). - Refactors
ApidManagerUTs into aTestStateshadow-model and per-group rule implementation.cppfiles. - Updates the ApidManager UT CMake registration to compile the new rule/state sources.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| TestUtils/RuleBasedTesting.hpp | Adds a macro-based pattern for defining STest::Rule types that delegate to tester methods. |
| Svc/Ccsds/ApidManager/test/ut/TestState/TestState.hpp | Introduces an ApidManager shadow-state model API for rule preconditions/actions. |
| Svc/Ccsds/ApidManager/test/ut/TestState/TestState.cpp | Implements shadow-state helpers (sequence count tracking + random APID selection). |
| Svc/Ccsds/ApidManager/test/ut/Rules/GetSeqCount.cpp | Adds rule implementations for exercising getApidSeqCountIn. |
| Svc/Ccsds/ApidManager/test/ut/Rules/ValidateSeqCount.cpp | Adds rule implementations for exercising validateApidSeqCountIn. |
| Svc/Ccsds/ApidManager/test/ut/ApidManagerTestMain.cpp | Updates tests to instantiate/apply the new nested rule types and run randomized scenarios. |
| Svc/Ccsds/ApidManager/test/ut/ApidManagerTester.hpp | Refactors the tester to use FW_RBT_DEFINE_RULE and the new ApidManagerTestState. |
| Svc/Ccsds/ApidManager/test/ut/ApidManagerTester.cpp | Removes legacy embedded rule/helper implementations from the tester .cpp. |
| Svc/Ccsds/ApidManager/CMakeLists.txt | Adds new UT source files (shadow state + rule groups) to the unit test target. |
LeStarch
previously approved these changes
Apr 9, 2026
bocchino
requested changes
Apr 10, 2026
Collaborator
bocchino
left a comment
There was a problem hiding this comment.
Looks great! I like the simplification into one macro. I just had one suggested revision to the naming in the macro.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
LeStarch
requested changes
Apr 14, 2026
LeStarch
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
Preface to #3134
The goal here is to provide a “standard" pattern for doing Rule-Based Testing. This does not mean restricting to only that pattern, but I will next document how to work with this specific pattern, and provide tooling to work with it.
ASSERT_EVENTS_*etc. macros to be usable within the rule body by... simply making the body of the rule delegate to a member function of the tester. this is all declared / handled by the macro, and users need simply to implement each body.Future Work
fprime-util new --rule-based-testing--> bootstraps the RBT structure (TestState folder and class definition, Rules/*.cpp file)fprime-util new --rulefor each rule, as we need to insert the MACROs inside the ComponentTester.hpp which would be very brittle and not much added value. Instruct users to copy-paste is fine imo.fprime-util new --rule-groupthat creates theRuleGroup.cppfile and a TODO rule ?AI Usage (see policy)
Help think through the architecture and refactor the ApidManager test code to the new architecture