Skip to content

Commit

Permalink
Fix #1090, UT event check bounds
Browse files Browse the repository at this point in the history
Divide the "position" (in bytes) by the size of the event IDs
to get the number of events.

Also correct bad event checks in TBL UT.
  • Loading branch information
jphickey committed Jan 12, 2021
1 parent 1ede295 commit ad9ae56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fsw/cfe-core/unit-test/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,7 @@ void Test_CFE_TBL_Load(void)
RtnCode = CFE_TBL_Load(App1TblHandle2,
CFE_TBL_SRC_FILE,
"TblSrcFileName.dat");
EventsCorrect = (UT_EventIsInHistory(CFE_SUCCESS) == true &&
EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_TBLNAME_MISMATCH_ERR_EID) == true &&
UT_GetNumEventsSent() == 1);
UT_Report(__FILE__, __LINE__,
RtnCode == CFE_TBL_ERR_FILE_FOR_WRONG_TABLE && EventsCorrect,
Expand Down Expand Up @@ -2846,7 +2846,7 @@ void Test_CFE_TBL_Load(void)
UT_InitData();
UT_SetDeferredRetcode(UT_KEY(Test_CFE_TBL_ValidationFunc), 1, -1);
RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1);
EventsCorrect = (UT_EventIsInHistory(CFE_SUCCESS) == true &&
EventsCorrect = (UT_EventIsInHistory(CFE_TBL_VALIDATION_ERR_EID) == true &&
UT_GetNumEventsSent() == 1);
UT_Report(__FILE__, __LINE__,
RtnCode == -1 && EventsCorrect,
Expand All @@ -2859,7 +2859,7 @@ void Test_CFE_TBL_Load(void)
UT_InitData();
UT_SetDeferredRetcode(UT_KEY(Test_CFE_TBL_ValidationFunc), 1, 1);
RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1);
EventsCorrect = (UT_EventIsInHistory(CFE_SUCCESS) == true &&
EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_VAL_ERR_EID) == true &&
UT_GetNumEventsSent() == 2);
UT_Report(__FILE__, __LINE__,
RtnCode == -1 && EventsCorrect,
Expand Down
1 change: 1 addition & 0 deletions fsw/cfe-core/unit-test/ut_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ static bool UT_CheckEventHistoryFromFunc(UT_EntryKey_t Func, uint16 EventIDToSea
UT_GetDataBuffer(Func, (void**)&EvBuf, &MaxSize, &Position);
if (EvBuf != NULL && MaxSize > 0)
{
Position /= sizeof(*EvBuf);
while (Position > 0)
{
if (*EvBuf == EventIDToSearchFor)
Expand Down

0 comments on commit ad9ae56

Please sign in to comment.