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 #7, Resolve UT static analysis warnings #11

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
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: 17 additions & 5 deletions unit-test/hk_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,18 @@ void Test_HK_ProcessNewCopyTable_PoolBufFail(void)

char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];

snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"HK Processing New Table: ES_GetPoolBuf for size %%d returned 0x%%04X");

UT_SetDefaultReturnValue(UT_KEY(CFE_ES_GetPoolBuf), (CFE_SUCCESS - 1));

hk_runtime_tbl_entry_t RtTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

memset(RtTblPtr, 0, sizeof(RtTblPtr));

HK_Test_InitGoodCopyTable(CopyTblPtr);

snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"HK Processing New Table: ES_GetPoolBuf for size %%d returned 0x%%04X");

UT_SetDefaultReturnValue(UT_KEY(CFE_ES_GetPoolBuf), (CFE_SUCCESS - 1));

/* Act */
ReturnValue = HK_ProcessNewCopyTable(CopyTblPtr, RtTblPtr);

Expand Down Expand Up @@ -529,6 +531,8 @@ void Test_HK_ProcessNewCopyTable_Success(void)
hk_runtime_tbl_entry_t RtTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

memset(RtTblPtr, 0, sizeof(RtTblPtr));

HK_Test_InitGoodCopyTable(CopyTblPtr);

/* Act */
Expand Down Expand Up @@ -576,6 +580,8 @@ void Test_HK_ProcessNewCopyTable_Success2(void)
hk_runtime_tbl_entry_t RtTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

memset(RtTblPtr, 0, sizeof(RtTblPtr));

HK_Test_InitGoodCopyTable(CopyTblPtr);

CopyTblPtr[1].InputMid = CFE_SB_INVALID_MSG_ID;
Expand Down Expand Up @@ -623,6 +629,8 @@ void Test_HK_ProcessNewCopyTable_PacketSizeZero(void)
hk_runtime_tbl_entry_t RtTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

memset(RtTblPtr, 0, sizeof(RtTblPtr));

HK_Test_InitGoodCopyTable(CopyTblPtr);

CopyTblPtr[1].OutputOffset = 0;
Expand Down Expand Up @@ -670,6 +678,8 @@ void Test_HK_ProcessNewCopyTable_AllPacketsSizeZero(void)
hk_runtime_tbl_entry_t RtTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

memset(RtTblPtr, 0, sizeof(RtTblPtr));

HK_Test_InitGoodCopyTable(CopyTblPtr);

for (i = 0; i < 5; i++)
Expand Down Expand Up @@ -721,6 +731,8 @@ void Test_HK_ProcessNewCopyTable_EmptyTable(void)
hk_runtime_tbl_entry_t RtTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

memset(RtTblPtr, 0, sizeof(RtTblPtr));

HK_Test_InitEmptyCopyTable(CopyTblPtr);

/* Act */
Expand Down
2 changes: 1 addition & 1 deletion unit-test/utilities/hk_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void UT_Handler_CFE_EVS_SendEvent(void *UserObj, UT_EntryKey_t FuncKey, const UT
void UT_Handler_CFE_ES_WriteToSysLog(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, va_list va)
{
strncpy(context_CFE_ES_WriteToSysLog.Spec, UT_Hook_GetArgValueByName(Context, "SpecStringPtr", const char *),
CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
CFE_MISSION_EVS_MAX_MESSAGE_LENGTH - 1);
context_CFE_ES_WriteToSysLog.Spec[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH - 1] = '\0';
}

Expand Down