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 #2372 TBL UT update for OSAL/CFE path length mismatch #2373

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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)

Check warning

Code scanning / CodeQL-security

Comparison result is always the same Warning

Comparison is always true because 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
Loading