Skip to content

Commit

Permalink
Merge pull request #11 from skliper/fix7-ut_static_analysis
Browse files Browse the repository at this point in the history
Fix #7, Resolve UT static analysis warnings
  • Loading branch information
astrogeco authored May 31, 2022
2 parents 25f3ae2 + 290b2ea commit 3efe7dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
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

0 comments on commit 3efe7dd

Please sign in to comment.