Skip to content

Fixed Svc/FileWorker: report FW_STATUS_FAILED_TO_WRITE when writeIn's…#5399

Open
bitWarrior wants to merge 1 commit into
nasa:develfrom
bitWarrior:PR_5397
Open

Fixed Svc/FileWorker: report FW_STATUS_FAILED_TO_WRITE when writeIn's…#5399
bitWarrior wants to merge 1 commit into
nasa:develfrom
bitWarrior:PR_5397

Conversation

@bitWarrior

Copy link
Copy Markdown
Collaborator
Related Issue(s) PR-5397
Has Unit Tests (y/n) Y
Documentation Included (y/n) N
Generative AI was used in this contribution (y/n) Y

Change Description

Two independent correctness fixes in Svc/FileWorker, one commit each:

  1. writeIn_handler status propagation. writeIn_handler emitted
    FW_STATUS_DONE_WRITE on writeDoneOut unconditionally, even when
    writeBufferToFile returned false (open failure, permission denied, disk
    full, partial write). The return value only gated the hash sidecar write, not
    the reported status. It now reports FW_STATUS_FAILED_TO_WRITE (existing
    enumerator in FileWorkerTypes.hpp) with 0 bytes on failure. Adds
    testWriteErrStatusReported to the error harness, which drives the full
    writeIn port handler with an injected open failure and asserts the failure
    status on writeDoneOut.

  2. readFileBytes partial-read telemetry. On a short read, the partially
    transferred bytes were not added to bytesRead before returning
    FW_READ_ERROR, so the ReadError event undercounted the amount actually
    read. bytesRead is now incremented by the real transferred count on that
    path. 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 writeDoneOut status is told a write
succeeded when it did not, so the reported status and the on-disk state diverge —
an operationally significant gap during incident investigation. The existing
testWriteErr covered the writeBufferToFile helper's return value and events
but never exercised the handler's writeDoneOut status, which is why this
slipped through. For (2), the corrected byte count makes ReadError telemetry
reflect what was actually transferred.

Testing/Review Recommendations

  • fprime-util check on Svc/FileWorker.
  • testWriteErrStatusReported is a genuine regression test: it fails against the
    pre-fix source (handler reports DONE_WRITE) and passes with the fix. Run it
    once before and once after applying commit 1 to confirm.
  • Reviewer decision point: commit 1 reports 0 bytes on the failure path
    (isWrite ? buffer.getSize() : 0). If retaining buffer.getSize() for
    diagnostics is preferred, the handler and the test's third assertion argument
    change together.
  • Fix (2) is telemetry-accuracy only and has no dedicated new test; it affects
    the bytesRead value passed to the existing ReadError event and nothing else.

Future Work

None

AI Usage (see policy)

Claude was used to update the unit tests and to draft this PR.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report — base devel

Overall (line): 82.08% → 82.07% (-0.01)
Regression threshold: 0.50% (line).

Regressions

(none over threshold)

Modules changed

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant