diff --git a/.github/workflows/unit-test-coverage.yml b/.github/workflows/unit-test-coverage.yml index 840b28b..d67e62b 100644 --- a/.github/workflows/unit-test-coverage.yml +++ b/.github/workflows/unit-test-coverage.yml @@ -8,5 +8,3 @@ jobs: unit-test-coverage: name: Run unit test and coverage uses: nasa/cFS/.github/workflows/unit-test-coverage.yml@main - with: - max-missed-branches: 9 diff --git a/fsw/src/hs_custom.c b/fsw/src/hs_custom.c index 0cc6614..fcb8535 100644 --- a/fsw/src/hs_custom.c +++ b/fsw/src/hs_custom.c @@ -91,6 +91,8 @@ int32 HS_CustomInit(void) { int32 Status; + memset(&HS_CustomData, 0, sizeof(HS_CustomData)); + /* ** Spawn the Idle Task */ @@ -118,16 +120,13 @@ int32 HS_CustomInit(void) (unsigned int)Status); } - HS_CustomData.UtilMult1 = HS_UTIL_CONV_MULT1; - HS_CustomData.UtilMult2 = HS_UTIL_CONV_MULT2; - HS_CustomData.UtilDiv = HS_UTIL_CONV_DIV; - HS_CustomData.UtilMask = HS_UTIL_DIAG_MASK; - HS_CustomData.UtilCycleCounter = 0; - HS_CustomData.UtilArrayIndex = 0; - HS_CustomData.UtilArrayMask = HS_UTIL_TIME_DIAG_ARRAY_MASK; - HS_CustomData.ThisIdleTaskExec = 0; - HS_CustomData.LastIdleTaskExec = 0; - HS_CustomData.LastIdleTaskInterval = 0; + /* Non-zero initialization */ + HS_CustomData.UtilMult1 = HS_UTIL_CONV_MULT1; + HS_CustomData.UtilMult2 = HS_UTIL_CONV_MULT2; + HS_CustomData.UtilDiv = HS_UTIL_CONV_DIV; + HS_CustomData.UtilMask = HS_UTIL_DIAG_MASK; + HS_CustomData.UtilArrayMask = HS_UTIL_TIME_DIAG_ARRAY_MASK; + HS_CustomData.UtilCallsPerMark = HS_UTIL_CALLS_PER_MARK; return (Status); @@ -183,7 +182,7 @@ void HS_UtilizationMark(void) CycleCount++; - if (CycleCount >= HS_UTIL_CALLS_PER_MARK) + if (CycleCount >= HS_CustomData.UtilCallsPerMark) { HS_CustomData.LastIdleTaskInterval = HS_CustomData.ThisIdleTaskExec - HS_CustomData.LastIdleTaskExec; HS_CustomData.LastIdleTaskExec = HS_CustomData.ThisIdleTaskExec; @@ -278,10 +277,9 @@ void HS_UtilDiagReport(void) { uint32 DiagValue[HS_UTIL_TIME_DIAG_ARRAY_LENGTH]; uint32 DiagCount[HS_UTIL_TIME_DIAG_ARRAY_LENGTH]; - uint32 i = 0; - uint32 j = 0; - uint32 ThisValue = 0; - bool MatchFound = false; + uint32 i = 0; + uint32 j = 0; + uint32 ThisValue = 0; uint32 Ordinal = 0; uint32 NewOrdinalIndex = 0; @@ -314,24 +312,19 @@ void HS_UtilDiagReport(void) ThisValue = HS_CustomData.UtilArray[i] - HS_CustomData.UtilArray[i - 1]; } - j = 0; - MatchFound = false; - while ((MatchFound == false) && (j < HS_UTIL_TIME_DIAG_ARRAY_LENGTH)) + for (j = 0; j < HS_UTIL_TIME_DIAG_ARRAY_LENGTH; j++) { - if (ThisValue == DiagValue[j]) - { - DiagCount[j]++; - MatchFound = true; - } - else if (DiagValue[j] == 0xFFFFFFFF) + if (DiagValue[j] == 0xFFFFFFFF) { + /* Acquire a slot if empty */ DiagValue[j] = ThisValue; - DiagCount[j]++; - MatchFound = true; } - else + + if (ThisValue == DiagValue[j]) { - j++; + /* Increment count and cause loop to exit on match */ + DiagCount[j]++; + j = HS_UTIL_TIME_DIAG_ARRAY_LENGTH; } } } diff --git a/fsw/src/hs_custom.h b/fsw/src/hs_custom.h index cf2ca1f..f69c061 100644 --- a/fsw/src/hs_custom.h +++ b/fsw/src/hs_custom.h @@ -266,6 +266,8 @@ typedef struct uint32 LastIdleTaskInterval; /**< \brief Idle Task Increments during Previous Interval */ uint32 UtilCycleCounter; /**< \brief Counter to determine when to monitor utilization */ + int32 UtilCallsPerMark; /**< \brief CPU Utilization Calls per mark */ + int32 IdleTaskRunStatus; /**< \brief HS Idle Task Run Status */ CFE_ES_TaskId_t IdleTaskID; /**< \brief HS Idle Task Task ID */ diff --git a/fsw/src/hs_monitors.c b/fsw/src/hs_monitors.c index b38e14e..6c876ed 100644 --- a/fsw/src/hs_monitors.c +++ b/fsw/src/hs_monitors.c @@ -172,20 +172,18 @@ void HS_MonitorApplications(void) break; /* - ** Also the case for Message Action types + ** Message Action types processing (invalid will be skipped) */ - case HS_AMT_ACT_NOACT: default: + + /* Calculate the requested message action index */ + MsgActsIndex = ActionType - HS_AMT_ACT_LAST_NONMSG - 1; + /* - ** Check to see if this is a Message Action Type + ** Check to see if this is a valid Message Action Type */ - if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && - (ActionType > HS_AMT_ACT_LAST_NONMSG) && - (ActionType <= (HS_AMT_ACT_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES))) + if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && (MsgActsIndex < HS_MAX_MSG_ACT_TYPES)) { - /* Calculate index in Message Action Table */ - MsgActsIndex = ActionType - HS_AMT_ACT_LAST_NONMSG - 1; - /* ** Send the message if off cooldown and not disabled */ @@ -332,17 +330,18 @@ void HS_MonitorEvent(const CFE_EVS_LongEventTlm_t *EventPtr) break; /* - ** Also the case for Message Action types + ** Message Action types processing (invalid will be skipped) */ - case HS_EMT_ACT_NOACT: default: + + /* Calculate the requested message action index */ + MsgActsIndex = ActionType - HS_AMT_ACT_LAST_NONMSG - 1; + /* - ** Check to see if this is a Message Action Type + ** Check to see if this is a valid Message Action Type */ - if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && (ActionType > HS_EMT_ACT_LAST_NONMSG) && - (ActionType <= (HS_EMT_ACT_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES))) + if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && (MsgActsIndex < HS_MAX_MSG_ACT_TYPES)) { - MsgActsIndex = ActionType - HS_EMT_ACT_LAST_NONMSG - 1; /* ** Send the message if off cooldown and not disabled diff --git a/unit-test/hs_cmds_tests.c b/unit-test/hs_cmds_tests.c index 3a8a4e7..b25714f 100644 --- a/unit-test/hs_cmds_tests.c +++ b/unit-test/hs_cmds_tests.c @@ -551,9 +551,11 @@ void HS_HousekeepingReq_Test_InvalidEventMon(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); + /* 2 entries that are not HS_EMT_ACT_NOACT for branch coverage */ HS_AppData.EMTablePtr[0].ActionType = HS_EMT_ACT_NOACT + 1; + HS_AppData.EMTablePtr[1].ActionType = HS_EMT_ACT_NOACT + 1; - /* Satisfies condition "if (Status == CFE_ES_ERR_APPNAME)" */ + /* Fail first, succeed on second */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppIDByName), 1, -1); /* ignore dummy message length check */ @@ -3119,6 +3121,8 @@ void HS_AppMonStatusRefresh_Test_CycleCountZero(void) HS_AMTEntry_t AMTable[HS_MAX_MONITORED_APPS]; uint32 i; + memset(AMTable, 0, sizeof(AMTable)); + HS_AppData.AMTablePtr = AMTable; for (i = 0; i <= ((HS_MAX_MONITORED_APPS - 1) / HS_BITS_PER_APPMON_ENABLE); i++) @@ -3176,6 +3180,7 @@ void HS_AppMonStatusRefresh_Test_ActionTypeNOACT(void) for (i = 0; i < HS_MAX_MONITORED_APPS; i++) { + HS_AppData.AMTablePtr[i].CycleCount = 1; HS_AppData.AMTablePtr[i].ActionType = HS_AMT_ACT_NOACT; } @@ -3213,6 +3218,8 @@ void HS_AppMonStatusRefresh_Test_ElseCase(void) HS_AMTEntry_t AMTable[HS_MAX_MONITORED_APPS]; uint32 i; + memset(AMTable, 0, sizeof(AMTable)); + HS_AppData.AMTablePtr = AMTable; for (i = 0; i <= ((HS_MAX_MONITORED_APPS - 1) / HS_BITS_PER_APPMON_ENABLE); i++) diff --git a/unit-test/hs_custom_tests.c b/unit-test/hs_custom_tests.c index 3fcf426..891bbb9 100644 --- a/unit-test/hs_custom_tests.c +++ b/unit-test/hs_custom_tests.c @@ -52,94 +52,55 @@ int32 HS_CUSTOM_TEST_CFE_ES_IncrementTaskCounterHook(void *UserObj, int32 StubRe void HS_IdleTask_Test(void) { HS_CustomData.UtilMask = 1; - HS_CustomData.ThisIdleTaskExec = 3; + HS_CustomData.ThisIdleTaskExec = 0; HS_CustomData.UtilArrayIndex = 0; - /* Set to make the while loop exit after the first run */ + /* Set to make the while loop exit after the first call to CFE_ES_IncrementTaskCounter */ UT_SetHookFunction(UT_KEY(CFE_ES_IncrementTaskCounter), HS_CUSTOM_TEST_CFE_ES_IncrementTaskCounterHook, NULL); /* Execute the function being tested */ HS_IdleTask(); - /* Verify results */ - UtAssert_True(HS_CustomData.UtilArray[0] != 0, "HS_CustomData.UtilArray[0] != 0"); - UtAssert_True(HS_CustomData.UtilArrayIndex == 1, "HS_CustomData.UtilArrayIndex == 1"); + /* Will loop incrementing ThisIdleTaskExec until update/stamp, covering all branches */ + UtAssert_UINT32_NEQ(HS_CustomData.UtilArray[0], 0); + UtAssert_UINT32_EQ(HS_CustomData.UtilArrayIndex, 1); + UtAssert_UINT32_EQ(HS_CustomData.ThisIdleTaskExec, 4); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end HS_IdleTask_Test */ -void HS_IdleTask_Test_IdleTaskExecEqualsUtilMask(void) -{ - HS_CustomData.UtilMask = 1; - HS_CustomData.ThisIdleTaskExec = 1; - HS_CustomData.UtilArrayIndex = 0; - - /* Set to make the while loop exit after the first run */ - UT_SetHookFunction(UT_KEY(CFE_ES_IncrementTaskCounter), HS_CUSTOM_TEST_CFE_ES_IncrementTaskCounterHook, NULL); - - /* Execute the function being tested */ - HS_IdleTask(); - - /* Verify results */ - UtAssert_True(HS_CustomData.UtilArrayIndex == 0, "HS_CustomData.UtilArrayIndex == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - -} /* end HS_IdleTask_Test_IdleTaskExecEqualsUtilMask */ - -void HS_IdleTask_Test_IdleTaskExecAndFail(void) +void HS_CustomInit_Test_Nominal(void) { - HS_CustomData.UtilMask = 1; - HS_CustomData.ThisIdleTaskExec = 2; - HS_CustomData.UtilArrayIndex = 0; + uint32 i; - /* Set to make the while loop exit after the first run */ - UT_SetHookFunction(UT_KEY(CFE_ES_IncrementTaskCounter), HS_CUSTOM_TEST_CFE_ES_IncrementTaskCounterHook, NULL); + /* Fill to confirm init */ + memset(&HS_CustomData, 0xFF, sizeof(HS_CustomData)); /* Execute the function being tested */ - HS_IdleTask(); + UtAssert_INT32_EQ(HS_CustomInit(), CFE_SUCCESS); - /* Verify results */ - UtAssert_True(HS_CustomData.UtilArrayIndex == 0, "HS_CustomData.UtilArrayIndex == 0"); + UtAssert_INT32_EQ(HS_CustomData.UtilMult1, HS_UTIL_CONV_MULT1); + UtAssert_INT32_EQ(HS_CustomData.UtilMult2, HS_UTIL_CONV_MULT2); + UtAssert_INT32_EQ(HS_CustomData.UtilDiv, HS_UTIL_CONV_DIV); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - -} /* end HS_IdleTask_Test_IdleTaskExecEqualsUtilMask */ - -void HS_CustomInit_Test_Nominal(void) -{ - int32 Result; - - /* No setup required for this test */ + UtAssert_UINT32_EQ(HS_CustomData.UtilMask, HS_UTIL_DIAG_MASK); + UtAssert_UINT32_EQ(HS_CustomData.UtilArrayIndex, 0); + UtAssert_UINT32_EQ(HS_CustomData.UtilArrayMask, HS_UTIL_TIME_DIAG_ARRAY_MASK); - /* Execute the function being tested */ - Result = HS_CustomInit(); + UtAssert_UINT32_EQ(HS_CustomData.ThisIdleTaskExec, 0); + UtAssert_UINT32_EQ(HS_CustomData.LastIdleTaskExec, 0); + UtAssert_UINT32_EQ(HS_CustomData.LastIdleTaskInterval, 0); + UtAssert_UINT32_EQ(HS_CustomData.UtilCycleCounter, 0); - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); + for (i = 0; i < sizeof(HS_CustomData.UtilArray) / sizeof(HS_CustomData.UtilArray[0]); i++) + { + UtAssert_UINT32_EQ(HS_CustomData.UtilArray[i], 0); + } - UtAssert_True(HS_CustomData.UtilMult1 == HS_UTIL_CONV_MULT1, "HS_CustomData.UtilMult1 == HS_UTIL_CONV_MULT1"); - UtAssert_True(HS_CustomData.UtilMult2 == HS_UTIL_CONV_MULT2, "HS_CustomData.UtilMult2 == HS_UTIL_CONV_MULT2"); - UtAssert_True(HS_CustomData.UtilDiv == HS_UTIL_CONV_DIV, "HS_CustomData.UtilDiv == HS_UTIL_CONV_DIV"); - UtAssert_True(HS_CustomData.UtilCycleCounter == 0, "HS_CustomData.UtilCycleCounter == 0"); - UtAssert_True(HS_CustomData.UtilMask == HS_UTIL_DIAG_MASK, "HS_CustomData.UtilMask == HS_UTIL_DIAG_MASK"); - UtAssert_True(HS_CustomData.UtilArrayIndex == 0, "HS_CustomData.UtilArrayIndex == 0"); - UtAssert_True(HS_CustomData.UtilArrayMask == HS_UTIL_TIME_DIAG_ARRAY_MASK, - "HS_CustomData.UtilArrayMask == HS_UTIL_TIME_DIAG_ARRAY_MASK"); - UtAssert_True(HS_CustomData.ThisIdleTaskExec == 0, "HS_CustomData.ThisIdleTaskExec == 0"); - UtAssert_True(HS_CustomData.LastIdleTaskExec == 0, "HS_CustomData.LastIdleTaskExec == 0"); - UtAssert_True(HS_CustomData.LastIdleTaskInterval == 0, "HS_CustomData.LastIdleTaskInterval == 0"); + UtAssert_UINT32_EQ(HS_CustomData.UtilCallsPerMark, HS_UTIL_CALLS_PER_MARK); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end HS_CustomInit_Test_Nominal */ @@ -254,14 +215,16 @@ void HS_UtilizationMark_Test(void) HS_CustomData.ThisIdleTaskExec = 3; HS_CustomData.LastIdleTaskExec = 1; - /* HS_UtilizationMark cannot bypass the setting of - * HS_CustomData.LastIdleTaskInterval or - * HS_CustomData.LastIdleTaskExec when HS_UTIL_CALLS_PER_MARK - * is defined to 0 or 1 (default value). Update this - * constant in hs_platform_cfg.h to modify this behavior - * and achieve full coverage of the function body. */ + /* Force calls per mark to be able to get branch coverage */ + HS_CustomData.UtilCallsPerMark = 2; - /* Execute the function being tested */ + /* First call will bypass */ + HS_UtilizationMark(); + + UtAssert_UINT32_EQ(HS_CustomData.LastIdleTaskInterval, 0); + UtAssert_UINT32_EQ(HS_CustomData.LastIdleTaskExec, 1); + + /* Next call will update variables */ HS_UtilizationMark(); /* Verify results */ @@ -290,24 +253,21 @@ void HS_MarkIdleCallback_Test(void) void HS_CustomMonitorUtilization_Test(void) { - HS_CustomData.UtilCycleCounter = 0; + /* Setting to max will cause rollover for coverage */ + HS_CustomData.UtilCycleCounter = UINT32_MAX; - /* HS_CustomMonitorUtilization cannot bypass the execution of - * HS_MonitorUtilization or the clearing of - * HS_CustomData.UtilCycleCounter when HS_UTIL_CYCLES_PER_INTERVAL - * is defined to 0 or 1 (default value). Update this constant - * in hs_platform_cfg.h to modify this behavior and achieve full - * coverage of the function body. */ + /* First call should skip stub call */ + HS_CustomMonitorUtilization(); - /* Execute the function being tested */ + UtAssert_STUB_COUNT(HS_MonitorUtilization, 0); + + /* Next call exercises logic */ HS_CustomMonitorUtilization(); - /* Verify results */ - UtAssert_True(HS_CustomData.UtilCycleCounter == 0, "HS_CustomData.UtilCycleCounter == 0"); + UtAssert_STUB_COUNT(HS_MonitorUtilization, 1); + UtAssert_UINT32_EQ(HS_CustomData.UtilCycleCounter, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end HS_CustomMonitorUtilization_Test */ @@ -619,10 +579,10 @@ void HS_SetUtilParamsCmd_Test_NominalMultZero(void) HS_SetUtilParamsCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(HS_CustomData.UtilMult1 == 1, "HS_CustomData.UtilMult1 == 1"); - UtAssert_True(HS_CustomData.UtilMult2 == 2, "HS_CustomData.UtilMult2 == 2"); - UtAssert_True(HS_CustomData.UtilDiv == 3, "HS_CustomData.UtilDiv == 3"); - UtAssert_True(HS_AppData.CmdCount == 0, "HS_AppData.CmdCount == 0"); + UtAssert_INT32_EQ(HS_CustomData.UtilMult1, 0); + UtAssert_INT32_EQ(HS_CustomData.UtilMult2, 0); + UtAssert_INT32_EQ(HS_CustomData.UtilDiv, 0); + UtAssert_INT32_EQ(HS_AppData.CmdCount, 0); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, HS_SET_UTIL_PARAMS_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); @@ -666,10 +626,10 @@ void HS_SetUtilParamsCmd_Test_NominalDivZero(void) HS_SetUtilParamsCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(HS_CustomData.UtilMult1 == 1, "HS_CustomData.UtilMult1 == 1"); - UtAssert_True(HS_CustomData.UtilMult2 == 2, "HS_CustomData.UtilMult2 == 2"); - UtAssert_True(HS_CustomData.UtilDiv == 3, "HS_CustomData.UtilDiv == 3"); - UtAssert_True(HS_AppData.CmdCount == 0, "HS_AppData.CmdCount == 0"); + UtAssert_INT32_EQ(HS_CustomData.UtilMult1, 0); + UtAssert_INT32_EQ(HS_CustomData.UtilMult2, 0); + UtAssert_INT32_EQ(HS_CustomData.UtilDiv, 0); + UtAssert_INT32_EQ(HS_AppData.CmdCount, 0); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, HS_SET_UTIL_PARAMS_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); @@ -753,10 +713,10 @@ void HS_SetUtilParamsCmd_Test_MsgLengthError(void) HS_SetUtilParamsCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(HS_CustomData.UtilMult1 == 1, "HS_CustomData.UtilMult1 == 1"); - UtAssert_True(HS_CustomData.UtilMult2 == 2, "HS_CustomData.UtilMult2 == 2"); - UtAssert_True(HS_CustomData.UtilDiv == 3, "HS_CustomData.UtilDiv == 3"); - UtAssert_True(HS_AppData.CmdCount == 0, "HS_AppData.CmdCount == 0"); + UtAssert_INT32_EQ(HS_CustomData.UtilMult1, 0); + UtAssert_INT32_EQ(HS_CustomData.UtilMult2, 0); + UtAssert_INT32_EQ(HS_CustomData.UtilDiv, 0); + UtAssert_INT32_EQ(HS_AppData.CmdCount, 0); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", @@ -843,10 +803,6 @@ void HS_SetUtilDiagCmd_Test_MsgLengthError(void) void UtTest_Setup(void) { UtTest_Add(HS_IdleTask_Test, HS_Test_Setup, HS_Test_TearDown, "HS_IdleTask_Test"); - UtTest_Add(HS_IdleTask_Test_IdleTaskExecEqualsUtilMask, HS_Test_Setup, HS_Test_TearDown, - "HS_IdleTask_Test_IdleTaskExecEqualsUtilMask"); - UtTest_Add(HS_IdleTask_Test_IdleTaskExecAndFail, HS_Test_Setup, HS_Test_TearDown, - "HS_IdleTask_Test_IdleTaskExecAndFail"); UtTest_Add(HS_CustomInit_Test_Nominal, HS_Test_Setup, HS_Test_TearDown, "HS_CustomInit_Test_Nominal"); UtTest_Add(HS_CustomInit_Test_CreateChildTaskError, HS_Test_Setup, HS_Test_TearDown, diff --git a/unit-test/hs_monitors_tests.c b/unit-test/hs_monitors_tests.c index 1e68873..696b77e 100644 --- a/unit-test/hs_monitors_tests.c +++ b/unit-test/hs_monitors_tests.c @@ -64,10 +64,14 @@ void HS_MonitorApplications_Test_AppNameNotFound(void) HS_AppData.AMTablePtr = AMTable; + /* Element 0 will run through logic with action and not expired */ HS_AppData.AMTablePtr[0].ActionType = -1; HS_AppData.AppMonCheckInCountdown[0] = 1; HS_AppData.AMTablePtr[0].CycleCount = 1; + /* Element 1 has action but expired */ + HS_AppData.AMTablePtr[1].ActionType = -1; + strncpy(HS_AppData.AMTablePtr[0].AppName, "AppName", 10); /* Set CFE_ES_GetAppIDByName to fail on first call, to generate error HS_APPMON_APPNAME_ERR_EID */ @@ -908,6 +912,7 @@ void HS_MonitorEvent_Test_AppName(void) HS_AppData.EMTablePtr = EMTable; HS_AppData.MATablePtr = MATable; + /* Active table entry where AppName does not match event */ HS_AppData.EMTablePtr[0].ActionType = HS_EMT_ACT_PROC_RESET; HS_AppData.EMTablePtr[0].EventID = Packet.Payload.PacketID.EventID; HS_AppData.CDSData.MaxResets = 10; @@ -915,6 +920,9 @@ void HS_MonitorEvent_Test_AppName(void) strncpy(HS_AppData.EMTablePtr[0].AppName, "AppName", 10); + /* Active table entry where event doesn't match */ + HS_AppData.EMTablePtr[1].ActionType = HS_EMT_ACT_PROC_RESET; + /* Execute the function being tested */ HS_MonitorEvent(&Packet); diff --git a/unit-test/utilities/hs_test_utils.c b/unit-test/utilities/hs_test_utils.c index e9c1644..dff3283 100644 --- a/unit-test/utilities/hs_test_utils.c +++ b/unit-test/utilities/hs_test_utils.c @@ -108,6 +108,7 @@ void HS_Test_Setup(void) UT_ResetState(0); memset(&HS_AppData, 0, sizeof(HS_AppData)); + memset(&HS_CustomData, 0, sizeof(HS_CustomData)); memset(context_CFE_EVS_SendEvent, 0, sizeof(context_CFE_EVS_SendEvent)); memset(&context_CFE_ES_WriteToSysLog, 0, sizeof(context_CFE_ES_WriteToSysLog)); memset(&UT_CmdBuf, 0, sizeof(UT_CmdBuf));