Skip to content

Improve string tests in FppTest - #5566

Merged
LeStarch merged 8 commits into
nasa:develfrom
karan9617:fix/fpptest-string-truncation
Aug 12, 2026
Merged

Improve string tests in FppTest#5566
LeStarch merged 8 commits into
nasa:develfrom
karan9617:fix/fpptest-string-truncation

Conversation

@karan9617

Copy link
Copy Markdown
Contributor

Fixes #3703
#3703

Reason for Change

  1. NonPrimitiveTest.ToString unit test was failing due to Fw::String buffer capacity limits truncating the formatted struct output during assertion checks.
  2. Clang compiler threw -Werror variadic macro warnings on INSTANTIATE_TYPED_TEST_SUITE_P in PrimitiveTest.cpp and main.cpp.

Description of Changes

  • Updated NonPrimitiveTest.cpp to use Fw::StringTemplate<1024> buffer capacity to hold complete string representations without truncation during toString() assertions.
  • Adjusted final whitespace formatting string in NonPrimitiveTest.ToString to match actual operator output.
  • Added trailing commas to INSTANTIATE_TYPED_TEST_SUITE_P instantiations in PrimitiveTest.cpp and main.cpp for standard C++ variadic macro compliance under strict compiler flags.

Build/Test Status

  • Ran unit tests locally: ninja FppTest_struct_ut_exe && ./bin/Darwin/FppTest_struct_ut_exe
  • Result: 38/38 PASSED across all 7 test suites with 0 gcov/coverage warnings.

@LeStarch
LeStarch requested review from Kronos3 and bocchino August 4, 2026 01:49
@LeStarch

LeStarch commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@Kronos3 does this fix your issues? @bocchino ?

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Coverage report — base devel

Overall (line): 83.66% → 83.66% (+0.00)
Regression threshold: 0.50% (line).

Regressions

(none over threshold)

Modules changed

Module Line Δ Function Δ Branch Δ
Svc/FpySequencer 86.31 -0.03 98.59 +0.00 77.18 +0.00
Svc/CmdDispatcher 97.00 +0.03 91.67 +0.00 91.49 -0.09
Os/Generic 89.25 +0.13 88.16 +0.00 73.27 +0.00
Fw/DataStructures 98.22 +0.44 97.14 +0.00 82.97 +0.74
Os/Generic/Types 92.50 +0.71 92.86 +0.00 76.64 +1.87

Modules without UTs

CFDP/Checksum/GTest, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/LinuxUartDriver, Drv/Ports/DataTypes, 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/Prm, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Ccsds/Types, 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/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

Comment thread FppTestProject/FppTest/struct/struct.fpp Outdated
Comment thread FppTestProject/FppTest/struct/PrimitiveTest.cpp Outdated
@Kronos3

Kronos3 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The preferred fix would be to get nasa/fpp#968 up to date and not rely on serializing to a string before sending to ostream

Comment thread FppTestProject/FppTest/struct/NonPrimitiveTest.cpp Outdated
Comment thread FppTestProject/FppTest/struct/NonPrimitiveTest.cpp Outdated
@bocchino
bocchino self-requested a review August 10, 2026 17:57
Comment thread FppTestProject/FppTest/struct/main.cpp Outdated

buf1 << s;
Fw::StringTemplate<1024> str;
s.toString(str);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better for testing s.toString, but now it doesn't test the << method of s at all. Can we keep both tests here (the truncated and non-truncated versions)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test to explicitly verify both the truncated operator<< behavior and the non-truncated toString() output using the larger buffer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you apply the same change to PrimitiveTest? The two cases (PrimitiveTest, NonPrimitiveTest) should operate in the same way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've updated PrimitiveTest to follow the exact same two-case testing pattern, verifying both the truncated operator<< output and the full toString() output.

@bocchino bocchino changed the title fix(fpptest): fix string truncation and variadic macro warnings in struct UTs Improve string tests in FppTest Aug 11, 2026
Comment thread FppTestProject/FppTest/struct/NonPrimitiveTest.cpp Outdated
@bocchino
bocchino self-requested a review August 12, 2026 17:23

@bocchino bocchino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@LeStarch
LeStarch merged commit 6a94152 into nasa:devel Aug 12, 2026
66 of 67 checks passed
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.

FppTest missing some testing due to string truncation

4 participants