diff --git a/README.md b/README.md index 8c154bba6..b38adf224 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,36 @@ The detailed cFE user's guide can be viewed at and + ### Development Build: v6.8.0-rc1+dev873 - Add CFE assert macros to functional test @@ -22,7 +52,7 @@ The detailed cFE user's guide can be viewed at and +- See and ### Development Build: v6.8.0-rc1+dev844 diff --git a/cmake/sample_defs/cpu1_msgids.h b/cmake/sample_defs/cpu1_msgids.h index 0da698f15..72f311c0e 100644 --- a/cmake/sample_defs/cpu1_msgids.h +++ b/cmake/sample_defs/cpu1_msgids.h @@ -86,8 +86,8 @@ /* ** cFE Command Message Id's */ -#define CFE_EVS_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_EVS_CMD_MSG /* 0x1801 */ - /* Message ID 0x1802 is available */ +#define CFE_EVS_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_EVS_CMD_MSG /* 0x1801 */ +#define CFE_TEST_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_TEST_CMD_MSG /* 0x1802 */ #define CFE_SB_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_SB_CMD_MSG /* 0x1803 */ #define CFE_TBL_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_TBL_CMD_MSG /* 0x1804 */ #define CFE_TIME_CMD_MID CFE_PLATFORM_CMD_MID_BASE + CFE_MISSION_TIME_CMD_MSG /* 0x1805 */ @@ -114,9 +114,9 @@ /* ** CFE Telemetry Message Id's */ -#define CFE_ES_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_ES_HK_TLM_MSG /* 0x0800 */ -#define CFE_EVS_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_EVS_HK_TLM_MSG /* 0x0801 */ - /* Message ID 0x0802 is available */ +#define CFE_ES_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_ES_HK_TLM_MSG /* 0x0800 */ +#define CFE_EVS_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_EVS_HK_TLM_MSG /* 0x0801 */ +#define CFE_TEST_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_TEST_HK_TLM_MSG /* 0x0802 */ #define CFE_SB_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_SB_HK_TLM_MSG /* 0x0803 */ #define CFE_TBL_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_TBL_HK_TLM_MSG /* 0x0804 */ #define CFE_TIME_HK_TLM_MID CFE_PLATFORM_TLM_MID_BASE + CFE_MISSION_TIME_HK_TLM_MSG /* 0x0805 */ diff --git a/cmake/sample_defs/cpu1_platform_cfg.h b/cmake/sample_defs/cpu1_platform_cfg.h index ee4c5d478..ce6769644 100644 --- a/cmake/sample_defs/cpu1_platform_cfg.h +++ b/cmake/sample_defs/cpu1_platform_cfg.h @@ -302,7 +302,7 @@ #define CFE_PLATFORM_SB_MEM_BLOCK_SIZE_14 8192 #define CFE_PLATFORM_SB_MEM_BLOCK_SIZE_15 16384 #define CFE_PLATFORM_SB_MEM_BLOCK_SIZE_16 32768 -#define CFE_PLATFORM_SB_MAX_BLOCK_SIZE (CFE_MISSION_SB_MAX_SB_MSG_SIZE + 40) +#define CFE_PLATFORM_SB_MAX_BLOCK_SIZE (CFE_MISSION_SB_MAX_SB_MSG_SIZE + 128) /** ** \cfetimecfg Time Server or Time Client Selection diff --git a/cmake/sample_defs/global_build_options.cmake b/cmake/sample_defs/global_build_options.cmake index d2d93cca8..d908b9606 100644 --- a/cmake/sample_defs/global_build_options.cmake +++ b/cmake/sample_defs/global_build_options.cmake @@ -20,6 +20,8 @@ set(OMIT_DEPRECATED $ENV{OMIT_DEPRECATED} CACHE STRING "Omit deprecated elements if (OMIT_DEPRECATED) message (STATUS "OMIT_DEPRECATED=true: Not including deprecated elements in build") add_definitions(-DCFE_OMIT_DEPRECATED_6_8 -DCFE_OMIT_DEPRECATED_6_7 -DCFE_OMIT_DEPRECATED_6_6 -DOSAL_OMIT_DEPRECATED) + set(MISSION_RESOURCEID_MODE "STRICT") # more type safe, but less backward compatible else() message (STATUS "OMIT_DEPRECATED=false: Deprecated elements included in build") + set(MISSION_RESOURCEID_MODE "SIMPLE") # less type safe, but more backward compatible endif (OMIT_DEPRECATED) diff --git a/cmake/sample_defs/sample_mission_cfg.h b/cmake/sample_defs/sample_mission_cfg.h index 319587389..144a9d0f2 100644 --- a/cmake/sample_defs/sample_mission_cfg.h +++ b/cmake/sample_defs/sample_mission_cfg.h @@ -307,8 +307,8 @@ ** \par Limits ** Not Applicable */ -#define CFE_MISSION_EVS_CMD_MSG 1 -/* Offset 2 is available */ +#define CFE_MISSION_EVS_CMD_MSG 1 +#define CFE_MISSION_TEST_CMD_MSG 2 #define CFE_MISSION_SB_CMD_MSG 3 #define CFE_MISSION_TBL_CMD_MSG 4 #define CFE_MISSION_TIME_CMD_MSG 5 @@ -351,9 +351,9 @@ ** \par Limits ** Not Applicable */ -#define CFE_MISSION_ES_HK_TLM_MSG 0 -#define CFE_MISSION_EVS_HK_TLM_MSG 1 -/* Offset 2 is available */ +#define CFE_MISSION_ES_HK_TLM_MSG 0 +#define CFE_MISSION_EVS_HK_TLM_MSG 1 +#define CFE_MISSION_TEST_HK_TLM_MSG 2 #define CFE_MISSION_SB_HK_TLM_MSG 3 #define CFE_MISSION_TBL_HK_TLM_MSG 4 #define CFE_MISSION_TIME_HK_TLM_MSG 5 @@ -418,6 +418,7 @@ ** anticipated to be reasonably small (i.e. tens, not hundreds). Large ** values have not been tested. ** +** */ #define CFE_MISSION_ES_POOL_MAX_BUCKETS 17 diff --git a/docs/cFE_FunctionalRequirements.csv b/docs/cFE_FunctionalRequirements.csv index 9197e107e..6545d4bf1 100644 --- a/docs/cFE_FunctionalRequirements.csv +++ b/docs/cFE_FunctionalRequirements.csv @@ -99,7 +99,7 @@ ES: Report Last Reset,cES1301,"Upon receipt of a Request, the cFE shall provide ES: Report Last Reset - Types,cES1301.1,The reset types include: Power On Reset Processor Reset.,cFE Applications may perform processing that is specific to each reset type. ES: Report Application ID,cES1304,"Upon receipt of a Request, the cFE shall provide the cFE Application ID of the calling cFE Application.",A cFE Application needs to determine its own Application ID. ES: Get Task Information,cES1305,Upon receipt of a Request the cFE shall provide information for the requested task.,Allows query of task information for reporting or management. -ES: Report Application ID,cES1306,"Upon receipt of a Request, the cFE shall provide the cFE Application ID which corresponds to the specified cFE Application Name.",The Executive Services will assign an Application ID. The Application Name is specified when the cFE Application is created. This Request will provide a way to determine the cFE Application ID when the pre-determined Application Name is passed in. +ES: Report Application ID By Name,cES1306,"Upon receipt of a Request, the cFE shall provide the cFE Application ID which corresponds to the specified cFE Application Name.",The Executive Services will assign an Application ID. The Application Name is specified when the cFE Application is created. This Request will provide a way to determine the cFE Application ID when the pre-determined Application Name is passed in. ES: Report Application Name,cES1307,"Upon receipt of a Request, the cFE shall provide the cFE Application Name which corresponds to the specified cFE Application ID.",The Executive Services will assign an Application ID. This Request will provide a way to determine an Application's name from its Application ID. ES: Delete Application,cES1309,"Upon receipt of a Request, the cFE shall delete the specified Application including all child tasks.",Need to be able to stop the execution of an Application and remove its System Resources. The delete will clean-up the application's main task and all of its child tasks. Note: other cFE components are required to have cleanup routines that ES calls. ES: Delete Application - Reject Undefined,cES1309.1,"If the specified Application is undefined then the cFE shall record the error in the System Log, and return an error code.",Can't delete an undefined application. @@ -113,7 +113,7 @@ ES: Create Child Task - Invalid From Child Task,cES1311.2,"In the event a child ES: Delete Child Task,cES1312,"Upon receipt of a Request, the cFE shall delete the specified cFE Child Task within the cFE Application that owns the task.","As part of a cFE Application cleanup, the Application needs to be able to delete each child task." ES: Delete Child Task - Error If Application Main Task,cES1312.1,"If the specified task is the cFE Application Main Task, the request shall record the error in the System Log, and return an error code.",Cannot use Child Task Exit or Delete on the cFE Application Main Task. ES: End Child Task,cES1314,"Upon receipt of a Request, the cFE shall end execution of the calling cFE Child Task.", cFE Child Task needs to be able to exit and end execution. -ES: End Child Task - Error If Application Main Task,cES1314.1,"If the calling task is the cFE Application Main Task, the cFE shall record the error in the System Log, and return an error code.",Cannot use Child Task Exit or Delete on the cFE Application Main Task. +ES: End Child Task - Reject If Application Main Task,cES1314.1,"If the calling task is the cFE Application Main Task, the cFE shall record the error in the System Log and reject the request.",Cannot use Child Task Exit or Delete on the cFE Application Main Task. ES: Reserve Critical Data Store,cES1315,"Upon receipt of a Request, the cFE shall reserve the Request specified amount of memory in the Critical Data Store for the cFE Application using the Request specified name.",The Critical Data Store will be used by Applications to store critical parameters that will be preserved after an application or processor restart. ES will allocate the memory for the application. A pointer or memory address will be provided to the alloc. ES: Reserve Critical Data Store - Size Change,cES1315.1,"If a Critical Data Store exists for the Request specified name but has a different size than what is specified in the Request, the cFE shall remove the existing Critical Data Store and create a new one using the Request specified name and size.",Assumes that if the sizes don't match then something has changed and the CDS can't be trusted. ES: Reserve Critical Data Store - Invalid Data Integrity,cES1315.2,"If a Critical Data Store exists for the Request specified name but the Data Integrity value is invalid, the cFE shall remove the existing Critical Data Store and create a new one using the Request specified name and size.",Assumes that if the CRC is invalid then the CDS can't be trusted. diff --git a/docs/src/cfe_api.dox b/docs/src/cfe_api.dox index 5cda61674..2bfc5dd25 100644 --- a/docs/src/cfe_api.dox +++ b/docs/src/cfe_api.dox @@ -139,6 +139,9 @@
  • \ref CFEAPIMSGHeader
    • #CFE_MSG_Init - \copybrief CFE_MSG_Init +
    +
  • \ref CFEAPIMSGHeaderPri +
    • #CFE_MSG_GetSize - \copybrief CFE_MSG_GetSize
    • #CFE_MSG_SetSize - \copybrief CFE_MSG_SetSize
    • #CFE_MSG_GetType - \copybrief CFE_MSG_GetType @@ -154,6 +157,9 @@
    • #CFE_MSG_GetSequenceCount - \copybrief CFE_MSG_GetSequenceCount
    • #CFE_MSG_SetSequenceCount - \copybrief CFE_MSG_SetSequenceCount
    • #CFE_MSG_GetNextSequenceCount - \copybrief CFE_MSG_GetNextSequenceCount +
    +
  • \ref CFEAPIMSGHeaderExt +
    • #CFE_MSG_GetEDSVersion - \copybrief CFE_MSG_GetEDSVersion
    • #CFE_MSG_SetEDSVersion - \copybrief CFE_MSG_SetEDSVersion
    • #CFE_MSG_GetEndian - \copybrief CFE_MSG_GetEndian @@ -164,6 +170,9 @@
    • #CFE_MSG_SetSubsystem - \copybrief CFE_MSG_SetSubsystem
    • #CFE_MSG_GetSystem - \copybrief CFE_MSG_GetSystem
    • #CFE_MSG_SetSystem - \copybrief CFE_MSG_SetSystem +
    +
  • \ref CFEAPIMSGHeaderSec +
    • #CFE_MSG_GenerateChecksum - \copybrief CFE_MSG_GenerateChecksum
    • #CFE_MSG_ValidateChecksum - \copybrief CFE_MSG_ValidateChecksum
    • #CFE_MSG_SetFcnCode - \copybrief CFE_MSG_SetFcnCode @@ -225,14 +234,11 @@
    • #CFE_SB_ReleaseMessageBuffer - \copybrief CFE_SB_ReleaseMessageBuffer
    • #CFE_SB_TransmitBuffer - \copybrief CFE_SB_TransmitBuffer
    -
  • \ref CFEAPISBSetMessage +
  • \ref CFEAPISBMessageCharacteristics
    • #CFE_SB_SetUserDataLength - \copybrief CFE_SB_SetUserDataLength
    • #CFE_SB_TimeStampMsg - \copybrief CFE_SB_TimeStampMsg
    • #CFE_SB_MessageStringSet - \copybrief CFE_SB_MessageStringSet -
    -
  • \ref CFEAPIGetMessage -
    • #CFE_SB_GetUserData - \copybrief CFE_SB_GetUserData
    • #CFE_SB_GetUserDataLength - \copybrief CFE_SB_GetUserDataLength
    • #CFE_SB_MessageStringGet - \copybrief CFE_SB_MessageStringGet diff --git a/modules/cfe_assert/inc/cfe_assert.h b/modules/cfe_assert/inc/cfe_assert.h index dc5736920..4224e46a6 100644 --- a/modules/cfe_assert/inc/cfe_assert.h +++ b/modules/cfe_assert/inc/cfe_assert.h @@ -151,6 +151,101 @@ typedef void (*CFE_Assert_StatusCallback_t)(uint8 MessageType, const char *Prefi UtAssert_GenericUnsignedCompare(CFE_SB_MsgIdToValue(mid1), UtAssert_Compare_EQ, CFE_SB_MsgIdToValue(mid2), \ UtAssert_Radix_HEX, __FILE__, __LINE__, "MsgId Check: ", #mid1, #mid2) +/*****************************************************************************/ +/** +** \brief Calls a function that returns CFE_Status_t with deferred validation +** +** \par Description +** The typical method of using #UtAssert_INT32_EQ to validate the result of a CFE call +** will both invoke the function and check the result in a single macro. However, this +** requires advance knowledge of what the result is supposed to be, before the call is made. +** +** This macro does invokes the function like the other macros do, but does _not_ check the +** return value. Rather, it stores the return the value in a local buffer for later checking, +** using the #CFE_Assert_STATUS_MAY_BE or #CFE_Assert_STATUS_MUST_BE macros. +** +** \par Assumptions, External Events, and Notes: +** In some functional test circumstances, particularly where the test is not being run +** in a clean/isolated environment, it may not always be feasible to predict the correct +** return code from an API call. +** +** In these cases, the test program will need to check the result of the call itself, +** typically by storing the result on the stack and checking it for correctness by +** reading system state as necessary. +** +** While the normal UtAssert_INT32_EQ assertion macro can still be used to retroactively check +** any status variable value (including a value on the stack from a previous API call), this +** will not include the "full text" of the API call, and so the test log will not reflect the +** full call details. +** +** The pair of macros (CFE_Assert_STATUS_STORE and CFE_Assert_STATUS_WAS) can be used in these +** circumstances, to call an API function and record the full text of the call, when the expected +** status is not fully known, but still confirm the status was correct once it is known. +** +** \sa #CFE_Assert_STATUS_MAY_BE, #CFE_Assert_STATUS_MUST_BE +** +** \returns Actual CFE_Status_t value from the call +*/ +#define CFE_Assert_STATUS_STORE(FN) CFE_Assert_Status_Store(FN, __FILE__, __LINE__, #FN) + +/*****************************************************************************/ +/** +** \brief Retroactively check for an acceptable status value from CFE_Assert_STATUS_STORE +** +** \par Description +** The typical method of using #UtAssert_INT32_EQ to validate the result of a CFE call +** will both invoke the function and check the result in a single macro. However, this +** requires advance knowledge of what the result is supposed to be, before the call is made. +** +** This retroactive macro does _not_ invoke any function, but rather checks the stored status +** from a previous call to #CFE_Assert_STATUS_STORE. It should be used for each status +** code that should be considered acceptable from the previous function call. +** +** \par Assumptions, External Events, and Notes: +** +** While the normal UtAssert_INT32_EQ assertion macro can still be used to check any +** status variable value (including a value on the stack from a previous API call), this +** will not include the "full text" of the API call. This macro is intended for those cases +** where it is desired to log the full text (function + arguments) of the API call, but +** when the call has already been made and the status value is stored in a local variable. +** +** \sa #CFE_Assert_STATUS_STORE, #CFE_Assert_STATUS_MUST_BE +** +** \returns Boolean pass/fail status +** +******************************************************************************/ +#define CFE_Assert_STATUS_MAY_BE(expected) \ + CFE_Assert_Status_DeferredCheck(expected, UTASSERT_CASETYPE_FLOW, __FILE__, __LINE__, #expected) + +/*****************************************************************************/ +/** +** \brief Retroactively check for a required status value from CFE_Assert_STATUS_STORE +** +** \par Description +** The typical method of using #UtAssert_INT32_EQ to validate the result of a CFE call +** will both invoke the function and check the result in a single macro. However, this +** requires advance knowledge of what the result is supposed to be, before the call is made. +** +** This retroactive macro does _not_ invoke any function, but rather checks the stored status +** from a previous call to #CFE_Assert_STATUS_STORE. This should be used as the final +** assertion, after checking for other acceptable values via #CFE_Assert_STATUS_MAY_BE. +** +** \par Assumptions, External Events, and Notes: +** +** While the normal UtAssert_INT32_EQ assertion macro can still be used to check any +** status variable value (including a value on the stack from a previous API call), this +** will not include the "full text" of the API call. This macro is intended for those cases +** where it is desired to log the full text (function + arguments) of the API call, but +** when the call has already been made and the status value is stored in a local variable. +** +** \sa #CFE_Assert_STATUS_STORE, #CFE_Assert_STATUS_MAY_BE +** +** \returns Boolean pass/fail status +** +******************************************************************************/ +#define CFE_Assert_STATUS_MUST_BE(expected) \ + CFE_Assert_Status_DeferredCheck(expected, UTASSERT_CASETYPE_FAILURE, __FILE__, __LINE__, #expected) + /************************************************************************* ** Exported Functions *************************************************************************/ @@ -276,4 +371,44 @@ void CFE_Assert_CloseLogFile(void); bool CFE_UtAssert_StatusCheck(CFE_Status_t Status, bool ExpectSuccess, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, const char *Text); +/*****************************************************************************/ +/** +** \brief Helper function for nominal CFE calls with deferred check +** +** \par Description +** This helper function will store the status into a temporary holding area, +** but _not_ assert on any specific value. +** +** \par Assumptions, External Events, and Notes: +** This facility should only be used by one task at a time. Normally tests +** are single-threaded, and CFE assert will serialize test apps, so this is +** not a concern in the typical test environment. +** +** However, if a particular test case uses child tasks, then the programmer must +** explicitly ensure that only one task uses this facility at a time. +** +** \returns Status value (pass through) +*/ +CFE_Status_t CFE_Assert_Status_Store(CFE_Status_t Status, const char *File, uint32 Line, const char *Text); + +/** +** \brief Helper function for nominal CFE calls with deferred check +** +** \par Description +** This helper function will assert on the status previously stored to a +** temporary holding area. +** +** \par Assumptions, External Events, and Notes: +** This facility should only be used by one task at a time. Normally tests +** are single-threaded, and CFE assert will serialize test apps, so this is +** not a concern in the typical test environment. +** +** However, if a particular test case uses child tasks, then the programmer must +** explicitly ensure that only one task uses this facility at a time. +** +** \returns Test pass status, returns true if status was successful, false if it failed. +*/ +bool CFE_Assert_Status_DeferredCheck(CFE_Status_t Status, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, + const char *Text); + #endif /* CFE_ASSERT_H */ diff --git a/modules/cfe_assert/src/cfe_assert_init.c b/modules/cfe_assert/src/cfe_assert_init.c index 83822bf96..b28f7db17 100644 --- a/modules/cfe_assert/src/cfe_assert_init.c +++ b/modules/cfe_assert/src/cfe_assert_init.c @@ -49,7 +49,7 @@ void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback) */ int32 CFE_Assert_OpenLogFile(const char *Filename) { - int32 Status; + int32 OsStatus; char * Ext; size_t NameLen; @@ -76,11 +76,12 @@ int32 CFE_Assert_OpenLogFile(const char *Filename) } strcpy(&CFE_Assert_Global.LogFileTemp[NameLen], ".tmp"); - Status = OS_OpenCreate(&CFE_Assert_Global.LogFileDesc, CFE_Assert_Global.LogFileTemp, - OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status != OS_SUCCESS) + OsStatus = OS_OpenCreate(&CFE_Assert_Global.LogFileDesc, CFE_Assert_Global.LogFileTemp, + OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Failed to open %s, rc=%d\n", __func__, CFE_Assert_Global.LogFileTemp, (int)Status); + CFE_ES_WriteToSysLog("%s: Failed to open %s, rc=%ld\n", __func__, CFE_Assert_Global.LogFileTemp, + (long)OsStatus); return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -109,17 +110,17 @@ void CFE_Assert_CloseLogFile(void) */ int32 CFE_Assert_LibInit(CFE_ES_LibId_t LibId) { - int32 status; + int32 OsStatus; memset(&CFE_Assert_Global, 0, sizeof(CFE_Assert_Global)); UtTest_EarlyInit(); UT_BSP_Setup(); - status = OS_MutSemCreate(&CFE_Assert_Global.AccessMutex, "CFE_Assert", 0); - if (status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_Assert_Global.AccessMutex, "CFE_Assert", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, rc=%d\n", __func__, (int)status); + CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, rc=%ld\n", __func__, (long)OsStatus); return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } diff --git a/modules/cfe_assert/src/cfe_assert_io.c b/modules/cfe_assert/src/cfe_assert_io.c index b16a0377f..fd67cf818 100644 --- a/modules/cfe_assert/src/cfe_assert_io.c +++ b/modules/cfe_assert/src/cfe_assert_io.c @@ -40,23 +40,23 @@ CFE_Assert_Global_t CFE_Assert_Global; void UT_BSP_Lock(void) { - int32 rc; + int32 OsStatus; - rc = OS_MutSemTake(CFE_Assert_Global.AccessMutex); - if (rc != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_Assert_Global.AccessMutex); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemTake(): %d\n", __func__, (int)rc); + CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemTake(): %ld\n", __func__, (long)OsStatus); } } void UT_BSP_Unlock(void) { - int32 rc; + int32 OsStatus; - rc = OS_MutSemGive(CFE_Assert_Global.AccessMutex); - if (rc != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_Assert_Global.AccessMutex); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemGive(): %d\n", __func__, (int)rc); + CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemGive(): %ld\n", __func__, (long)OsStatus); } } @@ -86,10 +86,14 @@ void UT_BSP_SysLogStatusReport(uint8 MessageType, const char *Prefix, const char void UT_BSP_WriteLogFile(osal_id_t FileDesc, uint8 MessageType, const char *Prefix, const char *OutputMessage) { - char LogFileBuffer[CFE_ASSERT_MAX_LOG_LINE_LENGTH]; + char LogFileBuffer[CFE_ASSERT_MAX_LOG_LINE_LENGTH]; + uint32 MsgEnabled = CFE_Assert_Global.CurrVerbosity >> MessageType; - snprintf(LogFileBuffer, sizeof(LogFileBuffer), "[%5s] %s\n", Prefix, OutputMessage); - OS_write(FileDesc, LogFileBuffer, strlen(LogFileBuffer)); + if (MsgEnabled & 1) + { + snprintf(LogFileBuffer, sizeof(LogFileBuffer), "[%5s] %s\n", Prefix, OutputMessage); + OS_write(FileDesc, LogFileBuffer, strlen(LogFileBuffer)); + } } void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage) @@ -97,45 +101,7 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage) const char * Prefix; CFE_Assert_StatusCallback_t StatusCallback; - switch (MessageType) - { - case UTASSERT_CASETYPE_ABORT: - Prefix = "ABORT"; - break; - case UTASSERT_CASETYPE_FAILURE: - Prefix = "FAIL"; - break; - case UTASSERT_CASETYPE_MIR: - Prefix = "MIR"; - break; - case UTASSERT_CASETYPE_TSF: - Prefix = "TSF"; - break; - case UTASSERT_CASETYPE_TTF: - Prefix = "TTF"; - break; - case UTASSERT_CASETYPE_NA: - Prefix = "N/A"; - break; - case UTASSERT_CASETYPE_BEGIN: - Prefix = "BEGIN"; - break; - case UTASSERT_CASETYPE_END: - Prefix = "END"; - break; - case UTASSERT_CASETYPE_PASS: - Prefix = "PASS"; - break; - case UTASSERT_CASETYPE_INFO: - Prefix = "INFO"; - break; - case UTASSERT_CASETYPE_DEBUG: - Prefix = "DEBUG"; - break; - default: - Prefix = "OTHER"; - break; - } + Prefix = UtAssert_GetCaseTypeAbbrev(MessageType); StatusCallback = CFE_Assert_Global.StatusCallback; diff --git a/modules/cfe_assert/src/cfe_assert_priv.h b/modules/cfe_assert/src/cfe_assert_priv.h index c90539eb5..5925213f7 100644 --- a/modules/cfe_assert/src/cfe_assert_priv.h +++ b/modules/cfe_assert/src/cfe_assert_priv.h @@ -136,6 +136,28 @@ typedef struct */ char CurrentTestName[CFE_MISSION_MAX_API_LEN]; + /* The following members support the "Deferred" assert feature */ + + /** + * Actual CFE status value from a previous function call + */ + CFE_Status_t StoredStatus; + + /** + * Full text of previous function call that produced "StoredStatus" + */ + char StoredText[CFE_ASSERT_MAX_LOG_LINE_LENGTH]; + + /** + * File name of source file that produced "StoredStatus" + */ + char StoredFile[CFE_MISSION_MAX_PATH_LEN]; + + /** + * Line number of source file that produced "StoredStatus" + */ + uint32 StoredLine; + } CFE_Assert_Global_t; extern CFE_Assert_Global_t CFE_Assert_Global; diff --git a/modules/cfe_assert/src/cfe_assert_runner.c b/modules/cfe_assert/src/cfe_assert_runner.c index ade244352..e9e223648 100644 --- a/modules/cfe_assert/src/cfe_assert_runner.c +++ b/modules/cfe_assert/src/cfe_assert_runner.c @@ -89,6 +89,68 @@ bool CFE_UtAssert_StatusCheck(CFE_Status_t Status, bool ExpectSuccess, UtAssert_ return UtAssertEx(Result, CaseType, File, Line, "%s (0x%lx) is %s", Text, (unsigned long)Status, MatchText); } +CFE_Status_t CFE_Assert_Status_Store(CFE_Status_t Status, const char *File, uint32 Line, const char *Text) +{ + const char *BaseName; + + /* All this needs to do is save the code+text, will assert later */ + CFE_Assert_Global.StoredStatus = Status; + strncpy(CFE_Assert_Global.StoredText, Text, sizeof(CFE_Assert_Global.StoredText) - 1); + CFE_Assert_Global.StoredText[sizeof(CFE_Assert_Global.StoredText) - 1] = 0; + + BaseName = strrchr(File, '/'); + if (BaseName == NULL) + { + BaseName = File; + } + else + { + ++BaseName; + } + strncpy(CFE_Assert_Global.StoredFile, BaseName, sizeof(CFE_Assert_Global.StoredFile) - 1); + CFE_Assert_Global.StoredFile[sizeof(CFE_Assert_Global.StoredFile) - 1] = 0; + CFE_Assert_Global.StoredLine = Line; + + /* Status code is just passed thru so the test case can check it however it needs to */ + return Status; +} + +bool CFE_Assert_Status_DeferredCheck(CFE_Status_t Status, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, + const char *Text) +{ + bool Result; + const char *ExtraTag; + + if (CFE_Assert_Global.StoredText[0] == 0) + { + /* If no status was stored, then this is a bug in the test program (need to store a result first) */ + UtAssertEx(false, UTASSERT_CASETYPE_FAILURE, File, Line, "TEST BUG: No stored status to assert (%s)", Text); + Result = false; + } + else + { + Result = (Status == CFE_Assert_Global.StoredStatus); + if (Result) + { + /* no extra tag added to "true" conditions */ + ExtraTag = ""; + } + else + { + /* if condition was false add an exta marker so user does not necessarily need to decode the string */ + ExtraTag = " [false]"; + } + + /* This produces a log message similar to what UtAssert_INT32_EQ would produce. + * Note the file/line will reflect where the call was made, not where this assertion was done */ + Result = UtAssertEx(Result, CaseType, CFE_Assert_Global.StoredFile, CFE_Assert_Global.StoredLine, + "%s (%ld) == %s (%ld)%s", CFE_Assert_Global.StoredText, + (long)CFE_Assert_Global.StoredStatus, Text, (long)Status, ExtraTag); + } + + return Result; +} + void CFE_Assert_StatusReport(uint8 MessageType, const char *Prefix, const char *OutputMessage) { uint16 EventType; diff --git a/modules/cfe_testcase/CMakeLists.txt b/modules/cfe_testcase/CMakeLists.txt index 8795cc96e..52be36953 100644 --- a/modules/cfe_testcase/CMakeLists.txt +++ b/modules/cfe_testcase/CMakeLists.txt @@ -21,7 +21,10 @@ add_cfe_app(cfe_testcase src/fs_util_test.c src/message_id_test.c src/msg_api_test.c + src/resource_id_misc_test.c src/sb_pipe_mang_test.c + src/sb_sendrecv_test.c + src/sb_subscription_test.c src/tbl_content_access_test.c src/tbl_content_mang_test.c src/tbl_information_test.c diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index e970fc444..cfc031ee4 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -74,7 +74,10 @@ void CFE_TestMain(void) FSUtilTestSetup(); MessageIdTestSetup(); MsgApiTestSetup(); + ResourceIdMiscTestSetup(); SBPipeMangSetup(); + SBSendRecvTestSetup(); + SBSubscriptionTestSetup(); TBLContentAccessTestSetup(); TBLContentMangTestSetup(); TBLInformationTestSetup(); diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index 4931c5063..f011eab3b 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -70,26 +70,6 @@ extern CFE_FT_Global_t CFE_FT_Global; */ #define CFE_ASSERT_LOG_FILE_NAME "/cf/cfe_test.log" -/* Compare two Resource IDs */ -#define cFE_FTAssert_ResourceID_EQ(actual, expect) \ - UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(actual, expect), "%s (%lu) == %s (%lu)", #actual, \ - CFE_RESOURCEID_TO_ULONG(actual), #expect, CFE_RESOURCEID_TO_ULONG(expect)) - -/* Check if a Resource ID is Undefined */ -#define cFE_FTAssert_ResourceID_Undefined(id) \ - UtAssert_True(!CFE_RESOURCEID_TEST_DEFINED(id), "%s (%lu) not defined", #id, CFE_RESOURCEID_TO_ULONG(id)) - -/* Assert a return code is not equal to cfe_success */ -#define cFE_FTAssert_NOT_CFE_SUCCESS(actual) \ - do \ - { \ - int32 rcact = (int32)(actual); \ - UtAssert_True(rcact < CFE_SUCCESS, "%s == (%ld) ", #actual, (long)rcact); \ - } while (0) - -/* Assert if status is CFE_SUCCESS */ -#define cFE_FTAssert_SUCCESS(status) UtAssert_INT32_EQ(status, CFE_SUCCESS) - bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t difference); void CFE_TestMain(void); @@ -109,7 +89,10 @@ void FSHeaderTestSetup(void); void FSUtilTestSetup(void); void MessageIdTestSetup(void); void MsgApiTestSetup(void); +void ResourceIdMiscTestSetup(void); void SBPipeMangSetup(void); +void SBSendRecvTestSetup(void); +void SBSubscriptionTestSetup(void); void TBLContentAccessTestSetup(void); void TBLContentMangTestSetup(void); void TBLInformationTestSetup(void); diff --git a/modules/cfe_testcase/src/es_cds_test.c b/modules/cfe_testcase/src/es_cds_test.c index 42a9778b0..44ba530e4 100644 --- a/modules/cfe_testcase/src/es_cds_test.c +++ b/modules/cfe_testcase/src/es_cds_test.c @@ -38,26 +38,44 @@ void TestRegisterCDS(void) CFE_ES_CDSHandle_t CDSHandlePtr; CFE_ES_CDSHandle_t CDSHandlePtr2; - size_t BlockSize = 10; - size_t BlockSize2 = 15; - const char * Name = "CDS_Test"; - const char * LongName = "VERY_LONG_NAME_CDS_Test"; - CFE_Status_t status; + size_t BlockSize = 10; + size_t BlockSize2 = 15; + const char *Name = "CDS_Test"; + const char *LongName = "VERY_LONG_NAME_CDS_Test"; UtPrintf("Testing: CFE_ES_RegisterCDS"); - status = CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize2, Name); + /* + * Since this test app may be executed multiple times, or the system may have + * been booted from a processor reset rather than a power-on reset, it is possible + * that the CDS already exists at the time this test is executed. In this case + * the new CDS allocation path cannot be checked in functional test, but other CDS + * functions can still be called. + */ - if (status == CFE_ES_CDS_ALREADY_EXISTS) + CFE_Assert_STATUS_STORE(CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize2, Name)); + + if (CFE_Assert_STATUS_MAY_BE(CFE_ES_CDS_ALREADY_EXISTS)) { - UtAssert_NA("CDS already exists. CFE_ES_RegisterCDS new allocation could not be properly tested"); + /* + * add an informational message that the functional test is incomplete here, due + * to preconditions beyond the control of this test app. Need to clear the CDS + * memory and/or do a power-on reset to get full test. + */ + UtAssert_WARN("CDS already exists. CFE_ES_RegisterCDS new allocation could not be properly tested"); } else { - UtAssert_INT32_EQ(status, CFE_SUCCESS); + /* + * If not CFE_ES_CDS_ALREADY_EXISTS, then the only other acceptable status is CFE_SUCCESS, + * which indicates that the CDS was created and initialized from a clean slate. + */ + CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); + + /* In this case, calling CFE_ES_RegisterCDS() again should return the CFE_ES_CDS_ALREADY_EXISTS */ + UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize2, Name), CFE_ES_CDS_ALREADY_EXISTS); } - UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize2, Name), CFE_ES_CDS_ALREADY_EXISTS); UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize, Name), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_RegisterCDS(NULL, BlockSize, Name), CFE_ES_BAD_ARGUMENT); diff --git a/modules/cfe_testcase/src/es_misc_test.c b/modules/cfe_testcase/src/es_misc_test.c index 18af9c48b..6545efa29 100644 --- a/modules/cfe_testcase/src/es_misc_test.c +++ b/modules/cfe_testcase/src/es_misc_test.c @@ -73,9 +73,16 @@ void TestProcessAsyncEvent(void) UtAssert_VOIDCALL(CFE_ES_ProcessAsyncEvent()); } +void TestBackgroundWakeup(void) +{ + UtPrintf("Testing: CFE_ES_BackgroundWakeup"); + UtAssert_VOIDCALL(CFE_ES_BackgroundWakeup()); +} + void ESMiscTestSetup(void) { UtTest_Add(TestCalculateCRC, NULL, NULL, "Test Calculate CRC"); UtTest_Add(TestWriteToSysLog, NULL, NULL, "Test Write To Sys Log"); UtTest_Add(TestProcessAsyncEvent, NULL, NULL, "Test Process Async Event"); + UtTest_Add(TestBackgroundWakeup, NULL, NULL, "Test Background Wakeup"); } diff --git a/modules/cfe_testcase/src/msg_api_test.c b/modules/cfe_testcase/src/msg_api_test.c index 6a4fb81f5..0690ef07a 100644 --- a/modules/cfe_testcase/src/msg_api_test.c +++ b/modules/cfe_testcase/src/msg_api_test.c @@ -46,6 +46,8 @@ void TestMsgApiBasic(void) CFE_SB_MsgId_t msgId; CFE_MSG_HeaderVersion_t hdrVer; CFE_MSG_ApId_t appId; + bool _expected = true; + bool _returned = false; memset(&cmd, 0xFF, sizeof(cmd)); msgId = CFE_SB_ValueToMsgId(0); @@ -53,71 +55,78 @@ void TestMsgApiBasic(void) /* test msg-init */ UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, msgId, 0), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, sizeof(cmd)), + CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_Init(&cmd.Msg, msgId, sizeof(cmd))); + UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, msgId, sizeof(cmd)), CFE_SUCCESS); /* test set-msg-size */ UtAssert_INT32_EQ(CFE_MSG_SetSize(NULL, 12), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetSize(&cmd.Msg, 0), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetSize(&cmd.Msg, UINT32_MAX), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetSize(&cmd.Msg, 12)); + UtAssert_INT32_EQ(CFE_MSG_SetSize(&cmd.Msg, 12), CFE_SUCCESS); /* test get-msg-size */ UtAssert_INT32_EQ(CFE_MSG_GetSize(NULL, &size), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_GetSize(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_GetSize(&cmd.Msg, &size)); + UtAssert_INT32_EQ(CFE_MSG_GetSize(&cmd.Msg, &size), CFE_SUCCESS); UtAssert_UINT32_EQ(size, 12); /* test get-type */ UtAssert_INT32_EQ(CFE_MSG_SetType(NULL, CFE_MSG_Type_Cmd), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Invalid), CFE_MSG_BAD_ARGUMENT); + + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Cmd), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetType(NULL, &type), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Cmd)); + UtAssert_INT32_EQ(CFE_MSG_GetType(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_GetType(&cmd.Msg, &type)); + UtAssert_INT32_EQ(CFE_MSG_GetType(&cmd.Msg, &type), CFE_SUCCESS); UtAssert_INT32_EQ(type, CFE_MSG_Type_Cmd); /* test msg set-type */ - cFE_FTAssert_SUCCESS(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Tlm)); + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Tlm), CFE_SUCCESS); /* check if set-type works like expected */ - cFE_FTAssert_SUCCESS(CFE_MSG_GetType(&cmd.Msg, &type)); + UtAssert_INT32_EQ(CFE_MSG_GetType(&cmd.Msg, &type), CFE_SUCCESS); UtAssert_INT32_EQ(type, CFE_MSG_Type_Tlm); /* test get header-version */ UtAssert_INT32_EQ(CFE_MSG_GetHeaderVersion(NULL, &hdrVer), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_GetHeaderVersion(&cmd.Msg, &hdrVer)); + UtAssert_INT32_EQ(CFE_MSG_GetHeaderVersion(&cmd.Msg, &hdrVer), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_MSG_GetHeaderVersion(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); /* test set header-version */ UtAssert_INT32_EQ(CFE_MSG_SetHeaderVersion(NULL, hdrVer), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetHeaderVersion(&cmd.Msg, 0)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetHeaderVersion(&cmd.Msg, &hdrVer)); + UtAssert_INT32_EQ(CFE_MSG_SetHeaderVersion(&cmd.Msg, UINT16_MAX), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetHeaderVersion(&cmd.Msg, 0), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetHeaderVersion(&cmd.Msg, &hdrVer), CFE_SUCCESS); UtAssert_True(hdrVer == 0, "hdrVer = 0"); /* test get-has-secondary-header and set-has-scondary-header*/ - bool _expected = true; - bool _returned = false; - UtAssert_INT32_EQ(CFE_MSG_GetHasSecondaryHeader(NULL, &_expected), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_GetHasSecondaryHeader(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetHasSecondaryHeader(NULL, _expected), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetHasSecondaryHeader(&cmd.Msg, _expected)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetHasSecondaryHeader(&cmd.Msg, &_returned)); + UtAssert_INT32_EQ(CFE_MSG_SetHasSecondaryHeader(&cmd.Msg, _expected), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetHasSecondaryHeader(&cmd.Msg, &_returned), CFE_SUCCESS); UtAssert_UINT32_EQ(_expected, _returned); /* test get-apid */ UtAssert_INT32_EQ(CFE_MSG_GetApId(NULL, &appId), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_GetApId(&cmd.Msg, &appId)); UtAssert_INT32_EQ(CFE_MSG_GetApId(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); /* test set-apid */ - UtAssert_INT32_EQ(CFE_MSG_GetApId(NULL, 0), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_SetApId(&cmd.Msg, 0xFFFF), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetApId(NULL, 0), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetApId(&cmd.Msg, 0)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetApId(&cmd.Msg, &appId)); - UtAssert_True(appId == 0, "CFE_MSG_SetApId => apid = 0"); + UtAssert_INT32_EQ(CFE_MSG_SetApId(&cmd.Msg, 5), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetApId(&cmd.Msg, &appId), CFE_SUCCESS); + UtAssert_INT32_EQ(appId, 5); } -void TestMsgApiAdvanced1(void) +void TestMsgApiAdvanced(void) { UtPrintf("Testing: CFE_MSG_GetSegmentationFlag, CFE_MSG_SetSegmentationFlag, " "CFE_MSG_GetSequenceCount, CFE_MSG_SetSequenceCount, CFE_MSG_GetNextSequenceCount"); @@ -131,108 +140,111 @@ void TestMsgApiAdvanced1(void) memset(&cmd, 0xFF, sizeof(cmd)); msgId = CFE_SB_ValueToMsgId(0); - /* test msg-init */ - UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT); - UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, msgId, 0), CFE_MSG_BAD_ARGUMENT); - - cFE_FTAssert_SUCCESS(CFE_MSG_Init(&cmd.Msg, msgId, sizeof(cmd))); + UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, msgId, sizeof(cmd)), CFE_SUCCESS); /* test get/set-segmentation-flag */ UtAssert_INT32_EQ(CFE_MSG_GetSegmentationFlag(NULL, &segFlag), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_GetSegmentationFlag(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_SetSegmentationFlag(NULL, CFE_MSG_SegFlag_Continue), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetSegmentationFlag(&cmd.Msg, CFE_MSG_SegFlag_Invalid), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetSegmentationFlag(&cmd.Msg, CFE_MSG_SegFlag_Continue)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetSegmentationFlag(&cmd.Msg, &segFlag)); - UtAssert_True(segFlag == CFE_MSG_SegFlag_Continue, - "CFE_MSG_SetSegmentationFlag => segFlag = CFE_MSG_SegFlag_Continue"); + UtAssert_INT32_EQ(CFE_MSG_SetSegmentationFlag(&cmd.Msg, CFE_MSG_SegFlag_Continue), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetSegmentationFlag(&cmd.Msg, CFE_MSG_SegFlag_First), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetSegmentationFlag(&cmd.Msg, CFE_MSG_SegFlag_Last), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetSegmentationFlag(&cmd.Msg, CFE_MSG_SegFlag_Unsegmented), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSegmentationFlag(&cmd.Msg, &segFlag), CFE_SUCCESS); + UtAssert_UINT32_EQ(segFlag, CFE_MSG_SegFlag_Unsegmented); /* test set/get-sequence-count */ UtAssert_INT32_EQ(CFE_MSG_SetSequenceCount(NULL, 2), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetSequenceCount(&cmd.Msg, UINT16_MAX), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(NULL, &seqCnt), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetSequenceCount(&cmd.Msg, 2)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetSequenceCount(&cmd.Msg, &seqCnt)); - - UtAssert_True(seqCnt == 2, "CFE_MSG_SetSequenceCount => seqCnt = 2"); + UtAssert_INT32_EQ(CFE_MSG_SetSequenceCount(&cmd.Msg, 2), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&cmd.Msg, &seqCnt), CFE_SUCCESS); + UtAssert_INT32_EQ(seqCnt, 2); /* test get-next-sequence-count */ - - /* 0x3FFF <- bad because defined CFE_MSG_SEQCNT_MASK value but not public */ - /* UtAssert_True(CFE_MSG_GetNextSequenceCount(0x3FFF) == 0, "CFE_MSG_GetNextSequenceCount(0x3FFF) = 0"); */ - UtAssert_True(CFE_MSG_GetNextSequenceCount(2) == 3, "CFE_MSG_GetNextSequenceCount(2) = 3"); + UtAssert_INT32_EQ(CFE_MSG_GetNextSequenceCount(seqCnt), 3); + UtAssert_INT32_EQ(CFE_MSG_GetNextSequenceCount(UINT16_MAX), 0); } -void TestMsgApiAdvanced2(void) +void TestMsgHeaderSecondaryApi(void) { UtPrintf("Testing: CFE_MSG_GenerateChecksum, CFE_MSG_ValidateChecksum, CFE_MSG_SetFcnCode, " "CFE_MSG_GetFcnCode, CFE_MSG_GetMsgTime, CFE_MSG_SetMsgTime "); /* declare local vars */ CFE_MSG_CommandHeader_t cmd; - CFE_SB_MsgId_t msgId; + CFE_MSG_CommandHeader_t cmdTlm; + CFE_MSG_CommandHeader_t cmd2; CFE_MSG_FcnCode_t fcnCode; CFE_TIME_SysTime_t msgTime; + bool isValid = true; + CFE_TIME_SysTime_t currentTime = {1000, 0xFFFF0000}; - memset(&cmd, 0xFF, sizeof(cmd)); - msgId = CFE_SB_ValueToMsgId(0); + memset(&cmd, 0, sizeof(cmd)); + memset(&cmdTlm, 0xFF, sizeof(cmdTlm)); + memset(&cmd2, 0xFF, sizeof(cmd2)); /* msg-init */ - UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT); - UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, msgId, 0), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_Init(&cmd.Msg, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetHasSecondaryHeader(&cmd.Msg, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Cmd), CFE_SUCCESS); + + UtAssert_INT32_EQ(CFE_MSG_Init(&cmdTlm.Msg, CFE_SB_ValueToMsgId(1), sizeof(cmdTlm)), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetHasSecondaryHeader(&cmdTlm.Msg, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmdTlm.Msg, CFE_MSG_Type_Tlm), CFE_SUCCESS); - cFE_FTAssert_SUCCESS(CFE_MSG_Init(&cmd.Msg, msgId, sizeof(cmd))); - cFE_FTAssert_SUCCESS(CFE_MSG_SetHasSecondaryHeader(&cmd.Msg, true)); + UtAssert_INT32_EQ(CFE_MSG_Init(&cmd2.Msg, CFE_SB_ValueToMsgId(2), sizeof(cmd2)), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetHasSecondaryHeader(&cmd2.Msg, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd2.Msg, CFE_MSG_Type_Cmd), CFE_SUCCESS); /* test generate-checksum */ UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(NULL), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Tlm)); - UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmd.Msg), CFE_MSG_WRONG_MSG_TYPE); - cFE_FTAssert_SUCCESS(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Cmd)); - - /* create new cmd message */ - CFE_MSG_CommandHeader_t cmd2; - bool isValid = true; - - memset(&cmd2, 0, sizeof(cmd2)); - cFE_FTAssert_SUCCESS(CFE_MSG_Init(&cmd2.Msg, CFE_SB_ValueToMsgId(1), sizeof(cmd2))); - cFE_FTAssert_SUCCESS(CFE_MSG_SetHasSecondaryHeader(&cmd2.Msg, true)); - cFE_FTAssert_SUCCESS(CFE_MSG_SetType(&cmd2.Msg, CFE_MSG_Type_Cmd)); + UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmdTlm.Msg), CFE_MSG_WRONG_MSG_TYPE); + UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmdTlm.Msg, &isValid), CFE_MSG_WRONG_MSG_TYPE); + UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(NULL, &isValid), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmdTlm.Msg, NULL), CFE_MSG_BAD_ARGUMENT); - cFE_FTAssert_SUCCESS(CFE_MSG_ValidateChecksum(&cmd2.Msg, &isValid)); - UtAssert_True(!isValid, "Is checksum valid = false"); - cFE_FTAssert_SUCCESS(CFE_MSG_GenerateChecksum(&cmd2.Msg)); - cFE_FTAssert_SUCCESS(CFE_MSG_ValidateChecksum(&cmd2.Msg, &isValid)); - UtAssert_True(isValid, "Checksum is valid"); + UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmd.Msg, &isValid), CFE_SUCCESS); + UtAssert_True(!isValid, "Checksum isValid (%d) = false", isValid); + UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmd.Msg), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmd.Msg, &isValid), CFE_SUCCESS); + UtAssert_True(isValid, "Checksum isValid (%d) = true", isValid); /* test get/set-fcn-code */ UtAssert_INT32_EQ(CFE_MSG_SetFcnCode(NULL, 4), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetFcnCode(&cmdTlm.Msg, 4), CFE_MSG_WRONG_MSG_TYPE); + UtAssert_INT32_EQ(CFE_MSG_GetFcnCode(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_GetFcnCode(NULL, &fcnCode), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_GetFcnCode(&cmdTlm.Msg, &fcnCode), CFE_MSG_WRONG_MSG_TYPE); - cFE_FTAssert_SUCCESS(CFE_MSG_SetFcnCode(&cmd.Msg, 4)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetFcnCode(&cmd.Msg, &fcnCode)); - - UtAssert_True(fcnCode == 4, "CFE_MSG_SetFcnCode => fcnCode = 4"); + UtAssert_INT32_EQ(CFE_MSG_SetFcnCode(&cmd.Msg, 4), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetFcnCode(&cmd.Msg, &fcnCode), CFE_SUCCESS); + UtAssert_INT32_EQ(fcnCode, 4); /* test get/set-msg-time */ - CFE_TIME_SysTime_t currentTime = CFE_TIME_GetTime(); - cFE_FTAssert_SUCCESS(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Tlm)); + UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd.Msg, CFE_MSG_Type_Tlm), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(NULL, &msgTime), CFE_MSG_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT); - UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(NULL, currentTime), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(&cmd2.Msg, &msgTime), CFE_MSG_WRONG_MSG_TYPE); - cFE_FTAssert_SUCCESS(CFE_MSG_SetMsgTime(&cmd.Msg, currentTime)); - cFE_FTAssert_SUCCESS(CFE_MSG_GetMsgTime(&cmd.Msg, &msgTime)); + UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(NULL, currentTime), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(&cmd2.Msg, currentTime), CFE_MSG_WRONG_MSG_TYPE); - UtAssert_UINT32_EQ(CFE_TIME_Compare(msgTime, currentTime), CFE_TIME_A_LT_B); + UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(&cmd.Msg, currentTime), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(&cmd.Msg, &msgTime), CFE_SUCCESS); + UtAssert_UINT32_EQ(CFE_TIME_Compare(msgTime, currentTime), CFE_TIME_EQUAL); } void MsgApiTestSetup(void) { UtTest_Add(TestMsgApiBasic, NULL, NULL, "Test basic message header apis"); - UtTest_Add(TestMsgApiAdvanced1, NULL, NULL, "Test advanced message header apis part 1"); - UtTest_Add(TestMsgApiAdvanced2, NULL, NULL, "Test advanced message header apis part 2"); + UtTest_Add(TestMsgApiAdvanced, NULL, NULL, "Test advanced message header apis"); + UtTest_Add(TestMsgHeaderSecondaryApi, NULL, NULL, "Test message secondary header apis"); } diff --git a/modules/cfe_testcase/src/resource_id_misc_test.c b/modules/cfe_testcase/src/resource_id_misc_test.c new file mode 100644 index 000000000..23af7fa7e --- /dev/null +++ b/modules/cfe_testcase/src/resource_id_misc_test.c @@ -0,0 +1,219 @@ +/************************************************************************* +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 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: resource_id_misc_test.c +** +** Purpose: +** Functional test of Miscellaneous Resource Id APIs +** +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" +/* Needed for CFE_RESOURCEID_MAKE_BASE macro */ +#include "cfe_resourceid_basevalue.h" + +bool TestReturnFalse(CFE_ResourceId_t CheckId) +{ + return false; +} + +bool TestReturnTrue(CFE_ResourceId_t CheckId) +{ + return true; +} + +void TestToFromInteger(void) +{ + UtPrintf("Testing: CFE_ResourceId_ToInteger, CFE_ResourceId_FromInteger, CFE_ResourceId_Equal"); + + /* Test integer -> resource ID -> integer */ + uint32 Id1 = 1; + uint32 Id2 = 999; + CFE_ResourceId_t ResourceId1 = CFE_ResourceId_FromInteger(Id1); + CFE_ResourceId_t ResourceId2 = CFE_ResourceId_FromInteger(Id2); + UtAssert_UINT32_EQ(CFE_ResourceId_ToInteger(ResourceId1), Id1); + UtAssert_UINT32_EQ(CFE_ResourceId_ToInteger(ResourceId2), Id2); + + /* Test resource ID -> integer -> resource ID */ + Id1 = CFE_ResourceId_ToInteger(ResourceId1); + Id2 = CFE_ResourceId_ToInteger(ResourceId2); + CFE_UtAssert_RESOURCEID_EQ((CFE_RESOURCEID_BASE_TYPE)CFE_RESOURCEID_WRAP(CFE_ResourceId_FromInteger(Id1)), + (CFE_RESOURCEID_BASE_TYPE)CFE_RESOURCEID_WRAP(ResourceId1)); + CFE_UtAssert_RESOURCEID_EQ((CFE_RESOURCEID_BASE_TYPE)CFE_RESOURCEID_WRAP(CFE_ResourceId_FromInteger(Id2)), + (CFE_RESOURCEID_BASE_TYPE)CFE_RESOURCEID_WRAP(ResourceId2)); +} + +void TestIsDefined(void) +{ + UtPrintf("Testing: CFE_ResourceId_IsDefined"); + CFE_ResourceId_t ResourceId1 = CFE_ResourceId_FromInteger(1); + CFE_ResourceId_t ResourceId2 = CFE_ResourceId_FromInteger(999); + UtAssert_BOOL_TRUE(CFE_ResourceId_IsDefined(ResourceId1)); + UtAssert_BOOL_TRUE(CFE_ResourceId_IsDefined(ResourceId2)); + UtAssert_BOOL_FALSE(CFE_ResourceId_IsDefined(CFE_RESOURCEID_UNDEFINED)); +} + +void TestGetBaseSerial(void) +{ + UtPrintf("Testing: CFE_ResourceId_GetBase, CFE_ResourceId_GetSerial"); + const char *LibName = "ASSERT_LIB"; + const char *CounterName = "TEST_COUNTER"; + int8 Pool[1024]; + size_t CDSBlockSize = 10; + const char *CDSName = "TEST_CDS"; + union + { + CFE_ES_AppId_t AppId; + CFE_ResourceId_t ResourceID; + } AppIdBuf; + union + { + CFE_ES_LibId_t LibId; + CFE_ResourceId_t ResourceID; + } LibIdBuf; + union + { + CFE_ES_TaskId_t TaskId; + CFE_ResourceId_t ResourceID; + } TaskIdBuf; + union + { + CFE_ES_CounterId_t CounterId; + CFE_ResourceId_t ResourceID; + } CounterIdBuf; + union + { + CFE_ES_MemHandle_t PoolId; + CFE_ResourceId_t ResourceID; + } PoolIdBuf; + union + { + CFE_ES_CDSHandle_t CDSHandleId; + CFE_ResourceId_t ResourceID; + } CDSHandleIdBuf; + + /* Referenced from cfe_core_resourceid_basevalues.h */ + int TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_OS_TASK); + int APPID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 1); + int LIBID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 2); + int COUNTID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 3); + int POOLID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 4); + int CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 5); + + /* App ID */ + UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppIdBuf.AppId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ResourceId_GetBase(AppIdBuf.ResourceID), APPID_BASE); + UtAssert_INT32_EQ(CFE_ResourceId_GetSerial(AppIdBuf.ResourceID), + CFE_RESOURCEID_UNWRAP(AppIdBuf.ResourceID) - APPID_BASE); + /* Lib ID */ + UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&LibIdBuf.LibId, LibName), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ResourceId_GetBase(LibIdBuf.ResourceID), LIBID_BASE); + UtAssert_INT32_EQ(CFE_ResourceId_GetSerial(LibIdBuf.ResourceID), + CFE_RESOURCEID_UNWRAP(LibIdBuf.ResourceID) - LIBID_BASE); + /* Task ID */ + UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskIdBuf.TaskId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ResourceId_GetBase(TaskIdBuf.ResourceID), TASKID_BASE); + UtAssert_INT32_EQ(CFE_ResourceId_GetSerial(TaskIdBuf.ResourceID), + CFE_RESOURCEID_UNWRAP(TaskIdBuf.ResourceID) - TASKID_BASE); + /* Counter ID */ + UtAssert_UINT32_EQ(CFE_ES_RegisterGenCounter(&CounterIdBuf.CounterId, CounterName), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ResourceId_GetBase(CounterIdBuf.ResourceID), COUNTID_BASE); + UtAssert_INT32_EQ(CFE_ResourceId_GetSerial(CounterIdBuf.ResourceID), + CFE_RESOURCEID_UNWRAP(CounterIdBuf.ResourceID) - COUNTID_BASE); + UtAssert_INT32_EQ(CFE_ES_DeleteGenCounter(CounterIdBuf.CounterId), CFE_SUCCESS); + /* Pool ID */ + UtAssert_INT32_EQ(CFE_ES_PoolCreate(&PoolIdBuf.PoolId, Pool, sizeof(Pool)), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ResourceId_GetBase(PoolIdBuf.ResourceID), POOLID_BASE); + UtAssert_INT32_EQ(CFE_ResourceId_GetSerial(PoolIdBuf.ResourceID), + CFE_RESOURCEID_UNWRAP(PoolIdBuf.ResourceID) - POOLID_BASE); + UtAssert_INT32_EQ(CFE_ES_PoolDelete(PoolIdBuf.PoolId), CFE_SUCCESS); + /* CDS Block Id */ + CFE_UtAssert_STATUS_OK(CFE_ES_RegisterCDS(&CDSHandleIdBuf.CDSHandleId, CDSBlockSize, CDSName)); + UtAssert_INT32_EQ(CFE_ResourceId_GetBase(CDSHandleIdBuf.ResourceID), CDSBLOCKID_BASE); + UtAssert_INT32_EQ(CFE_ResourceId_GetSerial(CDSHandleIdBuf.ResourceID), + CFE_RESOURCEID_UNWRAP(CDSHandleIdBuf.ResourceID) - CDSBLOCKID_BASE); +} + +void TestFindNext(void) +{ + UtPrintf("Testing: CFE_ResourceId_FindNext"); + union + { + CFE_ES_AppId_t AppId; + CFE_ResourceId_t ResourceID; + } AppIdBuf; + UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppIdBuf.AppId), CFE_SUCCESS); + /* + * The FindNext API requires a callback function to determine if a resource id is already in use. This test provides + * two local callback functions TestReturnFalse and TestReturnTrue to test the basic functionality of this API. + */ + UtAssert_INT32_EQ(CFE_ResourceId_ToInteger(CFE_ResourceId_FindNext( + AppIdBuf.ResourceID, CFE_PLATFORM_ES_MAX_APPLICATIONS, TestReturnFalse)), + CFE_RESOURCEID_UNWRAP(AppIdBuf.ResourceID) + 1); + /* Pretend every application id is used */ + AppIdBuf.ResourceID = + CFE_ResourceId_FindNext(AppIdBuf.ResourceID, CFE_PLATFORM_ES_MAX_APPLICATIONS, TestReturnTrue); + /* + * Why does this macro not accept a resource ID + * The following line won't compile + * CFE_UtAssert_RESOURCEID_UNDEFINED(AppIdBuf.ResourceId); + */ + CFE_UtAssert_RESOURCEID_UNDEFINED(AppIdBuf.AppId); + + /* maximum number of applications is 0 */ + AppIdBuf.ResourceID = CFE_ResourceId_FindNext(AppIdBuf.ResourceID, 0, TestReturnFalse); + CFE_UtAssert_RESOURCEID_UNDEFINED(AppIdBuf.AppId); +} + +void TestToIndex(void) +{ + UtPrintf("Testing: CFE_ResourceId_ToIndex"); + union + { + CFE_ES_AppId_t AppId; + CFE_ResourceId_t ResourceID; + } AppIdBuf; + uint32 idx; + int APPID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 1); + UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppIdBuf.AppId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(AppIdBuf.ResourceID, APPID_BASE, CFE_PLATFORM_ES_MAX_APPLICATIONS, NULL), + CFE_ES_BAD_ARGUMENT); + /* pretend maximum number of applications is 0 */ + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(AppIdBuf.ResourceID, APPID_BASE, 0, &idx), + CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(AppIdBuf.ResourceID, APPID_BASE, CFE_PLATFORM_ES_MAX_APPLICATIONS, &idx), + CFE_SUCCESS); + UtAssert_INT32_LTEQ(idx, CFE_PLATFORM_ES_MAX_APPLICATIONS); +} + +void ResourceIdMiscTestSetup(void) +{ + UtTest_Add(TestToFromInteger, NULL, NULL, "Test Resource Id to Integer"); + UtTest_Add(TestIsDefined, NULL, NULL, "Test Resource Id is Defined"); + UtTest_Add(TestGetBaseSerial, NULL, NULL, "Test Resource Id Get Base"); + UtTest_Add(TestFindNext, NULL, NULL, "Test Resource Id Find Next"); + UtTest_Add(TestToIndex, NULL, NULL, "Test Resource Id to Index"); +} diff --git a/modules/cfe_testcase/src/sb_sendrecv_test.c b/modules/cfe_testcase/src/sb_sendrecv_test.c new file mode 100644 index 000000000..699a73123 --- /dev/null +++ b/modules/cfe_testcase/src/sb_sendrecv_test.c @@ -0,0 +1,283 @@ +/************************************************************************* +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 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 + * + * Functional test of SB transmit/receive APIs + * CFE_SB_TransmitMsg - Transmit a message. + * CFE_SB_ReceiveBuffer - Receive a message from a software bus pipe. + * CFE_SB_AllocateMessageBuffer - Get a buffer pointer to use for "zero copy" SB sends. + * CFE_SB_ReleaseMessageBuffer - Release an unused "zero copy" buffer pointer. + * CFE_SB_TransmitBuffer - Transmit a buffer. + */ + +#include "cfe_test.h" +#include "cfe_msgids.h" + +/* A simple command message */ +typedef struct +{ + CFE_MSG_CommandHeader_t CmdHeader; + uint32 CmdPayload; +} CFE_FT_TestCmdMessage_t; + +/* A simple telemetry message */ +typedef struct +{ + CFE_MSG_TelemetryHeader_t TlmHeader; + uint32 TlmPayload; +} CFE_FT_TestTlmMessage_t; + +/* A message intended to be (overall) larger than the CFE_MISSION_SB_MAX_SB_MSG_SIZE */ +typedef struct +{ + CFE_MSG_Message_t Hdr; + uint8 MaxSize[CFE_MISSION_SB_MAX_SB_MSG_SIZE]; +} CFE_FT_TestBigMessage_t; + +/* + * This test procedure should be agnostic to specific MID values, but it should + * not overlap/interfere with real MIDs used by other apps. + */ +static const CFE_SB_MsgId_t CFE_FT_CMD_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_CMD_MID); +static const CFE_SB_MsgId_t CFE_FT_TLM_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_HK_TLM_MID); + +static CFE_FT_TestBigMessage_t CFE_FT_BigMsg; + +void TestBasicTransmitRecv(void) +{ + CFE_SB_PipeId_t PipeId1; + CFE_SB_PipeId_t PipeId2; + CFE_FT_TestCmdMessage_t CmdMsg; + CFE_FT_TestTlmMessage_t TlmMsg; + CFE_SB_MsgId_t MsgId; + CFE_MSG_SequenceCount_t Seq1, Seq2; + CFE_SB_Buffer_t * MsgBuf; + const CFE_FT_TestCmdMessage_t *CmdPtr; + const CFE_FT_TestTlmMessage_t *TlmPtr; + + UtPrintf("Testing: CFE_SB_TransmitMsg"); + + /* Setup, create a pipe and subscribe (one cmd, one tlm) */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 5, "TestPipe1"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId2, 5, "TestPipe2"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, PipeId1, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_TLM_MSGID, PipeId2, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS); + + /* Initialize the message content */ + UtAssert_INT32_EQ(CFE_MSG_Init(&CmdMsg.CmdHeader.Msg, CFE_FT_CMD_MSGID, sizeof(CmdMsg)), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_Init(&TlmMsg.TlmHeader.Msg, CFE_FT_TLM_MSGID, sizeof(TlmMsg)), CFE_SUCCESS); + + CFE_MSG_SetSequenceCount(&CmdMsg.CmdHeader.Msg, 11); + CFE_MSG_SetSequenceCount(&TlmMsg.TlmHeader.Msg, 21); + + /* Sending with sequence update should ignore the sequence in the msg struct */ + CmdMsg.CmdPayload = 0x0c0ffee; + TlmMsg.TlmPayload = 0x0d00d1e; + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CmdMsg.CmdHeader.Msg, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&TlmMsg.TlmHeader.Msg, true), CFE_SUCCESS); + + CmdMsg.CmdPayload = 0x1c0ffee; + TlmMsg.TlmPayload = 0x1d00d1e; + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CmdMsg.CmdHeader.Msg, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&TlmMsg.TlmHeader.Msg, true), CFE_SUCCESS); + + /* Sending without sequence update should use the sequence in the msg struct */ + CmdMsg.CmdPayload = 0x2c0ffee; + TlmMsg.TlmPayload = 0x2d00d1e; + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CmdMsg.CmdHeader.Msg, false), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&TlmMsg.TlmHeader.Msg, false), CFE_SUCCESS); + + /* Sending again should trigger MsgLimit errors on the pipe, however the call still returns CFE_SUCCESS */ + CmdMsg.CmdPayload = 0x3c0ffee; + TlmMsg.TlmPayload = 0x3d00d1e; + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CmdMsg.CmdHeader.Msg, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&TlmMsg.TlmHeader.Msg, true), CFE_SUCCESS); + + /* Attempt to send a msg which does not have a valid msgid */ + memset(&CFE_FT_BigMsg, 0xFF, sizeof(CFE_FT_BigMsg)); + CFE_MSG_SetSize(&CFE_FT_BigMsg.Hdr, sizeof(CFE_MSG_Message_t) + 4); + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CFE_FT_BigMsg.Hdr, true), CFE_SB_BAD_ARGUMENT); + + /* Attempt to send a msg which is too big */ + CFE_MSG_SetSize(&CFE_FT_BigMsg.Hdr, sizeof(CFE_FT_BigMsg)); + CFE_MSG_SetMsgId(&CFE_FT_BigMsg.Hdr, CFE_FT_CMD_MSGID); + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CFE_FT_BigMsg.Hdr, true), CFE_SB_MSG_TOO_BIG); + + /* Attempt to send a msg which is NULL */ + UtAssert_INT32_EQ(CFE_SB_TransmitMsg(NULL, true), CFE_SB_BAD_ARGUMENT); + + UtPrintf("Testing: CFE_SB_ReceiveBuffer"); + + /* off nominal / bad arguments */ + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, CFE_SB_INVALID_PIPE, 100), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(NULL, PipeId1, 100), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, -100), CFE_SB_BAD_ARGUMENT); + + /* + * Note, the CFE_SB_TransmitMsg ignores the "IncrementSequence" flag for commands. + * Thus, all the sequence numbers should come back with the original value set (11) + */ + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq1), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_CMD_MSGID); + CmdPtr = (const CFE_FT_TestCmdMessage_t *)MsgBuf; + UtAssert_UINT32_EQ(CmdPtr->CmdPayload, 0x0c0ffee); + UtAssert_UINT32_EQ(Seq1, 11); + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq1), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_CMD_MSGID); + CmdPtr = (const CFE_FT_TestCmdMessage_t *)MsgBuf; + UtAssert_UINT32_EQ(CmdPtr->CmdPayload, 0x1c0ffee); + UtAssert_UINT32_EQ(Seq1, 11); + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq1), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_CMD_MSGID); + CmdPtr = (const CFE_FT_TestCmdMessage_t *)MsgBuf; + UtAssert_UINT32_EQ(CmdPtr->CmdPayload, 0x2c0ffee); + UtAssert_UINT32_EQ(Seq1, 11); + + /* Final should not be in the pipe, should have been rejected due to MsgLim */ + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, 100), CFE_SB_TIME_OUT); + + /* + * For TLM, the CFE_SB_TransmitMsg obeys the "IncrementSequence" flag. + * Thus, first message gets the reference point, next message should be one more. + */ + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq1), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_TLM_MSGID); + TlmPtr = (const CFE_FT_TestTlmMessage_t *)MsgBuf; + UtAssert_UINT32_EQ(TlmPtr->TlmPayload, 0x0d00d1e); + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq2), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_TLM_MSGID); + TlmPtr = (const CFE_FT_TestTlmMessage_t *)MsgBuf; + UtAssert_UINT32_EQ(TlmPtr->TlmPayload, 0x1d00d1e); + UtAssert_UINT32_EQ(Seq2, CFE_MSG_GetNextSequenceCount(Seq1)); + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetSequenceCount(&MsgBuf->Msg, &Seq2), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_TLM_MSGID); + TlmPtr = (const CFE_FT_TestTlmMessage_t *)MsgBuf; + UtAssert_UINT32_EQ(TlmPtr->TlmPayload, 0x2d00d1e); + UtAssert_UINT32_EQ(Seq2, 21); + + /* Final should not be in the pipe, should have been rejected due to MsgLim */ + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, 100), CFE_SB_TIME_OUT); + + /* Cleanup */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId2), CFE_SUCCESS); +} + +/* This is a variant of the message transmit API that does not copy */ +void TestZeroCopyTransmitRecv(void) +{ + CFE_SB_PipeId_t PipeId1; + CFE_SB_PipeId_t PipeId2; + CFE_SB_Buffer_t *CmdBuf; + CFE_SB_Buffer_t *TlmBuf; + CFE_SB_Buffer_t *MsgBuf; + CFE_SB_MsgId_t MsgId; + + /* Setup, create a pipe and subscribe (one cmd, one tlm) */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 5, "TestPipe1"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId2, 5, "TestPipe2"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, PipeId1, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_TLM_MSGID, PipeId2, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS); + + UtPrintf("Testing: CFE_SB_AllocateMessageBuffer"); + + /* Confirm bad size rejection */ + UtAssert_NULL(CFE_SB_AllocateMessageBuffer(CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1)); + + /* Nominal */ + UtAssert_NOT_NULL(CmdBuf = CFE_SB_AllocateMessageBuffer(sizeof(CFE_FT_TestCmdMessage_t))); + UtAssert_NOT_NULL(TlmBuf = CFE_SB_AllocateMessageBuffer(sizeof(CFE_FT_TestTlmMessage_t))); + + UtPrintf("Testing: CFE_SB_ReleaseMessageBuffer"); + + /* allocate a buffer but then discard it without sending */ + UtAssert_NOT_NULL(MsgBuf = CFE_SB_AllocateMessageBuffer(sizeof(CFE_MSG_Message_t) + 4)); + UtAssert_INT32_EQ(CFE_SB_ReleaseMessageBuffer(MsgBuf), CFE_SUCCESS); + + /* Attempt to double-release, should fail validation */ + UtAssert_INT32_EQ(CFE_SB_ReleaseMessageBuffer(MsgBuf), CFE_SB_BUFFER_INVALID); + + /* Other bad input checking */ + UtAssert_INT32_EQ(CFE_SB_ReleaseMessageBuffer(NULL), CFE_SB_BAD_ARGUMENT); + + UtPrintf("Testing: CFE_SB_TransmitBuffer"); + + /* Initialize the message content */ + UtAssert_INT32_EQ(CFE_MSG_Init(&CmdBuf->Msg, CFE_FT_CMD_MSGID, sizeof(CFE_FT_TestCmdMessage_t)), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_Init(&TlmBuf->Msg, CFE_FT_TLM_MSGID, sizeof(CFE_FT_TestTlmMessage_t)), CFE_SUCCESS); + + UtAssert_INT32_EQ(CFE_SB_TransmitBuffer(CmdBuf, true), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_TransmitBuffer(TlmBuf, true), CFE_SUCCESS); + + /* Attempt to send a buffer which has been released */ + UtAssert_NOT_NULL(MsgBuf = CFE_SB_AllocateMessageBuffer(sizeof(CFE_MSG_Message_t) + 4)); + UtAssert_INT32_EQ(CFE_MSG_Init(&MsgBuf->Msg, CFE_FT_CMD_MSGID, sizeof(CFE_MSG_Message_t) + 4), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_ReleaseMessageBuffer(MsgBuf), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_TransmitBuffer(MsgBuf, true), CFE_SB_BUFFER_INVALID); + + /* Attempt to send a NULL buffer */ + UtAssert_INT32_EQ(CFE_SB_TransmitBuffer(NULL, true), CFE_SB_BAD_ARGUMENT); + + UtPrintf("Testing: CFE_SB_ReceiveBuffer"); + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_CMD_MSGID); + UtAssert_ADDRESS_EQ(MsgBuf, CmdBuf); /* should be the same actual buffer (not a copy) */ + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, 100), CFE_SB_TIME_OUT); + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, 100), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_MSG_GetMsgId(&MsgBuf->Msg, &MsgId), CFE_SUCCESS); + CFE_UtAssert_MSGID_EQ(MsgId, CFE_FT_TLM_MSGID); + UtAssert_ADDRESS_EQ(MsgBuf, TlmBuf); /* should be the same actual buffer (not a copy) */ + + UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId2, 100), CFE_SB_TIME_OUT); + + /* Cleanup */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId2), CFE_SUCCESS); +} + +void SBSendRecvTestSetup(void) +{ + UtTest_Add(TestBasicTransmitRecv, NULL, NULL, "Test Basic Transmit/Receive"); + UtTest_Add(TestZeroCopyTransmitRecv, NULL, NULL, "Test Zero Copy Transmit/Receive"); +} diff --git a/modules/cfe_testcase/src/sb_subscription_test.c b/modules/cfe_testcase/src/sb_subscription_test.c new file mode 100644 index 000000000..7fe51de5d --- /dev/null +++ b/modules/cfe_testcase/src/sb_subscription_test.c @@ -0,0 +1,253 @@ +/************************************************************************* +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 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 + * + * Functional test of SB subscription APIs + * CFE_SB_Subscribe - Subscribe to a message on the software bus with default parameters. + * CFE_SB_SubscribeEx - Subscribe to a message on the software bus. + * CFE_SB_SubscribeLocal - Subscribe to a message while keeping the request local to a cpu. + * CFE_SB_Unsubscribe - Remove a subscription to a message on the software bus. + * CFE_SB_UnsubscribeLocal - Remove a subscription to a message on the software bus on the current CPU. + */ + +#include "cfe_test.h" +#include "cfe_msgids.h" + +/* + * This test procedure should be agnostic to specific MID values, but it should + * not overlap/interfere with real MIDs used by other apps. + */ +static const CFE_SB_MsgId_t CFE_FT_CMD_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_CMD_MID); +static const CFE_SB_MsgId_t CFE_FT_TLM_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_HK_TLM_MID); + +void TestSubscribeUnsubscribe(void) +{ + CFE_SB_PipeId_t PipeId1; + CFE_SB_PipeId_t PipeId2; + + UtPrintf("Testing: CFE_SB_Subscribe, CFE_SB_Unsubscribe"); + + /* Setup, create some pipes */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 3, "TestPipe1"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId2, 3, "TestPipe2"), CFE_SUCCESS); + + /* Subscribe - Confirm Bad MsgId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_SB_INVALID_MSG_ID, PipeId1), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_SB_MSGID_RESERVED, PipeId2), CFE_SB_BAD_ARGUMENT); + + /* Subscribe - Confirm Bad PipeId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_CMD_MSGID, CFE_SB_INVALID_PIPE), CFE_SB_BAD_ARGUMENT); + + /* Subscribe - Nominal */ + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_CMD_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_TLM_MSGID, PipeId2), CFE_SUCCESS); + + /* Subscribe - Duplicate */ + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_CMD_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_TLM_MSGID, PipeId2), CFE_SUCCESS); + + /* Subscribe - Nominal 2 */ + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_TLM_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_Subscribe(CFE_FT_CMD_MSGID, PipeId2), CFE_SUCCESS); + + /* Unsubscribe - Confirm Bad MsgId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_SB_INVALID_MSG_ID, PipeId1), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_SB_MSGID_RESERVED, PipeId2), CFE_SB_BAD_ARGUMENT); + + /* Unsubscribe - Confirm Bad PipeId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_CMD_MSGID, CFE_SB_INVALID_PIPE), CFE_SB_BAD_ARGUMENT); + + /* Unsubscribe - Nominal */ + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_CMD_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_TLM_MSGID, PipeId2), CFE_SUCCESS); + + /* Unsubscribe - Already unsubscribed */ + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_CMD_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_TLM_MSGID, PipeId2), CFE_SUCCESS); + + /* Unsubscribe - Nominal 2 */ + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_TLM_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_Unsubscribe(CFE_FT_CMD_MSGID, PipeId2), CFE_SUCCESS); + + /* Teardown - delete the pipes. */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId2), CFE_SUCCESS); +} + +void TestSubscribeUnsubscribeLocal(void) +{ + CFE_SB_PipeId_t PipeId1; + CFE_SB_PipeId_t PipeId2; + + UtPrintf("Testing: CFE_SB_SubscribeLocal, CFE_SB_UnsubscribeLocal"); + + /* Setup, create some pipes */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 3, "TestPipe1"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId2, 3, "TestPipe2"), CFE_SUCCESS); + + /* Subscribe - Confirm Bad MsgId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_SB_INVALID_MSG_ID, PipeId1, 2), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_SB_MSGID_RESERVED, PipeId2, 2), CFE_SB_BAD_ARGUMENT); + + /* Subscribe - Confirm Bad PipeId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_CMD_MSGID, CFE_SB_INVALID_PIPE, 2), CFE_SB_BAD_ARGUMENT); + + /* Subscribe - Nominal */ + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_CMD_MSGID, PipeId1, 2), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_TLM_MSGID, PipeId2, 2), CFE_SUCCESS); + + /* Subscribe - Duplicate */ + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_CMD_MSGID, PipeId1, 2), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_TLM_MSGID, PipeId2, 2), CFE_SUCCESS); + + /* Subscribe - Nominal 2 */ + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_TLM_MSGID, PipeId1, 2), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(CFE_FT_CMD_MSGID, PipeId2, 2), CFE_SUCCESS); + + /* Unsubscribe - Confirm Bad MsgId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_SB_INVALID_MSG_ID, PipeId1), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_SB_MSGID_RESERVED, PipeId2), CFE_SB_BAD_ARGUMENT); + + /* Unsubscribe - Confirm Bad PipeId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_CMD_MSGID, CFE_SB_INVALID_PIPE), CFE_SB_BAD_ARGUMENT); + + /* Unsubscribe - Nominal */ + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_CMD_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_TLM_MSGID, PipeId2), CFE_SUCCESS); + + /* Unsubscribe - Already unsubscribed */ + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_CMD_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_TLM_MSGID, PipeId2), CFE_SUCCESS); + + /* Unsubscribe - Nominal 2 */ + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_TLM_MSGID, PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_UnsubscribeLocal(CFE_FT_CMD_MSGID, PipeId2), CFE_SUCCESS); + + /* Teardown - delete the pipes. */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId2), CFE_SUCCESS); +} + +void TestSubscribeEx(void) +{ + CFE_SB_PipeId_t PipeId1; + CFE_SB_PipeId_t PipeId2; + + /* + * NOTE: CFE_SB_SubscribeEx adds a "Quality" parameter for Qos, which is + * not utilized in the current SB implementation (only "default" is available). + * + * Otherwise, it is basically the same as the regular "CFE_SB_Subscribe" call. + */ + UtPrintf("Testing: CFE_SB_SubscribeEx"); + + /* Setup, create some pipes */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 3, "TestPipe1"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId2, 3, "TestPipe2"), CFE_SUCCESS); + + /* + * For completeness, repeat the bad arg rejection tests, even though internally + * it is likely identical (all going through CFE_SB_SubscribeFull). However + * this implementation detail should not be assumed in a black box test environment. + */ + + /* Subscribe - Confirm Bad MsgId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_SB_INVALID_MSG_ID, PipeId1, CFE_SB_DEFAULT_QOS, 2), CFE_SB_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_SB_MSGID_RESERVED, PipeId2, CFE_SB_DEFAULT_QOS, 2), CFE_SB_BAD_ARGUMENT); + + /* Subscribe - Confirm Bad PipeId Arg Rejection */ + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, CFE_SB_INVALID_PIPE, CFE_SB_DEFAULT_QOS, 2), + CFE_SB_BAD_ARGUMENT); + + /* Subscribe - Nominal */ + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, PipeId1, CFE_SB_DEFAULT_QOS, 2), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_TLM_MSGID, PipeId2, CFE_SB_DEFAULT_QOS, 2), CFE_SUCCESS); + + /* Teardown - delete the pipes (this also unsubscribes automatically) */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId2), CFE_SUCCESS); +} + +void TestSBMaxSubscriptions(void) +{ + CFE_Status_t Status; + uint32 NumSubs; + CFE_SB_MsgId_t TestMsgId; + CFE_SB_PipeId_t PipeId; + + UtPrintf("Testing: CFE_SB_Subscribe, max routing table limit"); + + /* Setup, create a pipe */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, 2, "TestPipe"), CFE_SUCCESS); + + /* + * Test max subscriptions - note this depends on the actual number of _other_ apps + * that are running and have made other subscriptions. Therefore it is not predictable + * exactly how many iterations of this loop will succeed, but it should be fewer than + * CFE_PLATFORM_SB_MAX_MSG_IDS. + * + * NOTE: after this loop, it may not be possible to add any more routes at all, until + * a processor reset is done, because routes are never actually deleted for sequence number persistence. + */ + NumSubs = 0; + while (NumSubs <= CFE_PLATFORM_SB_MAX_MSG_IDS) + { + /* fabricate a msgid to subscribe to (this may overlap real msgids) */ + TestMsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_PLATFORM_CMD_MID_BASE + NumSubs); + + Status = CFE_SB_Subscribe(TestMsgId, PipeId); + if (Status != CFE_SUCCESS) + { + break; + } + + ++NumSubs; + } + + /* Check that the number of subscriptions was within range */ + UtAssert_NONZERO(NumSubs); + UtAssert_UINT32_LTEQ(NumSubs, CFE_PLATFORM_SB_MAX_MSG_IDS); + + /* The last pass should have returned CFE_SB_MAX_MSGS_MET */ + UtAssert_True(Status == CFE_SB_MAX_MSGS_MET, + "CFE_SB_Subscribe(TestMsgId, PipeId1) (%ld) == CFE_SB_MAX_MSGS_MET (%ld)", (long)Status, + (long)CFE_SB_MAX_MSGS_MET); + + /* Note this should also remove any subscriptions from the above loop */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS); +} + +void SBSubscriptionTestSetup(void) +{ + UtTest_Add(TestSubscribeUnsubscribe, NULL, NULL, "Test SB Subscribe/Unsubscribe"); + UtTest_Add(TestSubscribeUnsubscribeLocal, NULL, NULL, "Test SB SubscribeLocal/UnsubscribeLocal"); + UtTest_Add(TestSubscribeEx, NULL, NULL, "Test SB SubscribeEx"); + + /* + * NOTE: The TestSBMaxSubscriptions() is not included/added by default, as it will fill the + * routing table and make it not possible to add new routes until the system is reset. + * + * The test can be optionally enabled by the user and should pass, if this is not a concern. + */ +} diff --git a/modules/cfe_testcase/src/tbl_content_mang_test.c b/modules/cfe_testcase/src/tbl_content_mang_test.c index 93a4b22e6..dd525c431 100644 --- a/modules/cfe_testcase/src/tbl_content_mang_test.c +++ b/modules/cfe_testcase/src/tbl_content_mang_test.c @@ -53,7 +53,6 @@ void TestLoad(void) CFE_TBL_ERR_FILE_FOR_WRONG_TABLE); UtAssert_INT32_EQ(CFE_TBL_Load(CFE_FT_Global.TblHandle, CFE_TBL_SRC_FILE, "/cf/sample_app_tbl.tbl"), CFE_TBL_ERR_FILE_FOR_WRONG_TABLE); - /* This is a very unintuitive error message. CFE_TBL_ERR_FILE_NOT_FOUND would be more accurate */ UtAssert_INT32_EQ(CFE_TBL_Load(CFE_FT_Global.TblHandle, CFE_TBL_SRC_FILE, "/cf/not_cfe_test_tbl.tbl"), CFE_TBL_ERR_ACCESS); diff --git a/modules/core_api/fsw/inc/cfe_error.h b/modules/core_api/fsw/inc/cfe_error.h index f28a2ee31..8f4ced247 100644 --- a/modules/core_api/fsw/inc/cfe_error.h +++ b/modules/core_api/fsw/inc/cfe_error.h @@ -600,15 +600,6 @@ typedef int32 CFE_Status_t; */ #define CFE_ES_POOL_BLOCK_INVALID ((CFE_Status_t)0xc400002C) -/** - * @brief Invalid pool size or buffer address - * - * A specified pool address or size is outside the acceptable - * bounds for that pool configuration. - * - */ -#define CFE_ES_POOL_BOUNDS_ERROR ((CFE_Status_t)0xc400002D) - /** * @brief Duplicate Name Error * @@ -907,13 +898,6 @@ typedef int32 CFE_Status_t; */ #define CFE_TBL_ERR_UNREGISTERED ((CFE_Status_t)0xcc000009) -/** - * @brief Bad Application ID - * - * The calling application does not have a legitimate Application ID. - */ -#define CFE_TBL_ERR_BAD_APP_ID ((CFE_Status_t)0xcc00000A) - /** * @brief Handles Full * @@ -990,14 +974,6 @@ typedef int32 CFE_Status_t; */ #define CFE_TBL_ERR_LOAD_IN_PROGRESS ((CFE_Status_t)0xcc000012) -/** - * @brief File Not Found - * - * The calling Application called #CFE_TBL_Load with a bad filename. - * - */ -#define CFE_TBL_ERR_FILE_NOT_FOUND ((CFE_Status_t)0xcc000013) - /** * @brief File Too Large * diff --git a/modules/core_api/fsw/inc/cfe_es.h b/modules/core_api/fsw/inc/cfe_es.h index 21d65c06a..44e6e79c3 100644 --- a/modules/core_api/fsw/inc/cfe_es.h +++ b/modules/core_api/fsw/inc/cfe_es.h @@ -1309,7 +1309,6 @@ CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t ** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS ** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT ** \retval #CFE_ES_NO_RESOURCE_IDS_AVAILABLE \copybrief CFE_ES_NO_RESOURCE_IDS_AVAILABLE -** \retval #CFE_ES_POOL_BOUNDS_ERROR \copybrief CFE_ES_POOL_BOUNDS_ERROR ** \retval #CFE_STATUS_EXTERNAL_RESOURCE_FAIL \copybrief CFE_STATUS_EXTERNAL_RESOURCE_FAIL ** ** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats diff --git a/modules/core_api/fsw/inc/cfe_msg.h b/modules/core_api/fsw/inc/cfe_msg.h index 89a52a9be..4b8cb3c0c 100644 --- a/modules/core_api/fsw/inc/cfe_msg.h +++ b/modules/core_api/fsw/inc/cfe_msg.h @@ -39,7 +39,7 @@ #include "cfe_sb_api_typedefs.h" #include "cfe_time_api_typedefs.h" -/** \defgroup CFEAPIMSGHeader cFE Message header APIs +/** \defgroup CFEAPIMSGHeader cFE Generic Message APIs * \{ */ @@ -61,6 +61,11 @@ * \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT */ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_MSG_Size_t Size); +/**\}*/ + +/** \defgroup CFEAPIMSGHeaderPri cFE Message Primary Header APIs + * \{ + */ /*****************************************************************************/ /** @@ -305,6 +310,11 @@ CFE_Status_t CFE_MSG_SetSequenceCount(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Sequenc * \return The next valid sequence count value */ CFE_MSG_SequenceCount_t CFE_MSG_GetNextSequenceCount(CFE_MSG_SequenceCount_t SeqCnt); +/**\}*/ + +/** \defgroup CFEAPIMSGHeaderExt cFE Message Extended Header APIs + * \{ + */ /*****************************************************************************/ /** @@ -470,6 +480,11 @@ CFE_Status_t CFE_MSG_GetSystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t * \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT */ CFE_Status_t CFE_MSG_SetSystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t System); +/**\}*/ + +/** \defgroup CFEAPIMSGHeaderSec cFE Message Secondary Header APIs + * \{ + */ /*****************************************************************************/ /** diff --git a/modules/core_api/fsw/inc/cfe_resourceid.h b/modules/core_api/fsw/inc/cfe_resourceid.h index 98e4e08a0..49108d207 100644 --- a/modules/core_api/fsw/inc/cfe_resourceid.h +++ b/modules/core_api/fsw/inc/cfe_resourceid.h @@ -199,7 +199,7 @@ uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId); * @param[in] TableSize the maximum size of the target table * @param[in] CheckFunc a function to check if the given ID is available * @returns Next ID value which does not map to a valid entry - * @retval #CFE_RESOURCEID_UNDEFINED if no open slots. + * @retval #CFE_RESOURCEID_UNDEFINED if no open slots or bad arguments. * */ CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, diff --git a/modules/core_api/fsw/inc/cfe_sb.h b/modules/core_api/fsw/inc/cfe_sb.h index 8189d3a7d..6f11d8029 100644 --- a/modules/core_api/fsw/inc/cfe_sb.h +++ b/modules/core_api/fsw/inc/cfe_sb.h @@ -569,7 +569,7 @@ CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IncrementSequen /** @} */ -/** @defgroup CFEAPISBSetMessage cFE Setting Message Characteristics APIs +/** @defgroup CFEAPISBMessageCharacteristics cFE Message Characteristics APIs * @{ */ @@ -648,11 +648,6 @@ void CFE_SB_TimeStampMsg(CFE_MSG_Message_t *MsgPtr); */ int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, size_t SourceMaxSize); -/** @} */ - -/** @defgroup CFEAPIGetMessage cFE Getting Message Characteristics APIs - * @{ - */ /*****************************************************************************/ /** diff --git a/modules/core_api/fsw/inc/cfe_tbl.h b/modules/core_api/fsw/inc/cfe_tbl.h index e4f03a552..277c62984 100644 --- a/modules/core_api/fsw/inc/cfe_tbl.h +++ b/modules/core_api/fsw/inc/cfe_tbl.h @@ -180,7 +180,7 @@ ** \retval #CFE_TBL_ERR_HANDLES_FULL \copybrief CFE_TBL_ERR_HANDLES_FULL ** \retval #CFE_TBL_ERR_INVALID_SIZE \copybrief CFE_TBL_ERR_INVALID_SIZE ** \retval #CFE_TBL_ERR_INVALID_NAME \copybrief CFE_TBL_ERR_INVALID_NAME -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID ** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT ** \retval #CFE_TBL_ERR_INVALID_OPTIONS \copybrief CFE_TBL_ERR_INVALID_OPTIONS ** \retval #CFE_TBL_WARN_DUPLICATE \copybrief CFE_TBL_WARN_DUPLICATE @@ -217,11 +217,11 @@ CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, ** that was registered by the application called "ACS". ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_ERR_HANDLES_FULL \copybrief CFE_TBL_ERR_HANDLES_FULL -** \retval #CFE_TBL_ERR_INVALID_NAME \copybrief CFE_TBL_ERR_INVALID_NAME -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_HANDLES_FULL \copybrief CFE_TBL_ERR_HANDLES_FULL +** \retval #CFE_TBL_ERR_INVALID_NAME \copybrief CFE_TBL_ERR_INVALID_NAME +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT ** ** \sa #CFE_TBL_Unregister, #CFE_TBL_Register ** @@ -257,10 +257,10 @@ CFE_Status_t CFE_TBL_Share(CFE_TBL_Handle_t *TblHandlePtr, const char *TblName); ** that identifies the Table to be unregistered. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** ** \sa #CFE_TBL_Share, #CFE_TBL_Register ** @@ -302,22 +302,22 @@ CFE_Status_t CFE_TBL_Unregister(CFE_TBL_Handle_t TblHandle); ** the address of the active table buffer. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_WARN_SHORT_FILE \copybrief CFE_TBL_WARN_SHORT_FILE -** \retval #CFE_TBL_WARN_PARTIAL_LOAD \copybrief CFE_TBL_WARN_PARTIAL_LOAD -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE -** \retval #CFE_TBL_ERR_DUMP_ONLY \copybrief CFE_TBL_ERR_DUMP_ONLY -** \retval #CFE_TBL_ERR_ILLEGAL_SRC_TYPE \copybrief CFE_TBL_ERR_ILLEGAL_SRC_TYPE -** \retval #CFE_TBL_ERR_LOAD_IN_PROGRESS \copybrief CFE_TBL_ERR_LOAD_IN_PROGRESS -** \retval #CFE_TBL_ERR_NO_BUFFER_AVAIL \copybrief CFE_TBL_ERR_NO_BUFFER_AVAIL -** \retval #CFE_TBL_ERR_FILE_NOT_FOUND \copybrief CFE_TBL_ERR_FILE_NOT_FOUND -** \retval #CFE_TBL_ERR_FILE_TOO_LARGE \copybrief CFE_TBL_ERR_FILE_TOO_LARGE -** \retval #CFE_TBL_ERR_BAD_CONTENT_ID \copybrief CFE_TBL_ERR_BAD_CONTENT_ID -** \retval #CFE_TBL_ERR_PARTIAL_LOAD \copybrief CFE_TBL_ERR_PARTIAL_LOAD -** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT -** \retval #CFE_TBL_WARN_PARTIAL_LOAD \copybrief CFE_TBL_WARN_PARTIAL_LOAD +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_WARN_SHORT_FILE \copybrief CFE_TBL_WARN_SHORT_FILE +** \retval #CFE_TBL_WARN_PARTIAL_LOAD \copybrief CFE_TBL_WARN_PARTIAL_LOAD +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_DUMP_ONLY \copybrief CFE_TBL_ERR_DUMP_ONLY +** \retval #CFE_TBL_ERR_ILLEGAL_SRC_TYPE \copybrief CFE_TBL_ERR_ILLEGAL_SRC_TYPE +** \retval #CFE_TBL_ERR_LOAD_IN_PROGRESS \copybrief CFE_TBL_ERR_LOAD_IN_PROGRESS +** \retval #CFE_TBL_ERR_NO_BUFFER_AVAIL \copybrief CFE_TBL_ERR_NO_BUFFER_AVAIL +** \retval #CFE_TBL_ERR_ACCESS \copybrief CFE_TBL_ERR_ACCESS +** \retval #CFE_TBL_ERR_FILE_TOO_LARGE \copybrief CFE_TBL_ERR_FILE_TOO_LARGE +** \retval #CFE_TBL_ERR_BAD_CONTENT_ID \copybrief CFE_TBL_ERR_BAD_CONTENT_ID +** \retval #CFE_TBL_ERR_PARTIAL_LOAD \copybrief CFE_TBL_ERR_PARTIAL_LOAD +** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT +** \retval #CFE_TBL_WARN_PARTIAL_LOAD \copybrief CFE_TBL_WARN_PARTIAL_LOAD ** ** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Manage ** @@ -341,11 +341,11 @@ CFE_Status_t CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, ** identifies the Table to be updated. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_INFO_NO_UPDATE_PENDING \copybrief CFE_TBL_INFO_NO_UPDATE_PENDING -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_NO_UPDATE_PENDING \copybrief CFE_TBL_INFO_NO_UPDATE_PENDING +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** ** \sa #CFE_TBL_Load, #CFE_TBL_Validate, #CFE_TBL_Manage ** @@ -371,7 +371,7 @@ CFE_Status_t CFE_TBL_Update(CFE_TBL_Handle_t TblHandle); ** \return Execution status, see \ref CFEReturnCodes ** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS ** \retval #CFE_TBL_INFO_NO_VALIDATION_PENDING \copybrief CFE_TBL_INFO_NO_VALIDATION_PENDING -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID ** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS ** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** @@ -399,7 +399,7 @@ CFE_Status_t CFE_TBL_Validate(CFE_TBL_Handle_t TblHandle); ** \return Execution status, see \ref CFEReturnCodes ** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS ** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID ** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS ** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** \retval #CFE_TBL_INFO_DUMP_PENDING \copybrief CFE_TBL_INFO_DUMP_PENDING @@ -427,11 +427,11 @@ CFE_Status_t CFE_TBL_Manage(CFE_TBL_Handle_t TblHandle); ** \param[in] TblHandle Handle of Table to be dumped. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE -** \retval #CFE_TBL_INFO_DUMP_PENDING \copybrief CFE_TBL_INFO_DUMP_PENDING +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_INFO_DUMP_PENDING \copybrief CFE_TBL_INFO_DUMP_PENDING ** ** \sa #CFE_TBL_Manage ** @@ -454,10 +454,10 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle); ** \param[in] TblHandle Handle of Table that was modified. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** ** \sa #CFE_TBL_Manage ** @@ -505,14 +505,14 @@ CFE_Status_t CFE_TBL_Modified(CFE_TBL_Handle_t TblHandle); ** identifies the Table whose address is to be returned. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE -** \retval #CFE_TBL_ERR_UNREGISTERED \copybrief CFE_TBL_ERR_UNREGISTERED -** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED -** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_UNREGISTERED \copybrief CFE_TBL_ERR_UNREGISTERED +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT ** ** \sa #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses ** @@ -537,12 +537,12 @@ CFE_Status_t CFE_TBL_GetAddress(void **TblPtr, CFE_TBL_Handle_t TblHandle); ** identifies the Table whose address is to be released. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE -** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED ** ** \sa #CFE_TBL_GetAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses ** @@ -586,14 +586,14 @@ CFE_Status_t CFE_TBL_ReleaseAddress(CFE_TBL_Handle_t TblHandle); ** of those tables whose start addresses are to be obtained. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE -** \retval #CFE_TBL_ERR_UNREGISTERED \copybrief CFE_TBL_ERR_UNREGISTERED -** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED -** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_UNREGISTERED \copybrief CFE_TBL_ERR_UNREGISTERED +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT ** ** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_ReleaseAddresses ** @@ -620,13 +620,13 @@ CFE_Status_t CFE_TBL_GetAddresses(void **TblPtrs[], uint16 NumTables, const CFE_ ** of those tables whose start addresses are to be released. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE -** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED -** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** \retval #CFE_TBL_BAD_ARGUMENT \copybrief CFE_TBL_BAD_ARGUMENT ** ** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses ** @@ -661,7 +661,7 @@ CFE_Status_t CFE_TBL_ReleaseAddresses(uint16 NumTables, const CFE_TBL_Handle_t T ** \retval #CFE_TBL_INFO_UPDATE_PENDING \copybrief CFE_TBL_INFO_UPDATE_PENDING ** \retval #CFE_TBL_INFO_VALIDATION_PENDING \copybrief CFE_TBL_INFO_VALIDATION_PENDING ** \retval #CFE_TBL_INFO_DUMP_PENDING \copybrief CFE_TBL_INFO_DUMP_PENDING -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID ** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS ** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** @@ -735,10 +735,10 @@ CFE_Status_t CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName); ** all table management notifications. ** ** \return Execution status, see \ref CFEReturnCodes -** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS -** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID -** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS -** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE ** ** \sa #CFE_TBL_Register ** diff --git a/modules/core_api/fsw/inc/cfe_version.h b/modules/core_api/fsw/inc/cfe_version.h index bcda53e52..cb02cfc46 100644 --- a/modules/core_api/fsw/inc/cfe_version.h +++ b/modules/core_api/fsw/inc/cfe_version.h @@ -28,7 +28,7 @@ #define CFE_VERSION_H /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 873 /**< @brief Development: Number of development commits since baseline */ +#define CFE_BUILD_NUMBER 933 /**< @brief Development: Number of development commits since baseline */ #define CFE_BUILD_BASELINE "v6.8.0-rc1" /**< @brief Development: Reference git tag for build number */ /* Version Macro Definitions updated for official releases only */ diff --git a/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c b/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c index 3973f58ab..ddb5bfcd6 100644 --- a/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c +++ b/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c @@ -42,55 +42,55 @@ const char *UT_OSP_MESSAGES[] = { [0] = NULL, /* Message 0 is reserved */ - [UT_OSP_MOUNT_VOLATILE] = "%s: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_MOUNT_VOLATILE] = "%s: Error Mounting Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_CORE_RUNTIME] = "%s: CORE Application %s Had a Runtime Error.\n", - [UT_OSP_CORE_APP_CREATE] = "%s: OS_TaskCreate error creating core App: %s: EC = 0x%08X\n", + [UT_OSP_CORE_APP_CREATE] = "%s: OS_TaskCreate error creating core App: %s: EC = %ld\n", [UT_OSP_EARLYINIT] = "%s: Error returned when calling function: %s: EC = 0x%08X\n", [UT_OSP_FIND_LIBRARY] = "%s: Could not find Library Init symbol:%s. EC = %d\n", [UT_OSP_POR_MAX_HW_SPECIAL] = "%s: POWER ON RESET due to max proc resets (HW Spec Cmd).\n", [UT_OSP_CANNOT_CALL_APP_MAIN] = "%s: Error: Cannot Call from a cFE App Main Task. ID = %d\n", [UT_OSP_FUNCTION_POINTER] = "%s: bad function pointer ( table entry = %d).\n", - [UT_OSP_STARTUP_READ] = "%s: Error Reading Startup file. EC = 0x%08X\n", + [UT_OSP_STARTUP_READ] = "%s: Error Reading Startup file. EC = %ld\n", [UT_OSP_PROC_RESET_COMMANDED] = "%s: PROCESSOR RESET called from CFE_ES_ResetCFE (Commanded).\n", - [UT_OSP_MUTEX_TAKE] = "%s: SharedData Mutex Take Err Stat=0x%x,Func=%s,Line=%d\n", + [UT_OSP_MUTEX_TAKE] = "%s: SharedData Mutex Take Err Stat=%ld,Func=%s,Line=%d\n", [UT_OSP_STARTUP_SYNC_FAIL_1] = "%s: Startup Sync failed - Applications may not have all started\n", [UT_OSP_SYSTEM_LOG_FULL] = "Warning: System Log full, log entry discarded.\n", [UT_OSP_FILE_LINE_TOO_LONG] = "%s: **WARNING** File Line %u is malformed: %u bytes, %u tokens.\n", - [UT_OSP_SHARED_LIBRARY_INIT] = "%s: Load Shared Library Init Error = 0x%08x\n", - [UT_OSP_REMOVE_VOLATILE] = "%s: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_SHARED_LIBRARY_INIT] = "%s: Load Shared Library Init Error = %ld\n", + [UT_OSP_REMOVE_VOLATILE] = "%s: Error Removing Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_POR_OTHER] = "%s: POWER ON RESET due to other cause (See Subtype).\n", - [UT_OSP_DETERMINE_BLOCKS] = "%s: Error Determining Blocks Free on Volume. EC = 0x%08X\n", + [UT_OSP_DETERMINE_BLOCKS] = "%s: Error Determining Blocks Free on Volume. EC = %ld\n", [UT_OSP_STARTUP_SYNC_FAIL_2] = "%s: Startup Sync failed - Applications may not have all initialized\n", [UT_OSP_LIBRARY_SLOTS] = "%s: No free library slots available\n", [UT_OSP_EXTRACT_FILENAME_UT] = "%s: Unable to extract filename from path: %s.\n", [UT_OSP_APP_PATH_FILE_TOO_LONG] = "%s: Application path plus file name length (%d) exceeds max allowed (%d)\n", - [UT_OSP_REFORMAT_VOLATILE] = "%s: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n", - [UT_OSP_EXTRACT_FILENAME_UT55] = "%s: Could not load file:%s. EC = 0x%08X\n", + [UT_OSP_REFORMAT_VOLATILE] = "%s: Error Re-Formating Volatile(RAM) Volume. EC = %ld\n", + [UT_OSP_EXTRACT_FILENAME_UT55] = "%s: Could not load file:%s. EC = %ld\n", [UT_OSP_EXTRACT_FILENAME_UT46] = "%s: Unable to extract filename from path: %s.\n", [UT_OSP_NO_FREE_APP_SLOTS] = "%s: No free application slots available\n", [UT_OSP_EXTRACT_FILENAME_UT57] = "%s: Unable to extract filename from path: %s.\n", - [UT_OSP_MUTEX_GIVE] = "%s: SharedData Mutex Give Err Stat=0x%x,Func=%s,Line=%d\n", - [UT_OSP_CANNOT_FIND_SYMBOL] = "%s: Could not find symbol:%s. EC = 0x%08X\n", - [UT_OSP_INIT_VOLATILE] = "%s: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_MUTEX_GIVE] = "%s: SharedData Mutex Give Err Stat=%ld,Func=%s,Line=%d\n", + [UT_OSP_CANNOT_FIND_SYMBOL] = "%s: Could not find symbol:%s. EC = %ld\n", + [UT_OSP_INIT_VOLATILE] = "%s: Error Initializing Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_APP_INIT] = "%s: Application Init Failed,RC=0x%08X\n", [UT_OSP_POR_MAX_PROC_RESETS] = "%s: POWER ON RESET due to max proc resets (Commanded).\n", [UT_OSP_CANNOT_RESTART_APP] = "%s: Cannot Restart Application %s, It is not running.\n", [UT_OSP_INSUFF_FREE_SPACE] = "%s: Insufficent Free Space on Volatile Disk, Reformatting.\n", [UT_OSP_LOAD_SHARED_LIBRARY] = "%s: Could not load cFE Shared Library\n", [UT_OSP_POR_HW_SPECIAL] = "%s: POWER ON RESET due to HW Special Cmd (Hw Spec Cmd).\n", - [UT_OSP_APP_CREATE] = "%s: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", - [UT_OSP_CREATE_VOLATILE] = "%s: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", - [UT_OSP_MODULE_UNLOAD_FAILED] = "%s: Failed to unload: %s. EC = 0x%08X\n", + [UT_OSP_APP_CREATE] = "%s: AppCreate Error: TaskCreate %s Failed. EC = %ld!\n", + [UT_OSP_CREATE_VOLATILE] = "%s: Error Creating Volatile(RAM) Volume. EC = %ld\n", + [UT_OSP_MODULE_UNLOAD_FAILED] = "%s: Failed to unload: %s. EC = %ld\n", [UT_OSP_POR_COMMANDED] = "%s: POWERON RESET called from CFE_ES_ResetCFE (Commanded).\n", - [UT_OSP_REMOUNT_VOLATILE] = "%s: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_REMOUNT_VOLATILE] = "%s: Error Re-Mounting Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_CORE_APP_EXIT] = "%s: Cannot Exit CORE Application %s\n", [UT_OSP_ES_APP_STARTUP_OPEN] = "%s: Opened ES App Startup file: %s\n", [UT_OSP_CORE_INIT] = "%s: CORE Application %s Had an Init Error.\n", [UT_OSP_PROC_RESET_MAX_HW_SPECIAL] = "%s: PROCESSOR RESET due to Hardware Special Command (HW Spec Cmd).\n", - [UT_OSP_COMMAND_PIPE] = "%s: Error reading cmd pipe,RC=0x%08X\n", - [UT_OSP_UNMOUNT_VOLATILE] = "%s: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_COMMAND_PIPE] = "%s: Error reading cmd pipe,RC=%ld\n", + [UT_OSP_UNMOUNT_VOLATILE] = "%s: Error Un-Mounting Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_TABLE_SLOT_IN_USE] = "%s: Error: ES_TaskTable slot in use at task creation!\n", - [UT_OSP_CANNOT_OPEN_ES_APP_STARTUP] = "%s: Error, Can't Open ES App Startup file: %s EC = 0x%08X\n", + [UT_OSP_CANNOT_OPEN_ES_APP_STARTUP] = "%s: Error, Can't Open ES App Startup file: %s, EC = %ld\n", [UT_OSP_EXTRACT_FILENAME_CF] = "%s: Unable to extract filename from path: %s.\n", [UT_OSP_INVALID_LOG_MODE] = "Warning: Invalid System Log mode, log entry discarded.\n", [UT_OSP_LIB_PATH_FILE_TOO_LONG] = "%s: Library path plus file name length (%d) exceeds max allowed (%d)\n", diff --git a/modules/es/fsw/src/cfe_es_api.c b/modules/es/fsw/src/cfe_es_api.c index 78b3e9b81..dd8c3094b 100644 --- a/modules/es/fsw/src/cfe_es_api.c +++ b/modules/es/fsw/src/cfe_es_api.c @@ -783,7 +783,7 @@ CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName) { osal_id_t OsalId; - int32 Status; + int32 OsStatus; CFE_Status_t Result; if (TaskName == NULL || TaskIdPtr == NULL) @@ -792,8 +792,8 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *Task } /* For tasks IDs, defer to OSAL for name lookup */ - Status = OS_TaskGetIdByName(&OsalId, TaskName); - if (Status == OS_SUCCESS) + OsStatus = OS_TaskGetIdByName(&OsalId, TaskName); + if (OsStatus == OS_SUCCESS) { Result = CFE_SUCCESS; *TaskIdPtr = CFE_ES_TaskId_FromOSAL(OsalId); @@ -981,7 +981,7 @@ CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t Buffe *-----------------------------------------------------------------*/ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength) { - int32 Result; + int32 OsStatus; osal_id_t OsalId; if (BufferLength == 0 || TaskName == NULL) @@ -997,10 +997,10 @@ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t B /* * Query OSAL to get the task name */ - OsalId = CFE_ES_TaskId_ToOSAL(TaskId); - Result = OS_GetResourceName(OsalId, TaskName, BufferLength); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); + OsStatus = OS_GetResourceName(OsalId, TaskName, BufferLength); - if (Result != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -1421,7 +1421,7 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) uint32 i; bool TaskIsMain; int32 ReturnCode = CFE_SUCCESS; - int32 OSReturnCode; + int32 OsStatus; osal_id_t OsalId; /* @@ -1464,9 +1464,9 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) /* ** Can delete the Task */ - OsalId = CFE_ES_TaskId_ToOSAL(TaskId); - OSReturnCode = OS_TaskDelete(OsalId); - if (OSReturnCode == OS_SUCCESS) + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); + OsStatus = OS_TaskDelete(OsalId); + if (OsStatus == OS_SUCCESS) { /* ** Invalidate the task table entry @@ -1482,8 +1482,8 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) } else { - CFE_ES_SysLogWrite_Unsync("%s: Error Calling OS_TaskDelete: Task %lu, RC = 0x%08X\n", __func__, - CFE_RESOURCEID_TO_ULONG(TaskId), (unsigned int)OSReturnCode); + CFE_ES_SysLogWrite_Unsync("%s: Error Calling OS_TaskDelete: Task %lu, RC = %ld\n", __func__, + CFE_RESOURCEID_TO_ULONG(TaskId), (long)OsStatus); ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE; } } @@ -2180,6 +2180,7 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { osal_id_t OsalID; osal_index_t OsalIndex; + int32 OsStatus; if (!CFE_RESOURCEID_TEST_DEFINED(TaskID)) { @@ -2191,8 +2192,9 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) return CFE_ES_BAD_ARGUMENT; } - OsalID = CFE_ES_TaskId_ToOSAL(TaskID); - if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS) + OsalID = CFE_ES_TaskId_ToOSAL(TaskID); + OsStatus = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex); + if (OsStatus != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -2230,17 +2232,17 @@ CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterId, uint32 *Idx) *-----------------------------------------------------------------*/ void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber) { - int32 Status; + int32 OsStatus; - Status = OS_MutSemTake(CFE_ES_Global.SharedDataMutex); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_ES_Global.SharedDataMutex); + if (OsStatus != OS_SUCCESS) { /* * NOTE: this is going to write into a buffer that itself * is _supposed_ to be protected by this same mutex. */ - CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Take Err Stat=0x%x,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, FunctionName, (int)LineNumber); + CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Take Err Stat=%ld,Func=%s,Line=%d\n", __func__, (long)OsStatus, + FunctionName, (int)LineNumber); } /* end if */ @@ -2257,17 +2259,17 @@ void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber) *-----------------------------------------------------------------*/ void CFE_ES_UnlockSharedData(const char *FunctionName, int32 LineNumber) { - int32 Status; + int32 OsStatus; - Status = OS_MutSemGive(CFE_ES_Global.SharedDataMutex); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_ES_Global.SharedDataMutex); + if (OsStatus != OS_SUCCESS) { /* * NOTE: this is going to write into a buffer that itself * is _supposed_ to be protected by this same mutex. */ - CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Give Err Stat=0x%x,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, FunctionName, (int)LineNumber); + CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Give Err Stat=%ld,Func=%s,Line=%d\n", __func__, (long)OsStatus, + FunctionName, (int)LineNumber); } /* end if */ diff --git a/modules/es/fsw/src/cfe_es_apps.c b/modules/es/fsw/src/cfe_es_apps.c index 2dab9e8b3..8db23681e 100644 --- a/modules/es/fsw/src/cfe_es_apps.c +++ b/modules/es/fsw/src/cfe_es_apps.c @@ -82,6 +82,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) uint32 BuffLen; /* Length of the current buffer */ osal_id_t AppFile = OS_OBJECT_ID_UNDEFINED; int32 Status; + int32 OsStatus; char c; bool LineTooLong = false; bool FileOpened = false; @@ -100,17 +101,22 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) if (Status == CFE_SUCCESS) { - Status = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); - } - - if (Status >= 0) - { - CFE_ES_WriteToSysLog("%s: Opened ES App Startup file: %s\n", __func__, ScriptFileName); - FileOpened = true; + OsStatus = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); + if (OsStatus == OS_SUCCESS) + { + FileOpened = true; + } + else + { + CFE_ES_WriteToSysLog("%s: Cannot Open Volatile Startup file: %s, Trying Nonvolatile.\n", __func__, + ScriptFileName); + } } else { - CFE_ES_WriteToSysLog("%s: Cannot Open Volatile Startup file, Trying Nonvolatile.\n", __func__); + /* not expected -- likely a misconfiguration in CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE setting */ + CFE_ES_WriteToSysLog("%s: CFE_FS_ParseInputFileName() RC=%08x parsing volatile script file name.\n", + __func__, (unsigned int)Status); } } /* end if */ @@ -129,17 +135,21 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) if (Status == CFE_SUCCESS) { - Status = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); - } - - if (Status >= 0) - { - CFE_ES_WriteToSysLog("%s: Opened ES App Startup file: %s\n", __func__, ScriptFileName); - FileOpened = true; + OsStatus = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); + if (OsStatus == OS_SUCCESS) + { + FileOpened = true; + } + else + { + CFE_ES_WriteToSysLog("%s: Error, Can't Open ES App Startup file: %s, EC = %ld\n", __func__, + ScriptFileName, (long)OsStatus); + } } else { - CFE_ES_WriteToSysLog("%s: Error, Can't Open ES App Startup file: %s EC = 0x%08X\n", __func__, StartFilePath, + /* not expected -- likely a misconfiguration in the user-supplied StartFilePath */ + CFE_ES_WriteToSysLog("%s: CFE_FS_ParseInputFileName() RC=%08x parsing StartFilePath.\n", __func__, (unsigned int)Status); } } @@ -149,6 +159,8 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) */ if (FileOpened == true) { + CFE_ES_WriteToSysLog("%s: Opened ES App Startup file: %s\n", __func__, ScriptFileName); + memset(ES_AppLoadBuffer, 0x0, ES_START_BUFF_SIZE); BuffLen = 0; NumTokens = 0; @@ -161,13 +173,13 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) */ while (1) { - Status = OS_read(AppFile, &c, 1); - if (Status < 0) + OsStatus = OS_read(AppFile, &c, 1); + if (OsStatus < OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Reading Startup file. EC = 0x%08X\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: Error Reading Startup file. EC = %ld\n", __func__, (long)OsStatus); break; } - else if (Status == 0) + else if (OsStatus == 0) { /* ** EOF Reached @@ -394,7 +406,7 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam osal_id_t ModuleId; cpuaddr InitSymbolAddress; int32 ReturnCode; - int32 StatusCode; + int32 OsStatus; uint32 LoadFlags; LoadFlags = 0; @@ -432,12 +444,12 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam /* * Load the module via OSAL. */ - StatusCode = OS_ModuleLoad(&ModuleId, ModuleName, LoadParams->FileName, LoadFlags); + OsStatus = OS_ModuleLoad(&ModuleId, ModuleName, LoadParams->FileName, LoadFlags); - if (StatusCode != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Could not load file:%s. EC = 0x%08X\n", __func__, LoadParams->FileName, - (unsigned int)StatusCode); + CFE_ES_WriteToSysLog("%s: Could not load file:%s. EC = %ld\n", __func__, LoadParams->FileName, + (long)OsStatus); ModuleId = OS_OBJECT_ID_UNDEFINED; ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -453,11 +465,11 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam if (ReturnCode == CFE_SUCCESS && LoadParams->InitSymbolName[0] != 0 && strcmp(LoadParams->InitSymbolName, "NULL") != 0) { - StatusCode = OS_ModuleSymbolLookup(ModuleId, &InitSymbolAddress, LoadParams->InitSymbolName); - if (StatusCode != OS_SUCCESS) + OsStatus = OS_ModuleSymbolLookup(ModuleId, &InitSymbolAddress, LoadParams->InitSymbolName); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Could not find symbol:%s. EC = 0x%08X\n", __func__, LoadParams->InitSymbolName, - (unsigned int)StatusCode); + CFE_ES_WriteToSysLog("%s: Could not find symbol:%s. EC = %ld\n", __func__, LoadParams->InitSymbolName, + (long)OsStatus); ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -472,11 +484,10 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam { /* If the module had been successfully loaded, then unload it, * so that it does not consume resources */ - StatusCode = OS_ModuleUnload(ModuleId); - if (StatusCode != OS_SUCCESS) /* There's not much we can do except notify */ + OsStatus = OS_ModuleUnload(ModuleId); + if (OsStatus != OS_SUCCESS) /* There's not much we can do except notify */ { - CFE_ES_WriteToSysLog("%s: Failed to unload: %s. EC = 0x%08X\n", __func__, ModuleName, - (unsigned int)StatusCode); + CFE_ES_WriteToSysLog("%s: Failed to unload: %s. EC = %ld\n", __func__, ModuleName, (long)OsStatus); } } @@ -583,23 +594,23 @@ int32 CFE_ES_StartAppTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ CFE_ES_TaskRecord_t *TaskRecPtr; osal_id_t OsalTaskId; CFE_ES_TaskId_t LocalTaskId; - int32 StatusCode; + int32 OsStatus; int32 ReturnCode; /* * Create the primary task for the newly loaded task */ - StatusCode = OS_TaskCreate(&OsalTaskId, /* task id */ - TaskName, /* task name matches app name for main task */ - CFE_ES_TaskEntryPoint, /* task function pointer */ - OSAL_TASK_STACK_ALLOCATE, /* stack pointer (allocate) */ - Params->StackSize, /* stack size */ - Params->Priority, /* task priority */ - OS_FP_ENABLED); /* task options */ + OsStatus = OS_TaskCreate(&OsalTaskId, /* task id */ + TaskName, /* task name matches app name for main task */ + CFE_ES_TaskEntryPoint, /* task function pointer */ + OSAL_TASK_STACK_ALLOCATE, /* stack pointer (allocate) */ + Params->StackSize, /* stack size */ + Params->Priority, /* task priority */ + OS_FP_ENABLED); /* task options */ CFE_ES_LockSharedData(__func__, __LINE__); - if (StatusCode == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { /* * As this is a newly-created task, this shouldn't fail. @@ -638,8 +649,8 @@ int32 CFE_ES_StartAppTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ } else { - CFE_ES_SysLogWrite_Unsync("%s: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", __func__, TaskName, - (unsigned int)StatusCode); + CFE_ES_SysLogWrite_Unsync("%s: AppCreate Error: TaskCreate %s Failed. EC = %ld!\n", __func__, TaskName, + (long)OsStatus); ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; } @@ -1330,6 +1341,7 @@ void CFE_ES_ProcessControlRequest(CFE_ES_AppId_t AppId) int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; + int32 OsStatus; int32 Status; int32 ReturnCode; CFE_ES_TaskId_t TaskList[OS_MAX_TASKS]; @@ -1509,11 +1521,11 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId) /* ** Unload the module only if it is an external app */ - Status = OS_ModuleUnload(ModuleId); - if (Status != OS_SUCCESS) + OsStatus = OS_ModuleUnload(ModuleId); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Module (ID:0x%08lX) Unload failed. RC=0x%08X\n", __func__, - OS_ObjectIdToInteger(ModuleId), (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: Module (ID:0x%08lX) Unload failed. RC=%ld\n", __func__, + OS_ObjectIdToInteger(ModuleId), (long)OsStatus); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } } @@ -1576,7 +1588,7 @@ typedef struct void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) { CFE_ES_CleanupState_t *CleanState; - int32 Status; + int32 OsStatus; osal_objtype_t ObjType; bool ObjIsValid; @@ -1587,46 +1599,46 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) switch (ObjType) { case OS_OBJECT_TYPE_OS_TASK: - Status = OS_TaskDelete(ObjectId); + OsStatus = OS_TaskDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_QUEUE: - Status = OS_QueueDelete(ObjectId); + OsStatus = OS_QueueDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_BINSEM: - Status = OS_BinSemDelete(ObjectId); + OsStatus = OS_BinSemDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_COUNTSEM: - Status = OS_CountSemDelete(ObjectId); + OsStatus = OS_CountSemDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_MUTEX: - Status = OS_MutSemDelete(ObjectId); + OsStatus = OS_MutSemDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_TIMECB: - Status = OS_TimerDelete(ObjectId); + OsStatus = OS_TimerDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_STREAM: - Status = OS_close(ObjectId); + OsStatus = OS_close(ObjectId); break; case OS_OBJECT_TYPE_OS_MODULE: - Status = OS_ModuleUnload(ObjectId); + OsStatus = OS_ModuleUnload(ObjectId); break; default: ObjIsValid = false; - Status = OS_ERROR; + OsStatus = OS_ERROR; break; } if (ObjIsValid) { ++CleanState->FoundObjects; - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { ++CleanState->DeletedObjects; } else { - CFE_ES_SysLogWrite_Unsync("%s: Call to OSAL Delete Object (ID:%lu) failed. RC=0x%08X\n", __func__, - OS_ObjectIdToInteger(ObjectId), (unsigned int)Status); + CFE_ES_SysLogWrite_Unsync("%s: Call to OSAL Delete Object (ID:%lu) failed. RC=%ld\n", __func__, + OS_ObjectIdToInteger(ObjectId), (long)OsStatus); if (CleanState->OverallStatus == CFE_SUCCESS) { /* @@ -1675,6 +1687,7 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId) { CFE_ES_CleanupState_t CleanState; + int32 OsStatus; int32 Result; osal_id_t OsalId; @@ -1713,8 +1726,8 @@ int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId) ** In this case the OS_ERR_INVALID_ID status is returned, but ** that is OK, there is nothing else needed to do. */ - Result = OS_TaskDelete(OsalId); - if (Result == OS_SUCCESS || Result == OS_ERR_INVALID_ID) + OsStatus = OS_TaskDelete(OsalId); + if (OsStatus == OS_SUCCESS || OsStatus == OS_ERR_INVALID_ID) { Result = CleanState.OverallStatus; if (Result == CFE_SUCCESS && CleanState.FoundObjects > 0) @@ -1772,10 +1785,10 @@ void CFE_ES_CopyModuleStatusInfo(const CFE_ES_ModuleLoadStatus_t *StatusPtr, CFE void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoPtr) { OS_module_prop_t ModuleInfo; - int32 ReturnCode; + int32 OsStatus; - ReturnCode = OS_ModuleInfo(ModuleId, &ModuleInfo); - if (ReturnCode == OS_SUCCESS) + OsStatus = OS_ModuleInfo(ModuleId, &ModuleInfo); + if (OsStatus == OS_SUCCESS) { AppInfoPtr->AddressesAreValid = (sizeof(ModuleInfo.addr.code_address) <= sizeof(AppInfoPtr->CodeAddress)) && ModuleInfo.addr.valid; diff --git a/modules/es/fsw/src/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c index 4c2585caf..d0532ed31 100644 --- a/modules/es/fsw/src/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -99,7 +99,7 @@ const CFE_ES_BackgroundJobEntry_t CFE_ES_BACKGROUND_JOB_TABLE[] = { *-----------------------------------------------------------------*/ void CFE_ES_BackgroundTask(void) { - int32 status; + int32 OsStatus; uint32 JobTotal; uint32 NumJobsRunning; uint32 NextDelay; @@ -153,11 +153,11 @@ void CFE_ES_BackgroundTask(void) CFE_ES_Global.BackgroundTask.NumJobsRunning = NumJobsRunning; - status = OS_BinSemTimedWait(CFE_ES_Global.BackgroundTask.WorkSem, NextDelay); - if (status != OS_SUCCESS && status != OS_SEM_TIMEOUT) + OsStatus = OS_BinSemTimedWait(CFE_ES_Global.BackgroundTask.WorkSem, NextDelay); + if (OsStatus != OS_SUCCESS && OsStatus != OS_SEM_TIMEOUT) { /* should never occur */ - CFE_ES_WriteToSysLog("%s: Failed to take background sem: %08lx\n", __func__, (unsigned long)status); + CFE_ES_WriteToSysLog("%s: Failed to take background sem: %ld\n", __func__, (long)OsStatus); break; } } @@ -174,12 +174,13 @@ void CFE_ES_BackgroundTask(void) int32 CFE_ES_BackgroundInit(void) { int32 status; + int32 OsStatus; - status = OS_BinSemCreate(&CFE_ES_Global.BackgroundTask.WorkSem, CFE_ES_BACKGROUND_SEM_NAME, 0, 0); - if (status != OS_SUCCESS) + OsStatus = OS_BinSemCreate(&CFE_ES_Global.BackgroundTask.WorkSem, CFE_ES_BACKGROUND_SEM_NAME, 0, 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Failed to create background sem: %08lx\n", __func__, (unsigned long)status); - return status; + CFE_ES_WriteToSysLog("%s: Failed to create background sem: %ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* Spawn a task to write the performance data to a file */ diff --git a/modules/es/fsw/src/cfe_es_cds.c b/modules/es/fsw/src/cfe_es_cds.c index bf61381e9..2604b6c2e 100644 --- a/modules/es/fsw/src/cfe_es_cds.c +++ b/modules/es/fsw/src/cfe_es_cds.c @@ -57,15 +57,17 @@ int32 CFE_ES_CDS_EarlyInit(void) CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; uint32 PlatformSize; size_t MinRequiredSize; + int32 OsStatus; int32 Status; + int32 PspStatus; CFE_ES_Global.CDSIsAvailable = false; /* Create CDS general access mutex */ - Status = OS_MutSemCreate(&CDS->GenMutex, CFE_ES_CDS_MUT_REG_NAME, CFE_ES_CDS_MUT_REG_VALUE); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CDS->GenMutex, CFE_ES_CDS_MUT_REG_NAME, CFE_ES_CDS_MUT_REG_VALUE); + if (OsStatus != OS_SUCCESS) { - CFE_ES_SysLogWrite_Unsync("%s: Failed to create mutex with error %d\n", __func__, (int)Status); + CFE_ES_SysLogWrite_Unsync("%s: Failed to create mutex with error %ld\n", __func__, (long)OsStatus); return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -73,12 +75,13 @@ int32 CFE_ES_CDS_EarlyInit(void) /* Get CDS size from PSP. Note that the PSP interface * uses "uint32" for size here. */ - Status = CFE_PSP_GetCDSSize(&PlatformSize); - if (Status != CFE_PSP_SUCCESS) + PspStatus = CFE_PSP_GetCDSSize(&PlatformSize); + if (PspStatus != CFE_PSP_SUCCESS) { /* Error getting the size of the CDS from the BSP */ - CFE_ES_WriteToSysLog("%s: Unable to obtain CDS Size from BSP (Err=0x%08X)\n", __func__, (unsigned int)Status); - return Status; + CFE_ES_WriteToSysLog("%s: Unable to obtain CDS Size from BSP (Err=0x%08X)\n", __func__, + (unsigned int)PspStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* Always truncate the size to the nearest 4 byte boundary */ @@ -654,18 +657,18 @@ int32 CFE_ES_InitCDSRegistry(void) int32 CFE_ES_UpdateCDSRegistry(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - int32 Status; + int32 PspStatus; /* Copy the contents of the local registry to the CDS */ - Status = CFE_PSP_WriteToCDS(CDS->Registry, CDS_REG_OFFSET, sizeof(CDS->Registry)); + PspStatus = CFE_PSP_WriteToCDS(CDS->Registry, CDS_REG_OFFSET, sizeof(CDS->Registry)); - if (Status != CFE_PSP_SUCCESS) + if (PspStatus != CFE_PSP_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Failed to write CDS Registry. Status=0x%08X\n", __func__, (unsigned int)Status); - Status = CFE_ES_CDS_ACCESS_ERROR; + CFE_ES_WriteToSysLog("%s: Failed to write CDS Registry. Status=0x%08X\n", __func__, (unsigned int)PspStatus); + return CFE_ES_CDS_ACCESS_ERROR; } - return Status; + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -702,12 +705,13 @@ void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_AppId_t T int32 CFE_ES_LockCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; + int32 OsStatus; int32 Status; - Status = OS_MutSemTake(CDS->GenMutex); + OsStatus = OS_MutSemTake(CDS->GenMutex); /* Convert to CFE return code */ - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } @@ -730,12 +734,13 @@ int32 CFE_ES_LockCDS(void) int32 CFE_ES_UnlockCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; + int32 OsStatus; int32 Status; - Status = OS_MutSemGive(CDS->GenMutex); + OsStatus = OS_MutSemGive(CDS->GenMutex); /* Convert to CFE return code */ - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } @@ -800,6 +805,7 @@ int32 CFE_ES_RebuildCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; int32 Status; + int32 PspStatus; /* First, determine if the CDS registry stored in the CDS is smaller or equal */ /* in size to the CDS registry we are currently configured for */ @@ -820,9 +826,9 @@ int32 CFE_ES_RebuildCDS(void) return CFE_ES_CDS_INVALID; } - Status = CFE_PSP_ReadFromCDS(&CDS->Registry, CDS_REG_OFFSET, sizeof(CDS->Registry)); + PspStatus = CFE_PSP_ReadFromCDS(&CDS->Registry, CDS_REG_OFFSET, sizeof(CDS->Registry)); - if (Status == CFE_PSP_SUCCESS) + if (PspStatus == CFE_PSP_SUCCESS) { /* Scan the memory pool and identify the created but currently unused memory blocks */ Status = CFE_ES_RebuildCDSPool(CDS->DataSize, CDS_POOL_OFFSET); @@ -830,7 +836,7 @@ int32 CFE_ES_RebuildCDS(void) else { /* Registry in CDS is unreadable */ - CFE_ES_WriteToSysLog("%s: Registry in CDS is unreadable, PSP error %lx\n", __func__, (unsigned long)Status); + CFE_ES_WriteToSysLog("%s: Registry in CDS is unreadable, PSP error %lx\n", __func__, (unsigned long)PspStatus); Status = CFE_ES_CDS_INVALID; } diff --git a/modules/es/fsw/src/cfe_es_cds_mempool.c b/modules/es/fsw/src/cfe_es_cds_mempool.c index 2c041c084..e3c94f940 100644 --- a/modules/es/fsw/src/cfe_es_cds_mempool.c +++ b/modules/es/fsw/src/cfe_es_cds_mempool.c @@ -183,6 +183,7 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; int32 Status; + int32 PspStatus; size_t BlockSize; size_t UserDataSize; size_t UserDataOffset; @@ -239,12 +240,14 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) } else { - Status = CFE_PSP_WriteToCDS(DataToWrite, UserDataOffset, UserDataSize); - if (Status != CFE_PSP_SUCCESS) + PspStatus = CFE_PSP_WriteToCDS(DataToWrite, UserDataOffset, UserDataSize); + if (PspStatus != CFE_PSP_SUCCESS) { snprintf(LogMessage, sizeof(LogMessage), - "Err writing user data to CDS (Stat=0x%08x) @Offset=0x%08lx\n", (unsigned int)Status, + "Err writing user data to CDS (Stat=0x%08x) @Offset=0x%08lx\n", (unsigned int)PspStatus, (unsigned long)UserDataOffset); + + Status = CFE_ES_CDS_ACCESS_ERROR; } } } @@ -277,6 +280,7 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; int32 Status; + int32 PspStatus; uint32 CrcOfCDSData; size_t BlockSize; size_t UserDataSize; @@ -319,8 +323,8 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) if (Status == CFE_SUCCESS) { /* Read the data block */ - Status = CFE_PSP_ReadFromCDS(DataRead, UserDataOffset, UserDataSize); - if (Status == CFE_PSP_SUCCESS) + PspStatus = CFE_PSP_ReadFromCDS(DataRead, UserDataOffset, UserDataSize); + if (PspStatus == CFE_PSP_SUCCESS) { /* Compute the CRC for the data read from the CDS and determine if the data is still valid */ CrcOfCDSData = CFE_ES_CalculateCRC(DataRead, UserDataSize, 0, CFE_MISSION_ES_DEFAULT_CRC); @@ -335,6 +339,10 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) Status = CFE_SUCCESS; } } + else + { + Status = CFE_ES_CDS_ACCESS_ERROR; + } } } } diff --git a/modules/es/fsw/src/cfe_es_erlog.c b/modules/es/fsw/src/cfe_es_erlog.c index 841918b0a..93d3831be 100644 --- a/modules/es/fsw/src/cfe_es_erlog.c +++ b/modules/es/fsw/src/cfe_es_erlog.c @@ -282,6 +282,7 @@ void CFE_ES_BackgroundERLogFileEventHandler(void *Meta, CFE_FS_FileWriteEvent_t bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) { int32 Status; + int32 PspStatus; uint32 PspContextId; char ReasonString[CFE_ES_ERLOG_DESCRIPTION_MAX_LENGTH]; CFE_ES_TaskInfo_t EsTaskInfo; @@ -302,11 +303,12 @@ bool CFE_ES_RunExceptionScan(uint32 ElapsedTime, void *Arg) */ ResetType = 0; memset(&EsTaskInfo, 0, sizeof(EsTaskInfo)); - Status = CFE_PSP_Exception_GetSummary(&PspContextId, &ExceptionTaskID, ReasonString, sizeof(ReasonString)); - if (Status != CFE_PSP_SUCCESS) + PspStatus = CFE_PSP_Exception_GetSummary(&PspContextId, &ExceptionTaskID, ReasonString, sizeof(ReasonString)); + if (PspStatus != CFE_PSP_SUCCESS) { - /* reason string is not available - populate with something for the log */ - snprintf(ReasonString, sizeof(ReasonString), "Unknown - CFE_PSP_ExceptionGetSummary() error %ld", (long)Status); + /* reason string is not available - populate with something for the PspStatus*/ + snprintf(ReasonString, sizeof(ReasonString), "Unknown - CFE_PSP_ExceptionGetSummary() error %ld", + (long)PspStatus); PspContextId = 0; ExceptionTaskID = OS_OBJECT_ID_UNDEFINED; } /* end if */ diff --git a/modules/es/fsw/src/cfe_es_mempool.c b/modules/es/fsw/src/cfe_es_mempool.c index 1aacb5d26..46688c63c 100644 --- a/modules/es/fsw/src/cfe_es_mempool.c +++ b/modules/es/fsw/src/cfe_es_mempool.c @@ -201,6 +201,7 @@ CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size, uint16 NumBlockSizes, const size_t *BlockSizes, bool UseMutex) { + int32 OsStatus; int32 Status; CFE_ResourceId_t PendingID; CFE_ES_MemPoolRecord_t *PoolRecPtr; @@ -254,7 +255,7 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ if (PoolRecPtr == NULL) { - CFE_ES_SysLogWrite_Unsync("%s: No free MemPoolrary slots available\n", __func__); + CFE_ES_SysLogWrite_Unsync("%s: No free MemPool slots available\n", __func__); Status = CFE_ES_NO_RESOURCE_IDS_AVAILABLE; } else @@ -311,11 +312,11 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ snprintf(MutexName, OS_MAX_API_NAME, "Pool%08lX", CFE_ResourceId_ToInteger(PendingID)); /* create a mutex to protect this memory pool */ - Status = OS_MutSemCreate(&PoolRecPtr->MutexId, MutexName, 0); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&PoolRecPtr->MutexId, MutexName, 0); + if (OsStatus != OS_SUCCESS) { /* log error and rewrite to CFE status code */ - CFE_ES_WriteToSysLog("%s: OSAL error %d while creating mutex\n", __func__, (int)Status); + CFE_ES_WriteToSysLog("%s: OSAL error %ld while creating mutex\n", __func__, (long)OsStatus); Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -349,11 +350,6 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ */ CFE_ES_MemPoolRecordSetFree(PoolRecPtr); PendingID = CFE_RESOURCEID_UNDEFINED; - - if (Status == CFE_ES_POOL_BOUNDS_ERROR) - { - CFE_ES_WriteToSysLog("%s: Pool size(%lu) too small\n", __func__, (unsigned long)Size); - } } /* @@ -377,7 +373,7 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) CFE_ES_MemPoolRecord_t *PoolRecPtr; osal_id_t MutexId; int32 Status; - int32 MutDeleteStatus; + int32 OsStatus; PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(PoolID); @@ -403,8 +399,8 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) * potential conflict with holding two locks. */ if (OS_ObjectIdDefined(MutexId)) { - MutDeleteStatus = OS_MutSemDelete(MutexId); - if (MutDeleteStatus != OS_SUCCESS) + OsStatus = OS_MutSemDelete(MutexId); + if (OsStatus != OS_SUCCESS) { /* * Report to syslog for informational purposes only. @@ -412,7 +408,7 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) * The MemPool entry has already been deleted, so this * function should not return an error at this point. */ - CFE_ES_WriteToSysLog("%s: Error %d deleting mutex\n", __func__, (int)MutDeleteStatus); + CFE_ES_WriteToSysLog("%s: Error %ld deleting mutex\n", __func__, (long)OsStatus); } } diff --git a/modules/es/fsw/src/cfe_es_perf.c b/modules/es/fsw/src/cfe_es_perf.c index bb50bd385..5fb305bb2 100644 --- a/modules/es/fsw/src/cfe_es_perf.c +++ b/modules/es/fsw/src/cfe_es_perf.c @@ -281,6 +281,7 @@ int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfDataCmd_t *data) bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) { CFE_ES_PerfDumpGlobal_t *State = (CFE_ES_PerfDumpGlobal_t *)Arg; + int32 OsStatus; int32 Status; CFE_FS_Header_t FileHdr; size_t BlockSize; @@ -325,13 +326,13 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) { case CFE_ES_PerfDumpState_OPEN_FILE: /* Create the file to dump to */ - Status = OS_OpenCreate(&State->FileDesc, State->DataFileName, - OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status < 0) + OsStatus = OS_OpenCreate(&State->FileDesc, State->DataFileName, + OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { State->FileDesc = OS_OBJECT_ID_UNDEFINED; CFE_EVS_SendEvent(CFE_ES_PERF_LOG_ERR_EID, CFE_EVS_EventType_ERROR, - "Error creating file %s, RC = %d", State->DataFileName, (int)Status); + "Error creating file %s, RC = %ld", State->DataFileName, (long)OsStatus); } State->FileSize = 0; break; @@ -450,12 +451,14 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) case CFE_ES_PerfDumpState_WRITE_PERF_METADATA: /* write the performance metadata to the file */ BlockSize = sizeof(CFE_ES_PerfMetaData_t); - Status = OS_write(State->FileDesc, &Perf->MetaData, BlockSize); + OsStatus = OS_write(State->FileDesc, &Perf->MetaData, BlockSize); + Status = (long)OsStatus; /* status type conversion (size) */ break; case CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES: BlockSize = sizeof(CFE_ES_PerfDataEntry_t); - Status = OS_write(State->FileDesc, &Perf->DataBuffer[State->DataPos], BlockSize); + OsStatus = OS_write(State->FileDesc, &Perf->DataBuffer[State->DataPos], BlockSize); + Status = (long)OsStatus; /* status type conversion (size) */ ++State->DataPos; if (State->DataPos >= CFE_PLATFORM_ES_PERF_DATA_BUFFER_SIZE) diff --git a/modules/es/fsw/src/cfe_es_start.c b/modules/es/fsw/src/cfe_es_start.c index 3a72bfbcd..f20a1fa3e 100644 --- a/modules/es/fsw/src/cfe_es_start.c +++ b/modules/es/fsw/src/cfe_es_start.c @@ -75,7 +75,7 @@ CFE_ES_Global_t CFE_ES_Global; *-----------------------------------------------------------------*/ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath) { - int32 ReturnCode; + int32 OsStatus; /* * Clear the entire global data structure. @@ -93,12 +93,11 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha ** Create the ES Shared Data Mutex ** This must be done before ANY calls to CFE_ES_WriteToSysLog(), since this uses the mutex */ - ReturnCode = OS_MutSemCreate(&(CFE_ES_Global.SharedDataMutex), "ES_DATA_MUTEX", 0); - if (ReturnCode != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&(CFE_ES_Global.SharedDataMutex), "ES_DATA_MUTEX", 0); + if (OsStatus != OS_SUCCESS) { /* Cannot use SysLog here, since that requires the reset area to be set up */ - OS_printf("ES Startup: Error: ES Shared Data Mutex could not be created. RC=0x%08X\n", - (unsigned int)ReturnCode); + OS_printf("ES Startup: Error: ES Shared Data Mutex could not be created. RC=%ld\n", (long)OsStatus); /* ** Delay to allow the message to be printed @@ -134,11 +133,11 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha ** Also Create the ES Performance Data Mutex ** This is to separately protect against concurrent writes to the global performance log data */ - ReturnCode = OS_MutSemCreate(&CFE_ES_Global.PerfDataMutex, "ES_PERF_MUTEX", 0); - if (ReturnCode != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_ES_Global.PerfDataMutex, "ES_PERF_MUTEX", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_SysLogWrite_Unsync("%s: Error: ES Performance Data Mutex could not be created. RC=0x%08X\n", __func__, - (unsigned int)ReturnCode); + CFE_ES_SysLogWrite_Unsync("%s: Error: ES Performance Data Mutex could not be created. RC=%ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read @@ -249,25 +248,24 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha *-----------------------------------------------------------------*/ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 BootSource) { - - int32 status; + int32 PspStatus; uint32 resetAreaSize; cpuaddr ResetDataAddr; /* ** Get the pointer to the Reset area from the BSP */ - status = CFE_PSP_GetResetArea(&ResetDataAddr, &resetAreaSize); + PspStatus = CFE_PSP_GetResetArea(&ResetDataAddr, &resetAreaSize); /* ** Make sure the status is OK or size is big enough */ - if (status != CFE_PSP_SUCCESS) + if (PspStatus != CFE_PSP_SUCCESS) { /* ** Cannot use the ES System log without the Reset Area */ - OS_printf("ES Startup: CFE_PSP_GetResetArea call Failed (0x%08x)!\n", (unsigned int)status); + OS_printf("ES Startup: CFE_PSP_GetResetArea call Failed (0x%08x)!\n", (unsigned int)PspStatus); /* ** Delay to allow the message to be read @@ -477,7 +475,8 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo *-----------------------------------------------------------------*/ void CFE_ES_InitializeFileSystems(uint32 StartType) { - int32 RetStatus; + int32 OsStatus; + int32 PspStatus; cpuaddr RamDiskMemoryAddress; uint32 RamDiskMemorySize; int32 PercentFree; @@ -486,12 +485,12 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** Get the memory area for the RAM disk */ - RetStatus = CFE_PSP_GetVolatileDiskMem(&(RamDiskMemoryAddress), &(RamDiskMemorySize)); + PspStatus = CFE_PSP_GetVolatileDiskMem(&(RamDiskMemoryAddress), &(RamDiskMemorySize)); - if (RetStatus != CFE_PSP_SUCCESS) + if (PspStatus != CFE_PSP_SUCCESS) { CFE_ES_WriteToSysLog("%s: Cannot Get Memory for Volatile Disk. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + (unsigned int)PspStatus); /* ** Delay to allow the message to be read @@ -510,12 +509,11 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) */ if (StartType == CFE_PSP_RST_TYPE_POWERON) { - RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, - CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, + CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read @@ -530,20 +528,18 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) } else { - RetStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, - CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, + CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Initializing Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); CFE_ES_WriteToSysLog("%s: Formatting Volatile(RAM) Volume.\n", __func__); - RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, - CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, + CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read @@ -561,11 +557,10 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** Now, mount the RAM disk */ - RetStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Mounting Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -589,8 +584,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** See how many blocks are free in the RAM disk */ - RetStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf); - if (RetStatus == OS_SUCCESS && StatBuf.total_blocks > 0) + OsStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf); + if (OsStatus == OS_SUCCESS && StatBuf.total_blocks > 0) { /* ** Determine if the disk is too full @@ -605,32 +600,32 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** First, unmount the disk */ - RetStatus = OS_unmount(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if (RetStatus == OS_SUCCESS) + OsStatus = OS_unmount(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); + if (OsStatus == OS_SUCCESS) { /* ** Remove the file system from the OSAL */ - RetStatus = OS_rmfs("/ramdev0"); - if (RetStatus == OS_SUCCESS) + OsStatus = OS_rmfs("/ramdev0"); + if (OsStatus == OS_SUCCESS) { /* ** Next, make a new file system on the disk */ - RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", - CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus == OS_SUCCESS) + OsStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", + CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus == OS_SUCCESS) { /* ** Last, remount the disk */ - RetStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", - __func__, (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Re-Mounting Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -646,8 +641,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else { - CFE_ES_WriteToSysLog("%s: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Re-Formating Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -663,8 +658,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else /* could not Remove File system */ { - CFE_ES_WriteToSysLog("%s: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Removing Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -679,8 +674,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) } else /* could not un-mount disk */ { - CFE_ES_WriteToSysLog("%s: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Un-Mounting Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -697,8 +692,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else /* could not determine free blocks */ { /* Log error message -- note that BlocksFree returns the error code in this case */ - CFE_ES_WriteToSysLog("%s: Error Determining Blocks Free on Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Determining Blocks Free on Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read diff --git a/modules/es/fsw/src/cfe_es_syslog.c b/modules/es/fsw/src/cfe_es_syslog.c index 3f57561c5..fd2a7efce 100644 --- a/modules/es/fsw/src/cfe_es_syslog.c +++ b/modules/es/fsw/src/cfe_es_syslog.c @@ -453,6 +453,7 @@ void CFE_ES_SysLog_vsnprintf(char *Buffer, size_t BufferSize, const char *SpecSt int32 CFE_ES_SysLogDump(const char *Filename) { osal_id_t fd; + int32 OsStatus; int32 Status; size_t WritePos; size_t TotalSize; @@ -463,11 +464,11 @@ int32 CFE_ES_SysLogDump(const char *Filename) CFE_FS_Header_t FileHdr; } Buffer; - Status = OS_OpenCreate(&fd, Filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status < 0) + OsStatus = OS_OpenCreate(&fd, Filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { - CFE_EVS_SendEvent(CFE_ES_SYSLOG2_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating file %s, RC = 0x%08X", - Filename, (unsigned int)Status); + CFE_EVS_SendEvent(CFE_ES_SYSLOG2_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating file %s, RC = %ld", Filename, + (long)OsStatus); return CFE_ES_FILE_IO_ERR; } /* end if */ @@ -496,18 +497,21 @@ int32 CFE_ES_SysLogDump(const char *Filename) while (WritePos < Buffer.LogData.BlockSize) { LastReqSize = Buffer.LogData.BlockSize - WritePos; - Status = OS_write(fd, &Buffer.LogData.Data[WritePos], LastReqSize); - if (Status <= 0) + OsStatus = OS_write(fd, &Buffer.LogData.Data[WritePos], LastReqSize); + + /* NOTE: this stops for errors or EOF code (0) */ + if (OsStatus <= 0) { break; } /* end if */ - WritePos += Status; - TotalSize += Status; + WritePos += (long)OsStatus; + TotalSize += (long)OsStatus; } - if (Status <= 0) + if (OsStatus <= 0) { + Status = (long)OsStatus; break; } diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index d4beafa40..fbc74dcde 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -357,6 +357,7 @@ void CFE_ES_GenerateBuildInfoEvents(void) int32 CFE_ES_TaskInit(void) { int32 Status; + int32 PspStatus; uint32 SizeofCfeSegment; cpuaddr CfeSegmentAddr; uint8 VersionNumber[4]; @@ -442,9 +443,9 @@ int32 CFE_ES_TaskInit(void) ** Compute the CRC for the cfe core code segment and place ** in ES Housekeeping pkt. */ - Status = CFE_PSP_GetCFETextSegmentInfo(&CfeSegmentAddr, &SizeofCfeSegment); + PspStatus = CFE_PSP_GetCFETextSegmentInfo(&CfeSegmentAddr, &SizeofCfeSegment); - if (Status == CFE_PSP_SUCCESS) + if (PspStatus == CFE_PSP_SUCCESS) { CFE_ES_Global.TaskData.HkPacket.Payload.CFECoreChecksum = CFE_ES_CalculateCRC((void *)(CfeSegmentAddr), SizeofCfeSegment, 0, CFE_MISSION_ES_DEFAULT_CRC); @@ -745,7 +746,7 @@ void CFE_ES_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) { OS_heap_prop_t HeapProp; - int32 stat; + int32 OsStatus; uint32 PerfIdx; /* @@ -819,14 +820,14 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) } } - stat = OS_HeapGetInfo(&HeapProp); + OsStatus = OS_HeapGetInfo(&HeapProp); /* * If retrieving info from OSAL was not successful, * zero out the property struct, so all sizes will * in turn be reported in telemetry as 0. */ - if (stat != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { memset(&HeapProp, 0, sizeof(HeapProp)); } @@ -1274,6 +1275,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) uint32 i; uint32 EntryCount = 0; uint32 FileSize = 0; + int32 OsStatus; int32 Result; CFE_ES_AppInfo_t AppInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; @@ -1324,8 +1326,20 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) /* ** Create (or truncate) ES task log data file */ - Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, - OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, + OS_WRITE_ONLY); + + if (OsStatus != OS_SUCCESS) + { + CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write App Info file, OS_OpenCreate RC = %ld", (long)OsStatus); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + } + else + { + CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write App Info file, CFE_FS_ParseInputFileNameEx RC = %08x", (unsigned int)Result); } if (Result >= 0) @@ -1357,7 +1371,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) /* ** Maintain statistics of amount of data written to file */ - FileSize += Result; + FileSize += sizeof(CFE_FS_Header_t); /* ** Loop through the ES AppTable for main applications @@ -1373,14 +1387,14 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) /* ** Write the local entry to file */ - Result = OS_write(FileDescriptor, &AppInfo, sizeof(CFE_ES_AppInfo_t)); - if (Result != sizeof(CFE_ES_AppInfo_t)) + OsStatus = OS_write(FileDescriptor, &AppInfo, sizeof(CFE_ES_AppInfo_t)); + if (OsStatus != sizeof(CFE_ES_AppInfo_t)) { OS_close(FileDescriptor); CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKWR_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write App Info file, Task write RC = 0x%08X, exp %d", - (unsigned int)Result, (int)sizeof(CFE_ES_AppInfo_t)); + "Failed to write App Info file, Task write RC = %ld, exp %d", (long)OsStatus, + (int)sizeof(CFE_ES_AppInfo_t)); /* * returning "success" here as there is no other recourse; * the full extent of the error recovery has been done @@ -1388,7 +1402,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) return CFE_SUCCESS; } /* end if */ - FileSize += Result; + FileSize += sizeof(CFE_ES_AppInfo_t); EntryCount++; } @@ -1403,8 +1417,6 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) else { CFE_ES_Global.TaskData.CommandErrorCounter++; - CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write App Info file, OS_OpenCreate RC = 0x%08X", (unsigned int)Result); } return CFE_SUCCESS; @@ -1425,6 +1437,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) uint32 i; uint32 EntryCount = 0; uint32 FileSize = 0; + int32 OsStatus; int32 Result; CFE_ES_TaskInfo_t TaskInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; @@ -1466,8 +1479,21 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) /* ** Create (or truncate) ES task log data file */ - Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, - OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, + OS_WRITE_ONLY); + + if (OsStatus != OS_SUCCESS) + { + CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write Task Info file, OS_OpenCreate RC = %ld", (long)OsStatus); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + } + else + { + CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write Task Info file, CFE_FS_ParseInputFileNameEx RC = %08x", + (unsigned int)Result); } if (Result >= 0) @@ -1499,7 +1525,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) /* ** Maintain statistics of amount of data written to file */ - FileSize += Result; + FileSize += sizeof(CFE_FS_Header_t); /* ** Loop through the ES AppTable for main applications @@ -1515,14 +1541,14 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) /* ** Write the local entry to file */ - Result = OS_write(FileDescriptor, &TaskInfo, sizeof(CFE_ES_TaskInfo_t)); - if (Result != sizeof(CFE_ES_TaskInfo_t)) + OsStatus = OS_write(FileDescriptor, &TaskInfo, sizeof(CFE_ES_TaskInfo_t)); + if (OsStatus != sizeof(CFE_ES_TaskInfo_t)) { OS_close(FileDescriptor); CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_WR_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write Task Info file, Task write RC = 0x%08X, exp %d", - (unsigned int)Result, (int)sizeof(CFE_ES_TaskInfo_t)); + "Failed to write Task Info file, Task write RC = %ld, exp %d", (long)OsStatus, + (int)sizeof(CFE_ES_TaskInfo_t)); /* * returning "success" here as there is no other recourse; * the full extent of the error recovery has been done @@ -1530,7 +1556,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) return CFE_SUCCESS; } /* end if */ - FileSize += Result; + FileSize += sizeof(CFE_ES_TaskInfo_t); EntryCount++; } @@ -1545,8 +1571,6 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) else { CFE_ES_Global.TaskData.CommandErrorCounter++; - CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write Task Info file, OS_OpenCreate RC = 0x%08X", (unsigned int)Result); } return CFE_SUCCESS; @@ -1981,6 +2005,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) { CFE_FS_Header_t StdFileHeader; osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED; + int32 OsStatus; int32 Status; int16 RegIndex = 0; const CFE_ES_DumpCDSRegistryCmd_Payload_t *CmdPtr = &data->Payload; @@ -2006,13 +2031,14 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) else { /* Create a new dump file, overwriting anything that may have existed previously */ - Status = + OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { CFE_EVS_SendEvent(CFE_ES_CREATING_CDS_DUMP_ERR_EID, CFE_EVS_EventType_ERROR, - "Error creating CDS dump file '%s', Status=0x%08X", DumpFilename, (unsigned int)Status); + "Error creating CDS dump file '%s', Status=%ld", DumpFilename, (long)OsStatus); + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -2029,9 +2055,9 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) if (Status == sizeof(CFE_FS_Header_t)) { - Status = sizeof(CFE_ES_CDSRegDumpRec_t); + OsStatus = sizeof(CFE_ES_CDSRegDumpRec_t); RegRecPtr = CFE_ES_Global.CDSVars.Registry; - while ((RegIndex < CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES) && (Status == sizeof(CFE_ES_CDSRegDumpRec_t))) + while ((RegIndex < CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES) && (OsStatus == sizeof(CFE_ES_CDSRegDumpRec_t))) { /* Check to see if the Registry entry is empty */ if (CFE_ES_CDSBlockRecordIsUsed(RegRecPtr)) @@ -2044,9 +2070,9 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) strncpy(DumpRecord.Name, RegRecPtr->Name, sizeof(DumpRecord.Name) - 1); /* Output Registry Dump Record to Registry Dump File */ - Status = OS_write(FileDescriptor, &DumpRecord, sizeof(CFE_ES_CDSRegDumpRec_t)); + OsStatus = OS_write(FileDescriptor, &DumpRecord, sizeof(CFE_ES_CDSRegDumpRec_t)); - FileSize += Status; + FileSize += (long)OsStatus; NumEntries++; } @@ -2055,7 +2081,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) ++RegRecPtr; } - if (Status == sizeof(CFE_ES_CDSRegDumpRec_t)) + if (OsStatus == sizeof(CFE_ES_CDSRegDumpRec_t)) { CFE_EVS_SendEvent(CFE_ES_CDS_REG_DUMP_INF_EID, CFE_EVS_EventType_DEBUG, "Successfully dumped CDS Registry to '%s':Size=%d,Entries=%d", DumpFilename, @@ -2067,8 +2093,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) else { CFE_EVS_SendEvent(CFE_ES_CDS_DUMP_ERR_EID, CFE_EVS_EventType_ERROR, - "Error writing CDS Registry to '%s', Status=0x%08X", DumpFilename, - (unsigned int)Status); + "Error writing CDS Registry to '%s', Status=%ld", DumpFilename, (long)OsStatus); /* Increment Command Error Counter */ CFE_ES_Global.TaskData.CommandErrorCounter++; diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index 1a0719c99..cf315f6d5 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -2242,7 +2242,7 @@ void TestTask(void) /* Test task init with background init fail */ ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_BinSemCreate), 1, -7); - UtAssert_INT32_EQ(CFE_ES_TaskInit(), -7); + UtAssert_INT32_EQ(CFE_ES_TaskInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Set the log mode to OVERWRITE; CFE_ES_TaskInit() sets SystemLogMode to * DISCARD, which can result in a log overflow depending on the value that @@ -3526,6 +3526,12 @@ void TestAPI(void) AppId = CFE_ES_APPID_C(ES_UT_MakeAppIdForIndex(99999)); UtAssert_INT32_EQ(CFE_ES_RestartApp(AppId), CFE_ES_ERR_RESOURCEID_NOT_VALID); + /* Test successfully restarting an app */ + ES_ResetUnitTest(); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + UtAssert_INT32_EQ(CFE_ES_RestartApp(AppId), CFE_SUCCESS); + /* Test CFE_ES_ReloadApp with bad AppID argument */ ES_ResetUnitTest(); UtAssert_INT32_EQ(CFE_ES_ReloadApp(CFE_ES_APPID_UNDEFINED, "filename"), CFE_ES_ERR_RESOURCEID_NOT_VALID); @@ -4300,7 +4306,7 @@ void TestCDS() /* Test CDS initialization with size not obtainable */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_GetCDSSize), -1); - UtAssert_INT32_EQ(CFE_ES_CDS_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_ES_CDS_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Reset back to a sufficient CDS size */ UT_SetCDSSize(128 * 1024); @@ -4539,11 +4545,11 @@ void TestCDSMempool(void) /* Test CDS block write with a CDS write error (data content) */ UT_SetDeferredRetcode(UT_KEY(CFE_PSP_WriteToCDS), 2, OS_ERROR); - UtAssert_INT32_EQ(CFE_ES_CDSBlockWrite(BlockHandle, &Data), OS_ERROR); + UtAssert_INT32_EQ(CFE_ES_CDSBlockWrite(BlockHandle, &Data), CFE_ES_CDS_ACCESS_ERROR); /* Test CDS block read with a CDS read error (data content) */ UT_SetDeferredRetcode(UT_KEY(CFE_PSP_ReadFromCDS), 3, OS_ERROR); - UtAssert_INT32_EQ(CFE_ES_CDSBlockRead(&Data, BlockHandle), OS_ERROR); + UtAssert_INT32_EQ(CFE_ES_CDSBlockRead(&Data, BlockHandle), CFE_ES_CDS_ACCESS_ERROR); /* Corrupt the data as to cause a CRC mismatch */ UT_GetDataBuffer(UT_KEY(CFE_PSP_ReadFromCDS), (void **)&CdsPtr, NULL, NULL); @@ -4645,6 +4651,10 @@ void TestESMempool(void) */ UtAssert_INT32_EQ(CFE_ES_GetMemPoolStats(&Stats, CFE_ES_MEMHANDLE_UNDEFINED), CFE_ES_ERR_RESOURCEID_NOT_VALID); + /* Test successfully getting memory pool statistics + */ + CFE_UtAssert_SUCCESS(CFE_ES_GetMemPoolStats(&Stats, PoolID1)); + /* Test allocating a pool buffer where the memory block doesn't fit within * the remaining memory */ diff --git a/modules/evs/fsw/src/cfe_evs_log.c b/modules/evs/fsw/src/cfe_evs_log.c index e1004577e..22ff3e484 100644 --- a/modules/evs/fsw/src/cfe_evs_log.c +++ b/modules/evs/fsw/src/cfe_evs_log.c @@ -130,6 +130,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) const CFE_EVS_LogFileCmd_Payload_t *CmdPtr = &data->Payload; int32 Result; int32 LogIndex; + int32 OsStatus; int32 BytesWritten; osal_id_t LogFileHandle = OS_OBJECT_ID_UNDEFINED; uint32 i; @@ -152,12 +153,14 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) else { /* Create the log file */ - Result = OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Result != OS_SUCCESS) + OsStatus = + OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, - "Write Log File Command Error: OS_OpenCreate = 0x%08X, filename = %s", (unsigned int)Result, + "Write Log File Command Error: OS_OpenCreate = %ld, filename = %s", (long)OsStatus, LogFilename); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -192,10 +195,10 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) /* Write all the "in-use" event log entries to the file */ for (i = 0; i < CFE_EVS_Global.EVS_LogPtr->LogCount; i++) { - BytesWritten = OS_write(LogFileHandle, &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], - sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); + OsStatus = OS_write(LogFileHandle, &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], + sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); - if (BytesWritten == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) + if (OsStatus == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) { LogIndex++; @@ -223,8 +226,8 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) else { EVS_SendEvent(CFE_EVS_ERR_WRLOGFILE_EID, CFE_EVS_EventType_ERROR, - "Write Log File Command Error: OS_write = 0x%08X, filename = %s", - (unsigned int)BytesWritten, LogFilename); + "Write Log File Command Error: OS_write = %ld, filename = %s", (long)OsStatus, + LogFilename); } } diff --git a/modules/evs/fsw/src/cfe_evs_task.c b/modules/evs/fsw/src/cfe_evs_task.c index 5ebd5eef1..df4727d3e 100644 --- a/modules/evs/fsw/src/cfe_evs_task.c +++ b/modules/evs/fsw/src/cfe_evs_task.c @@ -62,8 +62,9 @@ bool CFE_EVS_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); *-----------------------------------------------------------------*/ int32 CFE_EVS_EarlyInit(void) { - + int32 OsStatus; int32 Status; + int32 PspStatus; uint32 resetAreaSize = 0; cpuaddr resetAreaAddr; CFE_ES_ResetData_t *CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)NULL; @@ -80,13 +81,14 @@ int32 CFE_EVS_EarlyInit(void) CFE_EVS_Global.EVS_TlmPkt.Payload.LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; /* Get a pointer to the CFE reset area from the BSP */ - Status = CFE_PSP_GetResetArea(&resetAreaAddr, &resetAreaSize); + PspStatus = CFE_PSP_GetResetArea(&resetAreaAddr, &resetAreaSize); /* Panic on error */ - if (Status != CFE_PSP_SUCCESS) + if (PspStatus != CFE_PSP_SUCCESS) { /* Can't log evs messages without the reset area */ - CFE_ES_WriteToSysLog("%s: Call to CFE_PSP_GetResetArea failed, RC=0x%08x\n", __func__, (unsigned int)Status); + Status = CFE_EVS_RESET_AREA_POINTER; + CFE_ES_WriteToSysLog("%s: Call to CFE_PSP_GetResetArea failed, RC=0x%08x\n", __func__, (unsigned int)PspStatus); /* Delay to allow message to be read */ OS_TaskDelay(CFE_EVS_PANIC_DELAY); @@ -112,16 +114,17 @@ int32 CFE_EVS_EarlyInit(void) CFE_EVS_Global.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log; /* Create semaphore to serialize access to event log */ - Status = OS_MutSemCreate(&CFE_EVS_Global.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0); + OsStatus = OS_MutSemCreate(&CFE_EVS_Global.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0); - if (Status != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, RC=0x%08x\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, RC=%ld\n", __func__, (long)OsStatus); /* Delay to allow message to be read */ OS_TaskDelay(CFE_EVS_PANIC_DELAY); CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM); + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } else { @@ -1549,6 +1552,7 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) { int32 Result; osal_id_t FileHandle = OS_OBJECT_ID_UNDEFINED; + int32 OsStatus; int32 BytesWritten; uint32 EntryCount = 0; uint32 i; @@ -1574,13 +1578,14 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) else { /* Create Application Data File */ - Result = OS_OpenCreate(&FileHandle, LocalName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileHandle, LocalName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Result != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRDATFILE_EID, CFE_EVS_EventType_ERROR, - "Write App Data Command Error: OS_OpenCreate = 0x%08X, filename = %s", (unsigned int)Result, + "Write App Data Command Error: OS_OpenCreate = %ld, filename = %s", (long)OsStatus, LocalName); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -1617,17 +1622,17 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) CFE_PLATFORM_EVS_MAX_EVENT_FILTERS * sizeof(EVS_BinFilter_t)); /* Write application data record to file */ - BytesWritten = OS_write(FileHandle, &AppDataFile, sizeof(CFE_EVS_AppDataFile_t)); + OsStatus = OS_write(FileHandle, &AppDataFile, sizeof(CFE_EVS_AppDataFile_t)); - if (BytesWritten == sizeof(CFE_EVS_AppDataFile_t)) + if (OsStatus == sizeof(CFE_EVS_AppDataFile_t)) { EntryCount++; } else { EVS_SendEvent(CFE_EVS_ERR_WRDATFILE_EID, CFE_EVS_EventType_ERROR, - "Write App Data Command Error: OS_write = 0x%08X, filename = %s", - (unsigned int)BytesWritten, LocalName); + "Write App Data Command Error: OS_write = %ld, filename = %s", (long)OsStatus, + LocalName); break; } } diff --git a/modules/evs/ut-coverage/evs_UT.c b/modules/evs/ut-coverage/evs_UT.c index ea5720268..d3a476d5d 100644 --- a/modules/evs/ut-coverage/evs_UT.c +++ b/modules/evs/ut-coverage/evs_UT.c @@ -44,7 +44,7 @@ static const char *EVS_SYSLOG_MSGS[] = { NULL, "%s: Call to CFE_PSP_GetResetArea failed, RC=0x%08x\n", "%s: Unexpected size from CFE_PSP_GetResetArea: expected = 0x%08lX, actual = 0x%08lX\n", - "%s: OS_MutSemCreate failed, RC=0x%08x\n", + "%s: OS_MutSemCreate failed, RC=%ld\n", "%s: Event Log cleared following power-on reset\n", "%s: Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n", "%s: Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n", @@ -922,7 +922,7 @@ void Test_Logging(void) UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); - UtAssert_INT32_EQ(CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd), OS_ERROR); + UtAssert_INT32_EQ(CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successfully writing all log entries */ UT_InitData(); diff --git a/modules/fs/fsw/src/cfe_fs_api.c b/modules/fs/fsw/src/cfe_fs_api.c index 81615f45c..2e52d8e37 100644 --- a/modules/fs/fsw/src/cfe_fs_api.c +++ b/modules/fs/fsw/src/cfe_fs_api.c @@ -125,6 +125,7 @@ const char *CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_t FileCategory) *-----------------------------------------------------------------*/ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) { + int32 OsStatus; int32 Result; int32 EndianCheck = 0x01020304; @@ -136,14 +137,14 @@ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) /* ** Ensure that we are at the start of the file... */ - Result = OS_lseek(FileDes, 0, OS_SEEK_SET); + OsStatus = OS_lseek(FileDes, 0, OS_SEEK_SET); - if (Result == OS_SUCCESS) + if (OsStatus >= OS_SUCCESS) { /* ** Read header structure into callers buffer... */ - Result = OS_read(FileDes, Hdr, sizeof(CFE_FS_Header_t)); + OsStatus = OS_read(FileDes, Hdr, sizeof(CFE_FS_Header_t)); /* Determine if this processor is a little endian processor */ if ((*(char *)(&EndianCheck)) == 0x04) @@ -154,6 +155,16 @@ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) } } + if (OsStatus >= OS_SUCCESS) + { + /* The "OsStatus" reflects size actually read */ + Result = (long)OsStatus; + } + else + { + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + return (Result); } @@ -190,6 +201,7 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) { CFE_TIME_SysTime_t Time; + int32 OsStatus; int32 Result; int32 EndianCheck = 0x01020304; CFE_ES_AppId_t AppID; @@ -202,9 +214,9 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) /* ** Ensure that we are at the start of the file... */ - Result = OS_lseek(FileDes, 0, OS_SEEK_SET); + OsStatus = OS_lseek(FileDes, 0, OS_SEEK_SET); - if (Result == OS_SUCCESS) + if (OsStatus >= OS_SUCCESS) { /* ** Fill in the ID fields... @@ -241,7 +253,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) /* ** Write header structure from callers buffer... */ - Result = OS_write(FileDes, Hdr, sizeof(CFE_FS_Header_t)); + OsStatus = OS_write(FileDes, Hdr, sizeof(CFE_FS_Header_t)); /* ** Determine if this is a little endian processor @@ -254,6 +266,16 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) } } + if (OsStatus >= OS_SUCCESS) + { + /* The "OsStatus" reflects size actually written */ + Result = (long)OsStatus; + } + else + { + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + return (Result); } @@ -267,6 +289,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) *-----------------------------------------------------------------*/ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp) { + int32 OsStatus; int32 Result; CFE_FS_Header_t TempHdr; int32 EndianCheck = 0x01020304; @@ -274,9 +297,9 @@ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimest int32 FileOffset = 0; FileOffset = ((char *)&TempHdr.TimeSeconds - (char *)&TempHdr.ContentType); - Result = OS_lseek(FileDes, FileOffset, OS_SEEK_SET); + OsStatus = OS_lseek(FileDes, FileOffset, OS_SEEK_SET); - if (Result == FileOffset) + if (OsStatus == FileOffset) { /* ** Determine if this is a little endian processor @@ -289,22 +312,23 @@ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimest CFE_FS_ByteSwapUint32(&OutTimestamp.Subseconds); } - Result = OS_write(FileDes, &OutTimestamp, sizeof(OutTimestamp)); + OsStatus = OS_write(FileDes, &OutTimestamp, sizeof(OutTimestamp)); /* On a good write, the value returned will equal the number of bytes written */ - if (Result == sizeof(OutTimestamp)) + if (OsStatus == sizeof(OutTimestamp)) { Result = CFE_SUCCESS; } else { - CFE_ES_WriteToSysLog("%s: Failed to write timestamp (Status=0x%08X)\n", __func__, (unsigned int)Result); + CFE_ES_WriteToSysLog("%s: Failed to write timestamp (Status=%ld)\n", __func__, (long)OsStatus); Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } else { - CFE_ES_WriteToSysLog("%s: Failed to lseek time fields (Status=0x%08X)\n", __func__, (unsigned int)Result); + CFE_ES_WriteToSysLog("%s: Failed to lseek time fields (Status=%ld)\n", __func__, (long)OsStatus); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } return (Result); @@ -674,6 +698,7 @@ bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) CFE_FS_CurrentFileState_t * State; CFE_FS_BackgroundFileDumpEntry_t *Curr; CFE_FS_FileWriteMetaData_t * Meta; + int32 OsStatus; int32 Status; CFE_FS_Header_t FileHdr; void * RecordPtr; @@ -717,11 +742,13 @@ bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) if (!OS_ObjectIdDefined(State->Fd) && Meta->IsPending) { /* First time processing this entry - open the file */ - Status = OS_OpenCreate(&State->Fd, Meta->FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status < 0) + OsStatus = + OS_OpenCreate(&State->Fd, Meta->FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { State->Fd = OS_OBJECT_ID_UNDEFINED; - Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_CREATE_ERROR, Status, 0, 0, 0); + /* NOTE: This converts the OSAL status directly into a CFE status for logging */ + Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_CREATE_ERROR, (long)OsStatus, 0, 0, 0); } else { @@ -764,17 +791,18 @@ bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) /* * Now write to file */ - Status = OS_write(State->Fd, RecordPtr, RecordSize); + OsStatus = OS_write(State->Fd, RecordPtr, RecordSize); - if (Status != RecordSize) + if (OsStatus != RecordSize) { /* end the file early (cannot set "IsEOF" as this would cause the complete event to be generated too) */ OS_close(State->Fd); State->Fd = OS_OBJECT_ID_UNDEFINED; /* generate write error event */ - Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_RECORD_WRITE_ERROR, Status, State->RecordNum, RecordSize, - State->FileSize); + /* NOTE: This converts the OSAL status directly into a CFE status for logging */ + Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_RECORD_WRITE_ERROR, (long)OsStatus, State->RecordNum, + RecordSize, State->FileSize); break; } else diff --git a/modules/fs/fsw/src/cfe_fs_priv.c b/modules/fs/fsw/src/cfe_fs_priv.c index 37e771112..d3dfe0f35 100644 --- a/modules/fs/fsw/src/cfe_fs_priv.c +++ b/modules/fs/fsw/src/cfe_fs_priv.c @@ -52,18 +52,18 @@ CFE_FS_Global_t CFE_FS_Global; *-----------------------------------------------------------------*/ int32 CFE_FS_EarlyInit(void) { - int32 Stat; + int32 OsStatus; memset(&CFE_FS_Global, 0, sizeof(CFE_FS_Global)); - Stat = OS_MutSemCreate(&CFE_FS_Global.SharedDataMutexId, "CFE_FS_SharedMutex", 0); - if (Stat != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_FS_Global.SharedDataMutexId, "CFE_FS_SharedMutex", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Shared Data Mutex creation failed! RC=0x%08x\n", __func__, (unsigned int)Stat); - return Stat; + CFE_ES_WriteToSysLog("%s: Shared Data Mutex creation failed! RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ - return Stat; + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -76,16 +76,15 @@ int32 CFE_FS_EarlyInit(void) *-----------------------------------------------------------------*/ void CFE_FS_LockSharedData(const char *FunctionName) { - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemTake(CFE_FS_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_FS_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); - - CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=0x%x,App=%lu,Function=%s\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=%ld,App=%lu,Function=%s\n", __func__, (long)OsStatus, + CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); } /* end if */ @@ -102,15 +101,15 @@ void CFE_FS_LockSharedData(const char *FunctionName) *-----------------------------------------------------------------*/ void CFE_FS_UnlockSharedData(const char *FunctionName) { - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemGive(CFE_FS_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_FS_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); - CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=0x%x,App=%lu,Function=%s\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=%ld,App=%lu,Function=%s\n", __func__, (long)OsStatus, + CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); } /* end if */ return; diff --git a/modules/fs/ut-coverage/fs_UT.c b/modules/fs/ut-coverage/fs_UT.c index 5fd87b2e5..b670d1bcc 100644 --- a/modules/fs/ut-coverage/fs_UT.c +++ b/modules/fs/ut-coverage/fs_UT.c @@ -42,8 +42,8 @@ #include "target_config.h" -const char *FS_SYSLOG_MSGS[] = {NULL, "%s: SharedData Mutex Take Err Stat=0x%x,App=%lu,Function=%s\n", - "%s: SharedData Mutex Give Err Stat=0x%x,App=%lu,Function=%s\n"}; +const char *FS_SYSLOG_MSGS[] = {NULL, "%s: SharedData Mutex Take Err Stat=%ld,App=%lu,Function=%s\n", + "%s: SharedData Mutex Give Err Stat=%ld,App=%lu,Function=%s\n"}; /* counts the number of times UT_FS_OnEvent() was invoked (below) */ uint32 UT_FS_FileWriteEventCount[CFE_FS_FileWriteEvent_MAX]; @@ -117,13 +117,13 @@ void Test_CFE_FS_ReadHeader(void) /* Test reading the header with a lseek failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_lseek), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successfully reading the header */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_read), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test calling with NULL pointer argument */ UtAssert_INT32_EQ(CFE_FS_ReadHeader(NULL, FileDes), CFE_FS_BAD_ARGUMENT); @@ -142,13 +142,13 @@ void Test_CFE_FS_WriteHeader(void) /* Test writing the header with a lseek failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_lseek), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successfully writing the header */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_SUCCESS); UT_SetDeferredRetcode(UT_KEY(OS_write), 1, OS_SUCCESS); - UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), OS_SUCCESS); + UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), CFE_SUCCESS); /* Test calling with NULL pointer argument */ UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, NULL), CFE_FS_BAD_ARGUMENT); @@ -167,7 +167,7 @@ void Test_CFE_FS_SetTimestamp(void) /* Test setting the time stamp with a lseek failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_lseek), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_SetTimestamp(FileDes, NewTimestamp), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_SetTimestamp(FileDes, NewTimestamp), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test setting the time stamp with a seconds write failure */ UT_InitData(); @@ -485,7 +485,7 @@ void Test_CFE_FS_Private(void) /* Test FS initialization with a mutex creation failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_MutSemCreate), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successful locking of shared data */ UT_InitData(); diff --git a/modules/resourceid/fsw/src/cfe_resourceid_api.c b/modules/resourceid/fsw/src/cfe_resourceid_api.c index 022bb9b86..89bc03c88 100644 --- a/modules/resourceid/fsw/src/cfe_resourceid_api.c +++ b/modules/resourceid/fsw/src/cfe_resourceid_api.c @@ -108,7 +108,7 @@ int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 Table * * Function: CFE_ResourceId_FindNext * - * Application-scope internal function + * Implemented per public API * See description in header file for argument/return detail * *-----------------------------------------------------------------*/ @@ -121,6 +121,11 @@ CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableS CFE_ResourceId_t CheckId; bool IsTaken; + if (CheckFunc == NULL) + { + return CFE_RESOURCEID_UNDEFINED; + } + ResourceType = CFE_ResourceId_GetBase(StartId); Serial = CFE_ResourceId_GetSerial(StartId); diff --git a/modules/resourceid/ut-coverage/test_cfe_resourceid.c b/modules/resourceid/ut-coverage/test_cfe_resourceid.c index 8f7952178..ec77dd709 100644 --- a/modules/resourceid/ut-coverage/test_cfe_resourceid.c +++ b/modules/resourceid/ut-coverage/test_cfe_resourceid.c @@ -164,7 +164,11 @@ void TestResourceID(void) CFE_ResourceId_ToInteger(Id), (unsigned long)RefIndex, (unsigned long)TestIndex); /* Validate off-nominal inputs */ - Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 0, NULL); + Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 0, UT_ResourceId_CheckIdSlotUsed); + UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx", + CFE_ResourceId_ToInteger(Id)); + + Id = CFE_ResourceId_FindNext(LastId, 0, NULL); UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx", CFE_ResourceId_ToInteger(Id)); diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index fddf3a204..531489ab3 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -103,6 +103,7 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c CFE_ES_AppId_t AppId; CFE_ES_TaskId_t TskId; osal_id_t SysQueueId; + int32 OsStatus; int32 Status; CFE_SB_PipeD_t * PipeDscPtr; CFE_ResourceId_t PendingPipeId = CFE_RESOURCEID_UNDEFINED; @@ -113,6 +114,7 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c SysQueueId = OS_OBJECT_ID_UNDEFINED; PendingEventId = 0; PipeDscPtr = NULL; + OsStatus = OS_SUCCESS; /* * Get caller AppId. @@ -163,19 +165,19 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c if (Status == CFE_SUCCESS) { /* create the queue */ - Status = OS_QueueCreate(&SysQueueId, PipeName, Depth, sizeof(CFE_SB_BufferD_t *), 0); - if (Status == OS_SUCCESS) + OsStatus = OS_QueueCreate(&SysQueueId, PipeName, Depth, sizeof(CFE_SB_BufferD_t *), 0); + if (OsStatus == OS_SUCCESS) { /* just translate the RC to CFE */ Status = CFE_SUCCESS; } else { - if (Status == OS_ERR_NAME_TAKEN) + if (OsStatus == OS_ERR_NAME_TAKEN) { PendingEventId = CFE_SB_CR_PIPE_NAME_TAKEN_EID; } - else if (Status == OS_ERR_NO_FREE_IDS) + else if (OsStatus == OS_ERR_NO_FREE_IDS) { PendingEventId = CFE_SB_CR_PIPE_NO_FREE_EID; } @@ -266,7 +268,7 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c break; case CFE_SB_CR_PIPE_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, - "CreatePipeErr:OS_QueueCreate returned %d,app %s", (int)Status, + "CreatePipeErr:OS_QueueCreate returned %ld,app %s", (long)OsStatus, CFE_SB_GetAppTskName(TskId, FullName)); break; } @@ -662,6 +664,7 @@ CFE_Status_t CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) *-----------------------------------------------------------------*/ CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId) { + int32 OsStatus; int32 Status; CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -699,9 +702,9 @@ CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_P } else { - Status = OS_GetResourceName(SysQueueId, PipeNameBuf, PipeNameSize); + OsStatus = OS_GetResourceName(SysQueueId, PipeNameBuf, PipeNameSize); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } @@ -756,6 +759,7 @@ CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_P *-----------------------------------------------------------------*/ CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) { + int32 OsStatus; int32 Status; CFE_ES_TaskId_t TskId; uint32 Idx; @@ -775,8 +779,8 @@ CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *Pipe else { /* Get QueueID from OSAL */ - Status = OS_QueueGetIdByName(&SysQueueId, PipeName); - if (Status == OS_SUCCESS) + OsStatus = OS_QueueGetIdByName(&SysQueueId, PipeName); + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } @@ -1554,7 +1558,7 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ CFE_SB_DestinationD_t *DestPtr; CFE_SB_PipeD_t * PipeDscPtr; CFE_SB_EventBuf_t SBSndErr; - int32 Status; + int32 OsStatus; uint32 i; char FullName[(OS_MAX_API_NAME * 2)]; char PipeName[OS_MAX_API_NAME]; @@ -1623,9 +1627,9 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ ** Write the buffer descriptor to the queue of the pipe. If the write ** failed, log info and increment the pipe's error counter. */ - Status = OS_QueuePut(PipeDscPtr->SysQueueId, &BufDscPtr, sizeof(BufDscPtr), 0); + OsStatus = OS_QueuePut(PipeDscPtr->SysQueueId, &BufDscPtr, sizeof(BufDscPtr), 0); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { /* The queue now holds a ref to the buffer, so increment its ref count. */ CFE_SB_IncrBufUseCnt(BufDscPtr); @@ -1638,7 +1642,7 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ PipeDscPtr->PeakQueueDepth = PipeDscPtr->CurrentQueueDepth; } } - else if (Status == OS_QUEUE_FULL) + else if (OsStatus == OS_QUEUE_FULL) { SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_FULL_ERR_EID; @@ -1649,9 +1653,9 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ else { /* Unexpected error while writing to queue. */ - SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; - SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID; - SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].ErrStat = Status; + SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; + SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID; + SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].OsStatus = OsStatus; SBSndErr.EvtsToSnd++; CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter++; PipeDscPtr->SendErrors++; @@ -1751,10 +1755,9 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ CFE_SB_GetPipeName(PipeName, sizeof(PipeName), SBSndErr.EvtBuf[i].PipeId); CFE_EVS_SendEventWithAppID(CFE_SB_Q_WR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, - "Pipe Write Err,MsgId 0x%x,pipe %s,sender %s,stat 0x%x", + "Pipe Write Err,MsgId 0x%x,pipe %s,sender %s,stat %ld", (unsigned int)CFE_SB_MsgIdToValue(BufDscPtr->MsgId), PipeName, - CFE_SB_GetAppTskName(TskId, FullName), - (unsigned int)SBSndErr.EvtBuf[i].ErrStat); + CFE_SB_GetAppTskName(TskId, FullName), (long)(SBSndErr.EvtBuf[i].OsStatus)); /* clear the bit so the task may send this event again */ CFE_SB_FinishSendEvent(TskId, CFE_SB_Q_WR_ERR_EID_BIT); @@ -1775,7 +1778,7 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) { int32 Status; - int32 RcvStatus; + int32 OsStatus; CFE_SB_BufferD_t * BufDscPtr; size_t BufDscSize; CFE_SB_PipeD_t * PipeDscPtr; @@ -1795,7 +1798,7 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe BufDscPtr = NULL; DestPtr = NULL; BufDscSize = 0; - RcvStatus = OS_SUCCESS; + OsStatus = OS_SUCCESS; /* * Check input args and see if any are bad, which require @@ -1880,7 +1883,7 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe if (Status == CFE_SUCCESS) { /* Read the buffer descriptor address from the queue. */ - RcvStatus = OS_QueueGet(SysQueueId, &BufDscPtr, sizeof(BufDscPtr), &BufDscSize, SysTimeout); + OsStatus = OS_QueueGet(SysQueueId, &BufDscPtr, sizeof(BufDscPtr), &BufDscSize, SysTimeout); /* * translate the return value - @@ -1888,16 +1891,16 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe * CFE functions have their own set of RC values should not directly return OSAL codes * The size should always match. If it does not, then generate CFE_SB_Q_RD_ERR_EID. */ - if (RcvStatus == OS_SUCCESS && BufDscPtr != NULL && BufDscSize == sizeof(BufDscPtr)) + if (OsStatus == OS_SUCCESS && BufDscPtr != NULL && BufDscSize == sizeof(BufDscPtr)) { /* Pass through */ } - else if (RcvStatus == OS_QUEUE_EMPTY) + else if (OsStatus == OS_QUEUE_EMPTY) { /* normal if using CFE_SB_POLL */ Status = CFE_SB_NO_MESSAGE; } - else if (RcvStatus == OS_QUEUE_TIMEOUT) + else if (OsStatus == OS_QUEUE_TIMEOUT) { /* normal if using a nonzero timeout */ Status = CFE_SB_TIME_OUT; @@ -1995,8 +1998,8 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe { case CFE_SB_Q_RD_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_Q_RD_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, - "Pipe Read Err,pipe %lu,app %s,stat 0x%x", CFE_RESOURCEID_TO_ULONG(PipeId), - CFE_SB_GetAppTskName(TskId, FullName), (unsigned int)RcvStatus); + "Pipe Read Err,pipe %lu,app %s,stat %ld", CFE_RESOURCEID_TO_ULONG(PipeId), + CFE_SB_GetAppTskName(TskId, FullName), (long)OsStatus); break; case CFE_SB_RCV_BAD_ARG_EID: CFE_EVS_SendEventWithAppID(CFE_SB_RCV_BAD_ARG_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, diff --git a/modules/sb/fsw/src/cfe_sb_init.c b/modules/sb/fsw/src/cfe_sb_init.c index 4d28cdaf7..4cdc016a6 100644 --- a/modules/sb/fsw/src/cfe_sb_init.c +++ b/modules/sb/fsw/src/cfe_sb_init.c @@ -58,17 +58,17 @@ const size_t CFE_SB_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = { *-----------------------------------------------------------------*/ int32 CFE_SB_EarlyInit(void) { - + int32 OsStatus; int32 Stat; /* Clear task global */ memset(&CFE_SB_Global, 0, sizeof(CFE_SB_Global)); - Stat = OS_MutSemCreate(&CFE_SB_Global.SharedDataMutexId, "CFE_SB_DataMutex", 0); - if (Stat != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_SB_Global.SharedDataMutexId, "CFE_SB_DataMutex", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Shared data mutex creation failed! RC=0x%08x\n", __func__, (unsigned int)Stat); - return Stat; + CFE_ES_WriteToSysLog("%s: Shared data mutex creation failed! RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ /* Initialize the state of susbcription reporting */ diff --git a/modules/sb/fsw/src/cfe_sb_priv.c b/modules/sb/fsw/src/cfe_sb_priv.c index 001da7582..b5b0e7c74 100644 --- a/modules/sb/fsw/src/cfe_sb_priv.c +++ b/modules/sb/fsw/src/cfe_sb_priv.c @@ -134,18 +134,15 @@ int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) *-----------------------------------------------------------------*/ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber) { - - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemTake(CFE_SB_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_SB_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { - CFE_ES_GetAppID(&AppId); - - CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=%ld,App=%lu,Func=%s,Line=%d\n", __func__, + (long)OsStatus, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); } /* end if */ @@ -162,18 +159,15 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber) *-----------------------------------------------------------------*/ void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber) { - - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemGive(CFE_SB_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_SB_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { - CFE_ES_GetAppID(&AppId); - - CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=%ld,App=%lu,Func=%s,Line=%d\n", __func__, + (long)OsStatus, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); } /* end if */ diff --git a/modules/sb/fsw/src/cfe_sb_priv.h b/modules/sb/fsw/src/cfe_sb_priv.h index cfb977c1f..d4a5c90e5 100644 --- a/modules/sb/fsw/src/cfe_sb_priv.h +++ b/modules/sb/fsw/src/cfe_sb_priv.h @@ -272,7 +272,7 @@ typedef struct typedef struct { uint32 EventId; - int32 ErrStat; + int32 OsStatus; CFE_SB_PipeId_t PipeId; } CFE_SB_SendErrEventBuf_t; diff --git a/modules/sb/ut-coverage/sb_UT.c b/modules/sb/ut-coverage/sb_UT.c index e01313969..da88d7151 100644 --- a/modules/sb/ut-coverage/sb_UT.c +++ b/modules/sb/ut-coverage/sb_UT.c @@ -1720,7 +1720,7 @@ void Test_SB_EarlyInit(void) void Test_SB_EarlyInit_SemCreateError(void) { UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERR_NO_FREE_IDS); - UtAssert_INT32_EQ(CFE_SB_EarlyInit(), OS_ERR_NO_FREE_IDS); + UtAssert_INT32_EQ(CFE_SB_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); } /* end Test_SB_EarlyInit_SemCreateError */ /* @@ -2436,6 +2436,12 @@ void Test_Subscribe_LocalSubscription(void) CFE_UtAssert_EVENTSENT(CFE_SB_PIPE_ADDED_EID); CFE_UtAssert_EVENTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); + /* Test_Subscribe_LocalSubscription with message + * limit greater than CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT + */ + CFE_UtAssert_SUCCESS(CFE_SB_Unsubscribe(MsgId, PipeId)); + UtAssert_INT32_EQ(CFE_SB_SubscribeLocal(MsgId, PipeId, UINT16_MAX), CFE_SUCCESS); + CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId)); } /* end Test_Subscribe_LocalSubscription */ @@ -3049,12 +3055,14 @@ void Test_TransmitMsg_MaxMsgSizePlusOne(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter = 0; UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&TlmPkt.Hdr.Msg, true), CFE_SB_MSG_TOO_BIG); CFE_UtAssert_EVENTCOUNT(1); CFE_UtAssert_EVENTSENT(CFE_SB_MSG_TOO_BIG_EID); + UtAssert_INT32_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter, 1); } /* end Test_TransmitMsg_MaxMsgSizePlusOne */ diff --git a/modules/tbl/fsw/src/cfe_tbl_api.c b/modules/tbl/fsw/src/cfe_tbl_api.c index 9bac32276..482b6515d 100644 --- a/modules/tbl/fsw/src/cfe_tbl_api.c +++ b/modules/tbl/fsw/src/cfe_tbl_api.c @@ -939,7 +939,7 @@ CFE_Status_t CFE_TBL_Update(CFE_TBL_Handle_t TblHandle) CFE_RESOURCEID_TO_ULONG(ThisAppId), (int)TblHandle); } - if (Status != CFE_TBL_ERR_BAD_APP_ID) + if (Status != CFE_ES_ERR_RESOURCEID_NOT_VALID) { /* Translate AppID of caller into App Name */ CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName)); diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c index c1d73ba5d..63b85f3aa 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -49,6 +49,7 @@ int32 CFE_TBL_EarlyInit(void) { uint16 i; uint32 j; + int32 OsStatus; int32 Status; /* Clear task global */ @@ -89,19 +90,19 @@ int32 CFE_TBL_EarlyInit(void) /* ** Create table registry access mutex */ - Status = OS_MutSemCreate(&CFE_TBL_Global.RegistryMutex, CFE_TBL_MUT_REG_NAME, CFE_TBL_MUT_REG_VALUE); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_TBL_Global.RegistryMutex, CFE_TBL_MUT_REG_NAME, CFE_TBL_MUT_REG_VALUE); + if (OsStatus != OS_SUCCESS) { - return Status; + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ /* ** Create working buffer access mutex */ - Status = OS_MutSemCreate(&CFE_TBL_Global.WorkBufMutex, CFE_TBL_MUT_WORK_NAME, CFE_TBL_MUT_WORK_VALUE); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_TBL_Global.WorkBufMutex, CFE_TBL_MUT_WORK_NAME, CFE_TBL_MUT_WORK_VALUE); + if (OsStatus != OS_SUCCESS) { - return Status; + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ /* Initialize memory partition and allocate shared table buffers. */ @@ -617,14 +618,19 @@ void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_AppId_ *-----------------------------------------------------------------*/ int32 CFE_TBL_LockRegistry(void) { + int32 OsStatus; int32 Status; - Status = OS_MutSemTake(CFE_TBL_Global.RegistryMutex); + OsStatus = OS_MutSemTake(CFE_TBL_Global.RegistryMutex); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } + else + { + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } return Status; } @@ -639,14 +645,19 @@ int32 CFE_TBL_LockRegistry(void) *-----------------------------------------------------------------*/ int32 CFE_TBL_UnlockRegistry(void) { + int32 OsStatus; int32 Status; - Status = OS_MutSemGive(CFE_TBL_Global.RegistryMutex); + OsStatus = OS_MutSemGive(CFE_TBL_Global.RegistryMutex); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } + else + { + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } return Status; } @@ -663,6 +674,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, CFE_TBL_Re bool CalledByApp) { int32 Status = CFE_SUCCESS; + int32 OsStatus; int32 i; int32 InactiveBufferIndex; CFE_TBL_Handle_t AccessIterator; @@ -737,13 +749,13 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, CFE_TBL_Re { /* Take Mutex to make sure we are not trying to grab a working buffer that some */ /* other application is also trying to grab. */ - Status = OS_MutSemTake(CFE_TBL_Global.WorkBufMutex); + OsStatus = OS_MutSemTake(CFE_TBL_Global.WorkBufMutex); /* Make note of any errors but continue and hope for the best */ - if (Status != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Internal error taking WorkBuf Mutex (Status=0x%08X)\n", __func__, - (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: Internal error taking WorkBuf Mutex (Status=%ld)\n", __func__, + (long)OsStatus); } /* Determine if there are any common buffers available */ @@ -799,6 +811,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe const char *Filename) { int32 Status = CFE_SUCCESS; + int32 OsStatus; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; @@ -817,12 +830,12 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe } /* Try to open the specified table file */ - Status = OS_OpenCreate(&FileDescriptor, Filename, OS_FILE_FLAG_NONE, OS_READ_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, Filename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (Status < 0) + if (OsStatus != OS_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, - "%s: Unable to open file (FileDescriptor=%d)", AppName, (int)Status); + "%s: Unable to open file (Status=%ld)", AppName, (long)OsStatus); return CFE_TBL_ERR_ACCESS; } @@ -871,8 +884,16 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe Status = CFE_TBL_WARN_SHORT_FILE; } - NumBytes = + OsStatus = OS_read(FileDescriptor, ((uint8 *)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset, TblFileHeader.NumBytes); + if (OsStatus >= OS_SUCCESS) + { + NumBytes = (long)OsStatus; /* status code conversion (size) */ + } + else + { + NumBytes = 0; + } if (NumBytes != TblFileHeader.NumBytes) { @@ -885,7 +906,15 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe } /* Check to see if the file is too large (ie - more data than header claims) */ - NumBytes = OS_read(FileDescriptor, &ExtraByte, 1); + OsStatus = OS_read(FileDescriptor, &ExtraByte, 1); + if (OsStatus >= OS_SUCCESS) + { + NumBytes = (long)OsStatus; /* status code conversion (size) */ + } + else + { + NumBytes = 0; + } /* If successfully read another byte, then file must have too much data */ if (NumBytes == 1) @@ -1058,6 +1087,7 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead CFE_TBL_File_Hdr_t *TblFileHeaderPtr, const char *LoadFilename) { int32 Status; + int32 OsStatus; int32 EndianCheck = 0x01020304; #if (CFE_PLATFORM_TBL_VALID_SCID_COUNT > 0) @@ -1109,14 +1139,14 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead } else { - Status = OS_read(FileDescriptor, TblFileHeaderPtr, sizeof(CFE_TBL_File_Hdr_t)); + OsStatus = OS_read(FileDescriptor, TblFileHeaderPtr, sizeof(CFE_TBL_File_Hdr_t)); /* Verify successful read of cFE Table File Header */ - if (Status != sizeof(CFE_TBL_File_Hdr_t)) + if (OsStatus != sizeof(CFE_TBL_File_Hdr_t)) { CFE_EVS_SendEventWithAppID( CFE_TBL_FILE_TBL_HDR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, - "Unable to read tbl header for '%s', Status = 0x%08X", LoadFilename, (unsigned int)Status); + "Unable to read tbl header for '%s', Status = %ld", LoadFilename, (long)OsStatus); Status = CFE_TBL_ERR_NO_TBL_HEADER; } diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.h b/modules/tbl/fsw/src/cfe_tbl_internal.h index 0873ea8ed..545599bfb 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.h +++ b/modules/tbl/fsw/src/cfe_tbl_internal.h @@ -93,7 +93,7 @@ int32 CFE_TBL_ValidateHandle(CFE_TBL_Handle_t TblHandle); *#CFE_ES_GetAppID ** ** \retval #CFE_SUCCESS \copydoc CFE_SUCCESS -** \retval #CFE_TBL_ERR_BAD_APP_ID \copydoc CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copydoc CFE_ES_ERR_RESOURCEID_NOT_VALID ** \retval #CFE_TBL_ERR_INVALID_HANDLE \copydoc CFE_TBL_ERR_INVALID_HANDLE ** \retval #CFE_TBL_ERR_NO_ACCESS \copydoc CFE_TBL_ERR_NO_ACCESS ** diff --git a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c index 0032eef8c..8cf5195d3 100644 --- a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c +++ b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c @@ -48,6 +48,7 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) { int32 Status; + int32 OsStatus; uint32 i; CFE_TBL_DumpControl_t *DumpCtrlPtr; CFE_TIME_SysTime_t DumpTime; @@ -101,10 +102,10 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) DumpTime.Seconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSecs; DumpTime.Subseconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSubSecs; - Status = OS_OpenCreate(&FileDescriptor, DumpCtrlPtr->DumpBufferPtr->DataSource, OS_FILE_FLAG_NONE, - OS_READ_WRITE); + OsStatus = OS_OpenCreate(&FileDescriptor, DumpCtrlPtr->DumpBufferPtr->DataSource, OS_FILE_FLAG_NONE, + OS_READ_WRITE); - if (Status >= 0) + if (OsStatus == OS_SUCCESS) { Status = CFE_FS_SetTimestamp(FileDescriptor, DumpTime); @@ -363,6 +364,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; int32 Status; + int32 OsStatus; int16 RegIndex; CFE_TBL_RegistryRec_t * RegRecPtr; CFE_TBL_LoadBuff_t * WorkingBufferPtr; @@ -374,9 +376,9 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) sizeof(CmdPtr->LoadFilename)); /* Try to open the specified table file */ - Status = OS_OpenCreate(&FileDescriptor, LoadFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, LoadFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (Status >= 0) + if (OsStatus == OS_SUCCESS) { Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, &LoadFilename[0]); @@ -423,19 +425,19 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) if (Status == CFE_SUCCESS) { /* Copy data from file into working buffer */ - Status = + OsStatus = OS_read(FileDescriptor, ((uint8 *)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset, TblFileHeader.NumBytes); /* Make sure the appropriate number of bytes were read */ - if (Status == (int32)TblFileHeader.NumBytes) + if ((long)OsStatus == TblFileHeader.NumBytes) { /* Check to ensure the file does not have any extra data at the end */ - Status = OS_read(FileDescriptor, &ExtraByte, 1); + OsStatus = OS_read(FileDescriptor, &ExtraByte, 1); /* If another byte was successfully read, then file contains more data than header * claims */ - if (Status == 1) + if ((long)OsStatus == 1) { CFE_EVS_SendEvent(CFE_TBL_FILE_TOO_BIG_ERR_EID, CFE_EVS_EventType_ERROR, "File '%s' has more data than Tbl Hdr indicates (%d)", @@ -531,8 +533,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) { /* Error opening specified file */ CFE_EVS_SendEvent(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, - "Unable to open file '%s' for table load, Status = 0x%08X", LoadFilename, - (unsigned int)Status); + "Unable to open file '%s' for table load, Status = %ld", LoadFilename, (long)OsStatus); } return ReturnCode; @@ -701,24 +702,25 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; int32 Status; + int32 OsStatus; int32 EndianCheck = 0x01020304; /* Clear Header of any garbage before copying content */ memset(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); /* Check to see if the dump file already exists */ - Status = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (Status >= 0) + if (OsStatus == OS_SUCCESS) { FileExistedPrev = true; OS_close(FileDescriptor); } /* Create a new dump file, overwriting anything that may have existed previously */ - Status = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status >= OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "Table Dump Image", CFE_FS_SubType_TBL_IMG); @@ -746,16 +748,16 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta } /* Output the Table Image Header to the Dump File */ - Status = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t)); + OsStatus = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t)); /* Make sure the header was output completely */ - if (Status == sizeof(CFE_TBL_File_Hdr_t)) + if ((long)OsStatus == sizeof(CFE_TBL_File_Hdr_t)) { /* Output the requested data to the dump file */ /* Output the active table image data to the dump file */ - Status = OS_write(FileDescriptor, DumpDataAddr, TblSizeInBytes); + OsStatus = OS_write(FileDescriptor, DumpDataAddr, TblSizeInBytes); - if (Status == TblSizeInBytes) + if ((long)OsStatus == TblSizeInBytes) { if (FileExistedPrev) { @@ -780,15 +782,14 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta else { CFE_EVS_SendEvent(CFE_TBL_WRITE_TBL_IMG_ERR_EID, CFE_EVS_EventType_ERROR, - "Error writing Tbl image to '%s', Status=0x%08X", DumpFilename, - (unsigned int)Status); + "Error writing Tbl image to '%s', Status=%ld", DumpFilename, (long)OsStatus); } } else { CFE_EVS_SendEvent(CFE_TBL_WRITE_TBL_HDR_ERR_EID, CFE_EVS_EventType_ERROR, - "Error writing Tbl image File Header to '%s', Status=0x%08X", DumpFilename, - (unsigned int)Status); + "Error writing Tbl image File Header to '%s', Status=%ld", DumpFilename, + (long)OsStatus); } } else @@ -804,7 +805,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta else { CFE_EVS_SendEvent(CFE_TBL_CREATING_DUMP_FILE_ERR_EID, CFE_EVS_EventType_ERROR, - "Error creating dump file '%s', Status=0x%08X", DumpFilename, (unsigned int)Status); + "Error creating dump file '%s', Status=%ld", DumpFilename, (long)OsStatus); } return ReturnCode; diff --git a/modules/tbl/ut-coverage/tbl_UT.c b/modules/tbl/ut-coverage/tbl_UT.c index 72ae5d5e2..f59974be1 100644 --- a/modules/tbl/ut-coverage/tbl_UT.c +++ b/modules/tbl/ut-coverage/tbl_UT.c @@ -144,6 +144,7 @@ void UtTest_Setup(void) UT_ADD_TEST(Test_CFE_TBL_ReleaseAddresses); UT_ADD_TEST(Test_CFE_TBL_Validate); UT_ADD_TEST(Test_CFE_TBL_Manage); + UT_ADD_TEST(Test_CFE_TBL_DumpToBuffer); UT_ADD_TEST(Test_CFE_TBL_Update); UT_ADD_TEST(Test_CFE_TBL_GetStatus); UT_ADD_TEST(Test_CFE_TBL_GetInfo); @@ -1386,6 +1387,13 @@ void Test_CFE_TBL_Register(void) UtPrintf("Begin Test Register"); + /* Test response to a null table handle and null table name */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_Register(NULL, "UT_Table1", sizeof(UT_Table1_t), CFE_TBL_OPT_DEFAULT, NULL), + CFE_TBL_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_TBL_Register(&TblHandle1, NULL, sizeof(UT_Table1_t), CFE_TBL_OPT_DEFAULT, NULL), + CFE_TBL_BAD_ARGUMENT); + /* Test response to an invalid application ID */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppID), 1, CFE_ES_ERR_RESOURCEID_NOT_VALID); @@ -1732,6 +1740,23 @@ void Test_CFE_TBL_Register(void) CFE_UtAssert_EVENTNOTSENT(CFE_TBL_REGISTER_ERR_EID); CFE_UtAssert_EVENTCOUNT(0); + /* Test registering a critical table with no space in the critical table registry */ + /* a. Setup test */ + UT_InitData(); + for (i = 0; i < CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) + { + CFE_TBL_Global.CritReg[i].CDSHandle = CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(i + 1)); + } + /* b. Perform test */ + CFE_UtAssert_SUCCESS(CFE_TBL_Register(&TblHandle1, "NOTABLE", sizeof(UT_Table1_t), CFE_TBL_OPT_CRITICAL, NULL)); + CFE_UtAssert_EVENTNOTSENT(CFE_TBL_REGISTER_ERR_EID); + CFE_UtAssert_EVENTCOUNT(0); + + /* c. Test cleanup: unregister table */ + UT_ClearEventHistory(); + CFE_UtAssert_SUCCESS(CFE_TBL_Unregister(TblHandle1)); + CFE_UtAssert_EVENTCOUNT(0); + /* Test response to no available handles */ /* a. Test setup */ UT_InitData(); @@ -1832,6 +1857,11 @@ void Test_CFE_TBL_Share(void) StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; StdFileHeader.ProcessorID = CFE_PLATFORM_TBL_VALID_PRID_1; + /* Test response to a null table handle and null table name */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_Share(NULL, "ut_cfe_tbl.UT_Table2"), CFE_TBL_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_TBL_Share(&App2TblHandle1, NULL), CFE_TBL_BAD_ARGUMENT); + /* Test response to an invalid application ID */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppID), 1, CFE_ES_ERR_RESOURCEID_NOT_VALID); @@ -1989,6 +2019,10 @@ void Test_CFE_TBL_Load(void) CFE_UtAssert_EVENTNOTSENT(CFE_TBL_REGISTER_ERR_EID); CFE_UtAssert_EVENTCOUNT(0); + /* Test response to a null source data pointer */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, NULL), CFE_TBL_BAD_ARGUMENT); + /* Test attempt to perform partial INITIAL load */ UT_InitData(); strncpy(StdFileHeader.Description, "Test description", sizeof(StdFileHeader.Description) - 1); @@ -2185,6 +2219,10 @@ void Test_CFE_TBL_GetAddress(void) UtPrintf("Begin Test Get Address"); + /* Test response to a null table pointer */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_GetAddress(NULL, App1TblHandle1), CFE_TBL_BAD_ARGUMENT); + /* Test attempt to get the address of a table for which the application * does not have access */ @@ -2274,6 +2312,14 @@ void Test_CFE_TBL_GetAddresses(void) UtAssert_NOT_NULL(Tbl1Ptr); UtAssert_NOT_NULL(Tbl2Ptr); + /* Test getting the addresses of zero tables */ + CFE_UtAssert_SUCCESS(CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 0, ArrayOfHandles)); + + /* Test response to a null table pointer and null table handle */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_GetAddresses(NULL, 2, ArrayOfHandles), CFE_TBL_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 2, NULL), CFE_TBL_BAD_ARGUMENT); + /* Test attempt to get addresses of tables that the application is not * allowed to see */ @@ -2281,6 +2327,12 @@ void Test_CFE_TBL_GetAddresses(void) UT_SetAppID(CFE_ES_APPID_UNDEFINED); UtAssert_INT32_EQ(CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 2, ArrayOfHandles), CFE_TBL_ERR_NO_ACCESS); CFE_UtAssert_EVENTCOUNT(0); + + /* Test attempt to get addresses of tables with a bad app ID */ + UT_InitData(); + UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppID), 1, CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 2, ArrayOfHandles), CFE_ES_ERR_RESOURCEID_NOT_VALID); + CFE_UtAssert_EVENTCOUNT(0); } /* @@ -2289,13 +2341,69 @@ void Test_CFE_TBL_GetAddresses(void) */ void Test_CFE_TBL_ReleaseAddresses(void) { + CFE_FS_Header_t FileHeader; + UT_TempFile_t File; + CFE_TBL_Handle_t TblHandle1; UtPrintf("Begin Test Release Addresses"); + /* Test response to a null table handle pointer */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_ReleaseAddresses(2, NULL), CFE_TBL_BAD_ARGUMENT); + CFE_UtAssert_EVENTCOUNT(0); + /* Test response to releasing two tables that have not been loaded */ UT_InitData(); UT_SetAppID(UT_TBL_APPID_1); UtAssert_INT32_EQ(CFE_TBL_ReleaseAddresses(2, ArrayOfHandles), CFE_TBL_ERR_NEVER_LOADED); CFE_UtAssert_EVENTCOUNT(0); + + /* Test releasing 0 then 1 addresses */ + UT_InitData(); + + /* a. Configure for successful file read to initialize table */ + strncpy(FileHeader.Description, "FS header description", sizeof(FileHeader.Description) - 1); + FileHeader.Description[sizeof(FileHeader.Description) - 1] = '\0'; + FileHeader.ContentType = CFE_FS_FILE_CONTENT_ID; + FileHeader.SubType = CFE_FS_SubType_TBL_IMG; + FileHeader.TimeSeconds = 1704; + FileHeader.TimeSubSeconds = 104; + strncpy(File.TblHeader.TableName, "ut_cfe_tbl.UT_RELEASE_TEST", sizeof(File.TblHeader.TableName) - 1); + File.TblHeader.TableName[sizeof(File.TblHeader.TableName) - 1] = '\0'; + UT_TBL_SetupHeader(&File.TblHeader, 0, sizeof(UT_Table1_t)); + + if (UT_Endianess == UT_LITTLE_ENDIAN) + { + File.TblData.TblElement1 = 0x04030201; + File.TblData.TblElement2 = 0x08070605; + } + else + { + File.TblData.TblElement1 = 0x01020304; + File.TblData.TblElement2 = 0x05060708; + } + + UT_SetReadBuffer(&File, sizeof(File)); + UT_SetReadHeader(&FileHeader, sizeof(FileHeader)); + UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); + + /* b. Perform load */ + CFE_UtAssert_SUCCESS( + CFE_TBL_Register(&TblHandle1, "UT_RELEASE_TEST", sizeof(UT_Table1_t), CFE_TBL_OPT_DEFAULT, NULL)); + CFE_UtAssert_SUCCESS(CFE_TBL_Load(TblHandle1, CFE_TBL_SRC_FILE, "MyInputFile")); + + /* c. Get addresses */ + ArrayOfHandles[0] = TblHandle1; + ArrayOfPtrsToTblPtrs[0] = &Tbl1Ptr; + CFE_UtAssert_SUCCESS(CFE_TBL_GetAddresses(ArrayOfPtrsToTblPtrs, 1, ArrayOfHandles)); + UT_ClearEventHistory(); + + /* d. Release 0 addresses */ + CFE_UtAssert_SUCCESS(CFE_TBL_ReleaseAddresses(0, ArrayOfHandles)); + CFE_UtAssert_EVENTCOUNT(0); + + /* e. Release 1 addresses */ + CFE_UtAssert_SUCCESS(CFE_TBL_ReleaseAddresses(1, ArrayOfHandles)); + CFE_UtAssert_EVENTCOUNT(0); } /* @@ -2303,8 +2411,14 @@ void Test_CFE_TBL_ReleaseAddresses(void) */ void Test_CFE_TBL_Validate(void) { + int16 RegIndex; + CFE_TBL_RegistryRec_t *RegRecPtr; UtPrintf("Begin Test Validate"); + /* Test setup */ + RegIndex = CFE_TBL_FindTableInRegistry("ut_cfe_tbl.UT_Table1"); + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; + /* Test response to attempt to validate a table that an application is * not allowed to see */ @@ -2320,6 +2434,44 @@ void Test_CFE_TBL_Validate(void) UT_SetAppID(UT_TBL_APPID_1); UtAssert_INT32_EQ(CFE_TBL_Validate(App1TblHandle1), CFE_TBL_INFO_NO_VALIDATION_PENDING); CFE_UtAssert_EVENTCOUNT(0); + + /* Test failed validation */ + UT_InitData(); + + /* a. Configure table for validation */ + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, "ut_cfe_tbl.UT_Table1", + sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; + RegRecPtr->ValidateInactiveIndex = 0; + + /* b. Perform failed validation */ + UT_SetDeferredRetcode(UT_KEY(Test_CFE_TBL_ValidationFunc), 1, -1); + CFE_UtAssert_SUCCESS(CFE_TBL_Validate(App1TblHandle1)); + CFE_UtAssert_EVENTSENT(CFE_TBL_VALIDATION_ERR_EID); + CFE_UtAssert_EVENTCOUNT(1); + UtAssert_INT32_EQ(CFE_TBL_Global.ValidationResults[0].Result, -1); + + /* Test successful validation */ + UT_InitData(); + + /* a. Configure table for validation */ + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, "ut_cfe_tbl.UT_Table1", + sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; + RegRecPtr->ValidateInactiveIndex = 0; + + /* b. Perform failed validation */ + UT_SetDeferredRetcode(UT_KEY(Test_CFE_TBL_ValidationFunc), 1, CFE_SUCCESS); + CFE_UtAssert_SUCCESS(CFE_TBL_Validate(App1TblHandle1)); + UtAssert_INT32_EQ(CFE_TBL_Global.ValidationResults[0].Result, CFE_SUCCESS); } /* @@ -2399,6 +2551,27 @@ void Test_CFE_TBL_Manage(void) CFE_UtAssert_EVENTCOUNT(1); UtAssert_INT32_EQ(CFE_TBL_Global.ValidationResults[0].Result, 1); + /* Test response to processing an unsuccessful validation request; + * CFE_TBL_Validate does not return CFE_SUCCESS + */ + UT_InitData(); + + /* Configure table for validation */ + CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_PENDING; + CFE_TBL_Global.ValidationResults[0].Result = 0; + strncpy(CFE_TBL_Global.ValidationResults[0].TableName, "ut_cfe_tbl.UT_Table1", + sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1); + CFE_TBL_Global.ValidationResults[0].TableName[sizeof(CFE_TBL_Global.ValidationResults[0].TableName) - 1] = '\0'; + CFE_TBL_Global.ValidationResults[0].CrcOfTable = 0; + CFE_TBL_Global.ValidationResults[0].ActiveBuffer = false; + RegRecPtr->ValidateInactiveIndex = 0; + + /* Perform validation via manage call */ + UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetAppID), 2, CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_TBL_Manage(App1TblHandle1), CFE_ES_ERR_RESOURCEID_NOT_VALID); + CFE_UtAssert_EVENTCOUNT(0); + UtAssert_INT32_EQ(CFE_TBL_Global.ValidationResults[0].Result, 0); + /* Test response to processing a successful validation request on an * inactive buffer */ @@ -2664,13 +2837,61 @@ void Test_CFE_TBL_Manage(void) CFE_UtAssert_EVENTCOUNT(0); } +/* +** Test function for dumping to a buffer +*/ +void Test_CFE_TBL_DumpToBuffer(void) +{ + UtPrintf("Begin Test Dump To Buffer"); + + /* Test successfully dumping to a buffer */ + UT_InitData(); + CFE_UtAssert_SUCCESS(CFE_TBL_DumpToBuffer(App1TblHandle1)); + + /* Test response to an attempt to dump the buffer on a table that the + * application is not allowed to see + */ + UT_InitData(); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); + UtAssert_INT32_EQ(CFE_TBL_DumpToBuffer(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS); + CFE_UtAssert_EVENTCOUNT(0); + + /* Test response to an attempt to dump the buffer on a bad table handle */ + UT_InitData(); + UT_SetAppID(CFE_ES_APPID_UNDEFINED); + UtAssert_INT32_EQ(CFE_TBL_DumpToBuffer(CFE_TBL_BAD_TABLE_HANDLE), CFE_TBL_ERR_INVALID_HANDLE); + CFE_UtAssert_EVENTCOUNT(0); +} + /* ** Test function that updates the contents of a table if an update is pending */ void Test_CFE_TBL_Update(void) { + int16 RegIndex; + CFE_TBL_LoadBuff_t * WorkingBufferPtr; + CFE_TBL_AccessDescriptor_t *AccessDescPtr; + CFE_TBL_RegistryRec_t * RegRecPtr; + AccessDescPtr = &CFE_TBL_Global.Handles[App1TblHandle1]; + RegRecPtr = &CFE_TBL_Global.Registry[AccessDescPtr->RegIndex]; + UtPrintf("Begin Test Update"); + /* Test a successful update */ + UT_InitData(); + + /* a. Configure table for update */ + RegIndex = CFE_TBL_FindTableInRegistry("ut_cfe_tbl.UT_Table1"); + RegRecPtr = &CFE_TBL_Global.Registry[RegIndex]; + CFE_UtAssert_SUCCESS(CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false)); + UT_SetAppID(UT_TBL_APPID_1); + RegRecPtr->LoadPending = true; + + /* b. Perform update test */ + UtAssert_INT32_EQ(CFE_TBL_Update(App1TblHandle1), CFE_SUCCESS); + CFE_UtAssert_EVENTSENT(CFE_TBL_UPDATE_SUCCESS_INF_EID); + CFE_UtAssert_EVENTCOUNT(1); + /* Test processing an update on a single buffered table without * privileges */ @@ -2694,6 +2915,9 @@ void Test_CFE_TBL_Update(void) UT_SetAppID(CFE_ES_APPID_UNDEFINED); UtAssert_INT32_EQ(CFE_TBL_Update(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS); CFE_UtAssert_EVENTCOUNT(1); + + /* Successfully process an update */ + UT_InitData(); } /* @@ -2703,20 +2927,17 @@ void Test_CFE_TBL_GetStatus(void) { UtPrintf("Begin Test Get Status"); - /* Test response to an attempt to get the status on a table that the - * application is not allowed to see - */ + /* Test response to successfully getting status of a table */ UT_InitData(); - UT_SetAppID(CFE_ES_APPID_UNDEFINED); - UtAssert_INT32_EQ(CFE_TBL_GetStatus(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS); + CFE_UtAssert_SUCCESS(CFE_TBL_GetStatus(App1TblHandle1)); CFE_UtAssert_EVENTCOUNT(0); - /* Test response to an attempt to dump the buffer on a table that the + /* Test response to an attempt to get the status on a table that the * application is not allowed to see */ UT_InitData(); UT_SetAppID(CFE_ES_APPID_UNDEFINED); - UtAssert_INT32_EQ(CFE_TBL_DumpToBuffer(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS); + UtAssert_INT32_EQ(CFE_TBL_GetStatus(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS); CFE_UtAssert_EVENTCOUNT(0); } @@ -2729,6 +2950,12 @@ void Test_CFE_TBL_GetInfo(void) UtPrintf("Begin Test Get Info"); + /* Test response to a null table info and null table name */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TBL_GetInfo(NULL, "ut_cfe_tbl.UT_Table1"), CFE_TBL_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_TBL_GetInfo(&TblInfo, NULL), CFE_TBL_BAD_ARGUMENT); + CFE_UtAssert_EVENTCOUNT(0); + /* Test successfully getting information on a table */ UT_InitData(); UT_SetAppID(UT_TBL_APPID_1); @@ -3151,13 +3378,13 @@ void Test_CFE_TBL_Internal(void) /* EarlyInit - Table Registry Mutex Create Failure */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_EarlyInit response to a work buffer mutex create failure */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 2, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_EarlyInit response to a memory pool create failure */ @@ -3467,7 +3694,7 @@ void Test_CFE_TBL_Internal(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_LockRegistry(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_LockRegistry(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_UnlockRegistry response when an error occurs giving the @@ -3475,7 +3702,7 @@ void Test_CFE_TBL_Internal(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 1, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_UnlockRegistry(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_UnlockRegistry(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_LoadFromFile response to an invalid header length */ diff --git a/modules/tbl/ut-coverage/tbl_UT.h b/modules/tbl/ut-coverage/tbl_UT.h index e7d579e40..a2540b61e 100644 --- a/modules/tbl/ut-coverage/tbl_UT.h +++ b/modules/tbl/ut-coverage/tbl_UT.h @@ -565,6 +565,21 @@ void Test_CFE_TBL_Validate(void); ******************************************************************************/ void Test_CFE_TBL_Manage(void); +/*****************************************************************************/ +/** +** \brief Test function for dumping to a buffer +** +** \par Description +** This function tests the function for dumping a table to a buffer +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +******************************************************************************/ +void Test_CFE_TBL_DumpToBuffer(void); + /*****************************************************************************/ /** ** \brief Test function that updates the contents of a table if an update diff --git a/modules/time/fsw/src/cfe_time_task.c b/modules/time/fsw/src/cfe_time_task.c index 61d11c01c..87915e3aa 100644 --- a/modules/time/fsw/src/cfe_time_task.c +++ b/modules/time/fsw/src/cfe_time_task.c @@ -133,6 +133,7 @@ void CFE_TIME_TaskMain(void) int32 CFE_TIME_TaskInit(void) { int32 Status; + int32 OsStatus; osal_id_t TimeBaseId; osal_id_t TimerId; @@ -143,20 +144,20 @@ int32 CFE_TIME_TaskInit(void) return Status; } /* end if */ - Status = OS_BinSemCreate(&CFE_TIME_Global.ToneSemaphore, CFE_TIME_SEM_TONE_NAME, CFE_TIME_SEM_VALUE, - CFE_TIME_SEM_OPTIONS); - if (Status != OS_SUCCESS) + OsStatus = OS_BinSemCreate(&CFE_TIME_Global.ToneSemaphore, CFE_TIME_SEM_TONE_NAME, CFE_TIME_SEM_VALUE, + CFE_TIME_SEM_OPTIONS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error creating tone semaphore:RC=0x%08X\n", __func__, (unsigned int)Status); - return Status; + CFE_ES_WriteToSysLog("%s: Error creating tone semaphore:RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ - Status = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, CFE_TIME_SEM_1HZ_NAME, CFE_TIME_SEM_VALUE, - CFE_TIME_SEM_OPTIONS); - if (Status != OS_SUCCESS) + OsStatus = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, CFE_TIME_SEM_1HZ_NAME, CFE_TIME_SEM_VALUE, + CFE_TIME_SEM_OPTIONS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=0x%08X\n", __func__, (unsigned int)Status); - return Status; + CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ Status = CFE_ES_CreateChildTask(&CFE_TIME_Global.ToneTaskID, CFE_TIME_TASK_TONE_NAME, CFE_TIME_Tone1HzTask, @@ -288,22 +289,22 @@ int32 CFE_TIME_TaskInit(void) * way any error here means the PSP must use the "old way" and call * the 1hz function directly. */ - Status = OS_TimeBaseGetIdByName(&TimeBaseId, "cFS-Master"); - if (Status == OS_SUCCESS) + OsStatus = OS_TimeBaseGetIdByName(&TimeBaseId, "cFS-Master"); + if (OsStatus == OS_SUCCESS) { /* Create the 1Hz callback */ - Status = OS_TimerAdd(&TimerId, "cFS-1Hz", TimeBaseId, CFE_TIME_Local1HzTimerCallback, NULL); - if (Status == OS_SUCCESS) + OsStatus = OS_TimerAdd(&TimerId, "cFS-1Hz", TimeBaseId, CFE_TIME_Local1HzTimerCallback, NULL); + if (OsStatus == OS_SUCCESS) { - Status = OS_TimerSet(TimerId, 500000, 1000000); - if (Status != OS_SUCCESS) + OsStatus = OS_TimerSet(TimerId, 500000, 1000000); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerSet failed:RC=0x%08X\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerSet failed:RC=%ld\n", __func__, (long)OsStatus); } } else { - CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerAdd failed:RC=0x%08X\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerAdd failed:RC=%ld\n", __func__, (long)OsStatus); } } diff --git a/modules/time/fsw/src/cfe_time_tone.c b/modules/time/fsw/src/cfe_time_tone.c index 56e471942..22d8f0fac 100644 --- a/modules/time/fsw/src/cfe_time_tone.c +++ b/modules/time/fsw/src/cfe_time_tone.c @@ -1103,7 +1103,7 @@ void CFE_TIME_Tone1HzISR(void) *-----------------------------------------------------------------*/ void CFE_TIME_Tone1HzTask(void) { - int32 Result; + int32 OsStatus; while (true) { @@ -1113,8 +1113,8 @@ void CFE_TIME_Tone1HzTask(void) /* ** Pend on semaphore given by tone ISR (above)... */ - Result = OS_BinSemTake(CFE_TIME_Global.ToneSemaphore); - if (Result != OS_SUCCESS) + OsStatus = OS_BinSemTake(CFE_TIME_Global.ToneSemaphore); + if (OsStatus != OS_SUCCESS) { break; } @@ -1301,7 +1301,7 @@ void CFE_TIME_Local1HzISR(void) *-----------------------------------------------------------------*/ void CFE_TIME_Local1HzTask(void) { - int32 Result; + int32 OsStatus; while (true) { @@ -1312,8 +1312,8 @@ void CFE_TIME_Local1HzTask(void) /* ** Pend on the 1HZ semaphore (given by local 1Hz ISR)... */ - Result = OS_BinSemTake(CFE_TIME_Global.LocalSemaphore); - if (Result != OS_SUCCESS) + OsStatus = OS_BinSemTake(CFE_TIME_Global.LocalSemaphore); + if (OsStatus != OS_SUCCESS) { break; } diff --git a/modules/time/fsw/src/cfe_time_utils.c b/modules/time/fsw/src/cfe_time_utils.c index aee970c9d..6b096ee94 100644 --- a/modules/time/fsw/src/cfe_time_utils.c +++ b/modules/time/fsw/src/cfe_time_utils.c @@ -116,7 +116,7 @@ void CFE_TIME_QueryResetVars(void) CFE_TIME_ResetVars_t LocalResetVars; uint32 DefSubsMET; uint32 DefSubsSTCF; - int32 status; + int32 PspStatus; volatile CFE_TIME_ReferenceState_t *RefState; uint32 resetAreaSize; cpuaddr resetAreaAddr; @@ -127,9 +127,9 @@ void CFE_TIME_QueryResetVars(void) /* ** Get the pointer to the Reset area from the BSP */ - status = CFE_PSP_GetResetArea(&(resetAreaAddr), &(resetAreaSize)); + PspStatus = CFE_PSP_GetResetArea(&(resetAreaAddr), &(resetAreaSize)); - if (status != CFE_PSP_SUCCESS) + if (PspStatus != CFE_PSP_SUCCESS) { /* There is something wrong with the Reset Area */ CFE_TIME_Global.DataStoreStatus = CFE_TIME_RESET_AREA_BAD; diff --git a/modules/time/ut-coverage/time_UT.c b/modules/time/ut-coverage/time_UT.c index 39b3d4f8a..e578caec0 100644 --- a/modules/time/ut-coverage/time_UT.c +++ b/modules/time/ut-coverage/time_UT.c @@ -43,9 +43,13 @@ /* ** External global variables */ -const char *TIME_SYSLOG_MSGS[] = {NULL, "%s: Error reading cmd pipe,RC=0x%08X\n", - "%s: Application Init Failed,RC=0x%08X\n", "%s: 1Hz OS_TimerAdd failed:RC=0x%08X\n", - "%s: 1Hz OS_TimerSet failed:RC=0x%08X\n"}; +const char *TIME_SYSLOG_MSGS[] = {NULL, + "%s: Error reading cmd pipe,RC=0x%08X\n", + "%s: Application Init Failed,RC=0x%08X\n", + "%s: 1Hz OS_TimerAdd failed:RC=%ld\n", + "%s: 1Hz OS_TimerSet failed:RC=%ld\n", + "%s: Application Init Failed,RC=0x%08X\n", + "%s: Failed invalid arguments\n"}; static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TIME_SEND_HK = {.MsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_SEND_HK_MID)}; @@ -188,6 +192,12 @@ void Test_Main(void) UtPrintf("Begin Test Main"); + /* Test error during Task Init */ + UT_InitData(); + UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, -1); + UtAssert_VOIDCALL(CFE_TIME_TaskMain()); + CFE_UtAssert_SYSLOG(TIME_SYSLOG_MSGS[5]); + /* Test successful run through (a pipe read error is expected) */ UT_InitData(); @@ -320,8 +330,7 @@ void Test_Init(void) * subscription */ UT_InitData(); -#if (CFE_PLATFORM_TIME_CFG_SERVER == true && CFE_PLATFORM_TIME_CFG_SOURCE != true && \ - CFE_MISSION_TIME_CFG_FAKE_TONE != true) +#if (CFE_PLATFORM_TIME_CFG_SERVER == true) SubErrCnt++; UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), SubErrCnt, -SubErrCnt); ExpRtn = -SubErrCnt; @@ -343,12 +352,12 @@ void Test_Init(void) /* Test response to failure creating a tone semaphore */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_BinSemCreate), 1, -1); - UtAssert_INT32_EQ(CFE_TIME_TaskInit(), -1); + UtAssert_INT32_EQ(CFE_TIME_TaskInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test response to failure creating a local semaphore */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_BinSemCreate), 2, -2); - UtAssert_INT32_EQ(CFE_TIME_TaskInit(), -2); + UtAssert_INT32_EQ(CFE_TIME_TaskInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test response to an EVS register failure */ UT_InitData(); @@ -836,6 +845,11 @@ void Test_Print(void) usingDefaultEpoch = false; } + /* Test print with null print buffer argument */ + UT_InitData(); + UtAssert_VOIDCALL(CFE_TIME_Print(NULL, time)); + CFE_UtAssert_SYSLOG(TIME_SYSLOG_MSGS[6]); + /* Test with zero time value */ time.Subseconds = 0; time.Seconds = 0; @@ -922,6 +936,13 @@ void Test_RegisterSyncCallbackTrue(void) UtPrintf("Begin Test Register Synch Callback"); UT_InitData(); + /* + * Test calling api function with NULL argument + */ + + UT_InitData(); + UtAssert_INT32_EQ(CFE_TIME_RegisterSynchCallback(NULL), CFE_TIME_BAD_ARGUMENT); + /* * One callback per application is allowed; the first should succeed, * the second should fail. @@ -2072,6 +2093,17 @@ void Test_Tone(void) UtAssert_UINT32_EQ(CFE_TIME_Global.LastVersionCounter, VersionSave + 1); UtAssert_UINT32_EQ(CFE_TIME_Global.ToneMatchCounter, 1); + /* Test tone validation when time 1 < time 2 and Forced2Fly is set to + * true (covers branch taken, and CFE_TIME_ToneUpdate not called). + */ + UT_InitData(); + VersionSave = CFE_TIME_Global.LastVersionCounter; + CFE_TIME_Global.ToneMatchCounter = 0; + CFE_TIME_Global.Forced2Fly = true; + UtAssert_VOIDCALL(CFE_TIME_ToneVerify(time1, time2)); + UtAssert_UINT32_EQ(CFE_TIME_Global.LastVersionCounter, VersionSave); + UtAssert_UINT32_EQ(CFE_TIME_Global.ToneMatchCounter, 0); + /* Test tone validation when time 1 equals the previous time 1 value */ UT_InitData(); CFE_TIME_Global.ToneMatchErrorCounter = 0; @@ -2302,6 +2334,13 @@ void Test_1Hz(void) CFE_TIME_Tone1HzISR(); UtAssert_INT32_EQ(ut_time_CallbackCalled, 3); + /* Test the local 1Hz ISR */ + UT_InitData(); + CFE_TIME_Global.LocalIntCounter = 1; + UtAssert_VOIDCALL(CFE_TIME_Local1HzISR()); + UtAssert_STUB_COUNT(OS_BinSemGive, 1); + UtAssert_UINT32_EQ(CFE_TIME_Global.LocalIntCounter, 2); + /* Test the local 1Hz task where the binary semaphore take fails on the * second call */ @@ -2415,6 +2454,10 @@ void Test_UnregisterSynchCallback(void) UtPrintf("Begin Test Unregister Callback"); + /* Test unregistering the callback function with NULL argument */ + UT_InitData(); + UtAssert_INT32_EQ(CFE_TIME_UnregisterSynchCallback(NULL), CFE_TIME_BAD_ARGUMENT); + /* Unregister callback function one too many times to test both valid and * invalid cases */