Skip to content

Comments

Fix #1143, SB_UT corrections and clear event count history after setup#2347

Merged
dzbaker merged 1 commit intonasa:mainfrom
thnkslprpt:fix-1143-clear-event-count-after-test-setup
Dec 17, 2025
Merged

Fix #1143, SB_UT corrections and clear event count history after setup#2347
dzbaker merged 1 commit intonasa:mainfrom
thnkslprpt:fix-1143-clear-event-count-after-test-setup

Conversation

@thnkslprpt
Copy link
Contributor

Checklist

Describe the contribution

While looking at this, I realised that lots of tests were checking events related the 'setup', not the actual function that is the focus of the test.

For example, there are dozens of asserts for CFE_SB_PIPE_ADDED_EID and CFE_SB_SUBSCRIPTION_RCVD_EID - even though CFE_SB_CreatePipe() and CFE_SB_Subscribe() have their own tests...

These asserts are largely redundant and just add clutter to the tests - I've removed the obvious cases from the tests I was already updating with UT_ClearEventHistory().

Test_SB_Cmds_MapInfoDef was checking for CFE_SB_PIPE_ADDED_EID and CFE_SB_SUBSCRIPTION_RCVD_EID which are part of the setup, not the function under test. I changed this to check for the command counter being incremented instead.

Test_Unsubscribe_Basic, Test_Unsubscribe_AppId and Test_Unsubscribe_Local were checking for CFE_SB_SUBSCRIPTION_RCVD_EID. They should really be checking for CFE_SB_SUBSCRIPTION_REMOVED_EID given that CFE_SB_Unsubscribe() is the focus of these tests.

  • In the case of Test_Unsubscribe_Local, it was actually sending a CFE_SB_UNSUB_NO_SUBS_EID event. The reason this wasn't noticed may be because CFE_SB_UnsubscribeLocal() returns CFE_SUCCESS (and sends the CFE_SB_UNSUB_NO_SUBS_EID event) if the pipe is not subscribed to the MsgId.
    • I've amended the test to subscribe using CFE_SB_SubscribeLocal(), instead of CFE_SB_Subscribe(), and now the call to CFE_SB_UnsubscribeLocal() in the test actually works and returns CFE_SUCCESS while sending the CFE_SB_SUBSCRIPTION_REMOVED_EID event.

Even though these are coverage tests, they should still be clear and at least check for what they are testing...

Testing performed
GitHub CI actions all passing successfully (incl. Build + Run, Unit/Functional Tests etc.).
Local testing confirms net coverage unchanged.

Expected behavior changes
No change to code behavior. Test behavior updated as described above.

System(s) tested on
Debian GNU/Linux 11 (bullseye)
Current main branch of cFS bundle.

Contributor Info
Avi Weiss @thnkslprpt

@skliper
Copy link
Contributor

skliper commented May 24, 2023

Even though these are coverage tests, they should still be clear and at least check for what they are testing...

Love it, great catch on the UT bug in Test_Unsubscribe_Local!

@thnkslprpt
Copy link
Contributor Author

thnkslprpt commented May 24, 2023

Love it, great catch on the UT bug in Test_Unsubscribe_Local!

Cheers Jake.

Yeah SubscribeLocal()/UnsubscribeLocal() are fully tested with functional tests, but still best to keep the coverage tests correct and up-to-date anyway of course.

@jphickey jphickey force-pushed the fix-1143-clear-event-count-after-test-setup branch from 19b4cc2 to d0b4430 Compare November 14, 2025 19:49
Copy link
Contributor

@jphickey jphickey left a comment

Choose a reason for hiding this comment

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

I rebased this one and confirmed its working.

This is an improvement to future maintainability and seems to also fix a few problems in the process.

@jphickey jphickey added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Nov 14, 2025
@thnkslprpt
Copy link
Contributor Author

I rebased this one and confirmed its working.

Thanks for updating it Joe.

@dzbaker dzbaker added CCB:Approved Indicates code review and approval by community CCB and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels Dec 17, 2025
@dzbaker dzbaker merged commit ec5e3ae into nasa:main Dec 17, 2025
21 checks passed
dzbaker added a commit to nasa/cFS that referenced this pull request Dec 17, 2025
*Combines:*

cFE equuleus-rc1+dev275
psp equuleus-rc1+dev85

**Includes:**

*cFE*
- nasa/cFE#2347
- nasa/cFE#2611
- nasa/cFE#2613
- nasa/cFE#2619
- nasa/cFE#2621
- nasa/cFE#2624
- nasa/cFE#2670

*osal*

*PSP*
- nasa/PSP#459
- nasa/PSP#460
- nasa/PSP#463

Co-authored by: Joseph Hickey <[email protected]>
Co-authored by: Avi Weiss <[email protected]>
@thnkslprpt thnkslprpt deleted the fix-1143-clear-event-count-after-test-setup branch December 18, 2025 10:32
@dzbaker dzbaker added this to the v7.0.0 milestone Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CCB:Approved Indicates code review and approval by community CCB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit test should clear event count history after setup

4 participants