From e904d4ba07b356ca3b26d6e2cf989553236d6474 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 22 Sep 2023 12:44:08 -0400 Subject: [PATCH] Fix #108, dispatch pattern for SC Move switch statements to a separate dispatch source file, and update all unit tests accordingly. All business logic of commands is put into separate command handler functions in sc_cmds.c. No logic is inside the switch statement, outside of message validation. --- CMakeLists.txt | 1 + fsw/src/sc_app.c | 2 +- fsw/src/sc_cmds.c | 316 ++----- fsw/src/sc_cmds.h | 32 +- fsw/src/sc_dispatch.c | 273 +++++++ fsw/src/sc_dispatch.h | 82 ++ fsw/src/sc_utils.c | 33 - fsw/src/sc_utils.h | 23 - unit-test/CMakeLists.txt | 1 + unit-test/sc_cmds_tests.c | 1180 ++------------------------- unit-test/sc_dispatch_tests.c | 1028 +++++++++++++++++++++++ unit-test/sc_utils_tests.c | 67 -- unit-test/stubs/sc_cmds_stubs.c | 46 +- unit-test/stubs/sc_dispatch_stubs.c | 68 ++ unit-test/stubs/sc_utils_stubs.c | 17 - 15 files changed, 1619 insertions(+), 1550 deletions(-) create mode 100644 fsw/src/sc_dispatch.c create mode 100644 fsw/src/sc_dispatch.h create mode 100644 unit-test/sc_dispatch_tests.c create mode 100644 unit-test/stubs/sc_dispatch_stubs.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f0a30de..b8ac632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(APP_SRC_FILES fsw/src/sc_state.c fsw/src/sc_loads.c fsw/src/sc_cmds.c + fsw/src/sc_dispatch.c ) # Create the app module diff --git a/fsw/src/sc_app.c b/fsw/src/sc_app.c index 9750212..1742266 100644 --- a/fsw/src/sc_app.c +++ b/fsw/src/sc_app.c @@ -34,7 +34,7 @@ #include "cfe.h" #include "sc_app.h" #include "sc_rts.h" -#include "sc_cmds.h" +#include "sc_dispatch.h" #include "sc_loads.h" #include "sc_events.h" #include "sc_msgids.h" diff --git a/fsw/src/sc_cmds.c b/fsw/src/sc_cmds.c index dfddaf8..87cbdc6 100644 --- a/fsw/src/sc_cmds.c +++ b/fsw/src/sc_cmds.c @@ -478,6 +478,33 @@ void SC_SendHkPacket(void) CFE_SB_TransmitMsg(&SC_OperData.HkPacket.TlmHeader.Msg, true); } +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Send HK Command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SC_SendHkCmd(const CFE_SB_Buffer_t *BufPtr) +{ + /* set during init to power on or processor reset auto-exec RTS */ + if (SC_AppData.AutoStartRTS != 0) + { + /* make sure the selected auto-exec RTS is enabled */ + if (SC_OperData.RtsInfoTblAddr[SC_RTS_NUM_TO_INDEX(SC_AppData.AutoStartRTS)].RtsStatus == SC_LOADED) + { + SC_OperData.RtsInfoTblAddr[SC_RTS_NUM_TO_INDEX(SC_AppData.AutoStartRTS)].DisabledFlag = false; + } + + /* send ground cmd to have SC start the RTS */ + SC_AutoStartRts(SC_AppData.AutoStartRTS); + + /* only start it once */ + SC_AppData.AutoStartRTS = 0; + } + + /* request from health and safety for housekeeping status */ + SC_SendHkPacket(); +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Reset Counters Command */ @@ -500,269 +527,70 @@ void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* No Op Command */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SC_NoOpCmd(const CFE_SB_Buffer_t *BufPtr) -{ - SC_OperData.HkPacket.Payload.CmdCtr++; - CFE_EVS_SendEvent(SC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", - SC_MAJOR_VERSION, SC_MINOR_VERSION, SC_REVISION, SC_MISSION_REV); -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Process Requests */ +/* 1Hz Wakeup Command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SC_ProcessRequest(const CFE_SB_Buffer_t *BufPtr) +void SC_OneHzWakeupCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - int8 IsThereAnotherCommandToExecute = false; - - /* cast the packet header pointer on the packet buffer */ - CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); + bool IsThereAnotherCommandToExecute = false; /* - ** Get the current system time in the global SC_AppData.CurrentTime + * Time to execute a command in the SC memory */ - SC_GetCurrentTime(); - - switch (CFE_SB_MsgIdToValue(MessageID)) + do { - case SC_CMD_MID: - /* request from the ground */ - SC_ProcessCommand(BufPtr); - break; + /* + * Check to see if there is an ATS switch Pending, if so service it. + */ + if (SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag == true) + { + SC_ServiceSwitchPend(); + } - case SC_SEND_HK_MID: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + if (SC_AppData.NextProcNumber == SC_ATP) + { + SC_ProcessAtpCmd(); + } + else + { + if (SC_AppData.NextProcNumber == SC_RTP) { - /* set during init to power on or processor reset auto-exec RTS */ - if (SC_AppData.AutoStartRTS != 0) - { - /* make sure the selected auto-exec RTS is enabled */ - if (SC_OperData.RtsInfoTblAddr[SC_RTS_NUM_TO_INDEX(SC_AppData.AutoStartRTS)].RtsStatus == SC_LOADED) - { - SC_OperData.RtsInfoTblAddr[SC_RTS_NUM_TO_INDEX(SC_AppData.AutoStartRTS)].DisabledFlag = false; - } - - /* send ground cmd to have SC start the RTS */ - SC_AutoStartRts(SC_AppData.AutoStartRTS); - - /* only start it once */ - SC_AppData.AutoStartRTS = 0; - } - - /* request from health and safety for housekeeping status */ - SC_SendHkPacket(); + SC_ProcessRtpCommand(); } - break; + } - case SC_1HZ_WAKEUP_MID: - /* - ** Time to execute a command in the SC memory - */ - do + SC_UpdateNextTime(); + if ((SC_AppData.NextProcNumber == SC_NONE) || + (SC_AppData.NextCmdTime[SC_AppData.NextProcNumber] > SC_AppData.CurrentTime)) + { + SC_OperData.NumCmdsSec = 0; + IsThereAnotherCommandToExecute = false; + } + else /* Command needs to run immediately */ + { + if (SC_OperData.NumCmdsSec >= SC_MAX_CMDS_PER_SEC) { - /* - ** Check to see if there is an ATS switch Pending, if so service it. - */ - if (SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag == true) - { - SC_ServiceSwitchPend(); - } - - if (SC_AppData.NextProcNumber == SC_ATP) - { - SC_ProcessAtpCmd(); - } - else - { - if (SC_AppData.NextProcNumber == SC_RTP) - { - SC_ProcessRtpCommand(); - } - } - - SC_UpdateNextTime(); - if ((SC_AppData.NextProcNumber == SC_NONE) || - (SC_AppData.NextCmdTime[SC_AppData.NextProcNumber] > SC_AppData.CurrentTime)) - { - SC_OperData.NumCmdsSec = 0; - IsThereAnotherCommandToExecute = false; - } - else /* Command needs to run immediately */ - { - if (SC_OperData.NumCmdsSec >= SC_MAX_CMDS_PER_SEC) - { - SC_OperData.NumCmdsSec = 0; - IsThereAnotherCommandToExecute = false; - } - else - { - IsThereAnotherCommandToExecute = true; - } - } - } while (IsThereAnotherCommandToExecute); - - break; - - default: - CFE_EVS_SendEvent(SC_MID_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid command pipe message ID: 0x%08lX", - (unsigned long)CFE_SB_MsgIdToValue(MessageID)); - - SC_OperData.HkPacket.Payload.CmdErrCtr++; - break; - } /* end switch */ + SC_OperData.NumCmdsSec = 0; + IsThereAnotherCommandToExecute = false; + } + else + { + IsThereAnotherCommandToExecute = true; + } + } + } while (IsThereAnotherCommandToExecute); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* Process a command */ +/* No Op Command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr) +void SC_NoOpCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_MSG_FcnCode_t CommandCode = 0; - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - - CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); - CFE_MSG_GetFcnCode(&BufPtr->Msg, &CommandCode); - - switch (CommandCode) - { - case SC_NOOP_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) - { - SC_NoOpCmd(BufPtr); - } - break; - - - case SC_RESET_COUNTERS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) - { - SC_ResetCountersCmd(BufPtr); - } - break; - - case SC_START_ATS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_StartAtsCmd_t))) - { - SC_StartAtsCmd(BufPtr); - } - break; - - case SC_STOP_ATS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) - { - SC_StopAtsCmd(BufPtr); - } - break; - - case SC_START_RTS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) - { - SC_StartRtsCmd(BufPtr); - } - else - { - SC_OperData.HkPacket.Payload.RtsActiveErrCtr++; - } - break; - - case SC_STOP_RTS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) - { - SC_StopRtsCmd(BufPtr); - } - break; - - case SC_DISABLE_RTS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) - { - SC_DisableRtsCmd(BufPtr); - } - break; - - case SC_ENABLE_RTS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) - { - SC_EnableRtsCmd(BufPtr); - } - break; - - case SC_SWITCH_ATS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) - { - SC_GroundSwitchCmd(BufPtr); - } - break; - - case SC_JUMP_ATS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_JumpAtsCmd_t))) - { - SC_JumpAtsCmd(BufPtr); - } - break; - - case SC_CONTINUE_ATS_ON_FAILURE_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_SetContinueAtsOnFailureCmd_t))) - { - SC_ContinueAtsOnFailureCmd(BufPtr); - } - break; - - case SC_APPEND_ATS_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_AppendAtsCmd_t))) - { - SC_AppendAtsCmd(BufPtr); - } - break; - - case SC_MANAGE_TABLE_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) - { - SC_TableManageCmd(BufPtr); - } - break; - - case SC_START_RTS_GRP_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) - { - SC_StartRtsGrpCmd(BufPtr); - } - break; - - case SC_STOP_RTS_GRP_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) - { - SC_StopRtsGrpCmd(BufPtr); - } - break; - - case SC_DISABLE_RTS_GRP_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) - { - SC_DisableRtsGrpCmd(BufPtr); - } - break; - - case SC_ENABLE_RTS_GRP_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) - { - SC_EnableRtsGrpCmd(BufPtr); - } - break; - - default: - CFE_EVS_SendEvent(SC_INVLD_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid Command Code: MID = 0x%08lX CC = %d", - (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode); - SC_OperData.HkPacket.Payload.CmdErrCtr++; - break; - } /* end switch */ + SC_OperData.HkPacket.Payload.CmdCtr++; + CFE_EVS_SendEvent(SC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", + SC_MAJOR_VERSION, SC_MINOR_VERSION, SC_REVISION, SC_MISSION_REV); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/fsw/src/sc_cmds.h b/fsw/src/sc_cmds.h index b469440..256e712 100644 --- a/fsw/src/sc_cmds.h +++ b/fsw/src/sc_cmds.h @@ -108,35 +108,6 @@ void SC_ManageAtsTable(int32 ArrayIndex); */ void SC_ManageTable(SC_TableType type, int32 ArrayIndex); -/** - * \brief Routes commands to be processed - * - * \par Description - * This routine determines the source of a request to - * the Stored Command processor and routes it to one of the lower - * level request processing routines - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param[in] BufPtr Pointer to Software Bus buffer - */ -void SC_ProcessRequest(const CFE_SB_Buffer_t *BufPtr); - -/** - * \brief Processes commands - * - * \par Description - * Process commands. Commands can be from external sources or from SC - * itself. - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param[in] BufPtr Pointer to Software Bus buffer - */ -void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr); - /** * \brief Sends out an Event message * @@ -180,6 +151,9 @@ void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr); */ void SC_SendHkPacket(void); +void SC_SendHkCmd(const CFE_SB_Buffer_t *BufPtr); +void SC_OneHzWakeupCmd(const CFE_SB_Buffer_t *BufPtr); + /** * \brief Process an ATS Command * diff --git a/fsw/src/sc_dispatch.c b/fsw/src/sc_dispatch.c new file mode 100644 index 0000000..7d179e1 --- /dev/null +++ b/fsw/src/sc_dispatch.c @@ -0,0 +1,273 @@ +/************************************************************************ + * NASA Docket No. GSC-18,924-1, and identified as “Core Flight + * System (cFS) Stored Command Application version 3.1.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 the functions to handle processing of ground + * command requests, housekeeping requests, and table updates + */ + +/************************************************************************** + ** + ** Include section + ** + **************************************************************************/ + +#include "cfe.h" +#include "sc_app.h" +#include "sc_atsrq.h" +#include "sc_cmds.h" +#include "sc_dispatch.h" +#include "sc_events.h" +#include "sc_msgids.h" +#include "sc_rtsrq.h" +#include "sc_utils.h" + +/************************************************************************** + ** + ** Functions + ** + **************************************************************************/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* SC Verify the length of the command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength) +{ + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t CommandCode = 0; + bool Result = true; + size_t ActualLength = 0; + + CFE_MSG_GetSize(Msg, &ActualLength); + + /* Verify the command packet length */ + if (ExpectedLength != ActualLength) + { + CFE_MSG_GetMsgId(Msg, &MessageID); + CFE_MSG_GetFcnCode(Msg, &CommandCode); + + CFE_EVS_SendEvent(SC_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); + Result = false; + if (CFE_SB_MsgIdToValue(MessageID) == SC_CMD_MID) + { + SC_OperData.HkPacket.Payload.CmdErrCtr++; + } + } + return (Result); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Process Requests */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SC_ProcessRequest(const CFE_SB_Buffer_t *BufPtr) +{ + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + + /* cast the packet header pointer on the packet buffer */ + CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); + + /* + ** Get the current system time in the global SC_AppData.CurrentTime + */ + SC_GetCurrentTime(); + + switch (CFE_SB_MsgIdToValue(MessageID)) + { + case SC_CMD_MID: + /* request from the ground */ + SC_ProcessCommand(BufPtr); + break; + + case SC_SEND_HK_MID: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_SendHkCmd(BufPtr); + } + break; + + case SC_1HZ_WAKEUP_MID: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_OneHzWakeupCmd(BufPtr); + } + break; + + default: + CFE_EVS_SendEvent(SC_MID_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid command pipe message ID: 0x%08lX", + (unsigned long)CFE_SB_MsgIdToValue(MessageID)); + + SC_OperData.HkPacket.Payload.CmdErrCtr++; + break; + } /* end switch */ +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Process a command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr) +{ + CFE_MSG_FcnCode_t CommandCode = 0; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + + CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); + CFE_MSG_GetFcnCode(&BufPtr->Msg, &CommandCode); + + switch (CommandCode) + { + case SC_NOOP_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_NoOpCmd(BufPtr); + } + break; + + case SC_RESET_COUNTERS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_ResetCountersCmd(BufPtr); + } + break; + + case SC_START_ATS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_StartAtsCmd_t))) + { + SC_StartAtsCmd(BufPtr); + } + break; + + case SC_STOP_ATS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_StopAtsCmd(BufPtr); + } + break; + + case SC_START_RTS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) + { + SC_StartRtsCmd(BufPtr); + } + else + { + SC_OperData.HkPacket.Payload.RtsActiveErrCtr++; + } + break; + + case SC_STOP_RTS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) + { + SC_StopRtsCmd(BufPtr); + } + break; + + case SC_DISABLE_RTS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) + { + SC_DisableRtsCmd(BufPtr); + } + break; + + case SC_ENABLE_RTS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsCmd_t))) + { + SC_EnableRtsCmd(BufPtr); + } + break; + + case SC_SWITCH_ATS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_GroundSwitchCmd(BufPtr); + } + break; + + case SC_JUMP_ATS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_JumpAtsCmd_t))) + { + SC_JumpAtsCmd(BufPtr); + } + break; + + case SC_CONTINUE_ATS_ON_FAILURE_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_SetContinueAtsOnFailureCmd_t))) + { + SC_ContinueAtsOnFailureCmd(BufPtr); + } + break; + + case SC_APPEND_ATS_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_AppendAtsCmd_t))) + { + SC_AppendAtsCmd(BufPtr); + } + break; + + case SC_MANAGE_TABLE_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t))) + { + SC_TableManageCmd(BufPtr); + } + break; + + case SC_START_RTS_GRP_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) + { + SC_StartRtsGrpCmd(BufPtr); + } + break; + + case SC_STOP_RTS_GRP_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) + { + SC_StopRtsGrpCmd(BufPtr); + } + break; + + case SC_DISABLE_RTS_GRP_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) + { + SC_DisableRtsGrpCmd(BufPtr); + } + break; + + case SC_ENABLE_RTS_GRP_CC: + if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_RtsGrpCmd_t))) + { + SC_EnableRtsGrpCmd(BufPtr); + } + break; + + default: + CFE_EVS_SendEvent(SC_INVLD_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid Command Code: MID = 0x%08lX CC = %d", + (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode); + SC_OperData.HkPacket.Payload.CmdErrCtr++; + break; + } /* end switch */ +} diff --git a/fsw/src/sc_dispatch.h b/fsw/src/sc_dispatch.h new file mode 100644 index 0000000..0c779a0 --- /dev/null +++ b/fsw/src/sc_dispatch.h @@ -0,0 +1,82 @@ +/************************************************************************ + * NASA Docket No. GSC-18,924-1, and identified as “Core Flight + * System (cFS) Stored Command Application version 3.1.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 functions to handle dispatching of commands + */ +#ifndef SC_DISPATCH_H +#define SC_DISPATCH_H + +#include "cfe_sb.h" +#include "cfe_msg.h" + +/** + * \brief Verify command message length + * + * \par Description + * This routine will check if the actual length of a software bus + * command message matches the expected length and send an + * error event message if a mismatch occurs + * + * \par Assumptions, External Events, and Notes: + * None + * + * \param [in] Msg Pointer to message + * \param [in] ExpectedLength The expected length of the message + * based upon the command code + * + * \return Boolean length verification result + * \retval true Length matches expected + * \retval false Length does not match expected + * + * \sa #SC_LEN_ERR_EID + */ +bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength); + +/** + * \brief Routes commands to be processed + * + * \par Description + * This routine determines the source of a request to + * the Stored Command processor and routes it to one of the lower + * level request processing routines + * + * \par Assumptions, External Events, and Notes: + * None + * + * \param[in] BufPtr Pointer to Software Bus buffer + */ +void SC_ProcessRequest(const CFE_SB_Buffer_t *BufPtr); + +/** + * \brief Processes commands + * + * \par Description + * Process commands. Commands can be from external sources or from SC + * itself. + * + * \par Assumptions, External Events, and Notes: + * None + * + * \param[in] BufPtr Pointer to Software Bus buffer + */ +void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr); + +#endif diff --git a/fsw/src/sc_utils.c b/fsw/src/sc_utils.c index 10aa943..549c74c 100644 --- a/fsw/src/sc_utils.c +++ b/fsw/src/sc_utils.c @@ -142,39 +142,6 @@ bool SC_CompareAbsTime(SC_AbsTimeTag_t AbsTime1, SC_AbsTimeTag_t AbsTime2) return Status; } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* SC Verify the length of the command */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength) -{ - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - CFE_MSG_FcnCode_t CommandCode = 0; - bool Result = true; - size_t ActualLength = 0; - - CFE_MSG_GetSize(Msg, &ActualLength); - - /* Verify the command packet length */ - if (ExpectedLength != ActualLength) - { - CFE_MSG_GetMsgId(Msg, &MessageID); - CFE_MSG_GetFcnCode(Msg, &CommandCode); - - CFE_EVS_SendEvent(SC_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); - Result = false; - if (CFE_SB_MsgIdToValue(MessageID) == SC_CMD_MID) - { - SC_OperData.HkPacket.Payload.CmdErrCtr++; - } - } - return (Result); -} - uint16 SC_ToggleAtsIndex(void) { uint16 CurrAtsIndex = SC_ATS_NUM_TO_INDEX(SC_OperData.AtsCtrlBlckAddr->AtsNumber); diff --git a/fsw/src/sc_utils.h b/fsw/src/sc_utils.h index fa7572c..b50bf38 100644 --- a/fsw/src/sc_utils.h +++ b/fsw/src/sc_utils.h @@ -89,29 +89,6 @@ SC_AbsTimeTag_t SC_ComputeAbsTime(SC_RelTimeTag_t RelTime); */ bool SC_CompareAbsTime(SC_AbsTimeTag_t AbsTime1, SC_AbsTimeTag_t AbsTime2); -/** - * \brief Verify command message length - * - * \par Description - * This routine will check if the actual length of a software bus - * command message matches the expected length and send an - * error event message if a mismatch occurs - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param [in] Msg Pointer to message - * \param [in] ExpectedLength The expected length of the message - * based upon the command code - * - * \return Boolean length verification result - * \retval true Length matches expected - * \retval false Length does not match expected - * - * \sa #SC_LEN_ERR_EID - */ -bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength); - /** * \brief Toggles the ATS index * diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index b7fef70..7e067e4 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -12,6 +12,7 @@ add_cfe_coverage_stubs("sc_internal" stubs/sc_global_stubs.c stubs/sc_loads_stubs.c stubs/sc_cmds_stubs.c + stubs/sc_dispatch_stubs.c stubs/sc_atsrq_stubs.c stubs/sc_state_stubs.c stubs/sc_app_stubs.c diff --git a/unit-test/sc_cmds_tests.c b/unit-test/sc_cmds_tests.c index 86ac61d..5bd1ace 100644 --- a/unit-test/sc_cmds_tests.c +++ b/unit-test/sc_cmds_tests.c @@ -841,18 +841,18 @@ void SC_SendHkPacket_Test(void) SC_OperData.HkPacket.Payload.LastRtsErrCmd = 12; SC_OperData.HkPacket.Payload.AppendCmdArg = 13; SC_OperData.HkPacket.Payload.AppendEntryCount = 14; - SC_AppData.AppendWordCount = 15; + SC_AppData.AppendWordCount = 15; SC_OperData.HkPacket.Payload.AppendLoadCount = 16; - SC_OperData.AtsInfoTblAddr[0].AtsSize = 0; - SC_OperData.AtsInfoTblAddr[1].AtsSize = 0; - SC_OperData.AtsCtrlBlckAddr->AtsNumber = 17; - SC_OperData.AtsCtrlBlckAddr->AtpState = 18; - SC_OperData.AtsCtrlBlckAddr->CmdNumber = 19; - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = 0; - SC_AppData.NextCmdTime[0] = 0; - SC_AppData.NextCmdTime[1] = 0; - SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 20; - SC_OperData.RtsCtrlBlckAddr->RtsNumber = 21; + SC_OperData.AtsInfoTblAddr[0].AtsSize = 0; + SC_OperData.AtsInfoTblAddr[1].AtsSize = 0; + SC_OperData.AtsCtrlBlckAddr->AtsNumber = 17; + SC_OperData.AtsCtrlBlckAddr->AtpState = 18; + SC_OperData.AtsCtrlBlckAddr->CmdNumber = 19; + SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = 0; + SC_AppData.NextCmdTime[0] = 0; + SC_AppData.NextCmdTime[1] = 0; + SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 20; + SC_OperData.RtsCtrlBlckAddr->RtsNumber = 21; SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = 1; for (i = 0; i < SC_NUMBER_OF_RTS - 1; i++) @@ -924,63 +924,10 @@ void SC_SendHkPacket_Test(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } -void SC_ProcessRequest_Test_CmdMID(void) -{ - /** - ** Test case: SC_CMD_MID - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_NOOP_INF_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - void SC_ProcessRequest_Test_HkMID(void) { - /** - ** Test case: SC_SEND_HK_MID - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); - - /* Verify results */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessRequest_Test_HkMIDNoVerifyCmdLength(void) -{ - /** - ** Test case: SC_SEND_HK_MID - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_SendHkCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -988,23 +935,13 @@ void SC_ProcessRequest_Test_HkMIDNoVerifyCmdLength(void) void SC_ProcessRequest_Test_HkMIDAutoStartRts(void) { - /** - ** Test case: SC_SEND_HK_MID - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); - SC_AppData.AutoStartRTS = 1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_SendHkCmd(&UT_CmdBuf.Buf)); /* Verify results */ - UtAssert_True(SC_AppData.AutoStartRTS == 0, "SC_AppData.AutoStartRTS == 0"); + UtAssert_UINT32_EQ(SC_AppData.AutoStartRTS, 0); UtAssert_BOOL_FALSE(SC_OperData.RtsInfoTblAddr[SC_AppData.AutoStartRTS].DisabledFlag); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -1012,24 +949,14 @@ void SC_ProcessRequest_Test_HkMIDAutoStartRts(void) void SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded(void) { - /** - ** Test case: SC_SEND_HK_MID - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); - SC_AppData.AutoStartRTS = 1; SC_OperData.RtsInfoTblAddr[SC_AppData.AutoStartRTS - 1].RtsStatus = SC_LOADED; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_SendHkCmd(&UT_CmdBuf.Buf)); /* Verify results */ - UtAssert_True(SC_AppData.AutoStartRTS == 0, "SC_AppData.AutoStartRTS == 0"); + UtAssert_UINT32_EQ(SC_AppData.AutoStartRTS, 0); UtAssert_BOOL_FALSE(SC_OperData.RtsInfoTblAddr[SC_AppData.AutoStartRTS].DisabledFlag); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -1037,93 +964,55 @@ void SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded(void) void SC_ProcessRequest_Test_1HzWakeupNONE(void) { - /** - ** Test case: SC_1HZ_WAKEUP_MID with SC_AppData.NextProcNumber == SC_NONE - **/ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = true; SC_AppData.NextProcNumber = SC_NONE; SC_AppData.NextCmdTime[SC_ATP] = 0; SC_AppData.CurrentTime = 0; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_OneHzWakeupCmd(&UT_CmdBuf.Buf)); /* Verify results */ - UtAssert_True(SC_OperData.NumCmdsSec == 0, "SC_OperData.NumCmdsSec == 0"); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRequest_Test_1HzWakeupNoSwitchPending(void) { - /** - ** Test case: SC_1HZ_WAKEUP_MID with SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag == false - **/ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; SC_AppData.NextProcNumber = SC_NONE; SC_AppData.NextCmdTime[SC_ATP] = 0; SC_AppData.CurrentTime = 0; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_OneHzWakeupCmd(&UT_CmdBuf.Buf)); /* Verify results */ - UtAssert_True(SC_OperData.NumCmdsSec == 0, "SC_OperData.NumCmdsSec == 0"); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRequest_Test_1HzWakeupAtpNotExecutionTime(void) { - /** - ** Test case: SC_1HZ_WAKEUP_MID with a pending ATP command that should not execute yet - **/ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = true; SC_AppData.NextProcNumber = SC_ATP; SC_AppData.NextCmdTime[SC_ATP] = 1000; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_OneHzWakeupCmd(&UT_CmdBuf.Buf)); /* Verify results */ - UtAssert_True(SC_OperData.NumCmdsSec == 0, "SC_OperData.NumCmdsSec == 0"); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRequest_Test_1HzWakeupRtpExecutionTime(void) { - /** - ** Test case: SC_1HZ_WAKEUP_MID with a pending RTP command that needs to execute immediately - **/ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); SC_AtsEntryHeader_t *Entry; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - /* required to exit processing loop after 2 iterations */ /* second iteration tests "IsThereAnotherCommandToExecute" */ @@ -1145,7 +1034,7 @@ void SC_ProcessRequest_Test_1HzWakeupRtpExecutionTime(void) SC_AppData.AtsCmdIndexBuffer[0][0] = 0; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_OneHzWakeupCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -1153,18 +1042,8 @@ void SC_ProcessRequest_Test_1HzWakeupRtpExecutionTime(void) void SC_ProcessRequest_Test_1HzWakeupRtpExecutionTimeTooManyCmds(void) { - /** - ** Test case: SC_1HZ_WAKEUP_MID with a pending RTP command that needs to execute immediately, but too many - *commands are being sent at once - **/ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); - SC_AppData.EnableHeaderUpdate = true; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - SC_AppData.NextProcNumber = SC_RTP; SC_AppData.NextCmdTime[SC_RTP] = 0; SC_AppData.NextCmdTime[SC_ATP] = 0; @@ -1172,55 +1051,18 @@ void SC_ProcessRequest_Test_1HzWakeupRtpExecutionTimeTooManyCmds(void) SC_OperData.AtsCtrlBlckAddr->AtpState = SC_EXECUTING; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_OneHzWakeupCmd(&UT_CmdBuf.Buf)); /* Verify results */ - UtAssert_True(SC_OperData.NumCmdsSec == 0, "SC_OperData.NumCmdsSec == 0"); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } -void SC_ProcessRequest_Test_MIDError(void) -{ - /** - ** Test case: SC_MID_ERR_EID - **/ - - CFE_SB_MsgId_t TestMsgId = SC_UT_MID_1; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 1, "CmdErrCtr == 1"); - - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_MID_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - void SC_ProcessCommand_Test_NoOp(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_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_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_NoOpCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1"); @@ -1230,52 +1072,10 @@ void SC_ProcessCommand_Test_NoOp(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } -void SC_ProcessCommand_Test_NoOpNoVerifyCmdLength(void) -{ - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - - 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_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - void SC_ProcessCommand_Test_ResetCounters(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_RESET_COUNTERS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_ResetCountersCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "CmdCtr == 0"); @@ -1291,278 +1091,91 @@ void SC_ProcessCommand_Test_ResetCounters(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } -void SC_ProcessCommand_Test_ResetCountersNoVerifyCmdLength(void) -{ - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_RESET_COUNTERS_CC; - - 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_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); - - /* Verify results */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - void SC_ProcessCommand_Test_StartAts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_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(SC_VerifyCmdLength), true); - UT_CmdBuf.StartAtsCmd.Payload.AtsId = 1; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_StartAtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_StopAts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_STOP_ATS_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_StopAtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_StartRts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_StartRtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_StopRts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_StopRtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_DisableRts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_DisableRtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_EnableRts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_EnableRtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_SwitchAts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_GroundSwitchCmd(&UT_CmdBuf.Buf)); - 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(SC_VerifyCmdLength), true); + /* This function is already verified to work correctly in another file, so no verifications here. */ +} +void SC_ProcessCommand_Test_JumpAts(void) +{ /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_JumpAtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } -void SC_ProcessCommand_Test_JumpAts(void) +void SC_ProcessCommand_Test_ContinueAtsOnFailure(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_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(SC_VerifyCmdLength), true); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_ContinueAtsOnFailure(void) -{ - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_CONTINUE_ATS_ON_FAILURE_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_ContinueAtsOnFailureCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_AppendAts(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_AppendAtsCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageAtsTableNominal(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; Entry->CmdNumber = 0; @@ -1573,35 +1186,20 @@ void SC_ProcessCommand_Test_TableManageAtsTableNominal(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageAtsTableGetAddressError(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_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(SC_VerifyCmdLength), true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_ATS_0; /* Set to generate error message SC_TABLE_MANAGE_ATS_ERR_EID */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, -1); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_ATS_ERR_EID); @@ -1610,21 +1208,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableGetAddressError(void) void SC_ProcessCommand_Test_TableManageAtsTableID(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; Entry->CmdNumber = 0; @@ -1636,7 +1220,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableID(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } @@ -1655,21 +1239,7 @@ void SC_ProcessCommand_Test_TableManageAtsTable_InvalidIndex(void) void SC_ProcessCommand_Test_TableManageAtsTableGetAddressNeverLoaded(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; Entry->CmdNumber = 0; @@ -1679,7 +1249,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableGetAddressNeverLoaded(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_NEVER_LOADED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } @@ -1695,12 +1265,6 @@ void SC_ProcessCommand_Test_TableManageAtsTableGetAddressSuccess(void) **/ SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; Entry->CmdNumber = 0; @@ -1710,7 +1274,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableGetAddressSuccess(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_SUCCESS); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } @@ -1726,12 +1290,6 @@ void SC_ProcessCommand_Test_TableManageAppendTableNominal(void) **/ SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AppendTblAddr; Entry->CmdNumber = 0; @@ -1742,35 +1300,20 @@ void SC_ProcessCommand_Test_TableManageAppendTableNominal(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageAppendTableGetAddressError(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_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(SC_VerifyCmdLength), true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_APPEND; /* Set to generate error message SC_TABLE_MANAGE_APPEND_ERR_EID */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, -1); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_APPEND_ERR_EID); @@ -1788,12 +1331,6 @@ void SC_ProcessCommand_Test_TableManageAppendTableGetAddressNeverLoaded(void) **/ SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AppendTblAddr; Entry->CmdNumber = 0; @@ -1803,7 +1340,7 @@ void SC_ProcessCommand_Test_TableManageAppendTableGetAddressNeverLoaded(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_NEVER_LOADED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } @@ -1819,12 +1356,6 @@ void SC_ProcessCommand_Test_TableManageAppendTableGetAddressSuccess(void) **/ SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AppendTblAddr; Entry->CmdNumber = 0; @@ -1834,63 +1365,33 @@ void SC_ProcessCommand_Test_TableManageAppendTableGetAddressSuccess(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_SUCCESS); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageRtsTableNominal(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_RTS_0; /* Set to reach "SC_LoadRts(ArrayIndex)" */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageRtsTableGetAddressError(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_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(SC_VerifyCmdLength), true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_RTS_0; /* Set to generate error message SC_TABLE_MANAGE_RTS_ERR_EID */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, -1); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_RTS_ERR_EID); @@ -1899,21 +1400,6 @@ void SC_ProcessCommand_Test_TableManageRtsTableGetAddressError(void) void SC_ProcessCommand_Test_TableManageRtsTableID(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - /* test TableID >= SC_TBL_ID_RTS_0 */ UT_CmdBuf.NotifyCmd.Payload.Parameter = 0; @@ -1921,7 +1407,7 @@ void SC_ProcessCommand_Test_TableManageRtsTableID(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } @@ -1940,204 +1426,84 @@ void SC_ProcessCommand_Test_TableManageRtsTable_InvalidIndex(void) void SC_ProcessCommand_Test_TableManageRtsTableGetAddressNeverLoaded(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_RTS_0; UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_NEVER_LOADED); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageRtsTableGetAddressSuccess(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_RTS_0; UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_SUCCESS); /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageRtsInfo(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_RTS_INFO; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageRtpCtrl(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_RTP_CTRL; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageAtsInfo(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_ATS_INFO; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageAtpCtrl(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_ATP_CTRL; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageAtsCmdStatus(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = SC_TBL_ID_ATS_CMD_0; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_TableManageInvalidTableID(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_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(SC_VerifyCmdLength), true); - UT_CmdBuf.NotifyCmd.Payload.Parameter = 999; /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_TableManageCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_ID_ERR_EID); @@ -2146,408 +1512,36 @@ void SC_ProcessCommand_Test_TableManageInvalidTableID(void) void SC_ProcessCommand_Test_StartRtsGrp(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_GRP_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_StartRtsGrpCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_StopRtsGrp(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_GRP_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_StopRtsGrpCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_DisableRtsGrp(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_GRP_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_DisableRtsGrpCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } void SC_ProcessCommand_Test_EnableRtsGrp(void) { - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_GRP_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(SC_VerifyCmdLength), true); - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(SC_EnableRtsGrpCmd(&UT_CmdBuf.Buf)); /* This function is already verified to work correctly in another file, so no verifications here. */ } -void SC_ProcessCommand_Test_StartAtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_StopAtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_STOP_ATS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_StartRtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_StopRtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_DisableRtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_EnableRtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_GroundSwitchInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_JumpAtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_ContinueAtsOnFailureInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_CONTINUE_ATS_ON_FAILURE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_AppendAtsInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_TableManageInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_StartRtsGrpInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_GRP_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_StopRtsGrpInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_GRP_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_DisableRtsGrpInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_GRP_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_EnableRtsGrpInvalidCmdLength(void) -{ - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_GRP_CC; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDeferredRetcode(UT_KEY(SC_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessCommand_Test_InvalidCmdError(void) -{ - /** - ** Note: This test does not follow the standard test guideline to only test what's directly in the - *function-under-test. - ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided - *to - ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. - **/ - - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = 99; - - 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_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 1, "CmdErrCtr == 1"); - - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_INVLD_CMD_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - /* Unreachable branches in sc_cmds.c SC_ProcessAtpCmd:236, 274, 310. There are only 2 ATS IDs defined, invalid IDs are already handled. */ @@ -2594,10 +1588,7 @@ void UtTest_Setup(void) UtTest_Add(SC_ProcessRtpCommand_Test_RtsStatus, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRtpCommand_Test_RtsStatus"); UtTest_Add(SC_SendHkPacket_Test, SC_Test_Setup, SC_Test_TearDown, "SC_SendHkPacket_Test"); - UtTest_Add(SC_ProcessRequest_Test_CmdMID, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_CmdMID"); UtTest_Add(SC_ProcessRequest_Test_HkMID, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_HkMID"); - UtTest_Add(SC_ProcessRequest_Test_HkMIDNoVerifyCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessRequest_Test_HkMIDNoVerifyCmdLength"); UtTest_Add(SC_ProcessRequest_Test_HkMIDAutoStartRts, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_HkMIDAutoStartRts"); UtTest_Add(SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded, SC_Test_Setup, SC_Test_TearDown, @@ -2612,14 +1603,9 @@ void UtTest_Setup(void) "SC_ProcessRequest_Test_1HzWakeupRtpExecutionTime"); UtTest_Add(SC_ProcessRequest_Test_1HzWakeupRtpExecutionTimeTooManyCmds, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_1HzWakeupRtpExecutionTimeTooManyCmds"); - UtTest_Add(SC_ProcessRequest_Test_MIDError, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_MIDError"); UtTest_Add(SC_ProcessCommand_Test_NoOp, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_NoOp"); - UtTest_Add(SC_ProcessCommand_Test_NoOpNoVerifyCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_NoOpNoVerifyCmdLength"); UtTest_Add(SC_ProcessCommand_Test_ResetCounters, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_ResetCounters"); - UtTest_Add(SC_ProcessCommand_Test_ResetCountersNoVerifyCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_ResetCountersNoVerifyCmdLength"); UtTest_Add(SC_ProcessCommand_Test_StartAts, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_StartAts"); UtTest_Add(SC_ProcessCommand_Test_StopAts, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_StopAts"); UtTest_Add(SC_ProcessCommand_Test_StartRts, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_StartRts"); @@ -2682,36 +1668,4 @@ void UtTest_Setup(void) "SC_ProcessCommand_Test_DisableRtsGrp"); UtTest_Add(SC_ProcessCommand_Test_EnableRtsGrp, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_EnableRtsGrp"); - UtTest_Add(SC_ProcessCommand_Test_StartAtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_StartAtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_StopAtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_StopAtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_StartRtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_StartRtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_StopRtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_StopRtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_DisableRtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_DisableRtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_EnableRtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_EnableRtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_GroundSwitchInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_GroundSwitchInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_JumpAtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_JumpAtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_ContinueAtsOnFailureInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_ContinueAtsOnFailureInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_AppendAtsInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_AppendAtsInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_TableManageInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_StartRtsGrpInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_StartRtsGrpInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_StopRtsGrpInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_StopRtsGrpInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_DisableRtsGrpInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_DisableRtsGrpInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_EnableRtsGrpInvalidCmdLength, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_EnableRtsGrpInvalidCmdLength"); - UtTest_Add(SC_ProcessCommand_Test_InvalidCmdError, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_InvalidCmdError"); } diff --git a/unit-test/sc_dispatch_tests.c b/unit-test/sc_dispatch_tests.c new file mode 100644 index 0000000..830fa01 --- /dev/null +++ b/unit-test/sc_dispatch_tests.c @@ -0,0 +1,1028 @@ +/************************************************************************ + * NASA Docket No. GSC-18,924-1, and identified as “Core Flight + * System (cFS) Stored Command Application version 3.1.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. + ************************************************************************/ + +/* + * Includes + */ + +#include "sc_cmds.h" +#include "sc_dispatch.h" +#include "sc_atsrq.h" +#include "sc_rtsrq.h" +#include "sc_state.h" +#include "sc_events.h" +#include "sc_msgids.h" +#include "sc_test_utils.h" +#include "sc_utils.h" +#include "sc_version.h" +#include "cfe_tbl_msg.h" +#include + +/* UT includes */ +#include "uttest.h" +#include "utassert.h" +#include "utstubs.h" + +void UT_SC_Dispatch_MsgSizeHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Size_t *Size = UT_Hook_GetArgValueByName(Context, "Size", CFE_MSG_Size_t *); + CFE_MSG_Size_t *TestCaseMsgSize = UserObj; + + *Size = *TestCaseMsgSize; +} + +void UT_SC_Dispatch_MsgIdHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_MsgId_t *MsgId = UT_Hook_GetArgValueByName(Context, "MsgId", CFE_SB_MsgId_t *); + CFE_SB_MsgId_t *TestCaseMsgId = UserObj; + + *MsgId = *TestCaseMsgId; +} + +void UT_SC_Dispatch_FcnCodeHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_FcnCode_t *FcnCode = UT_Hook_GetArgValueByName(Context, "FcnCode", CFE_MSG_FcnCode_t *); + CFE_MSG_FcnCode_t *TestCaseFcnCode = UserObj; + + *FcnCode = *TestCaseFcnCode; +} + +void UT_SC_Dispatch_SetMsgSize(CFE_MSG_Size_t MsgSize) +{ + static CFE_MSG_Size_t TestCaseMsgSize; + + TestCaseMsgSize = MsgSize; + + UT_SetHandlerFunction(UT_KEY(CFE_MSG_GetSize), UT_SC_Dispatch_MsgSizeHandler, &TestCaseMsgSize); +} + +void UT_SC_Dispatch_SetMsgId(CFE_SB_MsgId_t MsgId) +{ + static CFE_SB_MsgId_t TestCaseMsgId; + + TestCaseMsgId = MsgId; + + UT_SetHandlerFunction(UT_KEY(CFE_MSG_GetMsgId), UT_SC_Dispatch_MsgIdHandler, &TestCaseMsgId); +} + +void UT_SC_Dispatch_SetFcnCode(CFE_MSG_FcnCode_t FcnCode) +{ + static CFE_MSG_FcnCode_t TestCaseFcnCode; + + TestCaseFcnCode = FcnCode; + + UT_SetHandlerFunction(UT_KEY(CFE_MSG_GetFcnCode), UT_SC_Dispatch_FcnCodeHandler, &TestCaseFcnCode); +} + +void SC_VerifyCmdLength_Test_Nominal(void) +{ + SC_NoArgsCmd_t CmdPacket; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + size_t MsgSize = sizeof(CmdPacket); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(MsgSize); + + /* Execute the function being tested */ + UtAssert_BOOL_TRUE(SC_VerifyCmdLength(&CmdPacket.CmdHeader.Msg, sizeof(CmdPacket))); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 0); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); +} + +void SC_VerifyCmdLength_Test_LenError(void) +{ + SC_NoArgsCmd_t CmdPacket; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + size_t MsgSize = sizeof(CmdPacket); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(MsgSize); + + /* Execute the function being tested */ + UtAssert_BOOL_FALSE(SC_VerifyCmdLength(&CmdPacket.CmdHeader.Msg, 999)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +void SC_VerifyCmdLength_Test_LenErrorNotMID(void) +{ + SC_NoArgsCmd_t CmdPacket; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); + CFE_MSG_FcnCode_t FcnCode = 0; + size_t MsgSize = sizeof(CmdPacket); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(MsgSize); + + /* Execute the function being tested */ + UtAssert_BOOL_FALSE(SC_VerifyCmdLength(&CmdPacket.CmdHeader.Msg, 999)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +void SC_ProcessRequest_Test_CmdNominal(void) +{ + /** + ** Test case: SC_CMD_MID + **/ + + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_NoOpCmd, 1); +} + +void SC_ProcessRequest_Test_SendHkNominal(void) +{ + /** + ** Test case: SC_SEND_HK_MID + **/ + + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(0); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(SC_SendHkCmd, 1); +} + +void SC_ProcessRequest_Test_SendHkCmdInvalidLength(void) +{ + /** + ** Test case: SC_SEND_HK_MID + **/ + + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(0); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); + UtAssert_STUB_COUNT(SC_SendHkCmd, 0); +} + +void SC_ProcessRequest_Test_1HzWakeupNominal(void) +{ + /** + ** Test case: SC_1HZ_WAKEUP_MID + **/ + + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(0); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(SC_OneHzWakeupCmd, 1); +} + +void SC_ProcessRequest_Test_1HzWakeupCmdInvalidLength(void) +{ + /** + ** Test case: SC_1HZ_WAKEUP_MID + **/ + + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID); + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(0); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); + UtAssert_STUB_COUNT(SC_OneHzWakeupCmd, 0); +} + +void SC_ProcessRequest_Test_MIDError(void) +{ + /** + ** Test case: SC_MID_ERR_EID + **/ + + CFE_SB_MsgId_t TestMsgId = SC_UT_MID_1; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessRequest(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_MID_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +void SC_ProcessCommand_Test_NoopCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); + UtAssert_STUB_COUNT(SC_NoOpCmd, 0); +} + +void SC_ProcessCommand_Test_ResetCounterCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_RESET_COUNTERS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); + UtAssert_STUB_COUNT(SC_ResetCountersCmd, 0); +} + +void SC_ProcessCommand_Test_StartAtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_StopAtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_STOP_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_StartRtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_StopRtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_DisableRtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_EnableRtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_GroundSwitchCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_JumpAtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_ContinueAtsOnFailureCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_CONTINUE_ATS_ON_FAILURE_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_AppendAtsCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_TableManageCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_StartRtsGrpCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_StopRtsGrpCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_DisableRtsGrpCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_EnableRtsGrpCmdInvalidLength(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(CFE_MSG_Message_t) - 1); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); +} + +void SC_ProcessCommand_Test_NoopCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_NoOpCmd, 1); +} + +void SC_ProcessCommand_Test_ResetCounterCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_RESET_COUNTERS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_ResetCountersCmd, 1); +} + +void SC_ProcessCommand_Test_StartAtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_StartAtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_StartAtsCmd, 1); +} + +void SC_ProcessCommand_Test_StopAtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_STOP_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_StopAtsCmd, 1); +} + +void SC_ProcessCommand_Test_StartRtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_StartRtsCmd, 1); +} + +void SC_ProcessCommand_Test_StopRtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_StopRtsCmd, 1); +} + +void SC_ProcessCommand_Test_DisableRtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_DisableRtsCmd, 1); +} + +void SC_ProcessCommand_Test_EnableRtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_EnableRtsCmd, 1); +} + +void SC_ProcessCommand_Test_GroundSwitchCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_GroundSwitchCmd, 1); +} + +void SC_ProcessCommand_Test_JumpAtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_JumpAtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_JumpAtsCmd, 1); +} + +void SC_ProcessCommand_Test_ContinueAtsOnFailureCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_CONTINUE_ATS_ON_FAILURE_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_SetContinueAtsOnFailureCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_ContinueAtsOnFailureCmd, 1); +} + +void SC_ProcessCommand_Test_AppendAtsCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_AppendAtsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_AppendAtsCmd, 1); +} + +void SC_ProcessCommand_Test_TableManageCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_MANAGE_TABLE_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_NoArgsCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_TableManageCmd, 1); +} + +void SC_ProcessCommand_Test_StartRtsGrpCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsGrpCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_StartRtsGrpCmd, 1); +} + +void SC_ProcessCommand_Test_StopRtsGrpCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_STOP_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsGrpCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_StopRtsGrpCmd, 1); +} + +void SC_ProcessCommand_Test_DisableRtsGrpCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_DISABLE_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsGrpCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_DisableRtsGrpCmd, 1); +} + +void SC_ProcessCommand_Test_EnableRtsGrpCmdNominal(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_ENABLE_RTS_GRP_CC; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + UT_SC_Dispatch_SetMsgSize(sizeof(SC_RtsGrpCmd_t)); + + /* Execute the function being tested */ + SC_ProcessCommand(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_STUB_COUNT(SC_EnableRtsGrpCmd, 1); +} + +void SC_ProcessCommand_Test_InvalidCmdError(void) +{ + /** + ** Note: This test does not follow the standard test guideline to only test what's directly in the + *function-under-test. + ** Since the code for reaching each branch in SC_ProcessCommand is so trivial and non-verifiable, it was decided + *to + ** combine the tests for each command with the tests for reaching the command from SC_ProcessCommand. + **/ + + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = 99; + + UT_SC_Dispatch_SetMsgId(TestMsgId); + UT_SC_Dispatch_SetFcnCode(FcnCode); + + /* Execute the function being tested */ + UtAssert_VOIDCALL(SC_ProcessCommand(&UT_CmdBuf.Buf)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); + UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 1); + + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_INVLD_CMD_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +/* Unreachable branches in sc_cmds.c SC_ProcessAtpCmd:236, 274, 310. + There are only 2 ATS IDs defined, invalid IDs are already handled. */ + +void UtTest_Setup(void) +{ + UtTest_Add(SC_VerifyCmdLength_Test_Nominal, SC_Test_Setup, SC_Test_TearDown, "SC_VerifyCmdLength_Test_Nominal"); + UtTest_Add(SC_VerifyCmdLength_Test_LenError, SC_Test_Setup, SC_Test_TearDown, "SC_VerifyCmdLength_Test_LenError"); + UtTest_Add(SC_VerifyCmdLength_Test_LenErrorNotMID, SC_Test_Setup, SC_Test_TearDown, + "SC_VerifyCmdLength_Test_LenErrorNotMID"); + + UtTest_Add(SC_ProcessRequest_Test_CmdNominal, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_CmdNominal"); + UtTest_Add(SC_ProcessRequest_Test_SendHkNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_SendHkNominal"); + UtTest_Add(SC_ProcessRequest_Test_SendHkCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_SendHkCmdInvalidLength"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupCmdInvalidLength"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupNominal"); + UtTest_Add(SC_ProcessRequest_Test_MIDError, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_MIDError"); +#ifdef jphfix + UtTest_Add(SC_ProcessRequest_Test_HkMIDAutoStartRts, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_HkMIDAutoStartRts"); + UtTest_Add(SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupNONE, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupNONE"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupNoSwitchPending, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupNoSwitchPending"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupAtpNotExecutionTime, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupAtpNotExecutionTime"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupRtpExecutionTime, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupRtpExecutionTime"); + UtTest_Add(SC_ProcessRequest_Test_1HzWakeupRtpExecutionTimeTooManyCmds, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_1HzWakeupRtpExecutionTimeTooManyCmds"); +#endif + + UtTest_Add(SC_ProcessCommand_Test_NoopCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_NoopCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_ResetCounterCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_ResetCounterCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_StartAtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StartAtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_StopAtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StopAtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_StartRtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StartRtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_StopRtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StopRtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_DisableRtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_DisableRtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_EnableRtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_EnableRtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_GroundSwitchCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_GroundSwitchCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_JumpAtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_JumpAtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_ContinueAtsOnFailureCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_ContinueAtsOnFailureCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_AppendAtsCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_AppendAtsCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_TableManageCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_TableManageCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_StartRtsGrpCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StartRtsGrpCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_StopRtsGrpCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StopRtsGrpCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_DisableRtsGrpCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_DisableRtsGrpCmdNominal"); + UtTest_Add(SC_ProcessCommand_Test_EnableRtsGrpCmdNominal, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_EnableRtsGrpCmdNominal"); + + UtTest_Add(SC_ProcessCommand_Test_NoopCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_NoopCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_ResetCounterCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_ResetCounterCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_StartAtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StartAtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_StopAtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StopAtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_StartRtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StartRtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_StopRtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StopRtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_DisableRtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_DisableRtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_EnableRtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_EnableRtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_GroundSwitchCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_GroundSwitchCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_JumpAtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_JumpAtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_ContinueAtsOnFailureCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_ContinueAtsOnFailureCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_AppendAtsCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_AppendAtsCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_TableManageCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_TableManageCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_StartRtsGrpCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StartRtsGrpCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_StopRtsGrpCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_StopRtsGrpCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_DisableRtsGrpCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_DisableRtsGrpCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_EnableRtsGrpCmdInvalidLength, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_EnableRtsGrpCmdInvalidLength"); + UtTest_Add(SC_ProcessCommand_Test_InvalidCmdError, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessCommand_Test_InvalidCmdError"); +} diff --git a/unit-test/sc_utils_tests.c b/unit-test/sc_utils_tests.c index f01b2d2..b991791 100644 --- a/unit-test/sc_utils_tests.c +++ b/unit-test/sc_utils_tests.c @@ -82,69 +82,6 @@ void SC_CompareAbsTime_Test_False(void) UtAssert_BOOL_FALSE(SC_CompareAbsTime(AbsTimeTag1, AbsTimeTag2)); } -void SC_VerifyCmdLength_Test_Nominal(void) -{ - SC_NoArgsCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - size_t MsgSize = sizeof(CmdPacket); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), 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 */ - UtAssert_BOOL_TRUE(SC_VerifyCmdLength(&CmdPacket.CmdHeader.Msg, sizeof(CmdPacket))); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 0, "SC_OperData.HkPacket.Payload.CmdErrCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_VerifyCmdLength_Test_LenError(void) -{ - SC_NoArgsCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - size_t MsgSize = sizeof(CmdPacket); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), 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 */ - UtAssert_BOOL_FALSE(SC_VerifyCmdLength(&CmdPacket.CmdHeader.Msg, 999)); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - UtAssert_True(SC_OperData.HkPacket.Payload.CmdErrCtr == 1, "SC_OperData.HkPacket.Payload.CmdErrCtr == 1"); - - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void SC_VerifyCmdLength_Test_LenErrorNotMID(void) -{ - SC_NoArgsCmd_t CmdPacket; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_SEND_HK_MID); - CFE_MSG_FcnCode_t FcnCode = 0; - size_t MsgSize = sizeof(CmdPacket); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), 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 */ - UtAssert_BOOL_FALSE(SC_VerifyCmdLength(&CmdPacket.CmdHeader.Msg, 999)); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 0, "SC_OperData.HkPacket.Payload.CmdCtr == 0"); - - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - void SC_ToggleAtsIndex_Test(void) { SC_OperData.AtsCtrlBlckAddr->AtsNumber = 1; @@ -163,9 +100,5 @@ void UtTest_Setup(void) UtTest_Add(SC_ComputeAbsTime_Test, SC_Test_Setup, SC_Test_TearDown, "SC_ComputeAbsTime_Test"); UtTest_Add(SC_CompareAbsTime_Test_True, SC_Test_Setup, SC_Test_TearDown, "SC_CompareAbsTime_Test_True"); UtTest_Add(SC_CompareAbsTime_Test_False, SC_Test_Setup, SC_Test_TearDown, "SC_CompareAbsTime_Test_False"); - UtTest_Add(SC_VerifyCmdLength_Test_Nominal, SC_Test_Setup, SC_Test_TearDown, "SC_VerifyCmdLength_Test_Nominal"); - UtTest_Add(SC_VerifyCmdLength_Test_LenError, SC_Test_Setup, SC_Test_TearDown, "SC_VerifyCmdLength_Test_LenError"); - UtTest_Add(SC_VerifyCmdLength_Test_LenErrorNotMID, SC_Test_Setup, SC_Test_TearDown, - "SC_VerifyCmdLength_Test_LenErrorNotMID"); UtTest_Add(SC_ToggleAtsIndex_Test, SC_Test_Setup, SC_Test_TearDown, "SC_ToggleAtsIndex_Test"); } diff --git a/unit-test/stubs/sc_cmds_stubs.c b/unit-test/stubs/sc_cmds_stubs.c index ae892a0..e3b9334 100644 --- a/unit-test/stubs/sc_cmds_stubs.c +++ b/unit-test/stubs/sc_cmds_stubs.c @@ -26,6 +26,18 @@ #include "sc_cmds.h" #include "utgenstub.h" +/* + * ---------------------------------------------------- + * Generated stub function for SC_OneHzWakeupCmd() + * ---------------------------------------------------- + */ +void SC_OneHzWakeupCmd(const CFE_SB_Buffer_t *BufPtr) +{ + UT_GenStub_AddParam(SC_OneHzWakeupCmd, const CFE_SB_Buffer_t *, BufPtr); + + UT_GenStub_Execute(SC_OneHzWakeupCmd, Basic, NULL); +} + /* * ---------------------------------------------------- * Generated stub function for SC_ManageAtsTable() @@ -88,49 +100,37 @@ void SC_ProcessAtpCmd(void) /* * ---------------------------------------------------- - * Generated stub function for SC_ProcessCommand() - * ---------------------------------------------------- - */ -void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr) -{ - UT_GenStub_AddParam(SC_ProcessCommand, const CFE_SB_Buffer_t *, BufPtr); - - UT_GenStub_Execute(SC_ProcessCommand, Basic, NULL); -} - -/* - * ---------------------------------------------------- - * Generated stub function for SC_ProcessRequest() + * Generated stub function for SC_ProcessRtpCommand() * ---------------------------------------------------- */ -void SC_ProcessRequest(const CFE_SB_Buffer_t *BufPtr) +void SC_ProcessRtpCommand(void) { - UT_GenStub_AddParam(SC_ProcessRequest, const CFE_SB_Buffer_t *, BufPtr); - UT_GenStub_Execute(SC_ProcessRequest, Basic, NULL); + UT_GenStub_Execute(SC_ProcessRtpCommand, Basic, NULL); } /* * ---------------------------------------------------- - * Generated stub function for SC_ProcessRtpCommand() + * Generated stub function for SC_ResetCountersCmd() * ---------------------------------------------------- */ -void SC_ProcessRtpCommand(void) +void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) { + UT_GenStub_AddParam(SC_ResetCountersCmd, const CFE_SB_Buffer_t *, BufPtr); - UT_GenStub_Execute(SC_ProcessRtpCommand, Basic, NULL); + UT_GenStub_Execute(SC_ResetCountersCmd, Basic, NULL); } /* * ---------------------------------------------------- - * Generated stub function for SC_ResetCountersCmd() + * Generated stub function for SC_SendHkCmd() * ---------------------------------------------------- */ -void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) +void SC_SendHkCmd(const CFE_SB_Buffer_t *BufPtr) { - UT_GenStub_AddParam(SC_ResetCountersCmd, const CFE_SB_Buffer_t *, BufPtr); + UT_GenStub_AddParam(SC_SendHkCmd, const CFE_SB_Buffer_t *, BufPtr); - UT_GenStub_Execute(SC_ResetCountersCmd, Basic, NULL); + UT_GenStub_Execute(SC_SendHkCmd, Basic, NULL); } /* diff --git a/unit-test/stubs/sc_dispatch_stubs.c b/unit-test/stubs/sc_dispatch_stubs.c new file mode 100644 index 0000000..0cba02e --- /dev/null +++ b/unit-test/stubs/sc_dispatch_stubs.c @@ -0,0 +1,68 @@ +/************************************************************************ + * NASA Docket No. GSC-18,924-1, and identified as “Core Flight + * System (cFS) Stored Command Application version 3.1.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 sc_dispatch header + */ + +#include "sc_dispatch.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for SC_ProcessCommand() + * ---------------------------------------------------- + */ +void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr) +{ + UT_GenStub_AddParam(SC_ProcessCommand, const CFE_SB_Buffer_t *, BufPtr); + + UT_GenStub_Execute(SC_ProcessCommand, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SC_ProcessRequest() + * ---------------------------------------------------- + */ +void SC_ProcessRequest(const CFE_SB_Buffer_t *BufPtr) +{ + UT_GenStub_AddParam(SC_ProcessRequest, const CFE_SB_Buffer_t *, BufPtr); + + UT_GenStub_Execute(SC_ProcessRequest, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SC_VerifyCmdLength() + * ---------------------------------------------------- + */ +bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength) +{ + UT_GenStub_SetupReturnBuffer(SC_VerifyCmdLength, bool); + + UT_GenStub_AddParam(SC_VerifyCmdLength, const CFE_MSG_Message_t *, Msg); + UT_GenStub_AddParam(SC_VerifyCmdLength, size_t, ExpectedLength); + + UT_GenStub_Execute(SC_VerifyCmdLength, Basic, NULL); + + return UT_GenStub_GetReturnValue(SC_VerifyCmdLength, bool); +} diff --git a/unit-test/stubs/sc_utils_stubs.c b/unit-test/stubs/sc_utils_stubs.c index 9b1b224..5c8c10c 100644 --- a/unit-test/stubs/sc_utils_stubs.c +++ b/unit-test/stubs/sc_utils_stubs.c @@ -99,20 +99,3 @@ uint16 SC_ToggleAtsIndex(void) return UT_GenStub_GetReturnValue(SC_ToggleAtsIndex, uint16); } - -/* - * ---------------------------------------------------- - * Generated stub function for SC_VerifyCmdLength() - * ---------------------------------------------------- - */ -bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength) -{ - UT_GenStub_SetupReturnBuffer(SC_VerifyCmdLength, bool); - - UT_GenStub_AddParam(SC_VerifyCmdLength, const CFE_MSG_Message_t *, Msg); - UT_GenStub_AddParam(SC_VerifyCmdLength, size_t, ExpectedLength); - - UT_GenStub_Execute(SC_VerifyCmdLength, Basic, NULL); - - return UT_GenStub_GetReturnValue(SC_VerifyCmdLength, bool); -}