From 56f3d216ecc3ad96cd8b58f34f36380d9b527b2a Mon Sep 17 00:00:00 2001 From: Tvisha Andharia Date: Fri, 13 Dec 2024 07:52:19 -0500 Subject: [PATCH] Fix #84, Removing NextProcNumber --- fsw/src/sc_app.c | 4 +- fsw/src/sc_app.h | 3 +- fsw/src/sc_cmds.c | 26 ++--- fsw/src/sc_state.c | 43 -------- fsw/src/sc_state.h | 12 --- fsw/tables/sc_rts002.c | 3 +- unit-test/sc_app_tests.c | 6 +- unit-test/sc_cmds_tests.c | 164 +++++++++++-------------------- unit-test/sc_state_tests.c | 92 ----------------- unit-test/stubs/sc_state_stubs.c | 10 -- 10 files changed, 77 insertions(+), 286 deletions(-) diff --git a/fsw/src/sc_app.c b/fsw/src/sc_app.c index 729c1eb..2b9e12a 100644 --- a/fsw/src/sc_app.c +++ b/fsw/src/sc_app.c @@ -145,7 +145,7 @@ CFE_Status_t SC_AppInit(void) memset(&SC_AppData, 0, sizeof(SC_AppData)); /* Number of ATS and RTS commands already executed this second */ - SC_OperData.NumCmdsSec = 0; + SC_OperData.NumCmdsWakeup = 0; /* Continue ATS execution if ATS command checksum fails */ SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = SC_CONT_ON_FAILURE_START; @@ -155,8 +155,6 @@ CFE_Status_t SC_AppInit(void) /* assign the time ref accessor from the compile-time option */ SC_AppData.TimeRef = SC_LookupTimeAccessor(SC_TIME_TO_USE); - /* Make sure nothing is running */ - SC_AppData.NextProcNumber = SC_Process_NONE; /* SAD: SC_Process_ATP is 0, within the valid index range of NextCmdTime array, which has 2 elements */ SC_AppData.NextCmdTime[SC_Process_ATP] = SC_MAX_TIME; /* SAD: SC_Process_RTP is 1, within the valid index range of NextCmdTime array, which has 2 elements */ diff --git a/fsw/src/sc_app.h b/fsw/src/sc_app.h index f4fc3fa..ff2839a 100644 --- a/fsw/src/sc_app.h +++ b/fsw/src/sc_app.h @@ -322,7 +322,7 @@ typedef struct int32 AtsDupTestArray[SC_MAX_ATS_CMDS]; /**< \brief ATS test for duplicate cmd numbers */ - uint16 NumCmdsSec; /**< \brief the num of cmds that have gone out in a one second period */ + uint16 NumCmdsWakeup; /**< \brief the num of cmds that have gone out in this wakeup cycle */ SC_HkTlm_t HkPacket; /**< \brief SC Housekeeping structure */ } SC_OperData_t; @@ -368,7 +368,6 @@ typedef struct bool EnableHeaderUpdate; /**< \brief whether to update headers in outgoing messages */ - SC_Process_Enum_t NextProcNumber; /**< \brief the next command processor number */ uint32 NextCmdTime[2]; /**< \brief The overall next command time for ATP (0) and command wakeup count for RTP (1) */ SC_AbsTimeTag_t CurrentTime; /**< \brief this is the current time for SC */ uint32 CurrentWakeupCount; /**< \brief this is the current wakeup count for SC */ diff --git a/fsw/src/sc_cmds.c b/fsw/src/sc_cmds.c index ea145a3..5817aa8 100644 --- a/fsw/src/sc_cmds.c +++ b/fsw/src/sc_cmds.c @@ -75,7 +75,6 @@ void SC_ProcessAtpCmd(void) */ if ((SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_EXECUTING) && - (SC_AppData.NextProcNumber == SC_Process_ATP) && (!SC_CompareAbsTime(SC_AppData.NextCmdTime[SC_Process_ATP], SC_AppData.CurrentTime))) { /* @@ -113,7 +112,7 @@ void SC_ProcessAtpCmd(void) /* ** Count the command for the rate limiter */ - SC_OperData.NumCmdsSec++; + SC_OperData.NumCmdsWakeup++; /* ** First check to see if the command is a switch command, @@ -312,14 +311,13 @@ void SC_ProcessRtpCommand(void) RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - if ((SC_AppData.NextProcNumber == SC_Process_RTP) && - (SC_AppData.NextCmdTime[SC_Process_RTP] <= SC_AppData.CurrentWakeupCount) && (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING)) + if ((SC_AppData.NextCmdTime[SC_Process_RTP] <= SC_AppData.CurrentWakeupCount) && (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING)) { /* ** Count the command for the rate limiter ** even if the command fails */ - SC_OperData.NumCmdsSec++; + SC_OperData.NumCmdsWakeup++; /* ** Get the Command offset within the RTS @@ -543,11 +541,11 @@ void SC_WakeupCmd(const SC_WakeupCmd_t *Cmd) /* * Time to execute a command in the SC memory */ - while (SC_OperData.NumCmdsSec < SC_MAX_CMDS_PER_WAKEUP) + while (SC_OperData.NumCmdsWakeup < SC_MAX_CMDS_PER_WAKEUP) { - SC_UpdateNextTime(); + SC_GetNextRtsTime(); - CurrentNumCmds = SC_OperData.NumCmdsSec; + CurrentNumCmds = SC_OperData.NumCmdsWakeup; /* * Check to see if there is an ATS switch Pending, if so service it. @@ -559,17 +557,21 @@ void SC_WakeupCmd(const SC_WakeupCmd_t *Cmd) SC_ProcessAtpCmd(); - SC_ProcessRtpCommand(); - + if (CurrentNumCmds == SC_OperData.NumCmdsWakeup) + { + SC_ProcessRtpCommand(); + } + /* * No commands could be processed */ - if (CurrentNumCmds == SC_OperData.NumCmdsSec) { + if (CurrentNumCmds == SC_OperData.NumCmdsWakeup) + { break; } } - SC_OperData.NumCmdsSec = 0; + SC_OperData.NumCmdsWakeup = 0; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/fsw/src/sc_state.c b/fsw/src/sc_state.c index d9e71da..f82d7b8 100644 --- a/fsw/src/sc_state.c +++ b/fsw/src/sc_state.c @@ -96,49 +96,6 @@ void SC_GetNextRtsTime(void) } /* end if */ } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Decides whether an RTS or ATS command gets scheduled next */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SC_UpdateNextTime(void) -{ - /* - ** First, find out which RTS needs to run next - */ - SC_GetNextRtsTime(); - - /* - ** Start out with a default, no processors need to run next - */ - SC_AppData.NextProcNumber = SC_Process_NONE; - - /* - ** Check to see if the ATP needs to schedule commands - */ - if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_EXECUTING) - { - SC_AppData.NextProcNumber = SC_Process_ATP; - } - /* - ** Last, check to see if there is an RTS that needs to schedule commands - ** This is determined by the RTS number in the RTP control block - ** If it is zero, there is no RTS that needs to run - */ - if (SC_RtsNumIsValid(SC_OperData.RtsCtrlBlckAddr->CurrRtsNum)) - { - /* - ** If the RTP needs to send commands, only send them if - ** the ATP doesn't - the ATP has priority - */ - - if (SC_AppData.NextProcNumber != SC_Process_ATP) - { - SC_AppData.NextProcNumber = SC_Process_RTP; - } - } /* end if */ -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Gets the next RTS Command */ diff --git a/fsw/src/sc_state.h b/fsw/src/sc_state.h index c751cea..0127f4a 100644 --- a/fsw/src/sc_state.h +++ b/fsw/src/sc_state.h @@ -42,18 +42,6 @@ */ void SC_GetNextRtsTime(void); -/** - * \brief Decides whether the ATS or RTS runs next - * - * \par Description - * This function compares the next command times for the RTS - * and the ATS and decides which one to schedule next. - * - * \par Assumptions, External Events, and Notes: - * None - */ -void SC_UpdateNextTime(void); - /** * \brief Gets the next RTS command to run * diff --git a/fsw/tables/sc_rts002.c b/fsw/tables/sc_rts002.c index 9d1bf53..d250eb6 100644 --- a/fsw/tables/sc_rts002.c +++ b/fsw/tables/sc_rts002.c @@ -81,8 +81,7 @@ SC_RtsTable002_t SC_Rts002 = { /* 3 */ .rts.hdr3.WakeupCount = 5, - .rts.cmd3.CommandHeader = CFE_MSG_CMD_HDR_INIT(SC_CMD_MID, SC_MEMBER_SIZE(cmd3), SC_NOOP_CC, SC_NOOP_CKSUM) - }; + .rts.cmd3.CommandHeader = CFE_MSG_CMD_HDR_INIT(SC_CMD_MID, SC_MEMBER_SIZE(cmd3), SC_NOOP_CC, SC_NOOP_CKSUM)}; /* Macro for table structure */ CFE_TBL_FILEDEF(SC_Rts002, SC.RTS_TBL002, SC Example RTS_TBL002, sc_rts002.tbl) diff --git a/unit-test/sc_app_tests.c b/unit-test/sc_app_tests.c index 59152ca..c1bfdbe 100644 --- a/unit-test/sc_app_tests.c +++ b/unit-test/sc_app_tests.c @@ -146,7 +146,6 @@ void SC_AppInit_Test_NominalPowerOnReset(void) memset(&Expected_SC_OperData, 0, sizeof(Expected_SC_OperData)); memset(&Expected_SC_AppData, 0, sizeof(Expected_SC_AppData)); - Expected_SC_AppData.NextProcNumber = SC_Process_NONE; Expected_SC_AppData.NextCmdTime[SC_Process_ATP] = SC_MAX_TIME; Expected_SC_AppData.NextCmdTime[SC_Process_RTP] = SC_MAX_WAKEUP_CNT; Expected_SC_AppData.AutoStartRTS = SC_RTS_NUM_C(RTS_ID_AUTO_POWER_ON); @@ -183,7 +182,7 @@ void SC_AppInit_Test_NominalPowerOnReset(void) sizeof(Expected_SC_OperData.AtsCmdStatusHandle), "AtsCmdStatusHandle"); UtAssert_MemCmp(&SC_OperData.AtsDupTestArray, &Expected_SC_OperData.AtsDupTestArray, sizeof(Expected_SC_OperData.AtsDupTestArray), "21"); - UtAssert_MemCmp(&SC_OperData.NumCmdsSec, &Expected_SC_OperData.NumCmdsSec, sizeof(Expected_SC_OperData.NumCmdsSec), + UtAssert_MemCmp(&SC_OperData.NumCmdsWakeup, &Expected_SC_OperData.NumCmdsWakeup, sizeof(Expected_SC_OperData.NumCmdsWakeup), "22"); UtAssert_MemCmp(&SC_OperData.HkPacket, &Expected_SC_OperData.HkPacket, sizeof(Expected_SC_OperData.HkPacket), "23"); @@ -210,7 +209,6 @@ void SC_AppInit_Test_Nominal(void) memset(&Expected_SC_OperData, 0, sizeof(Expected_SC_OperData)); memset(&Expected_SC_AppData, 0, sizeof(Expected_SC_AppData)); - Expected_SC_AppData.NextProcNumber = SC_Process_NONE; Expected_SC_AppData.NextCmdTime[SC_Process_ATP] = SC_MAX_TIME; Expected_SC_AppData.NextCmdTime[SC_Process_RTP] = SC_MAX_WAKEUP_CNT; Expected_SC_AppData.AutoStartRTS = SC_RTS_NUM_C(RTS_ID_AUTO_PROCESSOR); @@ -247,7 +245,7 @@ void SC_AppInit_Test_Nominal(void) sizeof(Expected_SC_OperData.AtsCmdStatusHandle), "AtsCmdStatusHandle"); UtAssert_MemCmp(&SC_OperData.AtsDupTestArray, &Expected_SC_OperData.AtsDupTestArray, sizeof(Expected_SC_OperData.AtsDupTestArray), "21"); - UtAssert_MemCmp(&SC_OperData.NumCmdsSec, &Expected_SC_OperData.NumCmdsSec, sizeof(Expected_SC_OperData.NumCmdsSec), + UtAssert_MemCmp(&SC_OperData.NumCmdsWakeup, &Expected_SC_OperData.NumCmdsWakeup, sizeof(Expected_SC_OperData.NumCmdsWakeup), "22"); UtAssert_MemCmp(&SC_OperData.HkPacket, &Expected_SC_OperData.HkPacket, sizeof(Expected_SC_OperData.HkPacket), "23"); diff --git a/unit-test/sc_cmds_tests.c b/unit-test/sc_cmds_tests.c index 6600add..d3962f3 100644 --- a/unit-test/sc_cmds_tests.c +++ b/unit-test/sc_cmds_tests.c @@ -50,15 +50,6 @@ int32 Ut_CFE_TIME_CompareHookAlessthanB(void *UserObj, int32 StubRetcode, uint32 return CFE_TIME_A_LT_B; } -uint8 SC_CMDS_TEST_SC_UpdateNextTimeHook_RunCount; -int32 Ut_SC_UpdateNextTimeHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) -{ - if (SC_CMDS_TEST_SC_UpdateNextTimeHook_RunCount++) - SC_AppData.NextProcNumber = SC_Process_NONE; - - return 0; -} - void SC_ProcessAtpCmd_Test_SwitchCmd(void) { SC_AtsEntryHeader_t * Entry; @@ -74,7 +65,6 @@ void SC_ProcessAtpCmd_Test_SwitchCmd(void) Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); @@ -102,7 +92,7 @@ void SC_ProcessAtpCmd_Test_SwitchCmd(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EXECUTED); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -122,7 +112,6 @@ void SC_ProcessAtpCmd_Test_NonSwitchCmd(void) Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); @@ -150,7 +139,7 @@ void SC_ProcessAtpCmd_Test_NonSwitchCmd(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EXECUTED); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -170,7 +159,6 @@ void SC_ProcessAtpCmd_Test_InlineSwitchError(void) Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); @@ -199,7 +187,7 @@ void SC_ProcessAtpCmd_Test_InlineSwitchError(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_DISTRIB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, 1); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); @@ -224,7 +212,6 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsA(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); @@ -249,7 +236,7 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsA(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_DISTRIB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSA); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); @@ -276,7 +263,6 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsB(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSB); @@ -301,7 +287,7 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsB(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_DISTRIB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); @@ -329,7 +315,6 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsA(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); @@ -385,7 +370,6 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsB(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSB); @@ -441,7 +425,6 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsAContinue(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); @@ -494,7 +477,6 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsA(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); @@ -531,7 +513,6 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsB(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSB); @@ -566,7 +547,6 @@ void SC_ProcessAtpCmd_Test_CmdNotLoaded(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); @@ -599,7 +579,6 @@ void SC_ProcessAtpCmd_Test_CompareAbsTime(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); @@ -618,34 +597,6 @@ void SC_ProcessAtpCmd_Test_CompareAbsTime(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } -void SC_ProcessAtpCmd_Test_NextProcNumber(void) -{ - SC_AtsEntryHeader_t * Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - - CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); - Entry->CmdNumber = SC_COMMAND_NUM_C(1); - - SC_AppData.NextCmdTime[SC_Process_ATP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_NONE; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); - SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessAtpCmd()); - - /* Verify results */ - UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - void SC_ProcessAtpCmd_Test_AtpState(void) { SC_AtsEntryHeader_t * Entry; @@ -658,7 +609,6 @@ void SC_ProcessAtpCmd_Test_AtpState(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EMPTY; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); @@ -690,7 +640,6 @@ void SC_ProcessAtpCmd_Test_CmdMid(void) Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); @@ -717,7 +666,7 @@ void SC_ProcessAtpCmd_Test_CmdMid(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 1"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EXECUTED); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -731,7 +680,6 @@ void SC_ProcessRtpCommand_Test_Nominal(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -743,7 +691,7 @@ void SC_ProcessRtpCommand_Test_Nominal(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdCtr == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 0, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 0"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 1); UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 0); @@ -759,7 +707,6 @@ void SC_ProcessRtpCommand_Test_BadSoftwareBusReturn(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -774,7 +721,7 @@ void SC_ProcessRtpCommand_Test_BadSoftwareBusReturn(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.RtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 1); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrSeq, 1); @@ -794,7 +741,6 @@ void SC_ProcessRtpCommand_Test_BadChecksum(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -810,7 +756,7 @@ void SC_ProcessRtpCommand_Test_BadChecksum(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.RtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); + UtAssert_True(SC_OperData.NumCmdsWakeup == 1, "SC_OperData.NumCmdsWakeup == 1"); UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 1); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrSeq, 1); @@ -829,27 +775,6 @@ void SC_ProcessRtpCommand_Test_NextCmdTime(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 1; SC_AppData.CurrentTime = 0; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ProcessRtpCommand()); - - /* Verify results */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_ProcessRtpCommand_Test_ProcNumber(void) -{ - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); - SC_RtsInfoEntry_t *RtsInfoPtr; - - RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_NONE; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -864,7 +789,6 @@ void SC_ProcessRtpCommand_Test_RtsNumZero(void) { SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(0); /* CurrRtsNum > 0 will be false so nothing should happen, branch coverage */ @@ -878,7 +802,6 @@ void SC_ProcessRtpCommand_Test_RtsNumHigh(void) { SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(SC_NUMBER_OF_RTS + 1); /* Execute the function being tested */ @@ -897,7 +820,6 @@ void SC_ProcessRtpCommand_Test_RtsStatus(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EMPTY; @@ -1075,7 +997,6 @@ void SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded(void) void SC_ProcessRequest_Test_WakeupNONE(void) { SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = true; - SC_AppData.NextProcNumber = SC_Process_NONE; SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 0; @@ -1083,7 +1004,7 @@ void SC_ProcessRequest_Test_WakeupNONE(void) UtAssert_VOIDCALL(SC_WakeupCmd(&UT_CmdBuf.WakeupCmd)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -1091,7 +1012,6 @@ void SC_ProcessRequest_Test_WakeupNONE(void) void SC_ProcessRequest_Test_WakeupRtpNotExecutionTime(void) { SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_AppData.NextCmdTime[SC_Process_RTP] = 2; SC_AppData.CurrentWakeupCount = 0; @@ -1099,7 +1019,7 @@ void SC_ProcessRequest_Test_WakeupRtpNotExecutionTime(void) UtAssert_VOIDCALL(SC_WakeupCmd(&UT_CmdBuf.WakeupCmd)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -1107,7 +1027,6 @@ void SC_ProcessRequest_Test_WakeupRtpNotExecutionTime(void) void SC_ProcessRequest_Test_WakeupNoSwitchPending(void) { SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; - SC_AppData.NextProcNumber = SC_Process_NONE; SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 0; @@ -1115,7 +1034,7 @@ void SC_ProcessRequest_Test_WakeupNoSwitchPending(void) UtAssert_VOIDCALL(SC_WakeupCmd(&UT_CmdBuf.WakeupCmd)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -1123,14 +1042,13 @@ void SC_ProcessRequest_Test_WakeupNoSwitchPending(void) void SC_ProcessRequest_Test_WakeupAtpNotExecutionTime(void) { SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = true; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_AppData.NextCmdTime[SC_Process_ATP] = 1000; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_WakeupCmd(&UT_CmdBuf.WakeupCmd)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -1144,7 +1062,6 @@ void SC_ProcessRequest_Test_WakeupRtpExecutionTime(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentWakeupCount = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -1157,38 +1074,75 @@ void SC_ProcessRequest_Test_WakeupRtpExecutionTime(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } +void SC_ProcessRequest_Test_WakeupAtpExecutionTime(void) +{ + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + SC_AppData.NextCmdTime[SC_Process_ATP] = 0; + SC_AppData.CurrentTime = 0; + SC_OperData.NumCmdsWakeup = 0; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); + Entry->CmdNumber = SC_COMMAND_NUM_C(1); + + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); + + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; + + SC_AppData.EnableHeaderUpdate = true; + + 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_WakeupCmd(&UT_CmdBuf.WakeupCmd)); + + /* Verify results */ + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); +} + void SC_ProcessRequest_Test_WakeupRtpExecutionTimeTooManyCmds(void) { SC_AppData.EnableHeaderUpdate = true; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.NextCmdTime[SC_Process_ATP] = 0; - SC_OperData.NumCmdsSec = 1000; + SC_OperData.NumCmdsWakeup = 1000; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_WakeupCmd(&UT_CmdBuf.WakeupCmd)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRequest_Test_WakeupAtpExecutionTimeTooManyCmds(void) { - SC_AppData.NextProcNumber = SC_Process_ATP; SC_AppData.NextCmdTime[SC_Process_ATP] = 10; SC_AppData.CurrentTime = 100; - SC_OperData.NumCmdsSec = 1000; + SC_OperData.NumCmdsWakeup = 1000; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_WakeupCmd(&UT_CmdBuf.WakeupCmd)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.NumCmdsSec, 0); + UtAssert_UINT32_EQ(SC_OperData.NumCmdsWakeup, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -1705,8 +1659,6 @@ void UtTest_Setup(void) "SC_ProcessAtpCmd_Test_CmdNotLoaded"); UtTest_Add(SC_ProcessAtpCmd_Test_CompareAbsTime, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessAtpCmd_Test_CompareAbsTime"); - UtTest_Add(SC_ProcessAtpCmd_Test_NextProcNumber, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessAtpCmd_Test_NextProcNumber"); UtTest_Add(SC_ProcessAtpCmd_Test_AtpState, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessAtpCmd_Test_AtpState"); UtTest_Add(SC_ProcessAtpCmd_Test_CmdMid, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessAtpCmd_Test_CmdMid"); UtTest_Add(SC_ProcessRtpCommand_Test_Nominal, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRtpCommand_Test_Nominal"); @@ -1716,8 +1668,6 @@ void UtTest_Setup(void) "SC_ProcessRtpCommand_Test_BadChecksum"); UtTest_Add(SC_ProcessRtpCommand_Test_NextCmdTime, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRtpCommand_Test_NextCmdTime"); - UtTest_Add(SC_ProcessRtpCommand_Test_ProcNumber, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessRtpCommand_Test_ProcNumber"); UtTest_Add(SC_ProcessRtpCommand_Test_RtsNumZero, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRtpCommand_Test_RtsNumZero"); UtTest_Add(SC_ProcessRtpCommand_Test_RtsNumHigh, SC_Test_Setup, SC_Test_TearDown, @@ -1740,6 +1690,8 @@ void UtTest_Setup(void) "SC_ProcessRequest_Test_WakeupAtpNotExecutionTime"); UtTest_Add(SC_ProcessRequest_Test_WakeupRtpExecutionTime, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_WakeupRtpExecutionTime"); + UtTest_Add(SC_ProcessRequest_Test_WakeupAtpExecutionTime, SC_Test_Setup, SC_Test_TearDown, + "SC_ProcessRequest_Test_WakeupAtpExecutionTime"); UtTest_Add(SC_ProcessRequest_Test_WakeupRtpExecutionTimeTooManyCmds, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessRequest_Test_WakeupRtpExecutionTimeTooManyCmds"); UtTest_Add(SC_ProcessRequest_Test_WakeupAtpExecutionTimeTooManyCmds, SC_Test_Setup, SC_Test_TearDown, diff --git a/unit-test/sc_state_tests.c b/unit-test/sc_state_tests.c index 15b1fdb..04153b6 100644 --- a/unit-test/sc_state_tests.c +++ b/unit-test/sc_state_tests.c @@ -121,80 +121,6 @@ void SC_GetNextRtsTime_Test_RtsPriority(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } -void SC_UpdateNextTime_Test_Atp(void) -{ - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_UpdateNextTime()); - - /* Verify results */ - UtAssert_True(SC_AppData.NextProcNumber == SC_Process_ATP, "SC_AppData.NextProcNumber == SC_Process_ATP"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_UpdateNextTime_Test_Atp2(void) -{ - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(SC_NUMBER_OF_RTS + 1); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.NextCmdTime[SC_Process_ATP] = 10; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_UpdateNextTime()); - - /* Verify results */ - UtAssert_True(SC_AppData.NextProcNumber == SC_Process_ATP, "SC_AppData.NextProcNumber == SC_Process_ATP"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_UpdateNextTime_Test_Rtp(void) -{ - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); - SC_RtsInfoEntry_t *RtsInfoPtr; - - RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(10); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.NextCmdTime[SC_Process_ATP] = 10; - - RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - RtsInfoPtr->NextCommandTgtWakeup = 1; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_UpdateNextTime()); - - /* Verify results */ - UtAssert_True(SC_AppData.NextProcNumber == SC_Process_RTP, "SC_AppData.NextProcNumber == SC_Process_RTP"); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - -void SC_UpdateNextTime_Test_RtpAtpPriority(void) -{ - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); - SC_RtsInfoEntry_t *RtsInfoPtr; - - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.NextCmdTime[SC_Process_ATP] = 0; - - RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - RtsInfoPtr->NextCommandTgtWakeup = 1; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_UpdateNextTime()); - - /* Verify results */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); -} - void SC_GetNextRtsCommand_Test_GetNextCommand(void) { size_t MsgSize; @@ -208,7 +134,6 @@ void SC_GetNextRtsCommand_Test_GetNextCommand(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(1); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; AtsInfoPtr->NumberOfCommands = 1; @@ -253,7 +178,6 @@ void SC_GetNextRtsCommand_Test_RtsNumMax(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; AtsInfoPtr->NumberOfCommands = 1; @@ -284,7 +208,6 @@ void SC_GetNextRtsCommand_Test_RtsNumOverMax(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(SC_NUMBER_OF_RTS + 1); AtsInfoPtr->NumberOfCommands = 1; @@ -317,7 +240,6 @@ void SC_GetNextRtsCommand_Test_RtsNotExecuting(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_IDLE; AtsInfoPtr->NumberOfCommands = 1; @@ -354,7 +276,6 @@ void SC_GetNextRtsCommand_Test_RtsLengthError(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -407,7 +328,6 @@ void SC_GetNextRtsCommand_Test_CommandLengthError(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -460,7 +380,6 @@ void SC_GetNextRtsCommand_Test_ZeroCommandLength(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -509,7 +428,6 @@ void SC_GetNextRtsCommand_Test_ZeroCommandLengthLastRts(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -554,7 +472,6 @@ void SC_GetNextRtsCommand_Test_EndOfBuffer(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -600,7 +517,6 @@ void SC_GetNextRtsCommand_Test_EndOfBufferLastRts(void) SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; @@ -677,7 +593,6 @@ void SC_GetNextAtsCommand_Test_GetNextCommand(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(0))->CmdNum = SC_COMMAND_NUM_C(1); @@ -715,7 +630,6 @@ void SC_GetNextAtsCommand_Test_ExecutionACompleted(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(2); @@ -747,7 +661,6 @@ void SC_GetNextAtsCommand_Test_ExecutionBCompleted(void) SC_AppData.NextCmdTime[SC_Process_ATP] = 0; SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); @@ -771,11 +684,6 @@ void UtTest_Setup(void) "SC_GetNextRtsTime_Test_InvalidRtsNum"); UtTest_Add(SC_GetNextRtsTime_Test_RtsPriority, SC_Test_Setup, SC_Test_TearDown, "SC_GetNextRtsTime_Test_RtsPriority"); - UtTest_Add(SC_UpdateNextTime_Test_Atp, SC_Test_Setup, SC_Test_TearDown, "SC_UpdateNextTime_Test_Atp"); - UtTest_Add(SC_UpdateNextTime_Test_Atp2, SC_Test_Setup, SC_Test_TearDown, "SC_UpdateNextTime_Test_Atp2"); - UtTest_Add(SC_UpdateNextTime_Test_Rtp, SC_Test_Setup, SC_Test_TearDown, "SC_UpdateNextTime_Test_Rtp"); - UtTest_Add(SC_UpdateNextTime_Test_RtpAtpPriority, SC_Test_Setup, SC_Test_TearDown, - "SC_UpdateNextTime_Test_RtpAtpPriority"); UtTest_Add(SC_GetNextRtsCommand_Test_GetNextCommand, SC_Test_Setup, SC_Test_TearDown, "SC_GetNextRtsCommand_Test_GetNextCommand"); UtTest_Add(SC_GetNextRtsCommand_Test_RtsNumZero, SC_Test_Setup, SC_Test_TearDown, diff --git a/unit-test/stubs/sc_state_stubs.c b/unit-test/stubs/sc_state_stubs.c index 7484074..87e842e 100644 --- a/unit-test/stubs/sc_state_stubs.c +++ b/unit-test/stubs/sc_state_stubs.c @@ -55,13 +55,3 @@ void SC_GetNextRtsTime(void) { UT_GenStub_Execute(SC_GetNextRtsTime, Basic, NULL); } - -/* - * ---------------------------------------------------- - * Generated stub function for SC_UpdateNextTime() - * ---------------------------------------------------- - */ -void SC_UpdateNextTime(void) -{ - UT_GenStub_Execute(SC_UpdateNextTime, Basic, NULL); -}