From d233e9ed064d4b3aa356b9daea12eb0da969ae0e Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Mon, 30 Jun 2025 17:16:56 +0200 Subject: [PATCH] Fix #45, simplify by managing tables every app cycle --- config/default_sc_fcncodes.h | 36 --- config/default_sc_msgstruct.h | 10 - config/default_sc_tbldefs.h | 13 - fsw/inc/sc_events.h | 22 -- fsw/src/sc_app.c | 88 ++++--- fsw/src/sc_app.h | 19 +- fsw/src/sc_cmds.c | 177 ------------- fsw/src/sc_cmds.h | 80 ------ fsw/src/sc_dispatch.c | 7 - unit-test/sc_app_tests.c | 164 ++++++++++++ unit-test/sc_cmds_tests.c | 384 ---------------------------- unit-test/sc_dispatch_tests.c | 40 --- unit-test/stubs/sc_app_stubs.c | 6 +- unit-test/stubs/sc_cmds_stubs.c | 49 ---- unit-test/utilities/sc_test_utils.h | 1 - 15 files changed, 231 insertions(+), 865 deletions(-) diff --git a/config/default_sc_fcncodes.h b/config/default_sc_fcncodes.h index a3c7356..e4a3c71 100644 --- a/config/default_sc_fcncodes.h +++ b/config/default_sc_fcncodes.h @@ -408,42 +408,6 @@ */ #define SC_APPEND_ATS_CC 11 -/** - * \brief Request from cFE Table Services to manage a table - * - * \par Description - * This command signals a need for the host application (SC) - * to allow cFE Table Services to manage the specified table. - * For loadable tables, this command indicates that a table - * update is available. For dump only tables, this command - * indicates that cFE Table Services wants to dump the table - * data. In either case, the host application must call the - * table manage API function so that the pending function - * can be executed within the context of the host. - * - * Note: There is no reason for this command to be sent from - * any source other than cFE Table Services. - * - * \par Command Structure - * #SC_ManageTableCmd_t - * - * \par Command Verification - * Successful execution of this command may be verified via: - * - cFE Table Services housekeeping telemetry - * - * \par Error Conditions - * This command may fail for the following reason(s): - * - Invalid table ID - * - Unexpected result during manage of loadable table - * - * \par Evidence of failure for this command may be verified via: - * - cFE Table Services housekeeping telemetry - * - Error specific SC event message - * - * \par Criticality - * None - */ -#define SC_MANAGE_TABLE_CC 12 /** * \brief START a group of RTS diff --git a/config/default_sc_msgstruct.h b/config/default_sc_msgstruct.h index 087df62..dc7d38f 100644 --- a/config/default_sc_msgstruct.h +++ b/config/default_sc_msgstruct.h @@ -226,16 +226,6 @@ typedef struct SC_SetContinueAtsOnFailureCmd_Payload_t Payload; } SC_ContinueAtsOnFailureCmd_t; -/** - * \brief Manage Table Command - * - * For command details see #SC_MANAGE_TABLE_CC - */ -typedef struct -{ - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - CFE_TBL_NotifyCmd_Payload_t Payload; -} SC_ManageTableCmd_t; /** * \brief RTS Group Command diff --git a/config/default_sc_tbldefs.h b/config/default_sc_tbldefs.h index ad4b67c..a278b80 100644 --- a/config/default_sc_tbldefs.h +++ b/config/default_sc_tbldefs.h @@ -36,19 +36,6 @@ #define SC_ATS_HEADER_SIZE (sizeof(SC_AtsEntryHeader_t)) /**< \brief ATS header size in bytes */ #define SC_RTS_HEADER_SIZE (sizeof(SC_RtsEntryHeader_t)) /**< \brief RTS header size in bytes */ -/** - * \defgroup cfscstblids ID definitions for cFE Table Services manage table request command - * \{ - */ -#define SC_TBL_ID_ATS_0 (1) /**< \brief ATS 0 Table ID */ -#define SC_TBL_ID_APPEND (SC_TBL_ID_ATS_0 + SC_NUMBER_OF_ATS) /**< \brief Append Table ID */ -#define SC_TBL_ID_RTS_0 (SC_TBL_ID_APPEND + 1) /**< \brief RTS 0 Table ID */ -#define SC_TBL_ID_RTS_INFO (SC_TBL_ID_RTS_0 + SC_NUMBER_OF_RTS) /**< \brief RTS Info Table ID */ -#define SC_TBL_ID_RTP_CTRL (SC_TBL_ID_RTS_INFO + 1) /**< \brief RTS Control Table ID */ -#define SC_TBL_ID_ATS_INFO (SC_TBL_ID_RTP_CTRL + 1) /**< \brief ATS Info Table ID */ -#define SC_TBL_ID_ATP_CTRL (SC_TBL_ID_ATS_INFO + 1) /**< \brief ATS Control Table ID */ -#define SC_TBL_ID_ATS_CMD_0 (SC_TBL_ID_ATP_CTRL + 1) /**< \brief ATS 0 Command Table ID */ -/**\}*/ /************************************************************************ * Type Definitions diff --git a/fsw/inc/sc_events.h b/fsw/inc/sc_events.h index 052f572..2f876bf 100644 --- a/fsw/inc/sc_events.h +++ b/fsw/inc/sc_events.h @@ -1244,28 +1244,6 @@ */ #define SC_BEGINATS_INVLD_INDEX_ERR_EID 128 -/** - * \brief SC RTS Table Manage RTS Index Invalid Event ID - * - * \par Type: ERROR - * - * \par Cause: - * This event message is issued when an invalid RTS index is received - * in the SC_ManageRtsTable function - */ -#define SC_TABLE_MANAGE_RTS_INV_INDEX_ERR_EID 129 - -/** - * \brief SC ATS Table Manage ATS Index Invalid Event ID - * - * \par Type: ERROR - * - * \par Cause: - * This event message is issued when an invalid ATS index is received - * in the SC_ManageAtsTable function - */ -#define SC_TABLE_MANAGE_ATS_INV_INDEX_ERR_EID 130 - /** * \brief SC ATS Table Load ATS Index Invalid Event ID * diff --git a/fsw/src/sc_app.c b/fsw/src/sc_app.c index 2b9e12a..9f6a66b 100644 --- a/fsw/src/sc_app.c +++ b/fsw/src/sc_app.c @@ -103,7 +103,8 @@ void SC_AppMain(void) } else if (Result == CFE_SB_TIME_OUT) { - /* no action, but also no error */ + /* Perform table maintenance when no other work to do */ + SC_ManageTables(); } else { @@ -301,9 +302,6 @@ CFE_Status_t SC_InitTables(void) return Result; } - /* Register for table update notification commands */ - SC_RegisterManageCmds(); - return CFE_SUCCESS; } @@ -572,42 +570,74 @@ void SC_LoadDefaultTables(void) "RTS table files not loaded at initialization = %d of %d", (int)NotLoadedCount, SC_NUMBER_OF_RTS); } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Register to receive cFE table manage request commands */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -void SC_RegisterManageCmds(void) +void SC_ManageTables(void) { - int32 i; + CFE_Status_t GetAddressResult; + uint16 i; + void *TblPtrNew; - CFE_TBL_Handle_t TblHandles[5] = {SC_OperData.RtsInfoHandle, SC_OperData.RtsCtrlBlckHandle, - SC_OperData.AtsInfoHandle, SC_OperData.AtsCtrlBlckHandle, - SC_OperData.AppendTblHandle}; - uint32 params[5] = {SC_TBL_ID_RTS_INFO, SC_TBL_ID_RTP_CTRL, SC_TBL_ID_ATS_INFO, SC_TBL_ID_ATP_CTRL, - SC_TBL_ID_APPEND}; + /* Dump-only tables */ + CFE_TBL_Manage(SC_OperData.RtsInfoHandle); + CFE_TBL_Manage(SC_OperData.RtsCtrlBlckHandle); + CFE_TBL_Manage(SC_OperData.AtsInfoHandle); + CFE_TBL_Manage(SC_OperData.AtsCtrlBlckHandle); - for (i = 0; i < 5; i++) + /* ATS Command Status tables */ + for (i = 0; i < SC_NUMBER_OF_ATS; i++) { - CFE_TBL_NotifyByMessage(TblHandles[i], CFE_SB_ValueToMsgId(SC_CMD_MID), SC_MANAGE_TABLE_CC, params[i]); + CFE_TBL_Manage(SC_OperData.AtsCmdStatusHandle[i]); } - for (i = 0; i < SC_NUMBER_OF_ATS; i++) + /* ATS Append table */ + CFE_TBL_ReleaseAddress(SC_OperData.AppendTblHandle); + CFE_TBL_Manage(SC_OperData.AppendTblHandle); + GetAddressResult = CFE_TBL_GetAddress(&TblPtrNew, SC_OperData.AppendTblHandle); + SC_OperData.AppendTblAddr = TblPtrNew; + if (GetAddressResult == CFE_TBL_INFO_UPDATED) { - /* Register for ATS cmd status table manage request commands */ - CFE_TBL_NotifyByMessage(SC_OperData.AtsCmdStatusHandle[i], CFE_SB_ValueToMsgId(SC_CMD_MID), SC_MANAGE_TABLE_CC, - SC_TBL_ID_ATS_CMD_0 + i); + SC_UpdateAppend(); + } + else if ((GetAddressResult != CFE_SUCCESS) && (GetAddressResult != CFE_TBL_ERR_NEVER_LOADED)) + { + CFE_EVS_SendEvent(SC_TABLE_MANAGE_APPEND_ERR_EID, CFE_EVS_EventType_ERROR, + "ATS Append table manage process error: Result = 0x%X", (unsigned int)GetAddressResult); + } - /* Register for ATS table manage request commands */ - CFE_TBL_NotifyByMessage(SC_OperData.AtsTblHandle[i], CFE_SB_ValueToMsgId(SC_CMD_MID), SC_MANAGE_TABLE_CC, - SC_TBL_ID_ATS_0 + i); + /* ATS tables */ + for (i = 0; i < SC_NUMBER_OF_ATS; i++) + { + CFE_TBL_ReleaseAddress(SC_OperData.AtsTblHandle[i]); + CFE_TBL_Manage(SC_OperData.AtsTblHandle[i]); + GetAddressResult = CFE_TBL_GetAddress(&TblPtrNew, SC_OperData.AtsTblHandle[i]); + SC_OperData.AtsTblAddr[i] = TblPtrNew; + if (GetAddressResult == CFE_TBL_INFO_UPDATED) + { + SC_LoadAts(SC_ATS_IDX_C(i)); + } + else if ((GetAddressResult != CFE_SUCCESS) && (GetAddressResult != CFE_TBL_ERR_NEVER_LOADED)) + { + CFE_EVS_SendEvent(SC_TABLE_MANAGE_ATS_ERR_EID, CFE_EVS_EventType_ERROR, + "ATS table manage process error: ATS = %u, Result = 0x%X", + SC_IDNUM_AS_UINT(SC_AtsIndexToNum(SC_ATS_IDX_C(i))), (unsigned int)GetAddressResult); + } } + /* RTS tables */ for (i = 0; i < SC_NUMBER_OF_RTS; i++) { - /* Register for RTS table manage request commands */ - CFE_TBL_NotifyByMessage(SC_OperData.RtsTblHandle[i], CFE_SB_ValueToMsgId(SC_CMD_MID), SC_MANAGE_TABLE_CC, - SC_TBL_ID_RTS_0 + i); + CFE_TBL_ReleaseAddress(SC_OperData.RtsTblHandle[i]); + CFE_TBL_Manage(SC_OperData.RtsTblHandle[i]); + GetAddressResult = CFE_TBL_GetAddress(&TblPtrNew, SC_OperData.RtsTblHandle[i]); + SC_OperData.RtsTblAddr[i] = TblPtrNew; + if (GetAddressResult == CFE_TBL_INFO_UPDATED) + { + SC_LoadRts(SC_RTS_IDX_C(i)); + } + else if ((GetAddressResult != CFE_SUCCESS) && (GetAddressResult != CFE_TBL_ERR_NEVER_LOADED)) + { + CFE_EVS_SendEvent(SC_TABLE_MANAGE_RTS_ERR_EID, CFE_EVS_EventType_ERROR, + "RTS table manage process error: RTS = %u, Result = 0x%X", + SC_IDNUM_AS_UINT(SC_RtsIndexToNum(SC_RTS_IDX_C(i))), (unsigned int)GetAddressResult); + } } } diff --git a/fsw/src/sc_app.h b/fsw/src/sc_app.h index ff2839a..43168d3 100644 --- a/fsw/src/sc_app.h +++ b/fsw/src/sc_app.h @@ -222,25 +222,16 @@ CFE_Status_t SC_GetLoadTablePointers(void); void SC_LoadDefaultTables(void); /** - * \brief Register to receive cFE Table Services manage request commands + * \brief Manage all SC tables * * \par Description - * This function provides cFE Table Services with the information - * necessary to send a notification command when one of the SC dump - * only tables has a dump pending, or when one of the SC loadable - * tables has a load pending. Upon receipt of the command, the - * command handler will call the cFE Table Services API function - * to manage the table. This sequence of events ensures that dump - * tables are not being updated by SC at the same moment that the - * dump occurs, and likewise, that loadable tables are not being - * referenced by SC at the moment that the update occurs. + * This function checks and manages all SC tables and provides + * an opportunity to reload them if they have been updated. * * \par Assumptions, External Events, and Notes: - * None - * - * \sa #SC_ManageTableCmd + * None */ -void SC_RegisterManageCmds(void); +void SC_ManageTables(void); /************************************************************************ * Macro Definitions diff --git a/fsw/src/sc_cmds.c b/fsw/src/sc_cmds.c index 6e8bda5..5c3a6a0 100644 --- a/fsw/src/sc_cmds.c +++ b/fsw/src/sc_cmds.c @@ -586,180 +586,3 @@ void SC_NoopCmd(const SC_NoopCmd_t *Cmd) SC_MAJOR_VERSION, SC_MINOR_VERSION, SC_REVISION, SC_MISSION_REV); } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Table Manage Request Command (sent by cFE Table Services) */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -void SC_ManageTableCmd(const SC_ManageTableCmd_t *Cmd) -{ - int32 ArrayIndex; - int32 TableID = Cmd->Payload.Parameter; - - /* Manage selected table as appropriate for each table type */ - if ((TableID >= SC_TBL_ID_ATS_0) && (TableID < (SC_TBL_ID_ATS_0 + SC_NUMBER_OF_ATS))) - { - ArrayIndex = TableID - SC_TBL_ID_ATS_0; - SC_ManageAtsTable(ArrayIndex); - } - else if (TableID == SC_TBL_ID_APPEND) - { - SC_ManageTable(APPEND, -1); - } - else if ((TableID >= SC_TBL_ID_RTS_0) && (TableID < (SC_TBL_ID_RTS_0 + SC_NUMBER_OF_RTS))) - { - ArrayIndex = TableID - SC_TBL_ID_RTS_0; - SC_ManageRtsTable(ArrayIndex); - } - else if (TableID == SC_TBL_ID_RTS_INFO) - { - /* No need to release dump only table pointer */ - CFE_TBL_Manage(SC_OperData.RtsInfoHandle); - } - else if (TableID == SC_TBL_ID_RTP_CTRL) - { - /* No need to release dump only table pointer */ - CFE_TBL_Manage(SC_OperData.RtsCtrlBlckHandle); - } - else if (TableID == SC_TBL_ID_ATS_INFO) - { - /* No need to release dump only table pointer */ - CFE_TBL_Manage(SC_OperData.AtsInfoHandle); - } - else if (TableID == SC_TBL_ID_ATP_CTRL) - { - /* No need to release dump only table pointer */ - CFE_TBL_Manage(SC_OperData.AtsCtrlBlckHandle); - } - else if ((TableID >= SC_TBL_ID_ATS_CMD_0) && (TableID < (SC_TBL_ID_ATS_CMD_0 + SC_NUMBER_OF_ATS))) - { - /* No need to release dump only table pointer */ - ArrayIndex = TableID - SC_TBL_ID_ATS_CMD_0; - CFE_TBL_Manage(SC_OperData.AtsCmdStatusHandle[ArrayIndex]); - } - else - { - /* Invalid table ID */ - CFE_EVS_SendEvent(SC_TABLE_MANAGE_ID_ERR_EID, CFE_EVS_EventType_ERROR, - "Table manage command packet error: table ID = %d", (int)TableID); - } - - // No success/informational event is sent for this command intentionally, to avoid the risk of flooding. -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Allow cFE Table Services to manage loadable RTS table */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -void SC_ManageRtsTable(int32 ArrayIndex) -{ - /* validate array index */ - if (ArrayIndex >= SC_NUMBER_OF_RTS) - { - CFE_EVS_SendEvent(SC_TABLE_MANAGE_RTS_INV_INDEX_ERR_EID, CFE_EVS_EventType_ERROR, - "RTS table manage error: invalid RTS index %d", (int)ArrayIndex); - return; - } - - SC_ManageTable(RTS, ArrayIndex); -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Allow cFE Table Services to manage loadable ATS table */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -void SC_ManageAtsTable(int32 ArrayIndex) -{ - /* validate array index */ - if (ArrayIndex >= SC_NUMBER_OF_ATS) - { - CFE_EVS_SendEvent(SC_TABLE_MANAGE_ATS_INV_INDEX_ERR_EID, CFE_EVS_EventType_ERROR, - "ATS table manage error: invalid ATS index %d", (int)ArrayIndex); - return; - } - - SC_ManageTable(ATS, ArrayIndex); -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Allow cFE Table Services to manage loadable table */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -void SC_ManageTable(SC_TableType type, int32 ArrayIndex) -{ - CFE_Status_t Result; - CFE_TBL_Handle_t TblHandle; - uint32 **TblAddr; - void *TblPtrNew; - - switch (type) - { - case ATS: - TblHandle = SC_OperData.AtsTblHandle[ArrayIndex]; - TblAddr = &SC_OperData.AtsTblAddr[ArrayIndex]; - break; - case RTS: - TblHandle = SC_OperData.RtsTblHandle[ArrayIndex]; - TblAddr = &SC_OperData.RtsTblAddr[ArrayIndex]; - break; - case APPEND: - default: - TblHandle = SC_OperData.AppendTblHandle; - TblAddr = &SC_OperData.AppendTblAddr; - break; - } - - /* Release table data pointer */ - CFE_TBL_ReleaseAddress(TblHandle); - - /* Allow cFE to manage table */ - CFE_TBL_Manage(TblHandle); - - /* Re-acquire table data pointer */ - Result = CFE_TBL_GetAddress(&TblPtrNew, TblHandle); - *TblAddr = TblPtrNew; /* Note that CFE_TBL_GetAddress() sets this to NULL if it fails */ - if (Result == CFE_TBL_INFO_UPDATED) - { - /* Process new table data */ - if (type == ATS) - { - SC_LoadAts(SC_ATS_IDX_C(ArrayIndex)); - } - else if (type == RTS) - { - SC_LoadRts(SC_RTS_IDX_C(ArrayIndex)); - } - else - { - SC_UpdateAppend(); - } - } - else if ((Result != CFE_SUCCESS) && (Result != CFE_TBL_ERR_NEVER_LOADED)) - { - /* Ignore successful dump or validate and cmds before first activate. */ - if (type == ATS) - { - CFE_EVS_SendEvent(SC_TABLE_MANAGE_ATS_ERR_EID, CFE_EVS_EventType_ERROR, - "ATS table manage process error: ATS = %u, Result = 0x%X", - SC_IDNUM_AS_UINT(SC_AtsIndexToNum(SC_ATS_IDX_C(ArrayIndex))), (unsigned int)Result); - } - else if (type == RTS) - { - CFE_EVS_SendEvent(SC_TABLE_MANAGE_RTS_ERR_EID, CFE_EVS_EventType_ERROR, - "RTS table manage process error: RTS = %u, Result = 0x%X", - SC_IDNUM_AS_UINT(SC_RtsIndexToNum(SC_RTS_IDX_C(ArrayIndex))), (unsigned int)Result); - } - else - { - CFE_EVS_SendEvent(SC_TABLE_MANAGE_APPEND_ERR_EID, CFE_EVS_EventType_ERROR, - "ATS Append table manage process error: Result = 0x%X", (unsigned int)Result); - } - } -} /* End SC_ManageTable() */ diff --git a/fsw/src/sc_cmds.h b/fsw/src/sc_cmds.h index 224b18a..b341590 100644 --- a/fsw/src/sc_cmds.h +++ b/fsw/src/sc_cmds.h @@ -28,86 +28,6 @@ #include "common_types.h" #include "sc_msg.h" -typedef enum -{ - ATS, - RTS, - APPEND -} SC_TableType; - -/** - * \brief Table manage request command handler - * - * \par Description - * Handler for commands from cFE Table Service requesting that the - * application call the cFE table manage API function for the table - * indicated by the command packet argument. Using this command - * interface allows applications to call the table API functions - * only when load or dump activity is pending. - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param[in] Cmd Pointer to Software Bus buffer - * - * \sa #SC_MANAGE_TABLE_CC - */ -void SC_ManageTableCmd(const SC_ManageTableCmd_t *Cmd); - -/** - * \brief Manage pending update to an RTS table - * - * \par Description - * This function is invoked in response to a command from cFE Table - * Services indicating that an RTS table has a pending update. The - * function will release the data pointer for the specified table, - * allow cFE Table Services to update the table data and re-acquire - * the table data pointer. - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param [in] ArrayIndex index into array of RTS tables - * - * \sa #SC_ManageTableCmd - */ -void SC_ManageRtsTable(int32 ArrayIndex); - -/** - * \brief Manage pending update to an ATS table - * - * \par Description - * This function is invoked in response to a command from cFE Table - * Services indicating that an ATS table has a pending update. The - * function will release the data pointer for the specified table, - * allow cFE Table Services to update the table data and re-acquire - * the table data pointer. - * - * \par Assumptions, External Events, and Notes: - * None - * - * \param [in] ArrayIndex index into array of ATS tables - * - * \sa #SC_ManageTableCmd - */ -void SC_ManageAtsTable(int32 ArrayIndex); - -/** - * \brief Manage pending update to a table - * - * \par Description - * This function is invoked in response to a command from cFE Table - * Services indicating that a table has a pending update. - * The function will release the data pointer for the specified table, - * allow cFE Table Services to update the table data and re-acquire - * the table data pointer. - * - * \par Assumptions, External Events, and Notes: - * None - * - * \sa #SC_ManageTableCmd - */ -void SC_ManageTable(SC_TableType type, int32 ArrayIndex); /** * \brief Sends out an Event message diff --git a/fsw/src/sc_dispatch.c b/fsw/src/sc_dispatch.c index fbd063e..bc1f3ea 100644 --- a/fsw/src/sc_dispatch.c +++ b/fsw/src/sc_dispatch.c @@ -228,13 +228,6 @@ void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr) } break; - case SC_MANAGE_TABLE_CC: - if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_ManageTableCmd_t))) - { - SC_ManageTableCmd((const SC_ManageTableCmd_t *)BufPtr); - } - break; - case SC_START_RTS_GRP_CC: if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_StartRtsGrpCmd_t))) { diff --git a/unit-test/sc_app_tests.c b/unit-test/sc_app_tests.c index c1bfdbe..eae3535 100644 --- a/unit-test/sc_app_tests.c +++ b/unit-test/sc_app_tests.c @@ -687,6 +687,156 @@ void SC_LoadDefaultTables_Test(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); } +void SC_ManageTables_Test_TablesUpdated(void) +{ + /* Setup for updated tables */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + /* First check that the expected number of CFE_TBL functions were called */ + /* Manage: 4 Dump-only + SC_NUMBER_OF_ATS + 1 Append + SC_NUMBER_OF_ATS + SC_NUMBER_OF_RTS */ + UtAssert_STUB_COUNT(CFE_TBL_Manage, 4 + SC_NUMBER_OF_ATS + 1 + SC_NUMBER_OF_ATS + SC_NUMBER_OF_RTS); + + /* ReleaseAddress: Only loadable tables - Append + ATS + RTS */ + UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 1 + SC_NUMBER_OF_ATS + SC_NUMBER_OF_RTS); + + /* GetAddress: Only loadable tables - Append + ATS + RTS */ + UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1 + SC_NUMBER_OF_ATS + SC_NUMBER_OF_RTS); + + /* Next check that the SC update/load functions were called the expected number of times */ + UtAssert_STUB_COUNT(SC_UpdateAppend, 1); + UtAssert_STUB_COUNT(SC_LoadAts, SC_NUMBER_OF_ATS); + UtAssert_STUB_COUNT(SC_LoadRts, SC_NUMBER_OF_RTS); +} + +void SC_ManageTables_Test_Success_NoUpdates(void) +{ + /* Setup for CFE_SUCCESS on all tables - tables loaded but not updated */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + /* No update/load functions should be called when CFE_TBL_GetAddress returns CFE_SUCCESS */ + UtAssert_STUB_COUNT(SC_UpdateAppend, 0); + UtAssert_STUB_COUNT(SC_LoadAts, 0); + UtAssert_STUB_COUNT(SC_LoadRts, 0); + + /* But also no error events should be sent */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); +} + +void SC_ManageTables_Test_AppendTableError(void) +{ + /* Setup for error on Append table */ + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_UNREGISTERED); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_APPEND_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +void SC_ManageTables_Test_ATSTableError(void) +{ + /* Setup for success on Append table, error on first ATS table */ + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 2, CFE_TBL_ERR_UNREGISTERED); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_ATS_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +void SC_ManageTables_Test_RTSTableError(void) +{ + uint16 i; + + /* Setup for success on Append table and all ATS tables, Error on first RTS table */ + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); + for (i = 0; i < SC_NUMBER_OF_ATS; i++) + { + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 2 + i, CFE_TBL_INFO_UPDATED); + } + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 2 + SC_NUMBER_OF_ATS, CFE_TBL_ERR_UNREGISTERED); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_RTS_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); +} + +void SC_ManageTables_Test_MultipleErrors(void) +{ + uint16 i; + + /* Setup for error on Append table */ + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_UNREGISTERED); + + /* Setup for single error on first ATS table, rest no error */ + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 2, CFE_TBL_ERR_UNREGISTERED); + for (i = 1; i < SC_NUMBER_OF_ATS; i++) + { + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 2 + i, CFE_TBL_INFO_UPDATED); + } + + /* Error on first RTS table */ + UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 2 + SC_NUMBER_OF_ATS, CFE_TBL_ERR_UNREGISTERED); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_APPEND_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_TABLE_MANAGE_ATS_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[2].EventID, SC_TABLE_MANAGE_RTS_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 3); +} + +void SC_ManageTables_Test_TablesNeverLoaded(void) +{ + /* Setup for CFE_TBL_ERR_NEVER_LOADED on all tables */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_NEVER_LOADED); + + /* Set table addresses */ + UT_SetHandlerFunction(UT_KEY(CFE_TBL_GetAddress), UT_Handler_CFE_TBL_GetAddress, NULL); + + /* Execute the function being tested */ + SC_ManageTables(); + + /* Verify results */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); +} + void UtTest_Setup(void) { UtTest_Add(SC_AppMain_Test_Nominal, SC_Test_Setup, SC_Test_TearDown, "SC_AppMain_Test_Nominal"); @@ -753,4 +903,18 @@ void UtTest_Setup(void) UtTest_Add(SC_GetLoadTablePointers_Test_ErrorGetAddressLoadableRTS, SC_Test_Setup, SC_Test_TearDown, "SC_GetLoadTablePointers_Test_ErrorGetAddressLoadableRTS"); UtTest_Add(SC_LoadDefaultTables_Test, SC_Test_Setup, SC_Test_TearDown, "SC_LoadDefaultTables_Test"); + UtTest_Add(SC_ManageTables_Test_TablesUpdated, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_TablesUpdated"); + UtTest_Add(SC_ManageTables_Test_Success_NoUpdates, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_Success_NoUpdates"); + UtTest_Add(SC_ManageTables_Test_AppendTableError, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_AppendTableError"); + UtTest_Add(SC_ManageTables_Test_ATSTableError, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_ATSTableError"); + UtTest_Add(SC_ManageTables_Test_RTSTableError, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_RTSTableError"); + UtTest_Add(SC_ManageTables_Test_MultipleErrors, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_MultipleErrors"); + UtTest_Add(SC_ManageTables_Test_TablesNeverLoaded, SC_Test_Setup, SC_Test_TearDown, + "SC_ManageTables_Test_TablesNeverLoaded"); } diff --git a/unit-test/sc_cmds_tests.c b/unit-test/sc_cmds_tests.c index d3962f3..9834d3a 100644 --- a/unit-test/sc_cmds_tests.c +++ b/unit-test/sc_cmds_tests.c @@ -1261,346 +1261,6 @@ void SC_ProcessCommand_Test_AppendAts(void) /* This function is already verified to work correctly in another file, so no verifications here. */ } -void SC_ProcessCommand_Test_TableManageAtsTableNominal(void) -{ - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - - Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_0; - - /* Set to reach "SC_LoadAts(ArrayIndex)" */ - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAtsTableGetAddressError(void) -{ - UT_CmdBuf.ManageTableCmd.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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* Verify results */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_ATS_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void SC_ProcessCommand_Test_TableManageAtsTableID(void) -{ - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - - Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - /* test TableID >= SC_TBL_ID_ATS_0 */ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = 0; - - /* Set to reach "SC_LoadAts(ArrayIndex)" */ - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAtsTable_InvalidIndex(void) -{ - uint8 AtsIndex = SC_NUMBER_OF_ATS; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageAtsTable(AtsIndex)); - - /* Verify results */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_ATS_INV_INDEX_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void SC_ProcessCommand_Test_TableManageAtsTableGetAddressNeverLoaded(void) -{ - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - - Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_0; - - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_NEVER_LOADED); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAtsTableGetAddressSuccess(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; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - - Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_0; - - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_SUCCESS); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAppendTableNominal(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; - - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AppendTblAddr; - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_APPEND; - - /* Set to reach "SC_UpdateAppend()" */ - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_INFO_UPDATED); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAppendTableGetAddressError(void) -{ - UT_CmdBuf.ManageTableCmd.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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* Verify results */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_APPEND_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void SC_ProcessCommand_Test_TableManageAppendTableGetAddressNeverLoaded(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; - - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AppendTblAddr; - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_APPEND; - - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_TBL_ERR_NEVER_LOADED); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAppendTableGetAddressSuccess(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; - - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AppendTblAddr; - Entry->CmdNumber = SC_COMMAND_NUM_C(0); - - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_APPEND; - - UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetAddress), 1, CFE_SUCCESS); - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageRtsTableNominal(void) -{ - UT_CmdBuf.ManageTableCmd.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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageRtsTableGetAddressError(void) -{ - UT_CmdBuf.ManageTableCmd.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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* Verify results */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_RTS_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void SC_ProcessCommand_Test_TableManageRtsTableID(void) -{ - /* test TableID >= SC_TBL_ID_RTS_0 */ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = 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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageRtsTable_InvalidIndex(void) -{ - uint8 RtsIndex = SC_NUMBER_OF_RTS; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageRtsTable(RtsIndex)); - - /* Verify results */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_RTS_INV_INDEX_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void SC_ProcessCommand_Test_TableManageRtsTableGetAddressNeverLoaded(void) -{ - UT_CmdBuf.ManageTableCmd.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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageRtsTableGetAddressSuccess(void) -{ - UT_CmdBuf.ManageTableCmd.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_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageRtsInfo(void) -{ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_RTS_INFO; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageRtpCtrl(void) -{ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_RTP_CTRL; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAtsInfo(void) -{ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_INFO; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAtpCtrl(void) -{ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATP_CTRL; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageAtsCmdStatus(void) -{ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_CMD_0; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* This function is already verified to work correctly in another file, so no verifications here. */ -} - -void SC_ProcessCommand_Test_TableManageInvalidTableID(void) -{ - UT_CmdBuf.ManageTableCmd.Payload.Parameter = 999; - - /* Execute the function being tested */ - UtAssert_VOIDCALL(SC_ManageTableCmd(&UT_CmdBuf.ManageTableCmd)); - - /* Verify results */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_TABLE_MANAGE_ID_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - void SC_ProcessCommand_Test_StartRtsGrp(void) { /* Execute the function being tested */ @@ -1710,50 +1370,6 @@ void UtTest_Setup(void) UtTest_Add(SC_ProcessCommand_Test_ContinueAtsOnFailure, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_ContinueAtsOnFailure"); UtTest_Add(SC_ProcessCommand_Test_AppendAts, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_AppendAts"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsTableNominal, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsTableNominal"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsTableGetAddressError, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsTableGetAddressError"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsTableID, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsTableID"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsTable_InvalidIndex, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsTable_InvalidIndex"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsTableGetAddressNeverLoaded, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsTableGetAddressNeverLoaded"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsTableGetAddressSuccess, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsTableGetAddressSuccess"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAppendTableNominal, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAppendTableNominal"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAppendTableGetAddressError, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAppendTableGetAddressError"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAppendTableGetAddressNeverLoaded, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAppendTableGetAddressNeverLoaded"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAppendTableGetAddressSuccess, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAppendTableGetAddressSuccess"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsTableNominal, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsTableNominal"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsTableGetAddressError, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsTableGetAddressError"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsTableID, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsTableID"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsTable_InvalidIndex, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsTable_InvalidIndex"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsTableGetAddressNeverLoaded, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsTableGetAddressNeverLoaded"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsTableGetAddressSuccess, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsTableGetAddressSuccess"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtsInfo, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtsInfo"); - UtTest_Add(SC_ProcessCommand_Test_TableManageRtpCtrl, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageRtpCtrl"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsInfo, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsInfo"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtpCtrl, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtpCtrl"); - UtTest_Add(SC_ProcessCommand_Test_TableManageAtsCmdStatus, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageAtsCmdStatus"); - UtTest_Add(SC_ProcessCommand_Test_TableManageInvalidTableID, SC_Test_Setup, SC_Test_TearDown, - "SC_ProcessCommand_Test_TableManageInvalidTableID"); UtTest_Add(SC_ProcessCommand_Test_StartRtsGrp, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_StartRtsGrp"); UtTest_Add(SC_ProcessCommand_Test_StopRtsGrp, SC_Test_Setup, SC_Test_TearDown, "SC_ProcessCommand_Test_StopRtsGrp"); diff --git a/unit-test/sc_dispatch_tests.c b/unit-test/sc_dispatch_tests.c index 4340dd2..2ab4ae1 100644 --- a/unit-test/sc_dispatch_tests.c +++ b/unit-test/sc_dispatch_tests.c @@ -518,26 +518,6 @@ void SC_ProcessCommand_Test_AppendAtsCmdInvalidLength(void) UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CMD_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_CMD_LEN_ERR_EID); -} - void SC_ProcessCommand_Test_StartRtsGrpCmdInvalidLength(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); @@ -810,22 +790,6 @@ void SC_ProcessCommand_Test_AppendAtsCmdNominal(void) 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_ManageTableCmd_t)); - - /* Execute the function being tested */ - SC_ProcessCommand(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_STUB_COUNT(SC_ManageTableCmd, 1); -} - void SC_ProcessCommand_Test_StartRtsGrpCmdNominal(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); @@ -978,8 +942,6 @@ void UtTest_Setup(void) "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, @@ -1013,8 +975,6 @@ void UtTest_Setup(void) "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, diff --git a/unit-test/stubs/sc_app_stubs.c b/unit-test/stubs/sc_app_stubs.c index e72f85e..af931e2 100644 --- a/unit-test/stubs/sc_app_stubs.c +++ b/unit-test/stubs/sc_app_stubs.c @@ -146,10 +146,10 @@ CFE_Status_t SC_RegisterLoadableTables(void) /* * ---------------------------------------------------- - * Generated stub function for SC_RegisterManageCmds() + * Generated stub function for SC_ManageTables() * ---------------------------------------------------- */ -void SC_RegisterManageCmds(void) +void SC_ManageTables(void) { - UT_GenStub_Execute(SC_RegisterManageCmds, Basic, NULL); + UT_GenStub_Execute(SC_ManageTables, Basic, NULL); } diff --git a/unit-test/stubs/sc_cmds_stubs.c b/unit-test/stubs/sc_cmds_stubs.c index f9a19fe..319b14d 100644 --- a/unit-test/stubs/sc_cmds_stubs.c +++ b/unit-test/stubs/sc_cmds_stubs.c @@ -26,55 +26,6 @@ #include "sc_cmds.h" #include "utgenstub.h" -/* - * ---------------------------------------------------- - * Generated stub function for SC_ManageAtsTable() - * ---------------------------------------------------- - */ -void SC_ManageAtsTable(int32 ArrayIndex) -{ - UT_GenStub_AddParam(SC_ManageAtsTable, int32, ArrayIndex); - - UT_GenStub_Execute(SC_ManageAtsTable, Basic, NULL); -} - -/* - * ---------------------------------------------------- - * Generated stub function for SC_ManageRtsTable() - * ---------------------------------------------------- - */ -void SC_ManageRtsTable(int32 ArrayIndex) -{ - UT_GenStub_AddParam(SC_ManageRtsTable, int32, ArrayIndex); - - UT_GenStub_Execute(SC_ManageRtsTable, Basic, NULL); -} - -/* - * ---------------------------------------------------- - * Generated stub function for SC_ManageTable() - * ---------------------------------------------------- - */ -void SC_ManageTable(SC_TableType type, int32 ArrayIndex) -{ - UT_GenStub_AddParam(SC_ManageTable, SC_TableType, type); - UT_GenStub_AddParam(SC_ManageTable, int32, ArrayIndex); - - UT_GenStub_Execute(SC_ManageTable, Basic, NULL); -} - -/* - * ---------------------------------------------------- - * Generated stub function for SC_ManageTableCmd() - * ---------------------------------------------------- - */ -void SC_ManageTableCmd(const SC_ManageTableCmd_t *Cmd) -{ - UT_GenStub_AddParam(SC_ManageTableCmd, const SC_ManageTableCmd_t *, Cmd); - - UT_GenStub_Execute(SC_ManageTableCmd, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for SC_NoopCmd() diff --git a/unit-test/utilities/sc_test_utils.h b/unit-test/utilities/sc_test_utils.h index 82c47ed..74795db 100644 --- a/unit-test/utilities/sc_test_utils.h +++ b/unit-test/utilities/sc_test_utils.h @@ -73,7 +73,6 @@ typedef union SC_JumpAtsCmd_t JumpAtsCmd; SC_ContinueAtsOnFailureCmd_t ContinueAtsOnFailureCmd; SC_AppendAtsCmd_t AppendAtsCmd; - SC_ManageTableCmd_t ManageTableCmd; SC_StartRtsGrpCmd_t StartRtsGrpCmd; SC_StopRtsGrpCmd_t StopRtsGrpCmd; SC_DisableRtsGrpCmd_t DisableRtsGrpCmd;