Skip to content

Commit

Permalink
Merge pull request #1632 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
cFE Integration candidate: 2021-06-22
  • Loading branch information
astrogeco authored Jun 23, 2021
2 parents da76015 + d5480b5 commit 9d4fcae
Show file tree
Hide file tree
Showing 37 changed files with 7,193 additions and 9,062 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ The detailed cFE user's guide can be viewed at <https://github.com/nasa/cFS/blob

## Version History

### Development Build: v6.8.0-rc1+dev726

- correct path to users guide warning log
- add additional test cases for Child Tasks
- Add cfe functional tests to CI
- rename/clean CFE coverage assert macros
- Added UT tests for cFE ES Api
- Expand CDS Functional Tests.
- Event ID updates
- add test log file
- scrub all UT_Report calls
- See <https://github.com/nasa/cFE/pull/1632> and <https://github.com/nasa/cfs/pull/270>

### Development Build: v6.8.0-rc1+dev693

- Add CI workflow to run cFE coverage tests
Expand Down
3 changes: 1 addition & 2 deletions cmake/cfe-common.doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ ABBREVIATE_BRIEF = "The $name class " \
an \
the
TAB_SIZE = 8
ALIASES += "event=\xrefitem cfeevents \"Event Message\" \"cFE Event Message Cross Reference\" " \
"cfeescfg=\xrefitem cfeescfg \"Purpose\" \"cFE Executive Services Configuration Parameters\" " \
ALIASES += "cfeescfg=\xrefitem cfeescfg \"Purpose\" \"cFE Executive Services Configuration Parameters\" " \
"cfeevscfg=\xrefitem cfeevscfg \"Purpose\" \"cFE Event Services Configuration Parameters\" " \
"cfetblcfg=\xrefitem cfetblcfg \"Purpose\" \"cFE Table Services Configuration Parameters\" " \
"cfetimecfg=\xrefitem cfetimecfg \"Purpose\" \"cFE Time Services Configuration Parameters\" " \
Expand Down
36 changes: 36 additions & 0 deletions modules/cfe_assert/inc/cfe_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,40 @@ void CFE_Assert_ExecuteTest(void);
*/
void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback);

/************************************************************************/
/** \brief Start a test log file
*
* \par Description
* Sets the name of a file which will store the results of all tests
* The output is saved to the log file in addition to the normal callback
* function provided in CFE_Assert_RegisterCallback().
*
* \par Assumptions, External Events, and Notes:
* Only the test outputs are saved to this log file, thereby providing
* a file that can be checked by a script. During test operation, the
* file is first created with a "tmp" extension, and then will be renamed
* to the name given here once the test is complete.
*
* \param[in] Filename Name of log file to write
*
* \return CFE Status code
* \retval #CFE_SUCCESS if file was opened successfully
*
*/
int32 CFE_Assert_OpenLogFile(const char *Filename);

/************************************************************************/
/** \brief Complete a test log file
*
* \par Description
* Closes the test log file that was previously opened via CFE_Assert_OpenLogFile
*
* \par Assumptions, External Events, and Notes:
* This should be called once test cases have completed
*
* \return None
*
*/
void CFE_Assert_CloseLogFile(void);

#endif /* CFE_ASSERT_H */
60 changes: 60 additions & 0 deletions modules/cfe_assert/src/cfe_assert_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,66 @@ void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback)
CFE_Assert_Global.StatusCallback = Callback;
}

/*
* Opens a log file to "tee" the test output to
*/
int32 CFE_Assert_OpenLogFile(const char *Filename)
{
int32 Status;
char * Ext;
size_t NameLen;

strncpy(CFE_Assert_Global.LogFileFinal, Filename, sizeof(CFE_Assert_Global.LogFileFinal) - 1);
CFE_Assert_Global.LogFileFinal[sizeof(CFE_Assert_Global.LogFileFinal) - 1] = 0;

strncpy(CFE_Assert_Global.LogFileTemp, Filename, sizeof(CFE_Assert_Global.LogFileTemp) - 1);
CFE_Assert_Global.LogFileTemp[sizeof(CFE_Assert_Global.LogFileTemp) - 1] = 0;

Ext = strrchr(CFE_Assert_Global.LogFileTemp, '.');
if (Ext == NULL)
{
NameLen = strlen(CFE_Assert_Global.LogFileTemp);
}
else
{
NameLen = Ext - CFE_Assert_Global.LogFileTemp;
}

/* Use a ".tmp" file while actively writing, will rename at the end */
if (NameLen > (sizeof(CFE_Assert_Global.LogFileTemp) - 5))
{
NameLen = sizeof(CFE_Assert_Global.LogFileTemp) - 5;
}
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)
{
CFE_ES_WriteToSysLog("%s: Failed to open %s, rc=%d\n", __func__, CFE_Assert_Global.LogFileTemp, (int)Status);
return CFE_STATUS_EXTERNAL_RESOURCE_FAIL;
}

return CFE_SUCCESS;
}

/*
* Closes the log file
* This also renames the intermediate log file to its final name
*/
void CFE_Assert_CloseLogFile(void)
{
if (OS_ObjectIdDefined(CFE_Assert_Global.LogFileDesc))
{
OS_close(CFE_Assert_Global.LogFileDesc);
OS_rename(CFE_Assert_Global.LogFileTemp, CFE_Assert_Global.LogFileFinal);
}

CFE_Assert_Global.LogFileDesc = OS_OBJECT_ID_UNDEFINED;
CFE_Assert_Global.LogFileTemp[0] = 0;
CFE_Assert_Global.LogFileFinal[0] = 0;
}

/*
* Initialization Function for this library
*/
Expand Down
13 changes: 13 additions & 0 deletions modules/cfe_assert/src/cfe_assert_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,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];

snprintf(LogFileBuffer, sizeof(LogFileBuffer), "[%5s] %s\n", Prefix, OutputMessage);
OS_write(FileDesc, LogFileBuffer, strlen(LogFileBuffer));
}

void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)
{
const char * Prefix;
Expand Down Expand Up @@ -139,6 +147,11 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)

StatusCallback(MessageType, Prefix, OutputMessage);

if (OS_ObjectIdDefined(CFE_Assert_Global.LogFileDesc))
{
UT_BSP_WriteLogFile(CFE_Assert_Global.LogFileDesc, MessageType, Prefix, OutputMessage);
}

/*
* If any ABORT (major failure) message is thrown,
* then call a BSP-provided routine to stop the test and possibly dump a core
Expand Down
30 changes: 30 additions & 0 deletions modules/cfe_assert/src/cfe_assert_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@
*************************************************************************/
#include "common_types.h"
#include "cfe_assert.h"
#include "osconfig.h"
#include "cfe_mission_cfg.h"

/**
* Maximum length of a single line in the test log file
*
* Note this only applies to the log file. The user callback
* may have other limitations.
*/
#define CFE_ASSERT_MAX_LOG_LINE_LENGTH 512

/**
* State of the CFE assert library.
*
Expand Down Expand Up @@ -77,6 +86,27 @@ typedef struct
*/
CFE_Assert_StatusCallback_t StatusCallback;

/**
* Name of final log file for test results
*
* The temporary file will be renamed to this at the end of testing
*/
char LogFileFinal[OS_MAX_PATH_LEN];

/**
* Name of temporary log file for test results
*
* This is the file name that is actively written during the test
*/
char LogFileTemp[OS_MAX_PATH_LEN];

/**
* Log File descriptor
*
* Should be set to OS_OBJECT_ID_UNDEFINED if no log file is open
*/
osal_id_t LogFileDesc;

/**
* Mutex to control access to UtAssert structures.
*
Expand Down
1 change: 1 addition & 0 deletions modules/cfe_assert/src/cfe_assert_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void CFE_Assert_ExecuteTest(void)
/* unregister the callback and unset the appid */
UT_BSP_Lock();
CFE_Assert_RegisterCallback(NULL);
CFE_Assert_CloseLogFile();
CFE_Assert_Global.OwnerAppId = CFE_ES_APPID_UNDEFINED;
UT_BSP_Unlock();
}
1 change: 1 addition & 0 deletions modules/cfe_testcase/src/cfe_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void CFE_TestMain(void)
* state and gets ownership of the UtAssert subsystem
*/
CFE_Assert_RegisterTest("CFE API");
CFE_Assert_OpenLogFile(CFE_ASSERT_LOG_FILE_NAME);

/*
* Register test cases in UtAssert
Expand Down
9 changes: 9 additions & 0 deletions modules/cfe_testcase/src/cfe_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
#include "uttest.h"
#include "utassert.h"

/**
* Name of log file to write
*
* This file captures all of the test results, independently of the
* events generated during the test run. The file can be used as part
* of scripted tests and/or capturing test artifacts.
*/
#define CFE_ASSERT_LOG_FILE_NAME "/cf/cfe_test.log"

/* Compare two Resource IDs */
#define UtAssert_ResourceID_EQ(actual, expect) \
UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(actual, expect), "%s (%lu) == %s (%lu)", #actual, \
Expand Down
60 changes: 50 additions & 10 deletions modules/cfe_testcase/src/es_cds_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@

#include "cfe_test.h"

void TestCDS(void)
void TestRegisterCDS(void)
{
CFE_ES_CDSHandle_t CDSHandlePtr;
size_t BlockSize = 10;
const char * Name = "CDS_Test";
const char * CDSName = "CFE_TEST_APP.CDS_Test";
CFE_ES_CDSHandle_t IdByName;
char CDSNameBuf[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN];
CFE_Status_t status;
CFE_ES_CDSHandle_t CDSHandlePtr2;

size_t BlockSize = 10;
const char * Name = "CDS_Test";
const char * LongName = "VERY_LONG_NAME_CDS_Test";
CFE_Status_t status;

UtPrintf("Testing: CFE_ES_RegisterCDS, CFE_ES_GetCDSBlockIDByName, CFE_ES_GetCDSBlockName");
UtPrintf("Testing: CFE_ES_RegisterCDS");

status = CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, Name);

Expand All @@ -56,10 +56,42 @@ void TestCDS(void)
UtAssert_INT32_EQ(status, CFE_SUCCESS);
}

UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize, Name), CFE_ES_CDS_ALREADY_EXISTS);

UtAssert_INT32_EQ(CFE_ES_RegisterCDS(NULL, BlockSize, Name), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr, 0, Name), CFE_ES_CDS_INVALID_SIZE);
UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, NULL), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, LongName), CFE_ES_CDS_INVALID_NAME);
}

void TestCDSName(void)
{
CFE_ES_CDSHandle_t CDSHandlePtr;
size_t BlockSize = 10;
const char * Name = "CDS_Test";
const char * CDSName = "CFE_TEST_APP.CDS_Test";
const char * INVALID_NAME = "INVALID_NAME";

CFE_ES_CDSHandle_t IdByName;
char CDSNameBuf[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN];

UtPrintf("Testing: CFE_ES_GetCDSBlockIDByName, CFE_ES_GetCDSBlockName");

UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, Name), CFE_ES_CDS_ALREADY_EXISTS);

UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSNameBuf, CDSHandlePtr, sizeof(CDSNameBuf)), CFE_SUCCESS);
UtAssert_StrCmp(CDSNameBuf, CDSName, "CFE_ES_GetCDSBlockName() = %s", CDSNameBuf);
UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&IdByName, CDSNameBuf), CFE_SUCCESS);
UtAssert_ResourceID_EQ(CDSHandlePtr, IdByName);

UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(NULL, CDSHandlePtr, sizeof(CDSNameBuf)), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSNameBuf, CFE_ES_CDS_BAD_HANDLE, sizeof(CDSNameBuf)),
CFE_ES_ERR_RESOURCEID_NOT_VALID);
UtAssert_INT32_EQ(CFE_ES_GetCDSBlockName(CDSNameBuf, CDSHandlePtr, 0), CFE_ES_BAD_ARGUMENT);

UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(NULL, CDSNameBuf), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&IdByName, NULL), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_GetCDSBlockIDByName(&IdByName, INVALID_NAME), CFE_ES_ERR_NAME_NOT_FOUND);
}

void TestCopyRestoreCDS(void)
Expand All @@ -74,17 +106,25 @@ void TestCopyRestoreCDS(void)
UtPrintf("Testing: CFE_ES_CopyToCDS, CFE_ES_RestoreFromCDS");

snprintf(Data, BlockSize, "Test Data");
status = CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, Name);

status = CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, Name);
UtAssert_True(status == CFE_SUCCESS || status == CFE_ES_CDS_ALREADY_EXISTS, "Register CDS status = %d",
(int)status);

UtAssert_INT32_EQ(CFE_ES_CopyToCDS(CDSHandlePtr, Data), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_RestoreFromCDS(DataBuff, CDSHandlePtr), CFE_SUCCESS);
UtAssert_StrCmp(Data, DataBuff, "RestoreFromCDS = %s", DataBuff);

UtAssert_INT32_EQ(CFE_ES_CopyToCDS(CFE_ES_CDS_BAD_HANDLE, Data), CFE_ES_ERR_RESOURCEID_NOT_VALID);
UtAssert_INT32_EQ(CFE_ES_CopyToCDS(CDSHandlePtr, NULL), CFE_ES_BAD_ARGUMENT);

UtAssert_INT32_EQ(CFE_ES_RestoreFromCDS(DataBuff, CFE_ES_CDS_BAD_HANDLE), CFE_ES_ERR_RESOURCEID_NOT_VALID);
UtAssert_INT32_EQ(CFE_ES_RestoreFromCDS(NULL, CDSHandlePtr), CFE_ES_BAD_ARGUMENT);
}

void ESCDSTestSetup(void)
{
UtTest_Add(TestCDS, NULL, NULL, "Test CDS");
UtTest_Add(TestRegisterCDS, NULL, NULL, "Test Register CDS");
UtTest_Add(TestCDSName, NULL, NULL, "Test CDS Name");
UtTest_Add(TestCopyRestoreCDS, NULL, NULL, "Test Copy Restore CDS");
}
2 changes: 1 addition & 1 deletion modules/core_api/fsw/inc/cfe_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define CFE_VERSION_H

/* Development Build Macro Definitions */
#define CFE_BUILD_NUMBER 693 /**< @brief Development: Number of development commits since baseline */
#define CFE_BUILD_NUMBER 726 /**< @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 */
Expand Down
Loading

0 comments on commit 9d4fcae

Please sign in to comment.