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

Inconsistent use of CFE_EVS_SendEvent stub forces unnecessary UT complexity #296

Closed
3 tasks done
skliper opened this issue Aug 2, 2022 · 0 comments · Fixed by #305
Closed
3 tasks done

Inconsistent use of CFE_EVS_SendEvent stub forces unnecessary UT complexity #296

skliper opened this issue Aug 2, 2022 · 0 comments · Fixed by #305
Assignees
Labels
draco-rc3 unit-test Related to coverage or functional tests
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Aug 2, 2022

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I reviewed the CF README.md file to see if the feature is in the major future work.
  • I performed a cursory search to see if the feature request is relevant, not redundant, nor in conflict with other tickets.

Is your feature request related to a problem? Please describe.
Since two patterns are used for checking events, it can't be setup by default at startup causing every test that wants to check events to have to set up the data buffer (using either pattern A or B):

Pattern A uses UT_CF_ResetEventCapture, UT_CF_CheckEventID_Impl, UT_CF_CapturedEventIDs, example:

CF/unit-test/cf_app_tests.c

Lines 299 to 306 in 557c132

UT_CF_ResetEventCapture(UT_KEY(CFE_EVS_SendEvent));
/* Act */
UtAssert_INT32_EQ(CF_TableInit(), result);
/* Assert */
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UT_CF_AssertEventID(CF_EID_ERR_INIT_TBL_REG);

Pattern B set's up a custom buffer:

CF/unit-test/cf_app_tests.c

Lines 637 to 664 in 557c132

uint16 events[2] = {0};
memset(&sbbuf, 0, sizeof(sbbuf));
/* Run loop once */
UT_SetDeferredRetcode(UT_KEY(CFE_ES_RunLoop), 1, true);
UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RunLoop), false);
/* Capture events */
UT_SetDataBuffer(UT_KEY(CFE_EVS_SendEvent), events, sizeof(events), false);
/* Unit under test does not use the buffer in this case */
UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &sbbufptr, sizeof(sbbufptr), false);
UT_SetDeferredRetcode(UT_KEY(CFE_SB_ReceiveBuffer), 1, -1);
/* Act */
UtAssert_VOIDCALL(CF_AppMain());
/* Assert */
UtAssert_STUB_COUNT(CFE_ES_PerfLogAdd, 4);
UtAssert_STUB_COUNT(CFE_ES_RunLoop, 2);
UtAssert_STUB_COUNT(CFE_ES_ExitApp, 1);
/* Event from CF_Init and CF_AppMain */
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2);
UtAssert_UINT32_EQ(events[0], CF_EID_INF_INIT);
UtAssert_UINT32_EQ(events[1], CF_EID_ERR_INIT_MSG_RECV);

Describe the solution you'd like
Use a single pattern and setup automatically (like pattern A)

Describe alternatives you've considered
None

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper added the unit-test Related to coverage or functional tests label Aug 2, 2022
@skliper skliper added this to the Draco milestone Aug 2, 2022
@skliper skliper self-assigned this Aug 2, 2022
skliper added a commit to skliper/CF that referenced this issue Aug 2, 2022
skliper added a commit to skliper/CF that referenced this issue Aug 2, 2022
skliper added a commit to skliper/CF that referenced this issue Aug 2, 2022
dzbaker added a commit that referenced this issue Aug 3, 2022
Fix #296, Consistent CFE_EVS_SendEvent handling in UT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draco-rc3 unit-test Related to coverage or functional tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants