Skip to content

Commit

Permalink
Merge pull request #2373 from irowebbn:2372_fix_tbl_ut_path_len
Browse files Browse the repository at this point in the history
Fix #2372 TBL UT update for OSAL/CFE path length mismatch
  • Loading branch information
dzbaker committed Dec 5, 2023
2 parents 6b23796 + 3a7f23a commit 93c636f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions modules/tbl/ut-coverage/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -3037,6 +3037,7 @@ void Test_CFE_TBL_TblMod(void)
CFE_TBL_Handle_t AccessIterator;
uint8 CDS_Data[sizeof(UT_Table1_t)];
uint32 ExpectedCrc;
int maxPathLenDiff = (int) CFE_MISSION_MAX_PATH_LEN - (int) OS_MAX_PATH_LEN;

memset(&TblInfo1, 0, sizeof(TblInfo1));

Expand Down Expand Up @@ -3177,13 +3178,22 @@ void Test_CFE_TBL_TblMod(void)
UtAssert_INT32_EQ(CFE_TBL_GetAddress(&TblDataAddr, App1TblHandle1), CFE_TBL_INFO_UPDATED);

/*
* LastFileLoaded (limited by mission) can be bigger than MyFilename (limited by osal),
* need to adjust length of check to account for difference and modified marking
* LastFileLoaded (limited by mission) can be bigger than MyFilename (limited by osal)
*/
UtAssert_StrnCmp(TblInfo1.LastFileLoaded, MyFilename, sizeof(MyFilename) - 4, "%s == %s, %ld",
TblInfo1.LastFileLoaded, MyFilename, (long)sizeof(MyFilename) - 4);
UtAssert_StrCmp(&TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4], "(*)", "%s == (*)",
&TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4]);
UtAssert_StrnCmp(TblInfo1.LastFileLoaded, MyFilename, sizeof(TblInfo1.LastFileLoaded) - 4, "%s == %s, %ld",
TblInfo1.LastFileLoaded, MyFilename, (long)sizeof(TblInfo1.LastFileLoaded) - 4);

if(maxPathLenDiff >= 0)
{
UtAssert_StrCmp(&TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4], "(*)", "%s == (*)",
&TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4]);
}
else if(maxPathLenDiff > -3)
{
int modIndicatorStart = (int) CFE_MISSION_MAX_PATH_LEN -4 - maxPathLenDiff;
UtAssert_StrCmp(&TblInfo1.LastFileLoaded[modIndicatorStart], "(*)", "%s == (*)",
&TblInfo1.LastFileLoaded[modIndicatorStart]);
}

/* Test response to an invalid handle */
UtAssert_INT32_EQ(CFE_TBL_Modified(CFE_TBL_BAD_TABLE_HANDLE), CFE_TBL_ERR_INVALID_HANDLE);
Expand Down

0 comments on commit 93c636f

Please sign in to comment.