Svc/PrmDb: document CRC and load state machine, clean up tests, factor save-file write helper - #5986
lestarch-autobot wants to merge 1 commit into
Conversation
…r save-file write helper (nasa#5918) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Svc/PrmDb |
92.42 | -0.65 | 95.00 | +0.26 | 89.20 | +0.28 |
Modules changed
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Svc/PrmDb |
92.42 | -0.65 | 95.00 | +0.26 | 89.20 | +0.28 |
Fw/DataStructures |
97.96 | -0.35 | 97.14 | +0.00 | 82.66 | -0.55 |
Os/Generic |
90.04 | -0.10 | 89.13 | +0.00 | 74.52 | +0.00 |
Os/Posix |
71.03 | +0.13 | 87.50 | +0.00 | 50.89 | +0.00 |
New modules
| Module | Line | Function | Branch |
|---|---|---|---|
Fw/Prm |
0.00 | 0.00 | 0.00 |
Modules without UTs
CFDP/Checksum/GTest, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/Ports/DataTypes, Drv/PosixUartDriver, FppTestProject/FppTest/topology/async, FppTestProject/FppTest/topology/components/Comp, FppTestProject/FppTest/topology/components/Framework, FppTestProject/FppTest/topology/components/Receiver, FppTestProject/FppTest/topology/components/Sender, FppTestProject/FppTest/topology/guarded, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Obj, Fw/Port, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Ccsds/Types, Svc/Ccsds/Utils, Svc/FatalHandler, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComCcsdsSdls, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Subtopologies/FileHandlingCfdp, Svc/Subtopologies/FileHandlingCfdp/FileHandlingCfdpConfig, TestDeploymentsProject/Ref/DpDemo, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestConfigDeployment, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestDuplicateDirective, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestLinkDepends, cmake/test/data/TestDeployment/TestRelative, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent
Change Description
Scoped to
Svc/PrmDb; no FPP, public API, or configuration changes.docs/sdd.md: on-disk format table now documents the 4-byte CRC32 at offset 0 (placeholder written first, real value written after the records, verified on load withPrmFileBadCrcon mismatch). §3.4 now describes thePrmDbFileLoadStatemachine (IDLE -> LOADING_FILE_UPDATES -> FILE_UPDATES_STAGED -> IDLE) and the rejections in each state, replacing the incorrect "no state machines" statement.PrmDbImpl.{hpp,cpp}: the four duplicated write-then-verify error ladders inPRM_SAVE_FILE_cmdHandler(delimiter, record size, parameter ID, parameter value) are factored into one private helperwriteSaveFileChunk(...)that preserves the original behaviour exactly: samePrmFileWriteErrorstage/record/status arguments,unLock()before reporting,EXECUTION_ERRORresponse, early return, CRC update only on success.test/ut/PrmDbTester.cpp: the "illegal operations in IDLE" section no longer writesm_state = IDLEdirectly; it reaches IDLE through a realPRM_COMMIT_STAGEDand then drives a real failingPRM_LOAD_FILE(missing file), assertingEXECUTION_ERROR,PrmFileReadError(OPEN),PrmDbFileLoadFailed, and the IDLE state. Swapped step 4/5 comments inrunDbEqualTestcorrected.printf/printDbdebug scaffolding and theprintDbhelper removed.test/ut/PrmDbTestMain.cpp: commented-outRefPrmFiletest block removed.test/int/test_cmd_PrmDb.py: dead debug lines and stale comments removed; assertions unchanged.No live test or assertion was removed or weakened.
Rationale
Issue #5918: the SDD omitted the CRC field and mis-stated that the component has no state machine; the failed-load-resets-to-IDLE test was tautological; test comments were swapped; and debug scaffolding and duplicated error ladders reduced maintainability.
Testing/Review Recommendations
cd Svc/PrmDb && fprime-util check— 15/15 pass, including the save-file error-path tests that exercise everyPrmFileWriteErrorstage through the new helper.Svc/PrmDb/test/int/test_cmd_PrmDb.pyrun withfprime-gdsagainst a Ref-equivalent deployment (Ref topology withoutwasmSeq, since the crates.io registry was unreachable in the build environment) — 2/2 pass.PRM_SAVE_FILE→PrmFileSaveComplete;PRM_LOAD_FILEon a missing file →PrmFileReadError(OPEN),PrmDbFileLoadFailed,EXECUTION_ERROR, followed by a successfulPRM_SAVE_FILE(state back to IDLE);PRM_COMMIT_STAGEDin IDLE →PrmDbFileLoadInvalidAction,VALIDATION_ERROR.writeSaveFileChunkagainst the removed ladders inPRM_SAVE_FILE_cmdHandler; verify the §3.4 state description againstPRM_LOAD_FILE_cmdHandler/PRM_COMMIT_STAGED_cmdHandler.Future Work
None.
AI Usage (see policy)
An AI agent (Devin) authored the code, tests, and documentation changes and ran the unit, integration, and manual GDS verification described above.
IAMAI