Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

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.

Unit test should clear event count history after setup
2 participants