From 82f5339a07f23f667f0e04d1976d31e92592f06a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 3 Sep 2021 11:56:19 -0400 Subject: [PATCH 1/3] Fix #303, check that module type is not invalid Rather than only calling "Init" on a "SIMPLE" module type, just check that it is not invalid instead. Even extension types still have an Init routine that needs to be called. --- fsw/shared/src/cfe_psp_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsw/shared/src/cfe_psp_module.c b/fsw/shared/src/cfe_psp_module.c index adc18174..afc81f92 100644 --- a/fsw/shared/src/cfe_psp_module.c +++ b/fsw/shared/src/cfe_psp_module.c @@ -64,7 +64,7 @@ void CFE_PSP_ModuleInitList(CFE_StaticModuleLoadEntry_t *ListPtr) while (Entry->Name != NULL) { ApiPtr = (CFE_PSP_ModuleApi_t *)Entry->Api; - if ((uint32)ApiPtr->ModuleType == CFE_PSP_MODULE_TYPE_SIMPLE && ApiPtr->Init != NULL) + if ((uint32)ApiPtr->ModuleType != CFE_PSP_MODULE_TYPE_INVALID && ApiPtr->Init != NULL) { (*ApiPtr->Init)(CFE_PSP_MODULE_BASE | CFE_PSP_ModuleCount); } From 3d2624b932e0e15d59e52fb3e8abe7da0b9c9fb7 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 3 Sep 2021 14:34:34 -0400 Subject: [PATCH 2/3] Fix #305, do not override add_psp_module for coverage test Implements a differently-named function instead, which does mostly the same thing, but does not directly re-add the original subdirectory. This does repeat some info (e.g. the list of FSW source files) that was not repeated otherwise, but it works in general. --- unit-test-coverage/modules/CMakeLists.txt | 39 ++++++++++--------- .../modules/timebase_vxworks/CMakeLists.txt | 11 ++++++ .../inc/cfe_psp_config.h | 0 .../inc/coveragetest-timebase_vxworks.h | 0 .../src/coveragetest-timebase_vxworks.c | 0 5 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 unit-test-coverage/modules/timebase_vxworks/CMakeLists.txt rename unit-test-coverage/modules/{ => timebase_vxworks}/inc/cfe_psp_config.h (100%) rename unit-test-coverage/modules/{ => timebase_vxworks}/inc/coveragetest-timebase_vxworks.h (100%) rename unit-test-coverage/modules/{ => timebase_vxworks}/src/coveragetest-timebase_vxworks.c (100%) diff --git a/unit-test-coverage/modules/CMakeLists.txt b/unit-test-coverage/modules/CMakeLists.txt index b28d4a51..daefcb31 100644 --- a/unit-test-coverage/modules/CMakeLists.txt +++ b/unit-test-coverage/modules/CMakeLists.txt @@ -4,27 +4,33 @@ # ###################################################################### -include_directories("${PSPCOVERAGE_SOURCE_DIR}/shared/inc") -include_directories("${PSPCOVERAGE_SOURCE_DIR}/modules/inc") -# redefine the add_psp_module to make a unit test variant -# this needs to name the target differently, so it doesn't conflict with the FSW target. -# this is similar to add_cfe_coverage_test() on the CFE side, but the set of interfaces -# and link libraries is different from that of a CFS app -function(add_psp_module MODULE_NAME) +# Function to simplify adding a coverage test for a PSP module +# This is very similar to the CFE "add_cfe_coverage" function, but +# include directories and link libraries are set up differently for PSP code, +# and it does not depend on having a FSW module by the same name. +function(add_psp_covtest MODULE_NAME TESTCASE_SRC UT_SRCS) + # A consistent name convention for all targets generated by this funtion set(TEST_NAME "coverage-pspmod-${MODULE_NAME}") set(OBJECT_TARGET "${TEST_NAME}-object") set(RUNNER_TARGET "${TEST_NAME}-testrunner") - # Create the module - add_library(${OBJECT_TARGET} OBJECT ${ARGN}) + # Compile the source unit(s) under test as a separate library + # This is done so that special coverage-specific compile flags can be used on these files + add_library(${OBJECT_TARGET} OBJECT + ${UT_SRCS} ${ARGN} + ) + # Apply the UT_COVERAGE_COMPILE_FLAGS to the units under test + # This should enable coverage analysis on platforms that support this target_compile_options(${OBJECT_TARGET} PRIVATE ${UT_COVERAGE_COMPILE_FLAGS} ) + target_include_directories(${OBJECT_TARGET} PRIVATE ${PSPCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc # overrides for system headers + ${PSPCOVERAGE_SOURCE_DIR}/shared/inc ${CFEPSP_SOURCE_DIR}/fsw/inc # PSP public API ${CFEPSP_SOURCE_DIR}/fsw/shared/inc # all PSP shared headers ${CFE_SOURCE_DIR}/cmake/target/inc # for sysconfig headers @@ -34,7 +40,7 @@ function(add_psp_module MODULE_NAME) # Compile a test runner application, which contains the # actual coverage test code (test cases) and the unit under test add_executable(${RUNNER_TARGET} - ${PSPCOVERAGE_SOURCE_DIR}/modules/src/coveragetest-${MODULE_NAME}.c + ${TESTCASE_SRC} $ ) @@ -49,19 +55,14 @@ function(add_psp_module MODULE_NAME) ut_assert ) + # Add it to the set of tests to run as part of "make test" add_test(${TEST_NAME} ${RUNNER_TARGET}) foreach(TGT ${INSTALL_TARGET_LIST}) install(TARGETS ${RUNNER_TARGET} DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}) endforeach() -endfunction(add_psp_module) +endfunction(add_psp_covtest) -# a list of modules for which there is a coverage test implemented -set(UT_PSPMODLIST - timebase_vxworks -) - -foreach(UT_PSPMOD ${UT_PSPMODLIST}) - add_subdirectory(${CFEPSP_SOURCE_DIR}/fsw/modules/${UT_PSPMOD} ${UT_PSPMOD}) -endforeach() +# a list of modules for which there is a coverage test implemented +add_subdirectory(timebase_vxworks) diff --git a/unit-test-coverage/modules/timebase_vxworks/CMakeLists.txt b/unit-test-coverage/modules/timebase_vxworks/CMakeLists.txt new file mode 100644 index 00000000..854e88ba --- /dev/null +++ b/unit-test-coverage/modules/timebase_vxworks/CMakeLists.txt @@ -0,0 +1,11 @@ +###################################################################### +# +# CMAKE build recipe for white-box coverage tests of VxWorks timebase module +# +###################################################################### + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/inc") + +add_psp_covtest(timebase_vxworks src/coveragetest-timebase_vxworks.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/timebase_vxworks/cfe_psp_timebase_vxworks.c +) diff --git a/unit-test-coverage/modules/inc/cfe_psp_config.h b/unit-test-coverage/modules/timebase_vxworks/inc/cfe_psp_config.h similarity index 100% rename from unit-test-coverage/modules/inc/cfe_psp_config.h rename to unit-test-coverage/modules/timebase_vxworks/inc/cfe_psp_config.h diff --git a/unit-test-coverage/modules/inc/coveragetest-timebase_vxworks.h b/unit-test-coverage/modules/timebase_vxworks/inc/coveragetest-timebase_vxworks.h similarity index 100% rename from unit-test-coverage/modules/inc/coveragetest-timebase_vxworks.h rename to unit-test-coverage/modules/timebase_vxworks/inc/coveragetest-timebase_vxworks.h diff --git a/unit-test-coverage/modules/src/coveragetest-timebase_vxworks.c b/unit-test-coverage/modules/timebase_vxworks/src/coveragetest-timebase_vxworks.c similarity index 100% rename from unit-test-coverage/modules/src/coveragetest-timebase_vxworks.c rename to unit-test-coverage/modules/timebase_vxworks/src/coveragetest-timebase_vxworks.c From e4722da79f85a16b9d543a7c1cda33577007fc8e Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Thu, 9 Sep 2021 13:00:52 -0400 Subject: [PATCH 3/3] IC:2021-09-07, Bump to v1.5.0-rc1+dev124 Part of nasa/cFS#351 --- README.md | 7 +++++++ fsw/mcp750-vxworks/inc/psp_version.h | 2 +- fsw/pc-linux/inc/psp_version.h | 2 +- fsw/pc-rtems/inc/psp_version.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 047fef61..ad5844b4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,13 @@ This is a collection of APIs abstracting platform specific functionality to be l ## Version History + +### Development Build: v1.5.0-rc1+dev124 + +- Relax strict of check before calling "Init" function of module, only check that module type is not invalid +- Remove override of `add_psp_module` for coverage test +- See and + ### Development Build: v1.5.0-rc1+dev118 - Implement Coding Standards in CodeQL diff --git a/fsw/mcp750-vxworks/inc/psp_version.h b/fsw/mcp750-vxworks/inc/psp_version.h index 46923374..99b7962c 100644 --- a/fsw/mcp750-vxworks/inc/psp_version.h +++ b/fsw/mcp750-vxworks/inc/psp_version.h @@ -29,7 +29,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 118 +#define CFE_PSP_IMPL_BUILD_NUMBER 124 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1" /* diff --git a/fsw/pc-linux/inc/psp_version.h b/fsw/pc-linux/inc/psp_version.h index 4c999859..73d2cbad 100644 --- a/fsw/pc-linux/inc/psp_version.h +++ b/fsw/pc-linux/inc/psp_version.h @@ -29,7 +29,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 118 +#define CFE_PSP_IMPL_BUILD_NUMBER 124 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1" /* diff --git a/fsw/pc-rtems/inc/psp_version.h b/fsw/pc-rtems/inc/psp_version.h index ebe85679..5f61087d 100644 --- a/fsw/pc-rtems/inc/psp_version.h +++ b/fsw/pc-rtems/inc/psp_version.h @@ -29,7 +29,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 118 +#define CFE_PSP_IMPL_BUILD_NUMBER 124 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1" /*