Fixed Svc/FileWorker: report FW_STATUS_FAILED_TO_WRITE when writeIn's…#5399
Fixed Svc/FileWorker: report FW_STATUS_FAILED_TO_WRITE when writeIn's…#5399bitWarrior wants to merge 1 commit into
Conversation
… write fails instead of DONE_WRITE
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Os/Posix |
62.00 | -0.40 | 84.21 | +0.00 | 43.87 | -0.23 |
Os/Generic |
89.03 | -0.13 | 88.16 | +0.00 | 73.11 | +0.00 |
Svc/FileWorker |
90.35 | +0.06 | 100.00 | +0.00 | 85.54 | +0.67 |
Fw/DataStructures |
98.48 | +0.27 | 96.95 | -0.19 | 83.21 | +0.37 |
Modules without UTs
CFDP/Checksum/GTest, Drv/ByteStreamDriverModel, Drv/Interfaces, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/LinuxUartDriver, Drv/Ports, Drv/Ports/DataTypes, FppTestProject/FppTest/interfaces, 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/ports, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Cmd, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Interfaces, Fw/Obj, Fw/Port, Fw/Ports/CompletionStatus, Fw/Ports/Ready, Fw/Ports/Signal, Fw/Ports/SuccessCondition, Fw/Prm, Fw/SerializableFile/test/TestSerializable, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Cycle, Svc/DpPorts, Svc/Fatal, Svc/FatalHandler, Svc/FileDownlinkPorts, Svc/FprimeProtocol, Svc/Interfaces, Svc/PassiveConsoleTextLogger, Svc/Ping, Svc/PolyIf, Svc/Ports/CommsPorts, Svc/Ports/FilePorts, Svc/Ports/OsTimeEpoch, Svc/Ports/TlmPacketizerPorts, Svc/Ports/VersionPorts, Svc/Sched, Svc/Seq, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Types/TlmPacketizerTypes, Svc/WatchDog, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestChainedAutocoder, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestTargetAutocoder, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent
Change Description
Two independent correctness fixes in
Svc/FileWorker, one commit each:writeIn_handlerstatus propagation.writeIn_handleremittedFW_STATUS_DONE_WRITEonwriteDoneOutunconditionally, even whenwriteBufferToFilereturnedfalse(open failure, permission denied, diskfull, partial write). The return value only gated the hash sidecar write, not
the reported status. It now reports
FW_STATUS_FAILED_TO_WRITE(existingenumerator in
FileWorkerTypes.hpp) with0bytes on failure. AddstestWriteErrStatusReportedto the error harness, which drives the fullwriteInport handler with an injected open failure and asserts the failurestatus on
writeDoneOut.readFileBytespartial-read telemetry. On a short read, the partiallytransferred bytes were not added to
bytesReadbefore returningFW_READ_ERROR, so theReadErrorevent undercounted the amount actuallyread.
bytesReadis now incremented by the real transferred count on thatpath. A short read remains an error (FileWorker reads a fixed, caller-specified
size and must not silently accept a truncated file) — only the reported count
is corrected.
Rationale
Both are status/telemetry-reporting correctness bugs. For (1), a downstream
consumer or ground operator keying on the
writeDoneOutstatus is told a writesucceeded when it did not, so the reported status and the on-disk state diverge —
an operationally significant gap during incident investigation. The existing
testWriteErrcovered thewriteBufferToFilehelper's return value and eventsbut never exercised the handler's
writeDoneOutstatus, which is why thisslipped through. For (2), the corrected byte count makes
ReadErrortelemetryreflect what was actually transferred.
Testing/Review Recommendations
fprime-util checkonSvc/FileWorker.testWriteErrStatusReportedis a genuine regression test: it fails against thepre-fix source (handler reports
DONE_WRITE) and passes with the fix. Run itonce before and once after applying commit 1 to confirm.
0bytes on the failure path(
isWrite ? buffer.getSize() : 0). If retainingbuffer.getSize()fordiagnostics is preferred, the handler and the test's third assertion argument
change together.
the
bytesReadvalue passed to the existingReadErrorevent and nothing else.Future Work
None
AI Usage (see policy)
Claude was used to update the unit tests and to draft this PR.