Skip to content

Inconsistent use of CFE_EVS_SendEvent stub forces unnecessary UT complexity #296

@skliper

Description

@skliper

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

Metadata

Metadata

Assignees

Labels

draco-rc3unit-testRelated to coverage or functional tests

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions