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 #12 #31 #32 #33, Coverage improvements #34

Merged
merged 3 commits into from
Jun 22, 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
2 changes: 0 additions & 2 deletions .github/workflows/unit-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 21 additions & 28 deletions fsw/src/hs_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ int32 HS_CustomInit(void)
{
int32 Status;

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

/*
** Spawn the Idle Task
*/
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions fsw/src/hs_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
29 changes: 14 additions & 15 deletions fsw/src/hs_monitors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion unit-test/hs_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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++)
Expand Down
Loading