Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Candidate - 20200311 #563

Merged
merged 11 commits into from
Mar 18, 2020
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This repository contains NASA's Core Flight Executive (cFE), which is a framewor
This is a collection of services and associated framework to be located in the `cfe` subdirectory of a cFS Mission Tree. The Core Flight System is bundled at https://github.com/nasa/cFS, which includes build and execution instructions.

## Version Notes
- 6.7.10: DEVELOPMENT
- Fix potential unit test problems with name collisions
- Improve documentation
- Minor other updates (see https://github.com/nasa/cFE/pull/563)
- 6.7.9: DEVELOPMENT
- No longer requires sed "hack" to change the setting in default_config.h
- Minor other updates (see https://github.com/nasa/cFE/pull/544)
Expand Down
4 changes: 1 addition & 3 deletions cmake/cfe-usersguide.doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfe_usersguide.dox
PREDEFINED += @USERGUIDE_PREDEFINED@

# Bring in the cFE header files for the documentation of the various API calls
INPUT += \
@MISSION_USERGUIDE_HEADERFILES@ \
@USERGUIDE_MISC_ADDITION@
INPUT += @MISSION_USERGUIDE_HEADERFILES@
2 changes: 1 addition & 1 deletion cmake/global_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function(generate_config_includefile DESTFILE SUFFIX)
if (INCL_INDX LESS 0)
list(APPEND INCL_LIST "${SRC_LOCAL_PATH}")
if (EXISTS "${SRC_LOCAL_PATH}")
file(TO_NATIVE_PATH "${MISSION_DEFS}/${SRC}_${SUFFIX}" SRC_NATIVE)
file(TO_NATIVE_PATH "${SRC_LOCAL_PATH}" SRC_NATIVE)
set(DEST_CONTENTSTR "${DEST_CONTENTSTR}#include \"${SRC_NATIVE}\"\n")
else()
set(DEST_CONTENTSTR "${DEST_CONTENTSTR}/* ${SRC_LOCAL_PATH} does not exist */\n")
Expand Down
8 changes: 0 additions & 8 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,6 @@ function(prepare)
"${osal_MISSION_DIR}/src/os/inc/*.h")
string(REPLACE ";" " \\\n" MISSION_OSAL_HEADERFILES "${MISSION_OSAL_HEADERFILES}")

# Addition to usersguide
file(GLOB USERGUIDE_MISC_ADDITION
"${cfe-core_MISSION_DIR}/src/inc/private/*.h"
"${cfe-core_MISSION_DIR}/src/sb/*"
"${cfe-core_MISSION_DIR}/src/es/*"
"${cfe-core_MISSION_DIR}/src/evs/*")
string(REPLACE ";" " \\\n" USERGUIDE_MISC_ADDITION "${USERGUIDE_MISC_ADDITION}")

# PREDEFINED
set(USERGUIDE_PREDEFINED
"MESSAGE_FORMAT_IS_CCSDS")
Expand Down
Binary file removed docs/cFE Application Developers Guide.doc
Binary file not shown.
2,257 changes: 1,116 additions & 1,141 deletions docs/cFE Application Developers Guide.md

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions fsw/cfe-core/src/inc/cfe_es.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ bool CFE_ES_RunLoop(uint32 *ExitStatus);
** \param[in] MinSystemState Determine the state of the App
**
** \returns
** CFE_SUCCESS if state was successfully achieved
** CFE_ES_OPERATION_TIMED_OUT if the timeout was reached
** (or other defined error code in case of error)
** \retcode #CFE_SUCCESS \retdesc State successfully achieved \endcode
** \retcode #CFE_ES_OPERATION_TIMED_OUT \retdesc Timeout was reached \endcode
** \endreturns
**
** \sa #CFE_ES_RunLoop
**
Expand Down Expand Up @@ -969,7 +969,6 @@ int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) OS_PRINTF(1,2);
** a single value. Nominally, the user should set this value to zero.
**
** \param[in] TypeCRC One of the following CRC algorithm selections:
**
** \arg \c CFE_MISSION_ES_CRC_8 - (Not currently implemented)
** \arg \c CFE_MISSION_ES_CRC_16 - a CRC-16 algorithm
** \arg \c CFE_MISSION_ES_CRC_32 - (not currently implemented)
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/inc/cfe_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
*/
#define CFE_MAJOR_VERSION 6
#define CFE_MINOR_VERSION 7
#define CFE_REVISION 9
#define CFE_REVISION 10


#endif /* _cfe_version_ */
23 changes: 14 additions & 9 deletions fsw/cfe-core/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,47 @@ add_library(ut_${CFE_CORE_TARGET}_support STATIC
# UT version of the real module (compiled with coverage flags)
foreach(MODULE ${CFE_CORE_MODULES})

# The "UT_TARGET_NAME" is a concatenation of the configuration name with the current module
# This avoids target name duplication in case more than one configuration is used
# (All targets should be based on this name)
set(UT_TARGET_NAME "${CFE_CORE_TARGET}_${MODULE}")

set(CFE_MODULE_FILES)
aux_source_directory(${cfe-core_MISSION_DIR}/src/${MODULE} CFE_MODULE_FILES)

# Compile the unit(s) under test as an object library
# this allows easy configuration of special flags and include paths
# in particular this should use the UT_C_FLAGS for coverage instrumentation
add_library(ut_cfe_${MODULE}_object OBJECT
add_library(ut_${UT_TARGET_NAME}_object OBJECT
${CFE_MODULE_FILES})

# Apply the UT_C_FLAGS to the units under test
# This should enable coverage analysis on platforms that support this
set_target_properties(ut_cfe_${MODULE}_object PROPERTIES
set_target_properties(ut_${UT_TARGET_NAME}_object PROPERTIES
COMPILE_FLAGS "${UT_C_FLAGS}")

# For this object target only, the "override" includes should be injected
# into the include path BEFORE any other include path. This is so the
# override will take precedence over any system-provided version.
target_include_directories(ut_cfe_${MODULE}_object BEFORE PRIVATE
target_include_directories(ut_${UT_TARGET_NAME}_object BEFORE PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/modules/inc/overrides)

add_executable(${CFE_CORE_TARGET}_${MODULE}_UT
add_executable(${UT_TARGET_NAME}_UT
${MODULE}_UT.c
$<TARGET_OBJECTS:ut_cfe_${MODULE}_object>)
$<TARGET_OBJECTS:ut_${UT_TARGET_NAME}_object>)

target_link_libraries(${CFE_CORE_TARGET}_${MODULE}_UT
target_link_libraries(${UT_TARGET_NAME}_UT
ut_${CFE_CORE_TARGET}_support
ut_cfe-core_stubs
ut_assert)

# Also add the C FLAGS to the link command
# This should enable coverage analysis on platforms that support this
set_target_properties(${CFE_CORE_TARGET}_${MODULE}_UT PROPERTIES
set_target_properties(${UT_TARGET_NAME}_UT PROPERTIES
LINK_FLAGS "${UT_C_FLAGS}")

add_test(${CFE_CORE_TARGET}_${MODULE}_UT ${CFE_CORE_TARGET}_${MODULE}_UT)
install(TARGETS ${CFE_CORE_TARGET}_${MODULE}_UT DESTINATION ${TGTNAME}/${UT_INSTALL_SUBDIR})
add_test(${UT_TARGET_NAME}_UT ${UT_TARGET_NAME}_UT)
install(TARGETS ${UT_TARGET_NAME}_UT DESTINATION ${TGTNAME}/${UT_INSTALL_SUBDIR})
endforeach(MODULE ${CFE_CORE_MODULES})

# Generate the FS test input files
Expand Down
121 changes: 91 additions & 30 deletions fsw/cfe-core/ut-stubs/ut_es_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,30 @@
*/
#include <string.h>
#include "cfe.h"
#include "cfe_platform_cfg.h"
#include "utstubs.h"
#include "utassert.h"

/*
* Unit-test stub definitions/limits
*
* Note these limits only apply to the ES _stubs_ and not
* the normal implementation. It should not be necessary
* to configure these on a deployment basis.
*/

/*
* Maximum block size for ES pool requests
*
* This is only for pool block requests where the test
* case does _not_ register its own buffer, and therefore
* gets serviced from the default (static) pool buffer.
*
* This fixed value should be enough for most simple test
* cases. If a test case requires a larger block, it should
* register its own simulated pool using UT_SetDataBuffer,
* rather than changing this value.
*/
#define CFE_UT_ES_POOL_STATIC_BLOCK_SIZE 4096

/*
** Functions
Expand Down Expand Up @@ -351,10 +373,8 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr,
static union
{
uint32 Start;
long long int Align1;
long double Align2;
void *Align3;
uint8 Bytes[CFE_PLATFORM_ES_MAX_BLOCK_SIZE];
CFE_ES_PoolAlign_t Align;
uint8 Bytes[CFE_UT_ES_POOL_STATIC_BLOCK_SIZE];
} Buffer;
uint32 PoolSize;
uint32 Position;
Expand All @@ -366,35 +386,66 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr,
if (status > 0)
{
Size = status;
if (Size > CFE_PLATFORM_ES_MAX_BLOCK_SIZE)
if (Size < sizeof(CFE_ES_PoolAlign_t))
{
status = 0xffffffff;
Size = sizeof(CFE_ES_PoolAlign_t) - 1;
}
else
{
UT_GetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), (void**)&PoolPtr, &PoolSize, &Position);
--Size;
Size |= Size >> 1;
Size |= Size >> 2;
Size |= Size >> 4;
Size |= Size >> 8;
Size |= Size >> 16;
++Size;
if (Size > CFE_PLATFORM_ES_MAX_BLOCK_SIZE)
{
Size = CFE_PLATFORM_ES_MAX_BLOCK_SIZE;
}
memset(&Buffer, 0x55, Size);
}

/* find next higher power of 2 */
Size |= Size >> 1;
Size |= Size >> 2;
Size |= Size >> 4;
Size |= Size >> 8;
Size |= Size >> 16;
++Size;

UT_GetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), (void **)&PoolPtr, &PoolSize, &Position);
if (PoolSize == 0)
{
/*
* This means the test case did not register a buffer.
* Use the static buffer to fulfill the request.
*/
PoolPtr = Buffer.Bytes;
PoolSize = sizeof(Buffer);
}

if ((Position + Size) < PoolSize)
{
PoolPtr += Position;
*BufPtr = (uint32 *)PoolPtr;
status = Size;
if (BufPtr == NULL || (Position + Size) > PoolSize)
{
*BufPtr = &Buffer.Start;
}
else
memset(PoolPtr, 0x55, Size);

/*
* Unfortunately the UT assert stub library is missing
* the ability to set the buffer position, the only way
* to do it is by calling CopyFromLocal to advance the position.
*/
while (Size > sizeof(Buffer))
{
*BufPtr = (uint32 *)(PoolPtr + Position);
UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), Buffer.Bytes, Size);
UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), &Buffer,
sizeof(Buffer));
Size -= sizeof(Buffer);
}
UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), &Buffer, Size);
}
else
{
/*
* This a a bug in the test case.
*
* The buffer is insufficient, so the test case must
* use UT_SetDataBuffer() to register a pool buffer that is
* sufficient for the code under test.
*/
UtAssert_Failed("Pool buffer empty in %s: need at least %lu bytes",
__func__, (unsigned long)(Position + Size));
status = -1;
}
}

Expand Down Expand Up @@ -708,15 +759,20 @@ void CFE_ES_ExitApp(uint32 ExitStatus)
int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy)
{
int32 status;
uint32 CdsBufferSize;

UT_Stub_RegisterContext(UT_KEY(CFE_ES_CopyToCDS), (void*)Handle);
UT_Stub_RegisterContext(UT_KEY(CFE_ES_CopyToCDS), DataToCopy);
status = UT_DEFAULT_IMPL(CFE_ES_CopyToCDS);

if (status >= 0)
{
UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_CopyToCDS), DataToCopy,
CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE);
/* query the size of the supplied data buffer, if any */
UT_GetDataBuffer(UT_KEY(CFE_ES_CopyToCDS), NULL, &CdsBufferSize, NULL);
if (CdsBufferSize > 0)
{
UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_CopyToCDS), DataToCopy, CdsBufferSize);
}
}

return status;
Expand Down Expand Up @@ -745,15 +801,20 @@ int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy)
int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle)
{
int32 status;
uint32 CdsBufferSize;

UT_Stub_RegisterContext(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory);
UT_Stub_RegisterContext(UT_KEY(CFE_ES_RestoreFromCDS), (void*)Handle);
status = UT_DEFAULT_IMPL(CFE_ES_RestoreFromCDS);

if (status >= 0)
{
UT_Stub_CopyToLocal(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory,
CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE);
/* query the size of the supplied data buffer, if any */
UT_GetDataBuffer(UT_KEY(CFE_ES_RestoreFromCDS), NULL, &CdsBufferSize, NULL);
if (CdsBufferSize > 0)
{
UT_Stub_CopyToLocal(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory, CdsBufferSize);
}
}

return status;
Expand Down
1 change: 0 additions & 1 deletion fsw/cfe-core/ut-stubs/ut_evs_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*/
#include <string.h>
#include "cfe.h"
#include "cfe_platform_cfg.h"
#include "utstubs.h"

/*
Expand Down
1 change: 0 additions & 1 deletion fsw/cfe-core/ut-stubs/ut_fs_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*/
#include <string.h>
#include "cfe.h"
#include "cfe_platform_cfg.h"
#include "utstubs.h"


Expand Down
1 change: 0 additions & 1 deletion fsw/cfe-core/ut-stubs/ut_sb_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*/
#include <string.h>
#include "cfe.h"
#include "cfe_platform_cfg.h"
#include "utstubs.h"

/*
Expand Down
1 change: 0 additions & 1 deletion fsw/cfe-core/ut-stubs/ut_tbl_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
#include <string.h>
#include "cfe.h"
#include "cfe_platform_cfg.h"
#include "utstubs.h"

/*
Expand Down