From c37b6f37268df648a0c46f680d2e6cf0b14a3b63 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 16 Mar 2021 12:39:14 -0400 Subject: [PATCH] Fix #1224, reinstate recipes for coverage test This also fixes up/simplifies some include directives in UT headers Additionally this updates UT_ResetState() in ut_support to always configure the AppId for CFE_ES_GetAppId. Unfortunately some TBL test cases require/assume the "real" app IDs. This works around the issue and allows TBL tests to pass. (This is really a weakness/fragility in TBL tests). --- .../fsw/inc/cfe_time_resetvars_typedef.h | 2 ++ .../core_private/ut-stubs/src/ut_support.c | 6 ++++++ modules/es/ut-coverage/CMakeLists.txt | 17 ++++++++++++++++- modules/es/ut-coverage/es_UT.h | 19 +++++-------------- modules/evs/ut-coverage/CMakeLists.txt | 18 +++++++++++++++++- modules/evs/ut-coverage/evs_UT.h | 11 +---------- modules/fs/ut-coverage/CMakeLists.txt | 18 +++++++++++++++++- modules/fs/ut-coverage/fs_UT.h | 5 +---- modules/sb/ut-coverage/CMakeLists.txt | 18 +++++++++++++++++- modules/sb/ut-coverage/sb_UT.h | 6 +----- modules/tbl/ut-coverage/CMakeLists.txt | 19 ++++++++++++++++++- modules/tbl/ut-coverage/tbl_UT.h | 8 +------- modules/time/fsw/src/cfe_time_utils.h | 3 +-- modules/time/ut-coverage/CMakeLists.txt | 19 ++++++++++++++++++- modules/time/ut-coverage/time_UT.h | 7 +------ 15 files changed, 122 insertions(+), 54 deletions(-) diff --git a/modules/core_private/fsw/inc/cfe_time_resetvars_typedef.h b/modules/core_private/fsw/inc/cfe_time_resetvars_typedef.h index 5414a8d82..e67509d95 100644 --- a/modules/core_private/fsw/inc/cfe_time_resetvars_typedef.h +++ b/modules/core_private/fsw/inc/cfe_time_resetvars_typedef.h @@ -41,6 +41,8 @@ #include "common_types.h" #include "cfe_time_extern_typedefs.h" +#define CFE_TIME_RESET_SIGNATURE 0xA5A55A5A + /** ** \brief Time related variables that are maintained through a Processor Reset ** diff --git a/modules/core_private/ut-stubs/src/ut_support.c b/modules/core_private/ut-stubs/src/ut_support.c index 9a9cb062a..abbf61223 100644 --- a/modules/core_private/ut-stubs/src/ut_support.c +++ b/modules/core_private/ut-stubs/src/ut_support.c @@ -33,6 +33,7 @@ ** Includes */ #include "ut_support.h" +#include "cfe_core_resourceid_basevalues.h" #include @@ -164,6 +165,11 @@ void UT_InitData(void) */ UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppName), (uint8 *)UT_appname, sizeof(UT_appname), false); + /* + * Set up CFE_ES_GetAppID() to return the equivalent of AppID 1 by default + */ + UT_SetAppID(CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 1))); + /* * Reset the OSAL stubs to the default state */ diff --git a/modules/es/ut-coverage/CMakeLists.txt b/modules/es/ut-coverage/CMakeLists.txt index 11e674c02..c453c7e4f 100644 --- a/modules/es/ut-coverage/CMakeLists.txt +++ b/modules/es/ut-coverage/CMakeLists.txt @@ -4,4 +4,19 @@ # ################################################################## -# Nothing yet - placeholder for future use +foreach(SRC ${es_SOURCES}) + list(APPEND UT_SOURCES "${CFE_ES_SOURCE_DIR}/${SRC}") +endforeach() + +add_cfe_coverage_test(es ALL + "es_UT.c" + "${UT_SOURCES}" +) + +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-es-ALL-testrunner PRIVATE + ${CFE_ES_SOURCE_DIR}/fsw/src +) + +target_link_libraries(coverage-es-ALL-testrunner ut_core_private_stubs) + diff --git a/modules/es/ut-coverage/es_UT.h b/modules/es/ut-coverage/es_UT.h index 4f15727d2..d0ef41984 100644 --- a/modules/es/ut-coverage/es_UT.h +++ b/modules/es/ut-coverage/es_UT.h @@ -47,21 +47,12 @@ ** Includes */ #include -#include "cfe.h" -#include "common_types.h" -#include "osapi.h" +#include "cfe_es_module_all.h" +#include "cfe_time_core_internal.h" +#include "cfe_tbl_core_internal.h" +#include "cfe_evs_core_internal.h" +#include "cfe_sb_core_internal.h" #include "cfe_version.h" -#include "cfe_es.h" -#include "cfe_es_cds.h" -#include "cfe_es_cds_mempool.h" -#include "cfe_es_generic_pool.h" -#include "cfe_es_global.h" -#include "cfe_es_resource.h" -#include "cfe_es_log.h" -#include "cfe_es_perf.h" -#include "cfe_es_task.h" -#include "cfe_es_verify.h" -#include "cfe_es_start.h" #include "ut_support.h" #include "ut_osprintf_stubs.h" diff --git a/modules/evs/ut-coverage/CMakeLists.txt b/modules/evs/ut-coverage/CMakeLists.txt index 11e674c02..d66f0dc02 100644 --- a/modules/evs/ut-coverage/CMakeLists.txt +++ b/modules/evs/ut-coverage/CMakeLists.txt @@ -4,4 +4,20 @@ # ################################################################## -# Nothing yet - placeholder for future use + +foreach(SRC ${evs_SOURCES}) + list(APPEND UT_SOURCES "${CFE_EVS_SOURCE_DIR}/${SRC}") +endforeach() + +add_cfe_coverage_test(evs ALL + "evs_UT.c" + "${UT_SOURCES}" +) + +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-evs-ALL-testrunner PRIVATE + ${CFE_EVS_SOURCE_DIR}/fsw/src +) + +target_link_libraries(coverage-evs-ALL-testrunner ut_core_private_stubs) + diff --git a/modules/evs/ut-coverage/evs_UT.h b/modules/evs/ut-coverage/evs_UT.h index 26b7e60fd..ed2c94573 100644 --- a/modules/evs/ut-coverage/evs_UT.h +++ b/modules/evs/ut-coverage/evs_UT.h @@ -41,16 +41,7 @@ ** Includes */ #include -#include "cfe.h" -#include "common_types.h" -#include "osapi.h" -#include "cfe_evs.h" -#include "cfe_evs_log.h" -#include "cfe_evs_task.h" -#include "cfe_evs_utils.h" -#include "cfe_sb.h" -#include "cfe_es.h" -#include "cfe_time.h" +#include "cfe_evs_module_all.h" #include "ut_support.h" /* EVS unit test functions */ diff --git a/modules/fs/ut-coverage/CMakeLists.txt b/modules/fs/ut-coverage/CMakeLists.txt index 11e674c02..c1f031787 100644 --- a/modules/fs/ut-coverage/CMakeLists.txt +++ b/modules/fs/ut-coverage/CMakeLists.txt @@ -4,4 +4,20 @@ # ################################################################## -# Nothing yet - placeholder for future use + +foreach(SRC ${fs_SOURCES}) + list(APPEND UT_SOURCES "${CFE_FS_SOURCE_DIR}/${SRC}") +endforeach() + +add_cfe_coverage_test(fs ALL + "fs_UT.c" + "${UT_SOURCES}" +) + +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-fs-ALL-testrunner PRIVATE + ${CFE_FS_SOURCE_DIR}/fsw/src +) + +target_link_libraries(coverage-fs-ALL-testrunner ut_core_private_stubs) + diff --git a/modules/fs/ut-coverage/fs_UT.h b/modules/fs/ut-coverage/fs_UT.h index 92c5fa1b5..bc3cfa642 100644 --- a/modules/fs/ut-coverage/fs_UT.h +++ b/modules/fs/ut-coverage/fs_UT.h @@ -44,10 +44,7 @@ #include #include #include -#include "cfe.h" -#include "cfe_fs.h" -#include "cfe_fs_priv.h" -#include "common_types.h" +#include "cfe_fs_module_all.h" #include "ut_support.h" /* FS unit test functions */ diff --git a/modules/sb/ut-coverage/CMakeLists.txt b/modules/sb/ut-coverage/CMakeLists.txt index 11e674c02..372c9f8bc 100644 --- a/modules/sb/ut-coverage/CMakeLists.txt +++ b/modules/sb/ut-coverage/CMakeLists.txt @@ -4,4 +4,20 @@ # ################################################################## -# Nothing yet - placeholder for future use +foreach(SRC ${sb_SOURCES}) + list(APPEND UT_SOURCES "${CFE_SB_SOURCE_DIR}/${SRC}") +endforeach() + +add_cfe_coverage_test(sb ALL + "sb_UT.c" + "${UT_SOURCES}" +) + +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-sb-ALL-testrunner PRIVATE + ${CFE_SB_SOURCE_DIR}/fsw/src +) + +# The SB tests currently link with the _real_ SBR implementation (not a stub) +target_link_libraries(coverage-sb-ALL-testrunner ut_core_private_stubs sbr) + diff --git a/modules/sb/ut-coverage/sb_UT.h b/modules/sb/ut-coverage/sb_UT.h index 0ed41de4c..f7f08f63a 100644 --- a/modules/sb/ut-coverage/sb_UT.h +++ b/modules/sb/ut-coverage/sb_UT.h @@ -41,11 +41,7 @@ ** Includes */ #include -#include "cfe.h" -#include "cfe_sb_events.h" -#include "cfe_sb_priv.h" -#include "osapi.h" -#include "common_types.h" +#include "cfe_sb_module_all.h" #include "ut_support.h" /* diff --git a/modules/tbl/ut-coverage/CMakeLists.txt b/modules/tbl/ut-coverage/CMakeLists.txt index 11e674c02..1d1d6d6af 100644 --- a/modules/tbl/ut-coverage/CMakeLists.txt +++ b/modules/tbl/ut-coverage/CMakeLists.txt @@ -4,4 +4,21 @@ # ################################################################## -# Nothing yet - placeholder for future use + +foreach(SRC ${tbl_SOURCES}) + list(APPEND UT_SOURCES "${CFE_TBL_SOURCE_DIR}/${SRC}") +endforeach() + +add_cfe_coverage_test(tbl ALL + "tbl_UT.c" + "${UT_SOURCES}" +) + +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-tbl-ALL-testrunner PRIVATE + ${CFE_TBL_SOURCE_DIR}/fsw/src +) + +target_link_libraries(coverage-tbl-ALL-testrunner ut_core_private_stubs) + + diff --git a/modules/tbl/ut-coverage/tbl_UT.h b/modules/tbl/ut-coverage/tbl_UT.h index 6d3d6dd82..d5c4fbd1c 100644 --- a/modules/tbl/ut-coverage/tbl_UT.h +++ b/modules/tbl/ut-coverage/tbl_UT.h @@ -41,14 +41,8 @@ ** Includes */ #include -#include "cfe.h" -#include "cfe_tbl.h" -#include "common_types.h" -#include "ut_support.h" -#include "cfe_tbl_msg.h" #include "cfe_tbl_module_all.h" -#include "cfe_tbl_task.h" -#include "cfe_tbl_task_cmds.h" +#include "ut_support.h" typedef struct { diff --git a/modules/time/fsw/src/cfe_time_utils.h b/modules/time/fsw/src/cfe_time_utils.h index 5c5958de6..1d991b9d6 100644 --- a/modules/time/fsw/src/cfe_time_utils.h +++ b/modules/time/fsw/src/cfe_time_utils.h @@ -49,8 +49,7 @@ /* ** Main task definitions... */ -#define CFE_TIME_TASK_NAME "CFE_TIME" -#define CFE_TIME_RESET_SIGNATURE 0xA5A55A5A +#define CFE_TIME_TASK_NAME "CFE_TIME" /* ** Interrupt task definitions... diff --git a/modules/time/ut-coverage/CMakeLists.txt b/modules/time/ut-coverage/CMakeLists.txt index 11e674c02..38bd84193 100644 --- a/modules/time/ut-coverage/CMakeLists.txt +++ b/modules/time/ut-coverage/CMakeLists.txt @@ -4,4 +4,21 @@ # ################################################################## -# Nothing yet - placeholder for future use + +foreach(SRC ${time_SOURCES}) + list(APPEND UT_SOURCES "${CFE_TIME_SOURCE_DIR}/${SRC}") +endforeach() + +add_cfe_coverage_test(time ALL + "time_UT.c" + "${UT_SOURCES}" +) + +# This permits UT test cases to directly access private headers in the fsw/src dir +target_include_directories(coverage-time-ALL-testrunner PRIVATE + ${CFE_TIME_SOURCE_DIR}/fsw/src +) + +target_link_libraries(coverage-time-ALL-testrunner ut_core_private_stubs) + + diff --git a/modules/time/ut-coverage/time_UT.h b/modules/time/ut-coverage/time_UT.h index c6300c762..279feffe7 100644 --- a/modules/time/ut-coverage/time_UT.h +++ b/modules/time/ut-coverage/time_UT.h @@ -41,12 +41,7 @@ ** Includes */ #include -#include "cfe_platform_cfg.h" -#include "cfe_sb.h" -#include "cfe_time.h" -#include "cfe_time_msg.h" -#include "cfe_time_utils.h" -#include "common_types.h" +#include "cfe_time_module_all.h" #include "ut_support.h" /*