Os UT: guard shadow_read(0), fix counting semaphore tests and directory rule comments - #6004
lestarch-autobot wants to merge 1 commit into
Conversation
…ry comments Fixes nasa#5913 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Os/Posix |
70.64 | -0.39 | 87.50 | +0.00 | 50.89 | +0.00 |
Os/Generic |
90.24 | -0.10 | 89.13 | +0.00 | 75.10 | -0.57 |
Fw/DataStructures |
98.22 | +0.53 | 97.14 | +0.00 | 83.03 | +0.91 |
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
Test-only changes under
Os/test/ut/:file/FileRules.cpp:Tester::shadow_read(size)now skips them_shadow.read(...)call whensize == 0. A zero-lengthstd::vector<U8>has a nulldata(), andOs::File::readassertsbuffer != nullptr; the helper returns an empty vector and leaves the shadow file untouched, matching a zero-byte read of the file under test.countingsemaphore/CommonTests.cpp: replacedExceedMaxCountandInvalidParameters, which asserted against a non-existentmaxCountparameter and accepted any of several statuses (ASSERT_TRUE(a || b || c)), with deterministic tests of the realOs::CountingSemaphore(U32 initial_count)contract:PostAccumulatesCount— three posts yield exactly threetryWait()successes, thenERROR_TIMEOUT.ZeroInitialCount— no token untilpost();tryWait()on empty returnsERROR_TIMEOUT.LargeInitialCount— an initial count of N grants exactly Nwait()s.directory/DirectoryRules.cpp: corrected theReadAllFilesrule comments to state thatreadDirectoryrewinds before and after reading (perOs/Directory.hpp), instead of "minus the original seek position" / "resets the seek position to the end".Rationale
Closes the three OS unit-test defects reported in #5913: a helper that violates
Os::File::read's non-null buffer precondition, two tautological semaphore tests that could not fail and documented semantics the API does not have, and misleading comments in the directory rules. No production code, FPP, or public API is changed.Testing/Review Recommendations
PosixFileTest,StubFileTest,PosixDirectoryTest,StubDirectoryTest,PosixCountingSemaphoreTest— 5/5 pass viactest.||alternatives) and that they matchOs/CountingSemaphore.hpp.shadow_read(0)still satisfiesassert_file_readin theReadrule whensize_desired == 0.Future Work
None.
AI Usage (see policy)
This PR was authored by an AI agent (Devin): issue analysis, code changes, and local test execution. Changes were verified by building and running the affected unit tests.
IAMAI