diff --git a/CMakeLists.txt b/CMakeLists.txt index 3820585..1d5697f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ set(APP_SRC_FILES fsw/src/lc_custom.c fsw/src/lc_app.c fsw/src/lc_cmds.c + fsw/src/lc_dispatch.c fsw/src/lc_watch.c fsw/src/lc_action.c fsw/src/lc_utils.c diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index b6a8df9..9464898 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -33,6 +33,7 @@ #include "lc_perfids.h" #include "lc_version.h" #include "lc_cmds.h" +#include "lc_dispatch.h" #include "lc_action.h" #include "lc_watch.h" #include "lc_utils.h" diff --git a/fsw/src/lc_cmds.c b/fsw/src/lc_cmds.c index 14ff462..070beee 100644 --- a/fsw/src/lc_cmds.c +++ b/fsw/src/lc_cmds.c @@ -37,96 +37,6 @@ #define LC_GET_CMD_PAYLOAD(ptr, type) (&((const type *)(ptr))->Payload) -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Process a command pipe message */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) -{ - int32 Status = CFE_SUCCESS; - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - CFE_MSG_FcnCode_t CommandCode = 0; - - CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); - - switch (CFE_SB_MsgIdToValue(MessageID)) - { - /* - ** Sample actionpoints request - */ - case LC_SAMPLE_AP_MID: - LC_SampleAPReq(BufPtr); - break; - - /* - ** Housekeeping telemetry request - ** (only routine that can return a critical error indicator) - */ - case LC_SEND_HK_MID: - Status = LC_HousekeepingReq((CFE_MSG_CommandHeader_t *)BufPtr); - break; - - /* - ** LC application commands... - */ - case LC_CMD_MID: - - CFE_MSG_GetFcnCode(&BufPtr->Msg, &CommandCode); - switch (CommandCode) - { - case LC_NOOP_CC: - LC_NoopCmd(BufPtr); - break; - - case LC_RESET_CC: - LC_ResetCountersCmd(BufPtr); - break; - - case LC_SET_LC_STATE_CC: - LC_SetLCStateCmd(BufPtr); - break; - - case LC_SET_AP_STATE_CC: - LC_SetAPStateCmd(BufPtr); - break; - - case LC_SET_AP_PERM_OFF_CC: - LC_SetAPPermOffCmd(BufPtr); - break; - - case LC_RESET_AP_STATS_CC: - LC_ResetAPStatsCmd(BufPtr); - break; - - case LC_RESET_WP_STATS_CC: - LC_ResetWPStatsCmd(BufPtr); - break; - - default: - CFE_EVS_SendEvent(LC_CC_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid command code: ID = 0x%08lX, CC = %d", - (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode); - - LC_AppData.CmdErrCount++; - break; - - } /* end CommandCode switch */ - break; - - /* - ** All other message ID's should be monitor - ** packets - */ - default: - LC_CheckMsgForWPs(MessageID, BufPtr); - break; - - } /* end MessageID switch */ - - return Status; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Sample Actionpoints Request */ @@ -135,74 +45,64 @@ int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) { const LC_SampleAP_Payload_t *LC_SampleAP; - size_t ExpectedLength = sizeof(LC_SampleAPCmd_t); uint16 WatchIndex; bool ValidSampleCmd = false; + LC_SampleAP = LC_GET_CMD_PAYLOAD(BufPtr, LC_SampleAPCmd_t); + /* - ** Verify message packet length + ** Ignore AP sample requests if disabled at the application level */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + if (LC_AppData.CurrentLCState != LC_STATE_DISABLED) { - LC_SampleAP = LC_GET_CMD_PAYLOAD(BufPtr, LC_SampleAPCmd_t); - /* - ** Ignore AP sample requests if disabled at the application level + ** Range check the actionpoint array index arguments */ - if (LC_AppData.CurrentLCState != LC_STATE_DISABLED) + if ((LC_SampleAP->StartIndex == LC_ALL_ACTIONPOINTS) && (LC_SampleAP->EndIndex == LC_ALL_ACTIONPOINTS)) { /* - ** Range check the actionpoint array index arguments + ** Allow special "sample all" heritage values */ - if ((LC_SampleAP->StartIndex == LC_ALL_ACTIONPOINTS) && (LC_SampleAP->EndIndex == LC_ALL_ACTIONPOINTS)) - { - /* - ** Allow special "sample all" heritage values - */ - LC_SampleAPs(0, LC_MAX_ACTIONPOINTS - 1); - ValidSampleCmd = true; - } - else if ((LC_SampleAP->StartIndex <= LC_SampleAP->EndIndex) && - (LC_SampleAP->EndIndex < LC_MAX_ACTIONPOINTS)) - { - /* - ** Start is less or equal to end, and end is within the array - */ - LC_SampleAPs(LC_SampleAP->StartIndex, LC_SampleAP->EndIndex); - ValidSampleCmd = true; - } - else - { - /* - ** At least one actionpoint array index is out of range - */ - CFE_EVS_SendEvent(LC_APSAMPLE_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, - "Sample AP error: invalid AP number, start = %d, end = %d", LC_SampleAP->StartIndex, - LC_SampleAP->EndIndex); - } - + LC_SampleAPs(0, LC_MAX_ACTIONPOINTS - 1); + ValidSampleCmd = true; + } + else if ((LC_SampleAP->StartIndex <= LC_SampleAP->EndIndex) && (LC_SampleAP->EndIndex < LC_MAX_ACTIONPOINTS)) + { + /* + ** Start is less or equal to end, and end is within the array + */ + LC_SampleAPs(LC_SampleAP->StartIndex, LC_SampleAP->EndIndex); + ValidSampleCmd = true; + } + else + { /* - ** Optionally update the age of watchpoint results + ** At least one actionpoint array index is out of range */ - if ((LC_SampleAP->UpdateAge != 0) && (ValidSampleCmd)) + CFE_EVS_SendEvent(LC_APSAMPLE_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, + "Sample AP error: invalid AP number, start = %d, end = %d", LC_SampleAP->StartIndex, + LC_SampleAP->EndIndex); + } + + /* + ** Optionally update the age of watchpoint results + */ + if ((LC_SampleAP->UpdateAge != 0) && (ValidSampleCmd)) + { + for (WatchIndex = 0; WatchIndex < LC_MAX_WATCHPOINTS; WatchIndex++) { - for (WatchIndex = 0; WatchIndex < LC_MAX_WATCHPOINTS; WatchIndex++) + if (LC_OperData.WRTPtr[WatchIndex].CountdownToStale != 0) { - if (LC_OperData.WRTPtr[WatchIndex].CountdownToStale != 0) - { - LC_OperData.WRTPtr[WatchIndex].CountdownToStale--; + LC_OperData.WRTPtr[WatchIndex].CountdownToStale--; - if (LC_OperData.WRTPtr[WatchIndex].CountdownToStale == 0) - { - LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_STALE; - } + if (LC_OperData.WRTPtr[WatchIndex].CountdownToStale == 0) + { + LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_STALE; } } } } } - - return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -210,10 +110,8 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) /* Housekeeping request */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) +int32 LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr) { - int32 Result; - size_t ExpectedLength = sizeof(LC_SendHkCmd_t); uint16 TableIndex; uint16 HKIndex; uint8 ByteData; @@ -221,278 +119,269 @@ int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) LC_HkTlm_Payload_t *PayloadPtr; /* - ** Verify message packet length + ** Update HK variables */ - if (LC_VerifyMsgLength((CFE_MSG_Message_t *)MsgPtr, ExpectedLength)) + PayloadPtr = &LC_OperData.HkPacket.Payload; + + PayloadPtr->CmdCount = LC_AppData.CmdCount; + PayloadPtr->CmdErrCount = LC_AppData.CmdErrCount; + PayloadPtr->APSampleCount = LC_AppData.APSampleCount; + PayloadPtr->MonitoredMsgCount = LC_AppData.MonitoredMsgCount; + PayloadPtr->RTSExecCount = LC_AppData.RTSExecCount; + PayloadPtr->PassiveRTSExecCount = LC_AppData.PassiveRTSExecCount; + PayloadPtr->CurrentLCState = LC_AppData.CurrentLCState; + PayloadPtr->WPsInUse = LC_OperData.WatchpointCount; + + /* + ** Clear out the active actionpoint count, it will get + ** recomputed below + */ + PayloadPtr->ActiveAPs = 0; + + /* + ** Update packed watch results + ** (4 watch results in one 8-bit byte) + */ + for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex += 4) { + HKIndex = TableIndex / 4; + /* - ** Update HK variables + ** Pack in first result */ - PayloadPtr = &LC_OperData.HkPacket.Payload; + switch (LC_OperData.WRTPtr[TableIndex + 3].WatchResult) + { + case LC_WATCH_STALE: + ByteData = LC_HKWR_STALE << 6; + break; - PayloadPtr->CmdCount = LC_AppData.CmdCount; - PayloadPtr->CmdErrCount = LC_AppData.CmdErrCount; - PayloadPtr->APSampleCount = LC_AppData.APSampleCount; - PayloadPtr->MonitoredMsgCount = LC_AppData.MonitoredMsgCount; - PayloadPtr->RTSExecCount = LC_AppData.RTSExecCount; - PayloadPtr->PassiveRTSExecCount = LC_AppData.PassiveRTSExecCount; - PayloadPtr->CurrentLCState = LC_AppData.CurrentLCState; - PayloadPtr->WPsInUse = LC_OperData.WatchpointCount; + case LC_WATCH_FALSE: + ByteData = LC_HKWR_FALSE << 6; + break; + + case LC_WATCH_TRUE: + ByteData = LC_HKWR_TRUE << 6; + break; + + /* + ** We should never get an undefined watch result, + ** but we'll set an error result if we do + */ + case LC_WATCH_ERROR: + default: + ByteData = LC_HKWR_ERROR << 6; + break; + } /* - ** Clear out the active actionpoint count, it will get - ** recomputed below + ** Pack in second result */ - PayloadPtr->ActiveAPs = 0; + switch (LC_OperData.WRTPtr[TableIndex + 2].WatchResult) + { + case LC_WATCH_STALE: + ByteData = (ByteData | (LC_HKWR_STALE << 4)); + break; + + case LC_WATCH_FALSE: + ByteData = (ByteData | (LC_HKWR_FALSE << 4)); + break; + + case LC_WATCH_TRUE: + ByteData = (ByteData | (LC_HKWR_TRUE << 4)); + break; + + case LC_WATCH_ERROR: + default: + ByteData = (ByteData | (LC_HKWR_ERROR << 4)); + break; + } /* - ** Update packed watch results - ** (4 watch results in one 8-bit byte) + ** Pack in third result */ - for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex += 4) + switch (LC_OperData.WRTPtr[TableIndex + 1].WatchResult) { - HKIndex = TableIndex / 4; + case LC_WATCH_STALE: + ByteData = (ByteData | (LC_HKWR_STALE << 2)); + break; - /* - ** Pack in first result - */ - switch (LC_OperData.WRTPtr[TableIndex + 3].WatchResult) - { - case LC_WATCH_STALE: - ByteData = LC_HKWR_STALE << 6; - break; + case LC_WATCH_FALSE: + ByteData = (ByteData | (LC_HKWR_FALSE << 2)); + break; - case LC_WATCH_FALSE: - ByteData = LC_HKWR_FALSE << 6; - break; + case LC_WATCH_TRUE: + ByteData = (ByteData | (LC_HKWR_TRUE << 2)); + break; - case LC_WATCH_TRUE: - ByteData = LC_HKWR_TRUE << 6; - break; + case LC_WATCH_ERROR: + default: + ByteData = (ByteData | (LC_HKWR_ERROR << 2)); + break; + } - /* - ** We should never get an undefined watch result, - ** but we'll set an error result if we do - */ - case LC_WATCH_ERROR: - default: - ByteData = LC_HKWR_ERROR << 6; - break; - } + /* + ** Pack in fourth and last result + */ + switch (LC_OperData.WRTPtr[TableIndex].WatchResult) + { + case LC_WATCH_STALE: + ByteData = (ByteData | LC_HKWR_STALE); + break; - /* - ** Pack in second result - */ - switch (LC_OperData.WRTPtr[TableIndex + 2].WatchResult) - { - case LC_WATCH_STALE: - ByteData = (ByteData | (LC_HKWR_STALE << 4)); - break; - - case LC_WATCH_FALSE: - ByteData = (ByteData | (LC_HKWR_FALSE << 4)); - break; - - case LC_WATCH_TRUE: - ByteData = (ByteData | (LC_HKWR_TRUE << 4)); - break; - - case LC_WATCH_ERROR: - default: - ByteData = (ByteData | (LC_HKWR_ERROR << 4)); - break; - } + case LC_WATCH_FALSE: + ByteData = (ByteData | LC_HKWR_FALSE); + break; - /* - ** Pack in third result - */ - switch (LC_OperData.WRTPtr[TableIndex + 1].WatchResult) - { - case LC_WATCH_STALE: - ByteData = (ByteData | (LC_HKWR_STALE << 2)); - break; - - case LC_WATCH_FALSE: - ByteData = (ByteData | (LC_HKWR_FALSE << 2)); - break; - - case LC_WATCH_TRUE: - ByteData = (ByteData | (LC_HKWR_TRUE << 2)); - break; - - case LC_WATCH_ERROR: - default: - ByteData = (ByteData | (LC_HKWR_ERROR << 2)); - break; - } + case LC_WATCH_TRUE: + ByteData = (ByteData | LC_HKWR_TRUE); + break; - /* - ** Pack in fourth and last result - */ - switch (LC_OperData.WRTPtr[TableIndex].WatchResult) - { - case LC_WATCH_STALE: - ByteData = (ByteData | LC_HKWR_STALE); - break; - - case LC_WATCH_FALSE: - ByteData = (ByteData | LC_HKWR_FALSE); - break; - - case LC_WATCH_TRUE: - ByteData = (ByteData | LC_HKWR_TRUE); - break; - - case LC_WATCH_ERROR: - default: - ByteData = (ByteData | LC_HKWR_ERROR); - break; - } + case LC_WATCH_ERROR: + default: + ByteData = (ByteData | LC_HKWR_ERROR); + break; + } - /* - ** Update houskeeping watch results array - */ - PayloadPtr->WPResults[HKIndex] = ByteData; + /* + ** Update houskeeping watch results array + */ + PayloadPtr->WPResults[HKIndex] = ByteData; - } /* end watch results for loop */ + } /* end watch results for loop */ + + /* + ** Update packed action results + ** (2 action state/result pairs (4 bits each) in one 8-bit byte) + */ + for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex += 2) + { + HKIndex = TableIndex / 2; /* - ** Update packed action results - ** (2 action state/result pairs (4 bits each) in one 8-bit byte) + ** Pack in first actionpoint, current state */ - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex += 2) + switch (LC_OperData.ARTPtr[TableIndex + 1].CurrentState) { - HKIndex = TableIndex / 2; + case LC_APSTATE_NOT_USED: + ByteData = LC_HKAR_STATE_NOT_USED << 6; + break; + + case LC_APSTATE_ACTIVE: + ByteData = LC_HKAR_STATE_ACTIVE << 6; + PayloadPtr->ActiveAPs++; + break; + + case LC_APSTATE_PASSIVE: + ByteData = LC_HKAR_STATE_PASSIVE << 6; + break; + + case LC_APSTATE_DISABLED: + ByteData = LC_HKAR_STATE_DISABLED << 6; + break; /* - ** Pack in first actionpoint, current state + ** Permanantly disabled actionpoints get reported + ** as unused. We should never get an undefined + ** action state, but we'll set to not used if we do. */ - switch (LC_OperData.ARTPtr[TableIndex + 1].CurrentState) - { - case LC_APSTATE_NOT_USED: - ByteData = LC_HKAR_STATE_NOT_USED << 6; - break; - - case LC_APSTATE_ACTIVE: - ByteData = LC_HKAR_STATE_ACTIVE << 6; - PayloadPtr->ActiveAPs++; - break; + case LC_APSTATE_PERMOFF: + default: + ByteData = LC_HKAR_STATE_NOT_USED << 6; + break; + } - case LC_APSTATE_PASSIVE: - ByteData = LC_HKAR_STATE_PASSIVE << 6; - break; + /* + ** Pack in first actionpoint, action result + */ + switch (LC_OperData.ARTPtr[TableIndex + 1].ActionResult) + { + case LC_ACTION_STALE: + ByteData = (ByteData | (LC_HKAR_STALE << 4)); + break; - case LC_APSTATE_DISABLED: - ByteData = LC_HKAR_STATE_DISABLED << 6; - break; + case LC_ACTION_PASS: + ByteData = (ByteData | (LC_HKAR_PASS << 4)); + break; - /* - ** Permanantly disabled actionpoints get reported - ** as unused. We should never get an undefined - ** action state, but we'll set to not used if we do. - */ - case LC_APSTATE_PERMOFF: - default: - ByteData = LC_HKAR_STATE_NOT_USED << 6; - break; - } + case LC_ACTION_FAIL: + ByteData = (ByteData | (LC_HKAR_FAIL << 4)); + break; /* - ** Pack in first actionpoint, action result + ** We should never get an undefined action result, + ** but we'll set an error result if we do */ - switch (LC_OperData.ARTPtr[TableIndex + 1].ActionResult) - { - case LC_ACTION_STALE: - ByteData = (ByteData | (LC_HKAR_STALE << 4)); - break; + case LC_ACTION_ERROR: + default: + ByteData = (ByteData | (LC_HKAR_ERROR << 4)); + break; + } - case LC_ACTION_PASS: - ByteData = (ByteData | (LC_HKAR_PASS << 4)); - break; + /* + ** Pack in second actionpoint, current state + */ + switch (LC_OperData.ARTPtr[TableIndex].CurrentState) + { + case LC_APSTATE_NOT_USED: + ByteData = (ByteData | (LC_HKAR_STATE_NOT_USED << 2)); + break; - case LC_ACTION_FAIL: - ByteData = (ByteData | (LC_HKAR_FAIL << 4)); - break; + case LC_APSTATE_ACTIVE: + ByteData = (ByteData | (LC_HKAR_STATE_ACTIVE << 2)); + PayloadPtr->ActiveAPs++; + break; - /* - ** We should never get an undefined action result, - ** but we'll set an error result if we do - */ - case LC_ACTION_ERROR: - default: - ByteData = (ByteData | (LC_HKAR_ERROR << 4)); - break; - } + case LC_APSTATE_PASSIVE: + ByteData = (ByteData | (LC_HKAR_STATE_PASSIVE << 2)); + break; - /* - ** Pack in second actionpoint, current state - */ - switch (LC_OperData.ARTPtr[TableIndex].CurrentState) - { - case LC_APSTATE_NOT_USED: - ByteData = (ByteData | (LC_HKAR_STATE_NOT_USED << 2)); - break; - - case LC_APSTATE_ACTIVE: - ByteData = (ByteData | (LC_HKAR_STATE_ACTIVE << 2)); - PayloadPtr->ActiveAPs++; - break; - - case LC_APSTATE_PASSIVE: - ByteData = (ByteData | (LC_HKAR_STATE_PASSIVE << 2)); - break; - - case LC_APSTATE_DISABLED: - ByteData = (ByteData | (LC_HKAR_STATE_DISABLED << 2)); - break; - - case LC_APSTATE_PERMOFF: - default: - ByteData = (ByteData | (LC_HKAR_STATE_NOT_USED << 2)); - break; - } + case LC_APSTATE_DISABLED: + ByteData = (ByteData | (LC_HKAR_STATE_DISABLED << 2)); + break; - /* - ** Pack in second actionpoint, action result - */ - switch (LC_OperData.ARTPtr[TableIndex].ActionResult) - { - case LC_ACTION_STALE: - ByteData = (ByteData | LC_HKAR_STALE); - break; - - case LC_ACTION_PASS: - ByteData = (ByteData | LC_HKAR_PASS); - break; - - case LC_ACTION_FAIL: - ByteData = (ByteData | LC_HKAR_FAIL); - break; - - case LC_ACTION_ERROR: - default: - ByteData = (ByteData | LC_HKAR_ERROR); - break; - } + case LC_APSTATE_PERMOFF: + default: + ByteData = (ByteData | (LC_HKAR_STATE_NOT_USED << 2)); + break; + } - /* - ** Update houskeeping action results array - */ - PayloadPtr->APResults[HKIndex] = ByteData; + /* + ** Pack in second actionpoint, action result + */ + switch (LC_OperData.ARTPtr[TableIndex].ActionResult) + { + case LC_ACTION_STALE: + ByteData = (ByteData | LC_HKAR_STALE); + break; + + case LC_ACTION_PASS: + ByteData = (ByteData | LC_HKAR_PASS); + break; - } /* end action results for loop */ + case LC_ACTION_FAIL: + ByteData = (ByteData | LC_HKAR_FAIL); + break; + + case LC_ACTION_ERROR: + default: + ByteData = (ByteData | LC_HKAR_ERROR); + break; + } /* - ** Timestamp and send housekeeping packet + ** Update houskeeping action results array */ - CFE_SB_TimeStampMsg(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader)); - CFE_SB_TransmitMsg(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader), true); + PayloadPtr->APResults[HKIndex] = ByteData; - } /* end LC_VerifyMsgLength if */ + } /* end action results for loop */ - Result = LC_PerformMaintenance(); + /* + ** Timestamp and send housekeeping packet + */ + CFE_SB_TimeStampMsg(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader)); + CFE_SB_TransmitMsg(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader), true); - return Result; + return LC_PerformMaintenance(); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -502,20 +391,10 @@ int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_NoopCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_NoopCmd_t); - - /* - ** Verify message packet length - */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) - { - LC_AppData.CmdCount++; + LC_AppData.CmdCount++; - CFE_EVS_SendEvent(LC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command: Version %d.%d.%d.%d", - LC_MAJOR_VERSION, LC_MINOR_VERSION, LC_REVISION, LC_MISSION_REV); - } - - return; + CFE_EVS_SendEvent(LC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command: Version %d.%d.%d.%d", + LC_MAJOR_VERSION, LC_MINOR_VERSION, LC_REVISION, LC_MISSION_REV); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -525,19 +404,9 @@ void LC_NoopCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_ResetCountersCmd_t); - - /* - ** Verify message packet length - */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) - { - LC_ResetCounters(); + LC_ResetCounters(); - CFE_EVS_SendEvent(LC_RESET_DBG_EID, CFE_EVS_EventType_DEBUG, "Reset counters command"); - } - - return; + CFE_EVS_SendEvent(LC_RESET_DBG_EID, CFE_EVS_EventType_DEBUG, "Reset counters command"); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -554,8 +423,6 @@ void LC_ResetCounters(void) LC_AppData.MonitoredMsgCount = 0; LC_AppData.RTSExecCount = 0; LC_AppData.PassiveRTSExecCount = 0; - - return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -565,38 +432,29 @@ void LC_ResetCounters(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SetLCStateCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_SetLCStateCmd_t); const LC_SetLCState_Payload_t *CmdPtr; - /* - ** Verify message packet length - */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) - { - CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetLCStateCmd_t); + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetLCStateCmd_t); - switch (CmdPtr->NewLCState) - { - case LC_STATE_ACTIVE: - case LC_STATE_PASSIVE: - case LC_STATE_DISABLED: - LC_AppData.CurrentLCState = CmdPtr->NewLCState; - LC_AppData.CmdCount++; + switch (CmdPtr->NewLCState) + { + case LC_STATE_ACTIVE: + case LC_STATE_PASSIVE: + case LC_STATE_DISABLED: + LC_AppData.CurrentLCState = CmdPtr->NewLCState; + LC_AppData.CmdCount++; - CFE_EVS_SendEvent(LC_LCSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Set LC state command: new state = %d", CmdPtr->NewLCState); - break; + CFE_EVS_SendEvent(LC_LCSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, "Set LC state command: new state = %d", + CmdPtr->NewLCState); + break; - default: - CFE_EVS_SendEvent(LC_LCSTATE_ERR_EID, CFE_EVS_EventType_ERROR, "Set LC state error: invalid state = %d", - CmdPtr->NewLCState); + default: + CFE_EVS_SendEvent(LC_LCSTATE_ERR_EID, CFE_EVS_EventType_ERROR, "Set LC state error: invalid state = %d", + CmdPtr->NewLCState); - LC_AppData.CmdErrCount++; - break; - } + LC_AppData.CmdErrCount++; + break; } - - return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -606,127 +464,116 @@ void LC_SetLCStateCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SetAPStateCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_SetAPStateCmd_t); const LC_SetAPState_Payload_t *CmdPtr; uint32 TableIndex; uint8 CurrentAPState; bool ValidState = true; bool CmdSuccess = false; + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetAPStateCmd_t); + /* - ** Verify message packet length + ** Do a sanity check on the new actionpoint state + ** specified. */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + switch (CmdPtr->NewAPState) { - CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetAPStateCmd_t); - - /* - ** Do a sanity check on the new actionpoint state - ** specified. - */ - switch (CmdPtr->NewAPState) - { - case LC_APSTATE_ACTIVE: - case LC_APSTATE_PASSIVE: - case LC_APSTATE_DISABLED: - break; + case LC_APSTATE_ACTIVE: + case LC_APSTATE_PASSIVE: + case LC_APSTATE_DISABLED: + break; - default: - ValidState = false; - CFE_EVS_SendEvent(LC_APSTATE_NEW_ERR_EID, CFE_EVS_EventType_ERROR, - "Set AP state error: AP = %d, Invalid new state = %d", CmdPtr->APNumber, - CmdPtr->NewAPState); + default: + ValidState = false; + CFE_EVS_SendEvent(LC_APSTATE_NEW_ERR_EID, CFE_EVS_EventType_ERROR, + "Set AP state error: AP = %d, Invalid new state = %d", CmdPtr->APNumber, + CmdPtr->NewAPState); - LC_AppData.CmdErrCount++; - break; - } + LC_AppData.CmdErrCount++; + break; + } - /* - ** Do the rest based on the actionpoint ID we were given - */ - if (ValidState == true) + /* + ** Do the rest based on the actionpoint ID we were given + */ + if (ValidState == true) + { + if ((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) { - if ((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) + /* + ** Set all actionpoints to the new state except those that are not + ** used or set permanently off + */ + for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { - /* - ** Set all actionpoints to the new state except those that are not - ** used or set permanently off - */ - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) - { - CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; + CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; - if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) - { - LC_OperData.ARTPtr[TableIndex].CurrentState = CmdPtr->NewAPState; - } + if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) + { + LC_OperData.ARTPtr[TableIndex].CurrentState = CmdPtr->NewAPState; } - - /* - ** Set flag that we succeeded - */ - CmdSuccess = true; } - else + + /* + ** Set flag that we succeeded + */ + CmdSuccess = true; + } + else + { + if ((CmdPtr->APNumber) < LC_MAX_ACTIONPOINTS) { - if ((CmdPtr->APNumber) < LC_MAX_ACTIONPOINTS) - { - TableIndex = CmdPtr->APNumber; - CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; + TableIndex = CmdPtr->APNumber; + CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; - if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) - { - /* - ** Update state for single actionpoint specified - */ - LC_OperData.ARTPtr[TableIndex].CurrentState = CmdPtr->NewAPState; + if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) + { + /* + ** Update state for single actionpoint specified + */ + LC_OperData.ARTPtr[TableIndex].CurrentState = CmdPtr->NewAPState; - CmdSuccess = true; - } - else - { - /* - ** Actionpoints that are not used or set permanently - ** off can only be changed by a table load - */ - CFE_EVS_SendEvent(LC_APSTATE_CURR_ERR_EID, CFE_EVS_EventType_ERROR, - "Set AP state error: AP = %d, Invalid current AP state = %d", - CmdPtr->APNumber, CurrentAPState); - - LC_AppData.CmdErrCount++; - } + CmdSuccess = true; } else { /* - ** Actionpoint number is out of range - ** (it's zero based, since it's a table index) + ** Actionpoints that are not used or set permanently + ** off can only be changed by a table load */ - CFE_EVS_SendEvent(LC_APSTATE_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, - "Set AP state error: Invalid AP number = %d", CmdPtr->APNumber); + CFE_EVS_SendEvent(LC_APSTATE_CURR_ERR_EID, CFE_EVS_EventType_ERROR, + "Set AP state error: AP = %d, Invalid current AP state = %d", CmdPtr->APNumber, + CurrentAPState); LC_AppData.CmdErrCount++; } } - - /* - ** Update the command counter and send out event if command - ** executed - */ - if (CmdSuccess == true) + else { - LC_AppData.CmdCount++; + /* + ** Actionpoint number is out of range + ** (it's zero based, since it's a table index) + */ + CFE_EVS_SendEvent(LC_APSTATE_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, + "Set AP state error: Invalid AP number = %d", CmdPtr->APNumber); - CFE_EVS_SendEvent(LC_APSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Set AP state command: AP = %d, New state = %d", CmdPtr->APNumber, - CmdPtr->NewAPState); + LC_AppData.CmdErrCount++; } + } - } /* end ValidState if */ + /* + ** Update the command counter and send out event if command + ** executed + */ + if (CmdSuccess == true) + { + LC_AppData.CmdCount++; - } /* end LC_VerifyMsgLength if */ + CFE_EVS_SendEvent(LC_APSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, + "Set AP state command: AP = %d, New state = %d", CmdPtr->APNumber, CmdPtr->NewAPState); + } - return; + } /* end ValidState if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -736,64 +583,54 @@ void LC_SetAPStateCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SetAPPermOffCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_SetAPPermOffCmd_t); const LC_SetAPPermOff_Payload_t *CmdPtr; uint32 TableIndex; uint8 CurrentAPState; - /* - ** Verify message packet length - */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetAPPermOffCmd_t); + + if (((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) || ((CmdPtr->APNumber) >= LC_MAX_ACTIONPOINTS)) { - CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetAPPermOffCmd_t); + /* + ** Invalid actionpoint number + ** (This command can't be invoked for all actionpoints) + */ + CFE_EVS_SendEvent(LC_APOFF_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, + "Set AP perm off error: Invalid AP number = %d", CmdPtr->APNumber); - if (((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) || ((CmdPtr->APNumber) >= LC_MAX_ACTIONPOINTS)) + LC_AppData.CmdErrCount++; + } + else + { + TableIndex = CmdPtr->APNumber; + CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; + + if (CurrentAPState != LC_APSTATE_DISABLED) { /* - ** Invalid actionpoint number - ** (This command can't be invoked for all actionpoints) + ** Actionpoints can only be turned permanently off if + ** they are currently disabled */ - CFE_EVS_SendEvent(LC_APOFF_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, - "Set AP perm off error: Invalid AP number = %d", CmdPtr->APNumber); + CFE_EVS_SendEvent(LC_APOFF_CURR_ERR_EID, CFE_EVS_EventType_ERROR, + "Set AP perm off error, AP NOT Disabled: AP = %d, Current state = %d", CmdPtr->APNumber, + CurrentAPState); LC_AppData.CmdErrCount++; } else { - TableIndex = CmdPtr->APNumber; - CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; - - if (CurrentAPState != LC_APSTATE_DISABLED) - { - /* - ** Actionpoints can only be turned permanently off if - ** they are currently disabled - */ - CFE_EVS_SendEvent(LC_APOFF_CURR_ERR_EID, CFE_EVS_EventType_ERROR, - "Set AP perm off error, AP NOT Disabled: AP = %d, Current state = %d", - CmdPtr->APNumber, CurrentAPState); - - LC_AppData.CmdErrCount++; - } - else - { - /* - ** Update state for actionpoint specified - */ - LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_PERMOFF; - - LC_AppData.CmdCount++; - - CFE_EVS_SendEvent(LC_APOFF_INF_EID, CFE_EVS_EventType_INFORMATION, - "Set AP permanently off command: AP = %d", CmdPtr->APNumber); - } + /* + ** Update state for actionpoint specified + */ + LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_PERMOFF; - } /* end CmdPtr -> APNumber else */ + LC_AppData.CmdCount++; - } /* end LC_VerifyMsgLength if */ + CFE_EVS_SendEvent(LC_APOFF_INF_EID, CFE_EVS_EventType_INFORMATION, + "Set AP permanently off command: AP = %d", CmdPtr->APNumber); + } - return; + } /* end CmdPtr -> APNumber else */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -803,45 +640,38 @@ void LC_SetAPPermOffCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetAPStatsCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_ResetAPStatsCmd_t); const LC_ResetAPStats_Payload_t *CmdPtr; bool CmdSuccess = false; - /* verify message packet length */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) - { - CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_ResetAPStatsCmd_t); + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_ResetAPStatsCmd_t); - /* arg may be one or all AP's */ - if (CmdPtr->APNumber == LC_ALL_ACTIONPOINTS) - { - LC_ResetResultsAP(0, LC_MAX_ACTIONPOINTS - 1, true); - CmdSuccess = true; - } - else if (CmdPtr->APNumber < LC_MAX_ACTIONPOINTS) - { - LC_ResetResultsAP(CmdPtr->APNumber, CmdPtr->APNumber, true); - CmdSuccess = true; - } - else - { - /* arg is out of range (zero based table index) */ - LC_AppData.CmdErrCount++; + /* arg may be one or all AP's */ + if (CmdPtr->APNumber == LC_ALL_ACTIONPOINTS) + { + LC_ResetResultsAP(0, LC_MAX_ACTIONPOINTS - 1, true); + CmdSuccess = true; + } + else if (CmdPtr->APNumber < LC_MAX_ACTIONPOINTS) + { + LC_ResetResultsAP(CmdPtr->APNumber, CmdPtr->APNumber, true); + CmdSuccess = true; + } + else + { + /* arg is out of range (zero based table index) */ + LC_AppData.CmdErrCount++; - CFE_EVS_SendEvent(LC_APSTATS_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, - "Reset AP stats error: invalid AP number = %d", CmdPtr->APNumber); - } + CFE_EVS_SendEvent(LC_APSTATS_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, + "Reset AP stats error: invalid AP number = %d", CmdPtr->APNumber); + } - if (CmdSuccess == true) - { - LC_AppData.CmdCount++; + if (CmdSuccess == true) + { + LC_AppData.CmdCount++; - CFE_EVS_SendEvent(LC_APSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset AP stats command: AP = %d", - CmdPtr->APNumber); - } + CFE_EVS_SendEvent(LC_APSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset AP stats command: AP = %d", + CmdPtr->APNumber); } - - return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -872,8 +702,6 @@ void LC_ResetResultsAP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd) LC_OperData.ARTPtr[TableIndex].CumulativeRTSExecCount = 0; LC_OperData.ARTPtr[TableIndex].CumulativeEventMsgsSent = 0; } - - return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -883,45 +711,38 @@ void LC_ResetResultsAP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetWPStatsCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_ResetWPStatsCmd_t); const LC_ResetWPStats_Payload_t *CmdPtr; bool CmdSuccess = false; - /* verify message packet length */ - if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) - { - CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_ResetWPStatsCmd_t); + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_ResetWPStatsCmd_t); - /* arg may be one or all WP's */ - if (CmdPtr->WPNumber == LC_ALL_WATCHPOINTS) - { - LC_ResetResultsWP(0, LC_MAX_WATCHPOINTS - 1, true); - CmdSuccess = true; - } - else if (CmdPtr->WPNumber < LC_MAX_WATCHPOINTS) - { - LC_ResetResultsWP(CmdPtr->WPNumber, CmdPtr->WPNumber, true); - CmdSuccess = true; - } - else - { - /* arg is out of range (zero based table index) */ - LC_AppData.CmdErrCount++; + /* arg may be one or all WP's */ + if (CmdPtr->WPNumber == LC_ALL_WATCHPOINTS) + { + LC_ResetResultsWP(0, LC_MAX_WATCHPOINTS - 1, true); + CmdSuccess = true; + } + else if (CmdPtr->WPNumber < LC_MAX_WATCHPOINTS) + { + LC_ResetResultsWP(CmdPtr->WPNumber, CmdPtr->WPNumber, true); + CmdSuccess = true; + } + else + { + /* arg is out of range (zero based table index) */ + LC_AppData.CmdErrCount++; - CFE_EVS_SendEvent(LC_WPSTATS_WPNUM_ERR_EID, CFE_EVS_EventType_ERROR, - "Reset WP stats error: invalid WP number = %d", CmdPtr->WPNumber); - } + CFE_EVS_SendEvent(LC_WPSTATS_WPNUM_ERR_EID, CFE_EVS_EventType_ERROR, + "Reset WP stats error: invalid WP number = %d", CmdPtr->WPNumber); + } - if (CmdSuccess == true) - { - LC_AppData.CmdCount++; + if (CmdSuccess == true) + { + LC_AppData.CmdCount++; - CFE_EVS_SendEvent(LC_WPSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset WP stats command: WP = %d", - CmdPtr->WPNumber); - } + CFE_EVS_SendEvent(LC_WPSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset WP stats command: WP = %d", + CmdPtr->WPNumber); } - - return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -956,6 +777,4 @@ void LC_ResetResultsWP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd) LC_OperData.WRTPtr[TableIndex].LastTrueToFalse.Timestamp.Seconds = 0; LC_OperData.WRTPtr[TableIndex].LastTrueToFalse.Timestamp.Subseconds = 0; } - - return; } diff --git a/fsw/src/lc_cmds.h b/fsw/src/lc_cmds.h index ee5a4aa..1bf4fa5 100644 --- a/fsw/src/lc_cmds.h +++ b/fsw/src/lc_cmds.h @@ -34,27 +34,6 @@ * Exported Functions *************************************************************************/ -/** - * \brief Process a command pipe message - * - * \par Description - * Processes a single software bus command pipe message. Checks - * the message and command IDs and calls the appropriate routine - * to handle the message. - * - * All messageIDs other than #LC_CMD_MID, #LC_SEND_HK_MID, and - * #LC_SAMPLE_AP_MID are assumed to be monitor packets. - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param[in] BufPtr Pointer to Software Bus buffer - * - * \return Execution status, see \ref CFEReturnCodes - * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS - */ -int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr); - /** * \brief Reset HK counters * @@ -126,10 +105,8 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr); * * \param[in] MsgPtr Pointer to command header * - * \return Execution status, see \ref CFEReturnCodes - * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS */ -int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr); +int32 LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr); /** * \brief Noop command diff --git a/fsw/src/lc_dispatch.c b/fsw/src/lc_dispatch.c new file mode 100644 index 0000000..c4b7876 --- /dev/null +++ b/fsw/src/lc_dispatch.c @@ -0,0 +1,327 @@ +/************************************************************************ + * NASA Docket No. GSC-18,921-1, and identified as “CFS Limit Checker + * Application version 2.2.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * CFS Limit Checker (LC) command dispatch routines + */ + +/************************************************************************ +** Includes +*************************************************************************/ +#include "lc_app.h" +#include "lc_cmds.h" +#include "lc_dispatch.h" +#include "lc_msgids.h" +#include "lc_events.h" +#include "lc_platform_cfg.h" +#include "lc_watch.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Verify message packet length */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +bool LC_VerifyMsgLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) +{ + bool result = true; + CFE_MSG_FcnCode_t CommandCode = 0; + size_t ActualLength = 0; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + + /* + ** Verify the message packet length... + */ + + CFE_MSG_GetSize(MsgPtr, &ActualLength); + if (ExpectedLength != ActualLength) + { + CFE_MSG_GetMsgId(MsgPtr, &MessageID); + CFE_MSG_GetFcnCode(MsgPtr, &CommandCode); + + switch (CFE_SB_MsgIdToValue(MessageID)) + { + case LC_SEND_HK_MID: + /* + ** For a bad HK request, just send the event. We only increment + ** the error counter for ground commands and not internal messages. + */ + CFE_EVS_SendEvent(LC_HKREQ_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid HK request msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d", + (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength, + (int)ExpectedLength); + break; + + case LC_SAMPLE_AP_MID: + /* + ** Same thing as previous for a bad actionpoint sample request + */ + CFE_EVS_SendEvent(LC_APSAMPLE_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid AP sample msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d", + (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength, + (int)ExpectedLength); + break; + + default: + /* + ** All other cases, increment error counter + */ + CFE_EVS_SendEvent(LC_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d", + (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength, + (int)ExpectedLength); + LC_AppData.CmdErrCount++; + } + + result = false; + } + + return result; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Sample Actionpoints Request */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_SampleAPVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_SampleAPCmd_t); + + /* + ** Verify message packet length + */ + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_SampleAPReq(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Housekeeping request */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_SendHkVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_SendHkCmd_t); + + /* + ** Verify message packet length + */ + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_SendHkCmd((CFE_MSG_CommandHeader_t *)BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Noop command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_NoopVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_NoopCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_NoopCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Reset counters command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_ResetCountersVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_ResetCountersCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_ResetCountersCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Set LC state command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_SetLCStateVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_SetLCStateCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_SetLCStateCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Set actionpoint state command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_SetAPStateVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_SetAPStateCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_SetAPStateCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Set actionpoint permanently off command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_SetAPPermOffVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_SetAPPermOffCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_SetAPPermOffCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Reset actionpoint statistics command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_ResetAPStatsVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_ResetAPStatsCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_ResetAPStatsCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Reset watchpoint statistics command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void LC_ResetWPStatsVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) +{ + size_t ExpectedLength = sizeof(LC_ResetWPStatsCmd_t); + + if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) + { + LC_ResetWPStatsCmd(BufPtr); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Process a command pipe message */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) +{ + int32 Status = CFE_SUCCESS; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t CommandCode = 0; + + CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); + + switch (CFE_SB_MsgIdToValue(MessageID)) + { + /* + ** Sample actionpoints request + */ + case LC_SAMPLE_AP_MID: + LC_SampleAPVerifyDispatch(BufPtr); + break; + + /* + ** Housekeeping telemetry request + ** (only routine that can return a critical error indicator) + */ + case LC_SEND_HK_MID: + LC_SendHkVerifyDispatch(BufPtr); + break; + + /* + ** LC application commands... + */ + case LC_CMD_MID: + + CFE_MSG_GetFcnCode(&BufPtr->Msg, &CommandCode); + switch (CommandCode) + { + case LC_NOOP_CC: + LC_NoopVerifyDispatch(BufPtr); + break; + + case LC_RESET_CC: + LC_ResetCountersVerifyDispatch(BufPtr); + break; + + case LC_SET_LC_STATE_CC: + LC_SetLCStateVerifyDispatch(BufPtr); + break; + + case LC_SET_AP_STATE_CC: + LC_SetAPStateVerifyDispatch(BufPtr); + break; + + case LC_SET_AP_PERM_OFF_CC: + LC_SetAPPermOffVerifyDispatch(BufPtr); + break; + + case LC_RESET_AP_STATS_CC: + LC_ResetAPStatsVerifyDispatch(BufPtr); + break; + + case LC_RESET_WP_STATS_CC: + LC_ResetWPStatsVerifyDispatch(BufPtr); + break; + + default: + CFE_EVS_SendEvent(LC_CC_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid command code: ID = 0x%08lX, CC = %d", + (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode); + + LC_AppData.CmdErrCount++; + break; + + } /* end CommandCode switch */ + break; + + /* + ** All other message ID's should be monitor + ** packets + */ + default: + LC_CheckMsgForWPs(MessageID, BufPtr); + break; + + } /* end MessageID switch */ + + return Status; +} diff --git a/fsw/src/lc_dispatch.h b/fsw/src/lc_dispatch.h new file mode 100644 index 0000000..701c31b --- /dev/null +++ b/fsw/src/lc_dispatch.h @@ -0,0 +1,58 @@ +/************************************************************************ + * NASA Docket No. GSC-18,921-1, and identified as “CFS Limit Checker + * Application version 2.2.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the CFS Limit Checker (LC) routines that + * handle command processing + */ +#ifndef LC_DISPATCH_H +#define LC_DISPATCH_H + +/************************************************************************* + * Includes + *************************************************************************/ +#include "cfe_sb_api_typedefs.h" + +/************************************************************************* + * Exported Functions + *************************************************************************/ + +/** + * \brief Process a command pipe message + * + * \par Description + * Processes a single software bus command pipe message. Checks + * the message and command IDs and calls the appropriate routine + * to handle the message. + * + * All messageIDs other than #LC_CMD_MID, #LC_SEND_HK_MID, and + * #LC_SAMPLE_AP_MID are assumed to be monitor packets. + * + * \par Assumptions, External Events, and Notes: + * None + * + * \param[in] BufPtr Pointer to Software Bus buffer + * + * \return Execution status, see \ref CFEReturnCodes + * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS + */ +int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr); + +#endif diff --git a/fsw/src/lc_utils.c b/fsw/src/lc_utils.c index 4d0d0f4..fe3d5a8 100644 --- a/fsw/src/lc_utils.c +++ b/fsw/src/lc_utils.c @@ -35,68 +35,6 @@ #include "lc_platform_cfg.h" #include "lc_utils.h" -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Verify message packet length */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -bool LC_VerifyMsgLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) -{ - bool result = true; - CFE_MSG_FcnCode_t CommandCode = 0; - size_t ActualLength = 0; - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - - /* - ** Verify the message packet length... - */ - - CFE_MSG_GetSize(MsgPtr, &ActualLength); - if (ExpectedLength != ActualLength) - { - CFE_MSG_GetMsgId(MsgPtr, &MessageID); - CFE_MSG_GetFcnCode(MsgPtr, &CommandCode); - - switch (CFE_SB_MsgIdToValue(MessageID)) - { - case LC_SEND_HK_MID: - /* - ** For a bad HK request, just send the event. We only increment - ** the error counter for ground commands and not internal messages. - */ - CFE_EVS_SendEvent(LC_HKREQ_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid HK request msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d", - (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength, - (int)ExpectedLength); - break; - - case LC_SAMPLE_AP_MID: - /* - ** Same thing as previous for a bad actionpoint sample request - */ - CFE_EVS_SendEvent(LC_APSAMPLE_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid AP sample msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d", - (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength, - (int)ExpectedLength); - break; - - default: - /* - ** All other cases, increment error counter - */ - CFE_EVS_SendEvent(LC_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d", - (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength, - (int)ExpectedLength); - LC_AppData.CmdErrCount++; - } - - result = false; - } - - return result; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Manage tables - chance to be dumped, reloaded, etc. */ diff --git a/fsw/src/lc_utils.h b/fsw/src/lc_utils.h index 5a7dc43..c4af75b 100644 --- a/fsw/src/lc_utils.h +++ b/fsw/src/lc_utils.h @@ -29,29 +29,6 @@ ************************************************************************/ #include "cfe.h" -/** - * \brief Verify message length - * - * \par Description - * Checks if the actual length of a software bus message matches - * the expected length and sends an error event if a mismatch - * occures - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param[in] MsgPtr Pointer to Message - * \param[in] ExpectedLength The expected length of the message - * based upon the command code - * - * \return Boolean message length verification result - * \retval true Length verification passed - * \retval false Length verification failed - * - * \sa #LC_LEN_ERR_EID - */ -bool LC_VerifyMsgLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); - /** * \brief Manage LC application tables * diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 838ca87..57e0e99 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -13,6 +13,7 @@ add_cfe_coverage_stubs("lc_internal" stubs/lc_cmds_stubs.c stubs/lc_action_stubs.c stubs/lc_custom_stubs.c + stubs/lc_dispatch_stubs.c stubs/lc_utils_stubs.c stubs/lc_watch_stubs.c stubs/lc_global_stubs.c diff --git a/unit-test/lc_app_tests.c b/unit-test/lc_app_tests.c index b638c1e..9083a34 100644 --- a/unit-test/lc_app_tests.c +++ b/unit-test/lc_app_tests.c @@ -34,7 +34,7 @@ #include "lc_version.h" #include "lc_utils.h" #include "lc_test_utils.h" -#include "lc_cmds.h" +#include "lc_dispatch.h" #include "cfe.h" diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index c016b84..071f97e 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -47,307 +47,8 @@ uint8 call_count_CFE_EVS_SendEvent; -void LC_AppPipe_Test_SampleAPRequest(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - - TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); -} - -void LC_AppPipe_Test_HousekeepingRequest(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - - TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - /* Set to prevent unintended error messages in subfunctions */ - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - uint8 call_count_LC_PerformMaintenance = UT_GetStubCount(UT_KEY(LC_PerformMaintenance)); - UtAssert_INT32_EQ(call_count_LC_PerformMaintenance, 1); - /* Generates 1 event message we don't care about in this test */ -} - -void LC_AppPipe_Test_Noop(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "No-op command: Version %%d.%%d.%%d.%%d"); - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_NOOP_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - /* Note: this event message is generated in a subfunction, but is tested anyway to verify that the correct code path - * has been reached */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_NOOP_INF_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); -} - -void LC_AppPipe_Test_Reset(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset counters command"); - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_RESET_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - /* Note: this event message is generated in a subfunction, but is tested anyway to verify that the correct code path - * has been reached */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_RESET_DBG_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_DEBUG); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); -} - -void LC_AppPipe_Test_SetLCState(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_SET_LC_STATE_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - - /* Generates 1 event message we don't care about in this test */ -} - -void LC_AppPipe_Test_SetAPState(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_SET_AP_STATE_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - - /* Generates 1 event message we don't care about in this test */ -} - -void LC_AppPipe_Test_SetAPPermoff(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_SET_AP_PERM_OFF_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - - /* Generates 1 event message we don't care about in this test */ -} - -void LC_AppPipe_Test_ResetAPStats(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_RESET_AP_STATS_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - /* Generates 1 event message we don't care about in this test */ -} - -void LC_AppPipe_Test_ResetWPStats(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = LC_RESET_WP_STATS_CC; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - /* Generates 1 event message we don't care about in this test */ -} - -void LC_AppPipe_Test_InvalidCommandCode(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - - TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); - FcnCode = 99; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Invalid command code: ID = 0x%%08lX, CC = %%d"); - - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CC_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); -} - -void LC_AppPipe_Test_MonitorPacket(void) -{ - int32 Result; - CFE_SB_MsgId_t TestMsgId; - - TestMsgId = LC_UT_MID_1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - /* Execute the function being tested */ - Result = LC_AppPipe(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - uint8 call_count_LC_CheckMsgForWPs = UT_GetStubCount(UT_KEY(LC_CheckMsgForWPs)); - UtAssert_INT32_EQ(call_count_LC_CheckMsgForWPs, 1); -} - -void LC_SampleAPReq_Test_BadLength(void) -{ - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - LC_SampleAPReq(&UT_CmdBuf.Buf); -} - void LC_SampleAPReq_Test_StateDisabled(void) { - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_AppData.CurrentLCState = LC_STATE_DISABLED; LC_SampleAPReq(&UT_CmdBuf.Buf); @@ -361,8 +62,6 @@ void LC_SampleAPReq_Test_AllowSampleAllWatchStale(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_AppData.CurrentLCState = 99; PayloadPtr->StartIndex = LC_ALL_ACTIONPOINTS; @@ -388,8 +87,6 @@ void LC_SampleAPReq_Test_AllowSampleAllWatchNotStale(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_AppData.CurrentLCState = 99; LC_SampleAP_Payload_t *PayloadPtr = &UT_CmdBuf.SampleAPCmd.Payload; PayloadPtr->StartIndex = LC_ALL_ACTIONPOINTS; @@ -413,8 +110,6 @@ void LC_SampleAPReq_Test_StartLessOrEqualToEndAndEndWithinArrayWatchStale(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_AppData.CurrentLCState = 99; PayloadPtr->StartIndex = LC_MAX_ACTIONPOINTS - 1; PayloadPtr->EndIndex = LC_MAX_ACTIONPOINTS - 1; @@ -440,8 +135,6 @@ void LC_SampleAPReq_Test_ArrayIndexOutOfRange(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_AppData.CurrentLCState = 99; PayloadPtr->StartIndex = 2; PayloadPtr->EndIndex = 1; @@ -474,8 +167,6 @@ void LC_SampleAPReq_Test_BadSampleAllArgs(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -509,8 +200,6 @@ void LC_SampleAPReq_Test_ArrayEndIndexTooHigh(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -544,8 +233,6 @@ void LC_SampleAPReq_Test_SampleAllUpdateAgeZero(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_AppData.CurrentLCState = 99; PayloadPtr->StartIndex = LC_ALL_ACTIONPOINTS; PayloadPtr->EndIndex = LC_ALL_ACTIONPOINTS; @@ -561,7 +248,7 @@ void LC_SampleAPReq_Test_SampleAllUpdateAgeZero(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_WatchStale(void) +void LC_SendHkCmd_Test_WatchStale(void) { int32 Result; uint16 TableIndex; @@ -573,8 +260,6 @@ void LC_HousekeepingReq_Test_WatchStale(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex++) { LC_OperData.WRTPtr[TableIndex].WatchResult = LC_WATCH_STALE; @@ -584,7 +269,7 @@ void LC_HousekeepingReq_Test_WatchStale(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -613,7 +298,7 @@ void LC_HousekeepingReq_Test_WatchStale(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_WatchFalse(void) +void LC_SendHkCmd_Test_WatchFalse(void) { int32 Result; uint16 TableIndex; @@ -625,8 +310,6 @@ void LC_HousekeepingReq_Test_WatchFalse(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex++) { LC_OperData.WRTPtr[TableIndex].WatchResult = LC_WATCH_FALSE; @@ -636,7 +319,7 @@ void LC_HousekeepingReq_Test_WatchFalse(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -665,7 +348,7 @@ void LC_HousekeepingReq_Test_WatchFalse(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_WatchTrue(void) +void LC_SendHkCmd_Test_WatchTrue(void) { int32 Result; uint16 TableIndex; @@ -677,8 +360,6 @@ void LC_HousekeepingReq_Test_WatchTrue(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex++) { LC_OperData.WRTPtr[TableIndex].WatchResult = LC_WATCH_TRUE; @@ -688,7 +369,7 @@ void LC_HousekeepingReq_Test_WatchTrue(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -717,7 +398,7 @@ void LC_HousekeepingReq_Test_WatchTrue(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_WatchError(void) +void LC_SendHkCmd_Test_WatchError(void) { int32 Result; uint16 TableIndex; @@ -730,8 +411,6 @@ void LC_HousekeepingReq_Test_WatchError(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex++) { LC_OperData.WRTPtr[TableIndex].WatchResult = LC_WATCH_ERROR; @@ -741,7 +420,7 @@ void LC_HousekeepingReq_Test_WatchError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -770,7 +449,7 @@ void LC_HousekeepingReq_Test_WatchError(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_DefaultWatchResult(void) +void LC_SendHkCmd_Test_DefaultWatchResult(void) { int32 Result; uint16 TableIndex; @@ -782,8 +461,6 @@ void LC_HousekeepingReq_Test_DefaultWatchResult(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_WATCHPOINTS; TableIndex++) { LC_OperData.WRTPtr[TableIndex].WatchResult = 99; @@ -793,7 +470,7 @@ void LC_HousekeepingReq_Test_DefaultWatchResult(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -822,7 +499,7 @@ void LC_HousekeepingReq_Test_DefaultWatchResult(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_ActionNotUsedStale(void) +void LC_SendHkCmd_Test_ActionNotUsedStale(void) { int32 Result; uint16 TableIndex; @@ -834,8 +511,6 @@ void LC_HousekeepingReq_Test_ActionNotUsedStale(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_NOT_USED; @@ -846,7 +521,7 @@ void LC_HousekeepingReq_Test_ActionNotUsedStale(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -875,7 +550,7 @@ void LC_HousekeepingReq_Test_ActionNotUsedStale(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_APStateActiveActionPass(void) +void LC_SendHkCmd_Test_APStateActiveActionPass(void) { int32 Result; uint16 TableIndex; @@ -887,8 +562,6 @@ void LC_HousekeepingReq_Test_APStateActiveActionPass(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_ACTIVE; @@ -899,7 +572,7 @@ void LC_HousekeepingReq_Test_APStateActiveActionPass(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -930,7 +603,7 @@ void LC_HousekeepingReq_Test_APStateActiveActionPass(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_APStatePassiveActionFail(void) +void LC_SendHkCmd_Test_APStatePassiveActionFail(void) { int32 Result; uint16 TableIndex; @@ -942,8 +615,6 @@ void LC_HousekeepingReq_Test_APStatePassiveActionFail(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_PASSIVE; @@ -954,7 +625,7 @@ void LC_HousekeepingReq_Test_APStatePassiveActionFail(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -983,7 +654,7 @@ void LC_HousekeepingReq_Test_APStatePassiveActionFail(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_APStateDisabledActionError(void) +void LC_SendHkCmd_Test_APStateDisabledActionError(void) { int32 Result; uint16 TableIndex; @@ -995,8 +666,6 @@ void LC_HousekeepingReq_Test_APStateDisabledActionError(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_DISABLED; @@ -1007,7 +676,7 @@ void LC_HousekeepingReq_Test_APStateDisabledActionError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1036,7 +705,7 @@ void LC_HousekeepingReq_Test_APStateDisabledActionError(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_APStatePermOffActionError(void) +void LC_SendHkCmd_Test_APStatePermOffActionError(void) { int32 Result; uint16 TableIndex; @@ -1048,8 +717,6 @@ void LC_HousekeepingReq_Test_APStatePermOffActionError(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_PERMOFF; @@ -1060,7 +727,7 @@ void LC_HousekeepingReq_Test_APStatePermOffActionError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1089,7 +756,7 @@ void LC_HousekeepingReq_Test_APStatePermOffActionError(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult(void) +void LC_SendHkCmd_Test_DefaultCurrentStateAndActionResult(void) { int32 Result; uint16 TableIndex; @@ -1101,8 +768,6 @@ void LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - for (TableIndex = 0; TableIndex < LC_MAX_ACTIONPOINTS; TableIndex++) { LC_OperData.ARTPtr[TableIndex].CurrentState = 99; @@ -1113,7 +778,7 @@ void LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1142,7 +807,7 @@ void LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_HousekeepingReq_Test_ManageTablesError(void) +void LC_SendHkCmd_Test_ManageTablesError(void) { int32 Result; CFE_SB_MsgId_t TestMsgId; @@ -1151,13 +816,12 @@ void LC_HousekeepingReq_Test_ManageTablesError(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDefaultReturnValue(UT_KEY(LC_PerformMaintenance), -1); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); /* Set to satisfy condition "(Result = LC_ManageTables()) != CFE_SUCCESS" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), -1); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); + Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == -1, "Result == -1"); @@ -1166,22 +830,21 @@ void LC_HousekeepingReq_Test_ManageTablesError(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_NoopCmd_Test_BadLength(void) +void LC_NoopCmd_Test(void) { - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); + LC_AppData.CmdCount = 1; LC_NoopCmd(&UT_CmdBuf.Buf); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); + UtAssert_UINT8_EQ(LC_AppData.CmdCount, 2); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } -void LC_ResetCountersCmd_Test_BadLength(void) +void LC_ResetCountersCmd_Test(void) { - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - LC_ResetCountersCmd(&UT_CmdBuf.Buf); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } void LC_ResetCounters_Test(void) @@ -1209,15 +872,6 @@ void LC_ResetCounters_Test(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_SetLCStateCmd_Test_BadLength(void) -{ - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - LC_SetLCStateCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); -} - void LC_SetLCStateCmd_Test_Active(void) { CFE_SB_MsgId_t TestMsgId; @@ -1225,7 +879,6 @@ void LC_SetLCStateCmd_Test_Active(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1258,7 +911,6 @@ void LC_SetLCStateCmd_Test_Passive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1291,7 +943,6 @@ void LC_SetLCStateCmd_Test_Disabled(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1324,7 +975,6 @@ void LC_SetLCStateCmd_Test_Default(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1349,15 +999,6 @@ void LC_SetLCStateCmd_Test_Default(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_SetAPStateCmd_Test_BadLength(void) -{ - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - LC_SetAPStateCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); -} - void LC_SetAPStateCmd_Test_Default(void) { CFE_SB_MsgId_t TestMsgId; @@ -1365,7 +1006,6 @@ void LC_SetAPStateCmd_Test_Default(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1400,7 +1040,6 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsActive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1454,7 +1093,6 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsActiveOneNotUsed(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1509,7 +1147,6 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsActiveOnePermOff(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1564,7 +1201,6 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsPassive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1618,7 +1254,6 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsDisabled(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1671,7 +1306,6 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointActive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1708,7 +1342,6 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointNotUsed(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1745,7 +1378,6 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointPassive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1782,7 +1414,6 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointDisabled(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1819,7 +1450,6 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStateActive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1855,7 +1485,6 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStatePassive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1891,7 +1520,6 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStateDisabled(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1928,7 +1556,6 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberActive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1963,7 +1590,6 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberPassive(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1997,7 +1623,6 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberDisabled(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2023,15 +1648,6 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberDisabled(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_SetAPPermOffCmd_Test_BadLength(void) -{ - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - LC_SetAPPermOffCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); -} - void LC_SetAPPermOffCmd_Test_InvalidAPNumberMaxActionpoints(void) { CFE_SB_MsgId_t TestMsgId; @@ -2039,7 +1655,6 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberMaxActionpoints(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2070,7 +1685,6 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberAllActionpoints(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2101,7 +1715,6 @@ void LC_SetAPPermOffCmd_Test_APNotDisabled(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2135,7 +1748,6 @@ void LC_SetAPPermOffCmd_Test_Nominal(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2163,15 +1775,6 @@ void LC_SetAPPermOffCmd_Test_Nominal(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_ResetAPStatsCmd_Test_BadLength(void) -{ - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - LC_ResetAPStatsCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); -} - void LC_ResetAPStatsCmd_Test_AllActionPoints(void) { CFE_SB_MsgId_t TestMsgId; @@ -2179,7 +1782,6 @@ void LC_ResetAPStatsCmd_Test_AllActionPoints(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2210,7 +1812,6 @@ void LC_ResetAPStatsCmd_Test_SingleActionPoint(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2241,7 +1842,6 @@ void LC_ResetAPStatsCmd_Test_InvalidAPNumber(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2366,15 +1966,6 @@ void LC_ResetResultsAP_Test(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_ResetWPStatsCmd_Test_BadLength(void) -{ - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), false); - - LC_ResetWPStatsCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)), 0); -} - void LC_ResetWPStatsCmd_Test_AllWatchPoints(void) { CFE_SB_MsgId_t TestMsgId; @@ -2382,7 +1973,6 @@ void LC_ResetWPStatsCmd_Test_AllWatchPoints(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2413,7 +2003,6 @@ void LC_ResetWPStatsCmd_Test_SingleWatchPoint(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2443,7 +2032,6 @@ void LC_ResetWPStatsCmd_Test_InvalidWPNumber(void) TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -2597,20 +2185,6 @@ void LC_ResetResultsWP_Test(void) void UtTest_Setup(void) { - UtTest_Add(LC_AppPipe_Test_SampleAPRequest, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SampleAPRequest"); - UtTest_Add(LC_AppPipe_Test_HousekeepingRequest, LC_Test_Setup, LC_Test_TearDown, - "LC_AppPipe_Test_HousekeepingRequest"); - UtTest_Add(LC_AppPipe_Test_Noop, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_Noop"); - UtTest_Add(LC_AppPipe_Test_Reset, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_Reset"); - UtTest_Add(LC_AppPipe_Test_SetLCState, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SetLCState"); - UtTest_Add(LC_AppPipe_Test_SetAPState, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SetAPState"); - UtTest_Add(LC_AppPipe_Test_SetAPPermoff, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SetAPPermoff"); - UtTest_Add(LC_AppPipe_Test_ResetAPStats, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_ResetAPStats"); - UtTest_Add(LC_AppPipe_Test_ResetWPStats, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_ResetWPStats"); - UtTest_Add(LC_AppPipe_Test_InvalidCommandCode, LC_Test_Setup, LC_Test_TearDown, - "LC_AppPipe_Test_InvalidCommandCode"); - UtTest_Add(LC_AppPipe_Test_MonitorPacket, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_MonitorPacket"); - UtTest_Add(LC_SampleAPReq_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_SampleAPReq_Test_BadLength"); UtTest_Add(LC_SampleAPReq_Test_AllowSampleAllWatchStale, LC_Test_Setup, LC_Test_TearDown, "LC_SampleAPReq_Test_AllowSampleAllWatchStale"); UtTest_Add(LC_SampleAPReq_Test_AllowSampleAllWatchNotStale, LC_Test_Setup, LC_Test_TearDown, @@ -2628,33 +2202,29 @@ void UtTest_Setup(void) UtTest_Add(LC_SampleAPReq_Test_BadSampleAllArgs, LC_Test_Setup, LC_Test_TearDown, "LC_SampleAPReq_Test_BadSampleAllArgs"); - UtTest_Add(LC_HousekeepingReq_Test_WatchStale, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_WatchStale"); - UtTest_Add(LC_HousekeepingReq_Test_WatchFalse, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_WatchFalse"); - UtTest_Add(LC_HousekeepingReq_Test_WatchTrue, LC_Test_Setup, LC_Test_TearDown, "LC_HousekeepingReq_Test_WatchTrue"); - UtTest_Add(LC_HousekeepingReq_Test_WatchError, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_WatchError"); - UtTest_Add(LC_HousekeepingReq_Test_DefaultWatchResult, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_DefaultWatchResult"); - UtTest_Add(LC_HousekeepingReq_Test_ActionNotUsedStale, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_ActionNotUsedStale"); - UtTest_Add(LC_HousekeepingReq_Test_APStateActiveActionPass, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_APStateActiveActionPass"); - UtTest_Add(LC_HousekeepingReq_Test_APStatePassiveActionFail, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_APStatePassiveActionFail"); - UtTest_Add(LC_HousekeepingReq_Test_APStateDisabledActionError, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_APStateDisabledActionError"); - UtTest_Add(LC_HousekeepingReq_Test_APStatePermOffActionError, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_APStatePermOffActionError"); - UtTest_Add(LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult"); - UtTest_Add(LC_HousekeepingReq_Test_ManageTablesError, LC_Test_Setup, LC_Test_TearDown, - "LC_HousekeepingReq_Test_ManageTablesError"); - - UtTest_Add(LC_NoopCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_NoopCmd_Test_BadLength"); - UtTest_Add(LC_ResetCountersCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, - "LC_ResetCountersCmd_Test_BadLength"); + UtTest_Add(LC_SendHkCmd_Test_WatchStale, LC_Test_Setup, LC_Test_TearDown, "LC_SendHkCmd_Test_WatchStale"); + UtTest_Add(LC_SendHkCmd_Test_WatchFalse, LC_Test_Setup, LC_Test_TearDown, "LC_SendHkCmd_Test_WatchFalse"); + UtTest_Add(LC_SendHkCmd_Test_WatchTrue, LC_Test_Setup, LC_Test_TearDown, "LC_SendHkCmd_Test_WatchTrue"); + UtTest_Add(LC_SendHkCmd_Test_WatchError, LC_Test_Setup, LC_Test_TearDown, "LC_SendHkCmd_Test_WatchError"); + UtTest_Add(LC_SendHkCmd_Test_DefaultWatchResult, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_DefaultWatchResult"); + UtTest_Add(LC_SendHkCmd_Test_ActionNotUsedStale, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_ActionNotUsedStale"); + UtTest_Add(LC_SendHkCmd_Test_APStateActiveActionPass, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_APStateActiveActionPass"); + UtTest_Add(LC_SendHkCmd_Test_APStatePassiveActionFail, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_APStatePassiveActionFail"); + UtTest_Add(LC_SendHkCmd_Test_APStateDisabledActionError, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_APStateDisabledActionError"); + UtTest_Add(LC_SendHkCmd_Test_APStatePermOffActionError, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_APStatePermOffActionError"); + UtTest_Add(LC_SendHkCmd_Test_DefaultCurrentStateAndActionResult, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_DefaultCurrentStateAndActionResult"); + UtTest_Add(LC_SendHkCmd_Test_ManageTablesError, LC_Test_Setup, LC_Test_TearDown, + "LC_SendHkCmd_Test_ManageTablesError"); + + UtTest_Add(LC_NoopCmd_Test, LC_Test_Setup, LC_Test_TearDown, "LC_NoopCmd_Test"); + UtTest_Add(LC_ResetCountersCmd_Test, LC_Test_Setup, LC_Test_TearDown, "LC_ResetCountersCmd_Test"); UtTest_Add(LC_ResetCounters_Test, LC_Test_Setup, LC_Test_TearDown, "LC_ResetCounters_Test"); @@ -2662,9 +2232,7 @@ void UtTest_Setup(void) UtTest_Add(LC_SetLCStateCmd_Test_Passive, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_Passive"); UtTest_Add(LC_SetLCStateCmd_Test_Disabled, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_Disabled"); UtTest_Add(LC_SetLCStateCmd_Test_Default, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_Default"); - UtTest_Add(LC_SetLCStateCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_BadLength"); - UtTest_Add(LC_SetAPStateCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPStateCmd_Test_BadLength"); UtTest_Add(LC_SetAPStateCmd_Test_Default, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPStateCmd_Test_Default"); UtTest_Add(LC_SetAPStateCmd_Test_SetAllActionPointsActive, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPStateCmd_Test_SetAllActionPointsActive"); @@ -2701,7 +2269,6 @@ void UtTest_Setup(void) UtTest_Add(LC_SetAPPermOffCmd_Test_APNotDisabled, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPPermOffCmd_Test_APNotDisabled"); UtTest_Add(LC_SetAPPermOffCmd_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPPermOffCmd_Test_Nominal"); - UtTest_Add(LC_SetAPPermOffCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPPermOffCmd_Test_BadLength"); UtTest_Add(LC_SetAPStateCmd_Test_SetAllActionPointsActiveOneNotUsed, LC_Test_Setup, LC_Test_TearDown, "LC_SetAPStateCmd_Test_SetAllActionPointsActiveOneNotUsed"); UtTest_Add(LC_SetAPStateCmd_Test_SetAllActionPointsActiveOnePermOff, LC_Test_Setup, LC_Test_TearDown, @@ -2713,7 +2280,6 @@ void UtTest_Setup(void) "LC_ResetAPStatsCmd_Test_SingleActionPoint"); UtTest_Add(LC_ResetAPStatsCmd_Test_InvalidAPNumber, LC_Test_Setup, LC_Test_TearDown, "LC_ResetAPStatsCmd_Test_InvalidAPNumber"); - UtTest_Add(LC_ResetAPStatsCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_ResetAPStatsCmd_Test_BadLength"); UtTest_Add(LC_ResetResultsAP_Test, LC_Test_Setup, LC_Test_TearDown, "LC_ResetResultsAP_Test"); UtTest_Add(LC_ResetWPStatsCmd_Test_AllWatchPoints, LC_Test_Setup, LC_Test_TearDown, @@ -2723,6 +2289,5 @@ void UtTest_Setup(void) UtTest_Add(LC_ResetWPStatsCmd_Test_InvalidWPNumber, LC_Test_Setup, LC_Test_TearDown, "LC_ResetWPStatsCmd_Test_InvalidWPNumber"); - UtTest_Add(LC_ResetWPStatsCmd_Test_BadLength, LC_Test_Setup, LC_Test_TearDown, "LC_ResetWPStatsCmd_Test_BadLength"); UtTest_Add(LC_ResetResultsWP_Test, LC_Test_Setup, LC_Test_TearDown, "LC_ResetResultsWP_Test"); } diff --git a/unit-test/lc_dispatch_tests.c b/unit-test/lc_dispatch_tests.c new file mode 100644 index 0000000..9f16554 --- /dev/null +++ b/unit-test/lc_dispatch_tests.c @@ -0,0 +1,330 @@ +/************************************************************************ + * NASA Docket No. GSC-18,921-1, and identified as “CFS Limit Checker + * Application version 2.2.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * This file contains unit test cases for the functions contained in the file lc_dispatch.c + */ + +/* + * Includes + */ + +#include "lc_cmds.h" +#include "lc_app.h" +#include "lc_dispatch.h" +#include "lc_msg.h" +#include "lc_msgdefs.h" +#include "lc_msgids.h" +#include "lc_events.h" +#include "lc_utils.h" +#include "lc_watch.h" + +#include "lc_test_utils.h" + +/* UT includes */ +#include "uttest.h" +#include "utassert.h" +#include "utstubs.h" + +#include +#include + +/* + * Helper functions + */ +static void LC_Dispatch_Test_SetupMsg(CFE_SB_MsgId_t MsgId, CFE_MSG_FcnCode_t FcnCode, size_t MsgSize) +{ + /* Note some paths get the MsgId/FcnCode multiple times, so register accordingly, just in case */ + CFE_SB_MsgId_t RegMsgId[2] = {MsgId, MsgId}; + CFE_MSG_FcnCode_t RegFcnCode[2] = {FcnCode, FcnCode}; + size_t RegMsgSize[2] = {MsgSize, MsgSize}; + + UT_ResetState(UT_KEY(CFE_MSG_GetMsgId)); + UT_ResetState(UT_KEY(CFE_MSG_GetFcnCode)); + UT_ResetState(UT_KEY(CFE_MSG_GetSize)); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), RegMsgId, sizeof(RegMsgId), true); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), RegFcnCode, sizeof(RegFcnCode), true); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), RegMsgSize, sizeof(RegMsgSize), true); +} + +void LC_AppPipe_Test_SampleAPRequest(void) +{ + CFE_SB_MsgId_t TestMsgId; + + TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); + + LC_Dispatch_Test_SetupMsg(TestMsgId, 0, sizeof(LC_SampleAPCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_SampleAPReq, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, 0, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_SampleAPReq, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_APSAMPLE_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_SendHkCmd(void) +{ + CFE_SB_MsgId_t TestMsgId; + + TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); + LC_Dispatch_Test_SetupMsg(TestMsgId, 0, sizeof(LC_SendHkCmd_t)); + + /* Set to prevent unintended error messages in subfunctions */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_SendHkCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, 0, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_SendHkCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_HKREQ_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_Noop(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_NOOP_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_NoopCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_NoopCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_NoopCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_Reset(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_RESET_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_ResetCountersCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_ResetCountersCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_ResetCountersCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_SetLCState(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_SET_LC_STATE_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_SetLCStateCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_SetLCStateCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_SetLCStateCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_SetAPState(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_SET_AP_STATE_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_SetAPStateCmd_t)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_SetAPStateCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_SetAPStateCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_SetAPPermOff(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_SET_AP_PERM_OFF_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_SetAPPermOffCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_SetAPPermOffCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_SetAPPermOffCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_ResetAPStats(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_RESET_AP_STATS_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_ResetAPStatsCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_ResetAPStatsCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_ResetAPStatsCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_ResetWPStats(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = LC_RESET_WP_STATS_CC; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, sizeof(LC_ResetWPStatsCmd_t)); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_ResetWPStatsCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + + /* Bad Length */ + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 1); + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + /* Verify handler NOT called again */ + UtAssert_STUB_COUNT(LC_ResetWPStatsCmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_InvalidCommandCode(void) +{ + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + + TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); + FcnCode = 99; + LC_Dispatch_Test_SetupMsg(TestMsgId, FcnCode, 0); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CC_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); +} + +void LC_AppPipe_Test_MonitorPacket(void) +{ + CFE_SB_MsgId_t TestMsgId; + + TestMsgId = LC_UT_MID_1; + LC_Dispatch_Test_SetupMsg(TestMsgId, 0, 0); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + + /* Execute the function being tested */ + UtAssert_INT32_EQ(LC_AppPipe(&UT_CmdBuf.Buf), CFE_SUCCESS); + UtAssert_STUB_COUNT(LC_CheckMsgForWPs, 1); +} + +void UtTest_Setup(void) +{ + UtTest_Add(LC_AppPipe_Test_SampleAPRequest, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SampleAPRequest"); + UtTest_Add(LC_AppPipe_Test_SendHkCmd, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SendHkCmd"); + UtTest_Add(LC_AppPipe_Test_Noop, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_Noop"); + UtTest_Add(LC_AppPipe_Test_Reset, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_Reset"); + UtTest_Add(LC_AppPipe_Test_SetLCState, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SetLCState"); + UtTest_Add(LC_AppPipe_Test_SetAPState, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SetAPState"); + UtTest_Add(LC_AppPipe_Test_SetAPPermOff, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_SetAPPermOff"); + UtTest_Add(LC_AppPipe_Test_ResetAPStats, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_ResetAPStats"); + UtTest_Add(LC_AppPipe_Test_ResetWPStats, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_ResetWPStats"); + UtTest_Add(LC_AppPipe_Test_InvalidCommandCode, LC_Test_Setup, LC_Test_TearDown, + "LC_AppPipe_Test_InvalidCommandCode"); + UtTest_Add(LC_AppPipe_Test_MonitorPacket, LC_Test_Setup, LC_Test_TearDown, "LC_AppPipe_Test_MonitorPacket"); +} diff --git a/unit-test/lc_utils_tests.c b/unit-test/lc_utils_tests.c index 2175cb8..e3a4df3 100644 --- a/unit-test/lc_utils_tests.c +++ b/unit-test/lc_utils_tests.c @@ -37,138 +37,6 @@ uint8 call_count_CFE_EVS_SendEvent; -void LC_VerifyMsgLength_Test_HKRequestLengthError(void) -{ - bool Result; - LC_SendHkCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - size_t MsgSize; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Invalid HK request msg length: ID = 0x%%08lX, CC = %%d, Len = %%d, Expected = %%d"); - - TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); - FcnCode = LC_NOOP_CC; - MsgSize = sizeof(CmdPacket) + 1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - - /* Execute the function being tested */ - Result = LC_VerifyMsgLength((CFE_MSG_Message_t *)(&CmdPacket), sizeof(CmdPacket)); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_HKREQ_LEN_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); -} - -void LC_VerifyMsgLength_Test_APSampleLengthError(void) -{ - bool Result; - LC_SampleAPCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - size_t MsgSize; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Invalid AP sample msg length: ID = 0x%%08lX, CC = %%d, Len = %%d, Expected = %%d"); - - TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); - FcnCode = LC_NOOP_CC; - MsgSize = sizeof(CmdPacket) + 1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - - /* Execute the function being tested */ - Result = LC_VerifyMsgLength((CFE_MSG_Message_t *)(&CmdPacket), sizeof(CmdPacket)); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_APSAMPLE_LEN_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); -} - -void LC_VerifyMsgLength_Test_GenericLengthError(void) -{ - bool Result; - LC_NoopCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - size_t MsgSize; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Invalid msg length: ID = 0x%%08lX, CC = %%d, Len = %%d, Expected = %%d"); - - TestMsgId = LC_UT_MID_1; - FcnCode = LC_NOOP_CC; - MsgSize = sizeof(CmdPacket) + 1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - - /* Execute the function being tested */ - Result = LC_VerifyMsgLength((CFE_MSG_Message_t *)(&CmdPacket), sizeof(CmdPacket)); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); -} - -void LC_VerifyMsgLength_Test_Nominal(void) -{ - bool Result; - LC_NoopCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - size_t MsgSize; - - TestMsgId = LC_UT_MID_1; - FcnCode = LC_NOOP_CC; - MsgSize = sizeof(CmdPacket); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - - /* Execute the function being tested */ - Result = LC_VerifyMsgLength((CFE_MSG_Message_t *)(&CmdPacket), sizeof(CmdPacket)); - - /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); -} - void LC_ManageTables_Test_Nominal(void) { int32 Result; @@ -443,14 +311,6 @@ void LC_PerformMaintenance_Test_ManageTablesFail(void) void UtTest_Setup(void) { - UtTest_Add(LC_VerifyMsgLength_Test_HKRequestLengthError, LC_Test_Setup, LC_Test_TearDown, - "LC_VerifyMsgLength_Test_HKRequestLengthError"); - UtTest_Add(LC_VerifyMsgLength_Test_APSampleLengthError, LC_Test_Setup, LC_Test_TearDown, - "LC_VerifyMsgLength_Test_APSampleLengthError"); - UtTest_Add(LC_VerifyMsgLength_Test_GenericLengthError, LC_Test_Setup, LC_Test_TearDown, - "LC_VerifyMsgLength_Test_GenericLengthError"); - UtTest_Add(LC_VerifyMsgLength_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_VerifyMsgLength_Test_Nominal"); - UtTest_Add(LC_ManageTables_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_ManageTables_Test_Nominal"); UtTest_Add(LC_ManageTables_Test_InfoUpdated, LC_Test_Setup, LC_Test_TearDown, "LC_ManageTables_Test_InfoUpdated"); UtTest_Add(LC_ManageTables_Test_WDTGetAddressError, LC_Test_Setup, LC_Test_TearDown, diff --git a/unit-test/lc_watch_tests.c b/unit-test/lc_watch_tests.c index d67eeba..b6615ef 100644 --- a/unit-test/lc_watch_tests.c +++ b/unit-test/lc_watch_tests.c @@ -349,8 +349,6 @@ void LC_ProcessWP_Test_CustomFunctionWatchFalse(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_CUSTOM; LC_OperData.WDTPtr[WatchIndex].CustomFuncArgument = 0; @@ -385,8 +383,6 @@ void LC_ProcessWP_Test_OperatorCompareError(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = 99; LC_OperData.WRTPtr[WatchIndex].EvaluationCount = 0; @@ -417,8 +413,6 @@ void LC_ProcessWP_Test_OperatorCompareWatchTruePreviousStale(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_LE; LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_STALE; @@ -466,8 +460,6 @@ void LC_ProcessWP_Test_OperatorCompareWatchTruePreviousFalse(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_LE; LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_FALSE; @@ -516,8 +508,6 @@ void LC_ProcessWP_Test_OperatorCompareWatchFalsePreviousStale(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_GE; LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_STALE; @@ -562,8 +552,6 @@ void LC_ProcessWP_Test_OperatorCompareWatchFalsePreviousTrue(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_GE; LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_TRUE; @@ -606,8 +594,6 @@ void LC_ProcessWP_Test_BadSize(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = 99; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_CUSTOM; LC_OperData.WDTPtr[WatchIndex].CustomFuncArgument = 0; @@ -633,8 +619,6 @@ void LC_ProcessWP_Test_OperatorCompareWatchTruePreviousTrue(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_LE; LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_TRUE; @@ -679,8 +663,6 @@ void LC_ProcessWP_Test_OperatorCompareWatchFalsePreviousFalse(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_GE; LC_OperData.WRTPtr[WatchIndex].WatchResult = LC_WATCH_FALSE; @@ -1424,8 +1406,6 @@ void LC_WPOffsetValid_Test_DataUByte(void) size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UBYTE; LC_OperData.WDTPtr[WatchIndex].WatchpointOffset = 0; @@ -1449,8 +1429,6 @@ void LC_WPOffsetValid_Test_UWordLE(void) size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UWORD_LE; LC_OperData.WDTPtr[WatchIndex].WatchpointOffset = 0; @@ -1474,8 +1452,6 @@ void LC_WPOffsetValid_Test_UDWordLE(void) size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UDWORD_LE; LC_OperData.WDTPtr[WatchIndex].WatchpointOffset = 0; @@ -1498,8 +1474,6 @@ void LC_WPOffsetValid_Test_FloatLE(void) size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); - LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_FLOAT_LE; LC_OperData.WDTPtr[WatchIndex].WatchpointOffset = 0; @@ -1520,7 +1494,6 @@ void LC_WPOffsetValid_Test_DataTypeError(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; @@ -1559,7 +1532,6 @@ void LC_WPOffsetValid_Test_OffsetError(void) size_t MsgSize = 0; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - UT_SetDefaultReturnValue(UT_KEY(LC_VerifyMsgLength), true); int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; diff --git a/unit-test/stubs/lc_cmds_stubs.c b/unit-test/stubs/lc_cmds_stubs.c index 34feac5..fff4d0a 100644 --- a/unit-test/stubs/lc_cmds_stubs.c +++ b/unit-test/stubs/lc_cmds_stubs.c @@ -26,38 +26,6 @@ #include "lc_cmds.h" #include "utgenstub.h" -/* - * ---------------------------------------------------- - * Generated stub function for LC_AppPipe() - * ---------------------------------------------------- - */ -int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) -{ - UT_GenStub_SetupReturnBuffer(LC_AppPipe, int32); - - UT_GenStub_AddParam(LC_AppPipe, const CFE_SB_Buffer_t *, BufPtr); - - UT_GenStub_Execute(LC_AppPipe, Basic, NULL); - - return UT_GenStub_GetReturnValue(LC_AppPipe, int32); -} - -/* - * ---------------------------------------------------- - * Generated stub function for LC_HousekeepingReq() - * ---------------------------------------------------- - */ -int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) -{ - UT_GenStub_SetupReturnBuffer(LC_HousekeepingReq, int32); - - UT_GenStub_AddParam(LC_HousekeepingReq, const CFE_MSG_CommandHeader_t *, MsgPtr); - - UT_GenStub_Execute(LC_HousekeepingReq, Basic, NULL); - - return UT_GenStub_GetReturnValue(LC_HousekeepingReq, int32); -} - /* * ---------------------------------------------------- * Generated stub function for LC_NoopCmd() @@ -84,25 +52,25 @@ void LC_ResetAPStatsCmd(const CFE_SB_Buffer_t *BufPtr) /* * ---------------------------------------------------- - * Generated stub function for LC_ResetCountersCmd() + * Generated stub function for LC_ResetCounters() * ---------------------------------------------------- */ -void LC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) +void LC_ResetCounters(void) { - UT_GenStub_AddParam(LC_ResetCountersCmd, const CFE_SB_Buffer_t *, BufPtr); - UT_GenStub_Execute(LC_ResetCountersCmd, Basic, NULL); + UT_GenStub_Execute(LC_ResetCounters, Basic, NULL); } /* * ---------------------------------------------------- - * Generated stub function for LC_ResetCounters() + * Generated stub function for LC_ResetCountersCmd() * ---------------------------------------------------- */ -void LC_ResetCounters(void) +void LC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) { + UT_GenStub_AddParam(LC_ResetCountersCmd, const CFE_SB_Buffer_t *, BufPtr); - UT_GenStub_Execute(LC_ResetCounters, Basic, NULL); + UT_GenStub_Execute(LC_ResetCountersCmd, Basic, NULL); } /* @@ -157,6 +125,22 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) UT_GenStub_Execute(LC_SampleAPReq, Basic, NULL); } +/* + * ---------------------------------------------------- + * Generated stub function for LC_SendHkCmd() + * ---------------------------------------------------- + */ +int32 LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr) +{ + UT_GenStub_SetupReturnBuffer(LC_SendHkCmd, int32); + + UT_GenStub_AddParam(LC_SendHkCmd, const CFE_MSG_CommandHeader_t *, MsgPtr); + + UT_GenStub_Execute(LC_SendHkCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(LC_SendHkCmd, int32); +} + /* * ---------------------------------------------------- * Generated stub function for LC_SetAPPermOffCmd() diff --git a/unit-test/stubs/lc_dispatch_stubs.c b/unit-test/stubs/lc_dispatch_stubs.c new file mode 100644 index 0000000..2c34c2c --- /dev/null +++ b/unit-test/stubs/lc_dispatch_stubs.c @@ -0,0 +1,43 @@ +/************************************************************************ + * NASA Docket No. GSC-18,921-1, and identified as “CFS Limit Checker + * Application version 2.2.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in lc_dispatch header + */ + +#include "lc_dispatch.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for LC_AppPipe() + * ---------------------------------------------------- + */ +int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) +{ + UT_GenStub_SetupReturnBuffer(LC_AppPipe, int32); + + UT_GenStub_AddParam(LC_AppPipe, const CFE_SB_Buffer_t *, BufPtr); + + UT_GenStub_Execute(LC_AppPipe, Basic, NULL); + + return UT_GenStub_GetReturnValue(LC_AppPipe, int32); +} diff --git a/unit-test/stubs/lc_utils_stubs.c b/unit-test/stubs/lc_utils_stubs.c index 1ff19d5..da2b113 100644 --- a/unit-test/stubs/lc_utils_stubs.c +++ b/unit-test/stubs/lc_utils_stubs.c @@ -67,20 +67,3 @@ int32 LC_UpdateTaskCDS(void) return UT_GenStub_GetReturnValue(LC_UpdateTaskCDS, int32); } - -/* - * ---------------------------------------------------- - * Generated stub function for LC_VerifyMsgLength() - * ---------------------------------------------------- - */ -bool LC_VerifyMsgLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) -{ - UT_GenStub_SetupReturnBuffer(LC_VerifyMsgLength, bool); - - UT_GenStub_AddParam(LC_VerifyMsgLength, const CFE_MSG_Message_t *, MsgPtr); - UT_GenStub_AddParam(LC_VerifyMsgLength, size_t, ExpectedLength); - - UT_GenStub_Execute(LC_VerifyMsgLength, Basic, NULL); - - return UT_GenStub_GetReturnValue(LC_VerifyMsgLength, bool); -}