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

Fix810 es cds functional tests #1416

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ The detailed cFE user's guide can be viewed at <https://github.com/nasa/cFS/blob

## Version History

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

- Separates the list of CFE core interface modules (e.g. core_api) from the list of CFE core implementation modules (e.g. msg). This allows the content of core_api to be expanded to locally include any additional modules the user has added to cFE core via the `MISSION_CORE_MODULES` list.
- Adds documentation for `CFE_ES_RegisterCDS()` regarding clearing.
- Removes the separate CFE "testrunner" module and moves the logic associated with running a test into cfe_assert library. Converts the "testcase" module from a library into an app, by calling into the runner logic that is now inside cfe_assert. Each functional test is a separate app, not a library, so it can be started and stopped via ES command like any other app.
- Removes check on `ENABLE_UNIT_TESTS=true` when building "cfe_assert", it should be built all the time.
- See <https://github.com/nasa/cfe/pull/1406> and <https://github.com/nasa/cfs/pull/248>

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

- Reports test failures as CFE events. Test status messages are now sent as Events rather than Syslog. This allows for more processing capability, and allows failures to be received externally (e.g. ground system).
Expand Down
5 changes: 3 additions & 2 deletions cmake/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ endfunction(add_cfe_coverage_dependency)
# FUNCTION: add_cfe_coverage_test
#
# Add executable target for coverage testing. This builds the target
# units with extra compiler flags for coverage instrumentation, along with
# units with extra compiler flags for coverage instrumentation, along with
# a "testrunner" executable to run the tests. It also registers
# that testrunner with ctest via the add_test() function.
#
Expand Down Expand Up @@ -620,6 +620,7 @@ function(process_arch SYSVAR)
# this may result in "add_subdirectory" of itself which causes a loop. This can happen
# if the variables/lists were modified unexpectedly.
foreach(DEP
${MISSION_CORE_INTERFACES}
${MISSION_CORE_MODULES}
${TGTSYS_${SYSVAR}_PSPMODULES}
${TGTSYS_${SYSVAR}_STATICAPPS}
Expand All @@ -632,7 +633,7 @@ function(process_arch SYSVAR)

# Add all core modules
# The osal is handled explicitly (above) since this has special extra config
foreach(DEP ${MISSION_CORE_MODULES})
foreach(DEP ${MISSION_CORE_INTERFACES} ${MISSION_CORE_MODULES})
if(NOT DEP STREQUAL "osal")
message(STATUS "Building Core Module: ${DEP}")
add_subdirectory("${${DEP}_MISSION_DIR}" ${DEP})
Expand Down
10 changes: 2 additions & 8 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function(prepare)
# This reflects all modules for all CPUs. It is set as a usage convenience
# for iterating through the full set of dependencies regardless of which level
# or context each dependency relates to (CFE, PSP, apps, etc).
set(MISSION_DEPS ${MISSION_APPS} ${MISSION_CORE_MODULES} ${MISSION_PSPMODULES})
set(MISSION_DEPS ${MISSION_CORE_INTERFACES} ${MISSION_APPS} ${MISSION_CORE_MODULES} ${MISSION_PSPMODULES})
set(APP_MISSING_COUNT 0)

message(STATUS "Search path for modules: ${MISSION_MODULE_SEARCH_PATH}")
Expand Down Expand Up @@ -288,7 +288,7 @@ function(prepare)
"${osal_MISSION_DIR}/src/os/inc/*.h"
"${psp_MISSION_DIR}/psp/fsw/inc/*.h"
)
foreach(MODULE core_api es evs fs msg sb tbl time)
foreach(MODULE core_api ${MISSION_CORE_MODULES})
list(APPEND SUBMODULE_HEADER_PATHS "${${MODULE}_MISSION_DIR}/fsw/inc/*.h")
endforeach()
file(GLOB MISSION_USERGUIDE_HEADERFILES
Expand Down Expand Up @@ -371,12 +371,6 @@ function(prepare)
# Add all public include dirs for core components to include path for tools
include_directories(
${core_api_MISSION_DIR}/fsw/inc
#${es_MISSION_DIR}/fsw/inc
#${evs_MISSION_DIR}/fsw/inc
#${fs_MISSION_DIR}/fsw/inc
#${sb_MISSION_DIR}/fsw/inc
#${tbl_MISSION_DIR}/fsw/inc
#${time_MISSION_DIR}/fsw/inc
${osal_MISSION_DIR}/src/os/inc
${psp_MISSION_DIR}/psp/fsw/inc
)
Expand Down
26 changes: 20 additions & 6 deletions cmake/mission_defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
#
##################################################################

# The "MISSION_CORE_INTERFACES" defines the set of interface libraries
# that comprise CFE core. These are CMake interface libraries that define
# a set of include directories and compile options for all modules,
# including the ubiquitous "cfe.h" header file and all it depends on).
# NOTE: these interfaces are really what defines "CFE core" - changing
# this list is not recommend, as these interface names are important.
set(MISSION_CORE_INTERFACES
core_api # this is the "public" core API that apps use, includes cfe.h and all core headers
core_private # this is the "private" interface that core apps use, but not used by apps
)

# The "MISSION_CORE_MODULES" will be built and statically linked as part
# of the CFE core executable on every target. These can be used to amend
# or override parts of the CFE core on a mission-specific basis.
# The "intf" modules are headers only, and define the interface(s) between components
# NOTE: Everthing in this list becomes part of the "core_api" interface above.
# Missions may add/remove/replace components in this list as needed.
set(MISSION_CORE_MODULES
"core_api"
"core_private"
"es"
"evs"
"fs"
Expand Down Expand Up @@ -56,9 +66,13 @@ set(MISSION_MODULE_SEARCH_PATH
set(osal_SEARCH_PATH ".")
set(psp_SEARCH_PATH ".")

# If ENABLE_UNIT_TEST is enabled, then include the cfe_assert library in
# all targets. This can still be overridden in targets.cmake.
# Include "cfe_assert" library in all builds, because it is included
# in the default startup script. It should not have any effect if not
# used.
list(APPEND MISSION_GLOBAL_APPLIST cfe_assert)

# If ENABLE_UNIT_TEST is enabled, then include the cfe_testcase app
if (ENABLE_UNIT_TESTS)
list(APPEND MISSION_GLOBAL_APPLIST cfe_assert cfe_testrunner cfe_testcase)
list(APPEND MISSION_GLOBAL_APPLIST cfe_testcase)
endif (ENABLE_UNIT_TESTS)

11 changes: 6 additions & 5 deletions cmake/sample_defs/cpu1_cfe_es_startup.scr
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CFE_LIB, sample_lib, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0;
CFE_APP, sample_app, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0;
CFE_APP, ci_lab, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0;
CFE_APP, to_lab, TO_Lab_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0;
CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0;
CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0;
CFE_LIB, sample_lib, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0;
CFE_APP, sample_app, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0;
CFE_APP, ci_lab, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0;
CFE_APP, to_lab, TO_Lab_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0;
CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0;
!
! Startup script fields:
! 1. Object Type -- CFE_APP for an Application, or CFE_LIB for a library.
Expand Down
4 changes: 3 additions & 1 deletion cmake/target/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ configure_file(${CFE_SOURCE_DIR}/cmake/cfe_generated_file.h.in ${CMAKE_CURRENT_B

# Generate lists of modules that will be statically linked into this CFE core target
set(GENERATED_ENTRIES_CORE_MODULES)
foreach(DEP ${MISSION_CORE_MODULES})
foreach(DEP core_api ${MISSION_CORE_MODULES})
list(APPEND GENERATED_ENTRIES_CORE_MODULES "{ \"${DEP}\" },\n")
endforeach()

Expand Down Expand Up @@ -257,6 +257,8 @@ if (DEFINED ${TGTNAME}_EMBED_FILELIST)
endif (DEFINED ${TGTNAME}_EMBED_FILELIST)

target_link_libraries(core-${TGTNAME}
${MISSION_CORE_INTERFACES}

# The following libs should be included whole, even if they
# do not necessarily resolve any symbols, because they may be needed by apps
${START_WHOLE_ARCHIVE}
Expand Down
24 changes: 11 additions & 13 deletions docs/README_functionaltest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

This version of CFE includes additional modular libraries and an application
to execute functional tests within an unmodified CFE environment. These are
distinct from the unit tests, which are executed separately from CFE in a
distinct from the unit tests, which are executed separately from CFE in a
confined (non-CFE, test-specific) environment.

## Building the modules

These modules are built automatically when `ENABLE_UNIT_TESTS` is enabled
These modules are built automatically when `ENABLE_UNIT_TESTS` is enabled
in the build. However, they can be added to any CFE build by adding the
following to the `APPLIST` of any target in `targets.cmake`:

- `cfe_assert`: a CFE-compatible library wrapping the basic UT assert library. This
is the same library that all other unit tests use, but configured to be
is the same library that all other unit tests use, but configured to be
dynamically loaded into the CFE environment, and using CFE syslog for its output.
This must be the first library loaded for any functional test.

- `cfe_testcase`: a CFE-compatible library implementing test cases for CFE core apps.
This must be loaded after `cfe_assert`.
This must be loaded after `cfe_assert`.

- `cfe_testrunner`: a CFE application that actually executes the tests. This is a very
simple app that waits for CFE startup to complete, then executes all registered test
- `cfe_testrunner`: a CFE application that actually executes the tests. This is a very
simple app that waits for CFE startup to complete, then executes all registered test
cases. It also must be loaded after `cfe_assert`.


Expand All @@ -29,12 +29,10 @@ cases. It also must be loaded after `cfe_assert`.
To execute tests at startup, the following lines can be added to `cfe_es_startup.scr` on the
designated test target:

CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0;
CFE_APP, cfe_testrunner, CFE_TR_AppMain, TESTRUN_APP, 100, 16384, 0x0, 0;
CFE_LIB, cfe_testcase, CFE_Test_Init, CFETEST_LIB, 0, 0, 0x0, 0;
CFE_LIB, psp_test, PSP_Test_Init, PSPTEST_LIB, 0, 0, 0x0, 0;
CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0;
CFE_APP, cfe_testcase, CFE_TestMain, CFE_TEST_APP, 100, 16384, 0x0, 0;

It is important that `cfe_assert` is loaded first, as all other test libraries depend on
It is important that `cfe_assert` is loaded first, as all other test applications depend on
symbols provided in this library. The order of loading other test cases should not
matter with respect to symbol resolution, but note that test cases will be executed in
the same order that they are registered.
matter with respect to symbol resolution, but note that test apps may be executed in
a different order than they are listed in the startup script.
1 change: 1 addition & 0 deletions modules/cfe_assert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project(CFE_ASSERT C)
add_cfe_app(cfe_assert
src/cfe_assert_io.c
src/cfe_assert_init.c
src/cfe_assert_runner.c
$<TARGET_OBJECTS:ut_assert_pic>
)

Expand Down
33 changes: 30 additions & 3 deletions modules/cfe_assert/inc/cfe_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
** Includes
*************************************************************************/
#include "common_types.h"
#include "cfe_es_api_typedefs.h"

/************************************************************************
** Type Definitions
Expand All @@ -50,19 +51,45 @@ typedef void (*CFE_Assert_StatusCallback_t)(uint8 MessageType, const char *Prefi
*************************************************************************/

/************************************************************************/
/** \brief Application Entry Point Function
/** \brief Library Init Function
**
** \par Description
** This function should be specified in the cfe_es_startup.scr file
** as part of starting this application.
** as part of loading this library.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \return #CFE_SUCCESS if successful, or error code
**
*************************************************************************/
int32 CFE_Assert_LibInit(CFE_ES_LibId_t LibId);

/************************************************************************/
/** \brief Start Test
**
** \par Description
**
** \par Assumptions, External Events, and Notes:
** Must be followed by a call to CFE_Assert_ExecuteTest()
**
** \return None
**
*************************************************************************/
int32 CFE_Assert_RegisterTest(const char *TestName);

/************************************************************************/
/** \brief Execute Test and Exit
**
** \par Description
**
** \par Assumptions, External Events, and Notes:
** None
**
** \return None
**
*************************************************************************/
void CFE_Assert_AppMain(void);
void CFE_Assert_ExecuteTest(void);

/************************************************************************/
/** \brief Register a test status callback
Expand Down
13 changes: 12 additions & 1 deletion modules/cfe_assert/src/cfe_assert_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,22 @@ void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback)
/*
* Initialization Function for this library
*/
int32 CFE_Assert_LibInit(uint32 LibId)
int32 CFE_Assert_LibInit(CFE_ES_LibId_t LibId)
{
int32 status;

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)
{
CFE_ES_WriteToSysLog("%s(): OS_MutSemCreate failed, rc=%d\n", __func__, (int)status);
return CFE_STATUS_EXTERNAL_RESOURCE_FAIL;
}

/*
* Start a test case for all startup logic.
*
Expand Down
2 changes: 0 additions & 2 deletions modules/cfe_assert/src/cfe_assert_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,4 @@ void UT_BSP_EndTest(const UtAssert_TestCounter_t *TestCounters)

CFE_ES_WriteToSysLog("TEST COMPLETE: %u tests Segment(s) executed\n\n",
(unsigned int)TestCounters->TestSegmentCount);

OS_TaskExit();
}
54 changes: 54 additions & 0 deletions modules/cfe_assert/src/cfe_assert_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,73 @@
*************************************************************************/
#include "common_types.h"
#include "cfe_assert.h"
#include "cfe_mission_cfg.h"

/**
* State of the CFE assert library.
*
* Note that typically tests need to be deferred until the CFE system
* reaches "operational" state. CFE assert has its own internal state
* that needs to be managed as well.
*/
typedef enum
{
CFE_Assert_State_INIT, /**< Initial state prior to CFE_Assert_LibInit() */
CFE_Assert_State_STARTUP, /**< cFE starting: successful CFE_Assert_LibInit(), but no tests run yet. */
CFE_Assert_State_ACTIVE /**< cFE operational: Normal test applications are allowed to run */
} CFE_Assert_State_Enum_t;

/************************************************************************
** Type Definitions
*************************************************************************/

typedef struct
{
CFE_Assert_State_Enum_t LibState;

/**
* Verbosity of default (syslog) output
*
* This controls the type(s) of assert messages that will be written to syslog.
* This only applies for default syslog output. Use of a status callback
* function overrides this.
*/
uint32 CurrVerbosity;

/**
* Function to invoke to report test status
*/
CFE_Assert_StatusCallback_t StatusCallback;

/**
* Mutex to control access to UtAssert structures.
*
* The UtAssert library is designed for single-threaded testing. To use it
* in a multi-threaded environment like CFE, it requires synchronization between
* apps, such that only one test app registers/runs tests at a time.
*/
osal_id_t AccessMutex;

/**
* AppID of the current UtAssert resource owner.
*
* Only one test application may use UtAssert facilities at a given time.
* This records the AppID of the current owner. It is set when AccessMutex
* is first acquired, and cleared once the tests have executed and the
* resource becomes available to another app.
*/
CFE_ES_AppId_t OwnerAppId;

/**
* Name of current test set being prepared/executed.
*
* This is set when the AccessMutex is first acquired, and cleared when
* the mutex is released. It is a free-form string to indicate the owner,
* and may or may not match the app name (i.e. test apps may implement
* more than one test set).
*/
char CurrentTestName[CFE_MISSION_MAX_API_LEN];

} CFE_Assert_Global_t;

extern CFE_Assert_Global_t CFE_Assert_Global;
Expand Down
Loading