From 4dc0329a565dcba47d7ea6dd7f3a40a78f93a98a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 12 Jun 2020 14:03:05 -0400 Subject: [PATCH 01/14] Fix #739, add global module list and mission default file Add more hooks for additional flexibility when adding modular code blobs into the build. Three new directives are added: MISSION_CORE_MODULES, for modular components which are direct dependencies of CFE core and/or extend its functionality. MISSION_GLOBAL_APPLIST, for applications/libraries which should be built for every target, as if they were listed in every TGTx_APPLIST setting. MISSION_GLOBAL_STATIC_APPLIST, same as above but for the TGTx_STATIC_APPLIST setting. This also simplifies/reworks the search path to remove some logic that was never really utilized. --- CMakeLists.txt | 3 ++ cmake/global_functions.cmake | 11 ++++++ cmake/mission_build.cmake | 67 +++++++++++++++------------------ cmake/mission_defaults.cmake | 42 +++++++++++++++++++++ cmake/sample_defs/targets.cmake | 26 ++++++++++--- cmake/target/CMakeLists.txt | 1 + 6 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 cmake/mission_defaults.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a552d0181..69218c849 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,9 @@ initialize_globals() # Load the target configuration information (used by all builds) # This is at the top level so all vars set in here will become globals. +# The "defaults" file is included first, which the user-supplied targets +# file may override as necessary. +include("cmake/mission_defaults.cmake") include(${MISSION_DEFS}/targets.cmake) # Scan the list of targets and organize by target system type. diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index 790f91a70..c2edb78b0 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -122,6 +122,17 @@ function(read_targetconfig) # save the unmodified name for future reference set(SYSID_${SYSVAR} "${CURRSYS}" PARENT_SCOPE) + # if the "global" applist is not empty, append to every CPU applist + if (MISSION_GLOBAL_APPLIST) + list(APPEND TGT${TGTID}_APPLIST ${MISSION_GLOBAL_APPLIST}) + set(TGT${TGTID}_APPLIST ${TGT${TGTID}_APPLIST} PARENT_SCOPE) + endif (MISSION_GLOBAL_APPLIST) + + if (MISSION_GLOBAL_STATIC_APPLIST) + list(APPEND TGT${TGTID}_STATIC_APPLIST ${MISSION_GLOBAL_STATIC_APPLIST}) + set(TGT${TGTID}_STATIC_APPLIST ${TGT${TGTID}_STATIC_APPLIST} PARENT_SCOPE) + endif (MISSION_GLOBAL_STATIC_APPLIST) + # Append to global lists list(APPEND TGTSYS_LIST "${SYSVAR}") list(APPEND TGTSYS_${SYSVAR} "${TGTID}") diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 786d98cab..77b81efe6 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -123,48 +123,41 @@ function(prepare) add_custom_target(mission-prebuild) # Locate the source location for all the apps found within the target file - # Each of those may in turn have a "mission_build" file that calls out additional dependencies for that app, - # so this is run in a loop until the list of unfound apps is empty - string(REPLACE ":" ";" CFS_APP_PATH "$ENV{CFS_APP_PATH}") - list(APPEND CFS_APP_PATH "apps" "apps/CFS" "libs" "psp/fsw/modules") - set(MISSION_DEPS "cfe-core" "osal") + # This is done by searching through the list of paths to find a matching name + # The environment variable is cached so it will be retained across runs. + set(CFS_APP_PATH "$ENV{CFS_APP_PATH}" + CACHE STRING "Extra search path for code modules" + ) + string(REPLACE ":" ";" CFS_APP_PATH "${CFS_APP_PATH}") + set(MISSION_MODULE_SEARCH_PATH ${CFS_APP_PATH} ${MISSION_MODULE_SEARCH_PATH}) + + set(MISSION_DEPS "cfe-core" "osal" ${MISSION_CORE_MODULES}) set(APP_MISSING_COUNT 0) - # Set the search path of those dependency components which are fixed - # All other components/dependencies are subject to the search path - # In particular this is OSAL and the CFE core itself - set(cfe-core_SEARCH_PATH "cfe/fsw") - set(osal_SEARCH_PATH ".") + message(STATUS "Search path for modules: ${MISSION_MODULE_SEARCH_PATH}") # Now search for the rest of CFS applications/libraries/modules - these may exist in - # a variety of places and also may in turn add more dependencies onto the list. - # Repeat this loop until the list becomes empty. - set(FIND_DEP_LIST ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) - while(1) - set(FIND_DEP_CURRSET ${FIND_DEP_LIST}) - set(FIND_DEP_LIST) - foreach(APP ${FIND_DEP_CURRSET}) - set (APPFOUND) - foreach(APPSRC ${${APP}_SEARCH_PATH} ${CFS_APP_PATH}) - if(IS_DIRECTORY ${MISSION_SOURCE_DIR}/${APPSRC}/${APP}) - get_filename_component(APPFOUND "${MISSION_SOURCE_DIR}/${APPSRC}/${APP}" ABSOLUTE) - break() - endif() - endforeach(APPSRC ${CFS_APP_PATH}) - if (APPFOUND) - set(${APP}_MISSION_DIR ${APPFOUND}) - include(${APPFOUND}/mission_build.cmake OPTIONAL) - message(STATUS "Module '${APP}' found at ${APPFOUND}") - else() - message("** Module ${APP} NOT found **") - math(EXPR APP_MISSING_COUNT "${APP_MISSING_COUNT} + 1") + # any directory within the search path. + foreach(APP ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) + set (APPFOUND FALSE) + foreach(APPSRC ${MISSION_MODULE_SEARCH_PATH} ${${APP}_SEARCH_PATH}) + if (NOT IS_ABSOLUTE "${APPSRC}") + set(APPSRC "${MISSION_SOURCE_DIR}/${APPSRC}") endif() - endforeach(APP ${FIND_DEP_CURRSET}) - if (NOT FIND_DEP_LIST) - break() - endif (NOT FIND_DEP_LIST) - list(APPEND MISSION_DEPS ${FIND_DEP_LIST}) - endwhile(1) + if(IS_DIRECTORY "${APPSRC}/${APP}") + set(APPFOUND "${APPSRC}/${APP}") + break() + endif() + endforeach() + if (APPFOUND) + get_filename_component(${APP}_MISSION_DIR "${APPFOUND}" ABSOLUTE) + include("${APPFOUND}/mission_build.cmake" OPTIONAL) + message(STATUS "Module '${APP}' found at ${${APP}_MISSION_DIR}") + else() + message("** Module ${APP} NOT found **") + math(EXPR APP_MISSING_COUNT "${APP_MISSING_COUNT} + 1") + endif() + endforeach() if (APP_MISSING_COUNT GREATER 0) message(FATAL_ERROR "Target build incomplete, source for ${APP_MISSING_COUNT} module(s) not found.") diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake new file mode 100644 index 000000000..f00faeb5b --- /dev/null +++ b/cmake/mission_defaults.cmake @@ -0,0 +1,42 @@ +################################################################## +# +# cFS Mission default values +# +# This file provides default values for mission applications +# and module/library selection. +# +################################################################## + +# 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. +set(MISSION_CORE_MODULES) + +# The "MISSION_GLOBAL_APPLIST" is a set of apps/libs that will be built +# for every defined and target. These are built as dynamic modules +# and must be loaded explicitly via startup script or command. +# This list is effectively appended to every TGTx_APPLIST in targets.cmake. +set(MISSION_GLOBAL_APPLIST) + +# The "MISSION_GLOBAL_STATIC_APPLIST" is similar to MISSION_GLOBAL_APPLIST +# but the apps are statically linked. +# This list is effectively appended to every TGTx_STATIC_APPLIST in targets.cmake. +set(MISSION_GLOBAL_STATIC_APPLIST) + +# The "MISSION_MODULE_SEARCH_PATH" is a list of subdirectories +# which will be searched for modules (apps and libs) specified in +# the targets.cmake file. It may also be locally extended by setting +# the environment variable "CFS_APP_PATH" +set(MISSION_MODULE_SEARCH_PATH + "apps" # general purpose $[top}/apps directory + "libs" # general purpose $[top}/libs directory + "psp/fsw/modules" # modules for optional platform abstraction, associated with PSP + "cfe/modules" # modules for optional core functions, associated with CFE +) + +# The path for specific components can also be set via +# a variable named "_SEARCH_PATH". This is +# used for locating cfe-core and osal which are not part +# of the standard search path. +set(cfe-core_SEARCH_PATH "cfe/fsw") +set(osal_SEARCH_PATH ".") diff --git a/cmake/sample_defs/targets.cmake b/cmake/sample_defs/targets.cmake index 03d72f454..961b93d54 100644 --- a/cmake/sample_defs/targets.cmake +++ b/cmake/sample_defs/targets.cmake @@ -75,9 +75,23 @@ SET(MISSION_NAME "SampleMission") # should be an integer. SET(SPACECRAFT_ID 42) -# UI_INSTALL_SUBDIR indicates where the UI data files (included in some apps) should -# be copied during the install process. -SET(UI_INSTALL_SUBDIR "host/ui") +# 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. +set(MISSION_CORE_MODULES) + +# The "MISSION_GLOBAL_APPLIST" is a set of apps/libs that will be built +# for every defined and target. These are built as dynamic modules +# and must be loaded explicitly via startup script or command. +# This list is effectively appended to every TGTx_APPLIST in targets.cmake. +# Example: +list(APPEND MISSION_GLOBAL_APPLIST sample_app sample_lib) + +# The "MISSION_GLOBAL_STATIC_APPLIST" is similar to MISSION_GLOBAL_APPLIST +# but the apps are statically linked. +# This list is effectively appended to every TGTx_STATIC_APPLIST in targets.cmake. +# Example: +# list(APPEND MISSION_GLOBAL_STATIC_APPLIST my_static_app) # FT_INSTALL_SUBDIR indicates where the black box test data files (lua scripts) should # be copied during the install process. @@ -85,16 +99,16 @@ SET(FT_INSTALL_SUBDIR "host/functional-test") # Each target board can have its own HW arch selection and set of included apps SET(TGT1_NAME cpu1) -SET(TGT1_APPLIST sample_app sample_lib ci_lab to_lab sch_lab) +SET(TGT1_APPLIST ci_lab to_lab sch_lab) SET(TGT1_FILELIST cfe_es_startup.scr) # CPU2/3 are duplicates of CPU1. These are not built by default anymore but are # commented out to serve as an example of how one would configure multiple cpus. #SET(TGT2_NAME cpu2) -#SET(TGT2_APPLIST sample_app ci_lab to_lab sch_lab) +#SET(TGT2_APPLIST ci_lab to_lab sch_lab) #SET(TGT2_FILELIST cfe_es_startup.scr) #SET(TGT3_NAME cpu3) -#SET(TGT3_APPLIST sample_app ci_lab to_lab sch_lab) +#SET(TGT3_APPLIST ci_lab to_lab sch_lab) #SET(TGT3_FILELIST cfe_es_startup.scr) diff --git a/cmake/target/CMakeLists.txt b/cmake/target/CMakeLists.txt index d7b30c6f9..903b9a45c 100644 --- a/cmake/target/CMakeLists.txt +++ b/cmake/target/CMakeLists.txt @@ -110,6 +110,7 @@ endif (TGT${TGTID}_APPLIST) # This depends on whether any special features are included or not set(CFE_LINK_WHOLE_LIBS ${CFE_CORE_TARGET} + ${MISSION_CORE_MODULES} psp-${CFE_SYSTEM_PSPNAME} osal ) From 05eb82a90adbda89e1f950e93018a11661de1f82 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 2 Jun 2020 12:54:23 -0400 Subject: [PATCH 02/14] Fix #724, implement config-based target builds The existing build system built target executables grouped by toolchain as a proxy for CPU architecture + machine options/flags. The app binaries would be built once and copied to any/all targets sharing that toolchain. The side effect of doing this is that the application needs to be written in an CPU-agnostic manner, performing its subscriptions and configurations from runtime table data rather than hardcoded/fixed values. Unfortunately most apps are not coded that way, so workarounds were needed. This changes the top level process to include the "platform" within this target build logic, effectively treating different platform configs as entirely different builds, even if they share the same toolchain file. As a result, binaries will only be shared between targets that explicitly set the "TGTx_PLATFORM" setting in targets.cmake to the same value. --- cmake/Makefile.sample | 2 +- cmake/arch_build.cmake | 33 +----- cmake/cfe_generated_file.h.in | 5 + cmake/global_functions.cmake | 156 +++++++++++++++++--------- cmake/mission_build.cmake | 115 +++++++++++++++---- cmake/target/CMakeLists.txt | 10 +- fsw/cfe-core/CMakeLists.txt | 14 +-- fsw/cfe-core/unit-test/CMakeLists.txt | 6 +- 8 files changed, 210 insertions(+), 131 deletions(-) create mode 100644 cmake/cfe_generated_file.h.in diff --git a/cmake/Makefile.sample b/cmake/Makefile.sample index bea332e6f..c1466e7d3 100644 --- a/cmake/Makefile.sample +++ b/cmake/Makefile.sample @@ -62,7 +62,7 @@ # Establish default values for critical variables. Any of these may be overridden # on the command line or via the make environment configuration in an IDE O ?= build -ARCH ?= native +ARCH ?= native/default_cpu1 BUILDTYPE ?= debug INSTALLPREFIX ?= /exe DESTDIR ?= $(O) diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index dfe5309f1..04984f8b3 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -411,16 +411,6 @@ function(process_arch SYSVAR) set(TGTLIST_DRV_${DRV}) endforeach() - # INCLUDE_REFACTOR: apps and the PSP like to #include cfe_platform_cfg.h -- they shouldn't - # This will become unnecessary when dependency refactoring is merged in, but for now - # they need to be able to find it. Remove the next line once refactoring is merged. - # Also do not do this if more than one CPU shares this architecture - this hack can only - # be done if a 1:1 mapping between cpus and architectures (so all apps are rebuilt per-cpu) - list(LENGTH TGTSYS_${SYSVAR} ARCHLEN) - if (ARCHLEN EQUAL 1) - include_directories(${CMAKE_BINARY_DIR}/cfe_core_default_${TGT${TGTSYS_${SYSVAR}}_NAME}/inc) - endif (ARCHLEN EQUAL 1) - # Process each PSP module that is referenced on this system architecture (any cpu) foreach(PSPMOD ${TGTSYS_${SYSVAR}_PSPMODULES}) message(STATUS "Building PSP Module: ${PSPMOD}") @@ -464,6 +454,9 @@ function(process_arch SYSVAR) add_subdirectory(${${APP}_MISSION_DIR} apps/${APP}) endforeach() + # Actual core library is a subdirectory + add_subdirectory(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core cfe-core) + # If unit test is enabled, build a generic ut stub library for CFE if (ENABLE_UNIT_TESTS) add_subdirectory(${cfe-core_MISSION_DIR}/ut-stubs ut_cfe_core_stubs) @@ -473,24 +466,8 @@ function(process_arch SYSVAR) # Second Pass: Build cfe-core and link final target executable foreach(TGTID ${TGTSYS_${SYSVAR}}) - set(TGTNAME ${TGT${TGTID}_NAME}) - set(TGTPLATFORM ${TGT${TGTID}_PLATFORM}) - if(NOT TGTPLATFORM) - set(TGTPLATFORM "default" ${TGTNAME}) - endif(NOT TGTPLATFORM) - - string(REPLACE ";" "_" CFE_CORE_TARGET "cfe_core_${TGTPLATFORM}") - if (NOT TARGET ${CFE_CORE_TARGET}) - - # Generate wrapper file for the requisite cfe_platform_cfg.h file - generate_config_includefile("${CFE_CORE_TARGET}/inc/cfe_msgids.h" msgids.h ${TGTPLATFORM}) - generate_config_includefile("${CFE_CORE_TARGET}/inc/cfe_platform_cfg.h" platform_cfg.h ${TGTPLATFORM}) - - # Actual core library is a subdirectory - add_subdirectory(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core ${CFE_CORE_TARGET}) - - endif (NOT TARGET ${CFE_CORE_TARGET}) - + set(TGTNAME ${TGT${TGTID}_NAME}) + # Target to generate the actual executable file add_subdirectory(cmake/target ${TGTNAME}) diff --git a/cmake/cfe_generated_file.h.in b/cmake/cfe_generated_file.h.in new file mode 100644 index 000000000..5bc4d4108 --- /dev/null +++ b/cmake/cfe_generated_file.h.in @@ -0,0 +1,5 @@ +@GENERATED_FILE_HEADER@ + +@GENERATED_FILE_CONTENT@ + +@GENERATED_FILE_TRAILER@ diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index c2edb78b0..8bcc91595 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -8,6 +8,49 @@ # ################################################################## +include(CMakeParseArguments) + +################################################################## +# +# FUNCTION: generate_c_headerfile +# +# Generates a C header file in the build directory. +# First argument is the file name to write. All remaining arguments will be +# concatenated and written to the file. +# +function(generate_c_headerfile FILE_NAME) + + # Determine the absolute location for this wrapper file + # If it is relative path then assume it is relative to ${CMAKE_BINARY_DIR} + # This should not write generated files to ${CMAKE_SOURCE_DIR} + if (NOT IS_ABSOLUTE "${FILE_NAME}") + set(FILE_NAME "${CMAKE_BINARY_DIR}/${FILE_NAME}") + endif (NOT IS_ABSOLUTE "${FILE_NAME}") + + # Generate an include guard + get_filename_component(FILE_GUARD "${FILE_NAME}" NAME) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" FILE_GUARD "${FILE_GUARD}") + string(TOUPPER "GENERATED_INCLUDE_${FILE_GUARD}" FILE_GUARD) + set(GENERATED_FILE_HEADER + "/* Generated header file. Do not edit */\n\n" + "#ifndef ${FILE_GUARD}\n" + "#define ${FILE_GUARD}\n\n" + ) + set(GENERATED_FILE_TRAILER + "#endif /* ${FILE_GUARD} */\n" + ) + + # Use configure_file() to write the file, as this automatically + # has the logic to not update the timestamp on the file unless it changes. + string(REPLACE ";" "" GENERATED_FILE_CONTENT "${ARGN}") + string(REPLACE ";" "" GENERATED_FILE_HEADER "${GENERATED_FILE_HEADER}") + string(REPLACE ";" "" GENERATED_FILE_TRAILER "${GENERATED_FILE_TRAILER}") + configure_file( + "${CFE_SOURCE_DIR}/cmake/cfe_generated_file.h.in" + "${FILE_NAME}" + @ONLY) + +endfunction(generate_c_headerfile) ################################################################## # @@ -21,58 +64,56 @@ # This also supports "stacking" multiple component files together by specifying more than one # source file for the wrapper. # -# In all cases, care must be used when updating such files -- if the timestamp is updated then -# everything that uses it will be rebuilt even if the content did not change. So the file content -# is checked against any pre-existing files, and if the content is the same then the update is -# skipped, preserving the original timestamp. +# This function now accepts named parameters: +# OUTPUT_DIRECTORY - where the generated file will be written +# FILE_NAME - the name of the file to write +# FALLBACK_FILE - if no files are found in "defs" using the name match, this file will be used instead. +# MATCH_SUFFIX - the suffix to match in the "defs" directory (optional) +# PREFIXES - a list of prefixes to match in the "defs" directory (optional) # -function(generate_config_includefile DESTFILE SUFFIX) +function(generate_config_includefile) - # Determine the absolute location for this wrapper file - if (NOT IS_ABSOLUTE ${DESTFILE}) - set(DESTFILE ${CMAKE_BINARY_DIR}/${DESTFILE}) - endif (NOT IS_ABSOLUTE ${DESTFILE}) - - set(INCL_LIST) - set(DEST_CONTENTSTR "/* This is a wrapper file generated by the build system - DO NOT EDIT */\n") - foreach(SRC ${ARGN}) - set(SRC_LOCAL_PATH "${MISSION_DEFS}/${SRC}_${SUFFIX}") - # only add this if not already included (prevent double inclusion) */ - list(FIND INCL_LIST "${SRC_LOCAL_PATH}" INCL_INDX) - if (INCL_INDX LESS 0) - list(APPEND INCL_LIST "${SRC_LOCAL_PATH}") - if (EXISTS "${SRC_LOCAL_PATH}") - 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") - endif (EXISTS "${SRC_LOCAL_PATH}") - endif (INCL_INDX LESS 0) - endforeach(SRC ${SRCFILES}) - if (EXISTS "${DESTFILE}") - file(READ "${DESTFILE}" DEST_EXISTING) - else (EXISTS "${DESTFILE}") - set(DEST_EXISTING) - endif (EXISTS "${DESTFILE}") - if (NOT DEST_CONTENTSTR STREQUAL DEST_EXISTING) - file(WRITE "${DESTFILE}" "${DEST_CONTENTSTR}") - endif (NOT DEST_CONTENTSTR STREQUAL DEST_EXISTING) - - # Create a copy of the generated file in a location where it can - # be found by an editor such as Eclipse. The user will still have to - # add the path to the IDEs include search path, but this makes it easier - # by at least putting them all in one spot. This is not used for the build. - get_filename_component(DESTBASENAME "${DESTFILE}" NAME) - if (MISSION_BINARY_DIR) - set(EDITOR_COPY_DIR ${MISSION_BINARY_DIR}/editor_inc) - else() - set(EDITOR_COPY_DIR ${CMAKE_BINARY_DIR}/editor_inc) - endif() - - file(MAKE_DIRECTORY ${EDITOR_COPY_DIR}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DESTFILE} ${EDITOR_COPY_DIR}/${DESTBASENAME}) + cmake_parse_arguments(GENCONFIG_ARG "" "OUTPUT_DIRECTORY;FILE_NAME;FALLBACK_FILE;MATCH_SUFFIX" "PREFIXES" ${ARGN} ) + + set(WRAPPER_FILE_CONTENT) + set(ITEM_FOUND FALSE) + + # Assemble a list of file names to test for + # Check for existence of a file in defs directory with an exact matching name + # Then Check for existence of file(s) with a matching prefix+suffix + set(CHECK_PATH_LIST "${MISSION_DEFS}/${GENCONFIG_ARG_FILE_NAME}") + if (GENCONFIG_ARG_MATCH_SUFFIX) + foreach(PREFIX ${GENCONFIG_ARG_PREFIXES} ${GENCONFIG_ARG_UNPARSED_ARGUMENTS}) + list(APPEND CHECK_PATH_LIST "${MISSION_DEFS}/${PREFIX}_${GENCONFIG_ARG_MATCH_SUFFIX}") + endforeach() + endif(GENCONFIG_ARG_MATCH_SUFFIX) + + # Check for existence of files, and add to content if present + # Note that all files are appended/concatenated together. + foreach(SRC_LOCAL_PATH ${CHECK_PATH_LIST}) + if (EXISTS "${SRC_LOCAL_PATH}") + file(TO_NATIVE_PATH "${SRC_LOCAL_PATH}" SRC_NATIVE_PATH) + list(APPEND WRAPPER_FILE_CONTENT "#include \"${SRC_NATIVE_PATH}\"\n") + set(ITEM_FOUND TRUE) + else() + list(APPEND WRAPPER_FILE_CONTENT "/* ${SRC_LOCAL_PATH} does not exist */\n") + endif (EXISTS "${SRC_LOCAL_PATH}") + endforeach() + + # If _no_ files were found in the above loop, + # then check for and use the fallback file. + # (if specified by the caller it should always exist) + if (NOT ITEM_FOUND AND GENCONFIG_ARG_FALLBACK_FILE) + file(TO_NATIVE_PATH "${GENCONFIG_ARG_FALLBACK_FILE}" SRC_NATIVE_PATH) + list(APPEND WRAPPER_FILE_CONTENT + "\n\n/* No configuration for ${GENCONFIG_ARG_FILE_NAME}, using fallback */\n" + "#include \"${GENCONFIG_ARG_FALLBACK_FILE}\"\n") + endif() + + # Generate a header file + generate_c_headerfile("${GENCONFIG_ARG_OUTPUT_DIRECTORY}/${GENCONFIG_ARG_FILE_NAME}" ${WRAPPER_FILE_CONTENT}) -endfunction(generate_config_includefile DESTFILE SUFFIX) +endfunction(generate_config_includefile) ################################################################## @@ -106,21 +147,28 @@ function(read_targetconfig) endif() if (NOT DEFINED TGT${TGTID}_SYSTEM) set(TGT${TGTID}_SYSTEM "cpu${TGTID}") + set(TGT${TGTID}_SYSTEM "${TGT${TGTID}_SYSTEM}" PARENT_SCOPE) + endif() + if (NOT DEFINED TGT${TGTID}_PLATFORM) + set(TGT${TGTID}_PLATFORM "default" "${TGT${TGTID}_NAME}") + set(TGT${TGTID}_PLATFORM "${TGT${TGTID}_PLATFORM}" PARENT_SCOPE) endif() if (SIMULATION) # if simulation use simulation system architecture for all targets - set(CURRSYS "${SIMULATION}") + set(TOOLCHAIN_NAME "${SIMULATION}") else (SIMULATION) # get the target system arch identifier string - set(CURRSYS "${TGT${TGTID}_SYSTEM}") + set(TOOLCHAIN_NAME "${TGT${TGTID}_SYSTEM}") endif (SIMULATION) - # make sure the string is safe for a variable name - string(REGEX REPLACE "[^A-Za-z0-9]" "_" SYSVAR "${CURRSYS}") + set(BUILD_CONFIG ${TOOLCHAIN_NAME} ${TGT${TGTID}_PLATFORM}) + + # convert to a the string which is safe for a variable name + string(REGEX REPLACE "[^A-Za-z0-9]" "_" SYSVAR "${BUILD_CONFIG}") # save the unmodified name for future reference - set(SYSID_${SYSVAR} "${CURRSYS}" PARENT_SCOPE) + set(BUILD_CONFIG_${SYSVAR} "${BUILD_CONFIG}" PARENT_SCOPE) # if the "global" applist is not empty, append to every CPU applist if (MISSION_GLOBAL_APPLIST) diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 77b81efe6..6cdbaa067 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -111,10 +111,6 @@ function(prepare) add_definitions(-DSIMULATION=${SIMULATION}) endif (SIMULATION) - # Generate the cfe_mission_cfg.h wrapper file - generate_config_includefile("inc/cfe_mission_cfg.h" mission_cfg.h ${MISSIONCONFIG}) - generate_config_includefile("inc/cfe_perfids.h" perfids.h ${MISSIONCONFIG} ) - # Create custom targets for building and cleaning all architectures # This is required particularly for doing extra stuff in the clean step add_custom_target(mission-all COMMAND $(MAKE) all) @@ -166,7 +162,7 @@ function(prepare) # Export the full set of dependencies to the parent build # including the individual dependency paths to each component set(MISSION_DEPS ${MISSION_DEPS} PARENT_SCOPE) - foreach(DEP ${MISSION_DEPS} ${MISSION_PSPMODULES}) + foreach(DEP ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) set(${DEP}_MISSION_DIR ${${DEP}_MISSION_DIR} PARENT_SCOPE) endforeach(DEP ${MISSION_DEPS}) @@ -251,6 +247,39 @@ function(prepare) doxygen osalguide.doxyfile WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc") + # Generate the cfe_mission_cfg.h wrapper file + generate_config_includefile( + OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" + FILE_NAME "cfe_mission_cfg.h" + MATCH_SUFFIX "mission_cfg.h" + PREFIXES ${MISSIONCONFIG} # May be a list of items + ) + + generate_config_includefile( + OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" + FILE_NAME "cfe_perfids.h" + MATCH_SUFFIX "perfids.h" + PREFIXES ${MISSIONCONFIG} # May be a list of items + ) + + # Create wrappers for any files provided in an "fsw/mission_inc" subdirectory of each app + # These may be optionally overridden by providing a file of the same name in the defs directory + foreach(APP_NAME ${MISSION_APPS}) + set(APP_MISSION_CONFIG_DIR "${${APP_NAME}_MISSION_DIR}/fsw/mission_inc") + if (IS_DIRECTORY "${APP_MISSION_CONFIG_DIR}") + file(GLOB APP_MISSION_CONFIG_FILES RELATIVE "${APP_MISSION_CONFIG_DIR}" "${APP_MISSION_CONFIG_DIR}/*.h") + foreach(CONFIG_FILE ${APP_MISSION_CONFIG_FILES}) + generate_config_includefile( + OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" + FILE_NAME "${CONFIG_FILE}" + FALLBACK_FILE "${APP_MISSION_CONFIG_DIR}/${CONFIG_FILE}" + MATCH_SUFFIX "${CONFIG_FILE}" + PREFIXES ${MISSIONCONFIG} + ) + endforeach() + endif() + endforeach() + # Certain runtime variables need to be "exported" to the subordinate build, such as # the specific arch settings and the location of all the apps. This is done by creating # a temporary file within the dir and then the subprocess will read that file and re-create @@ -319,22 +348,28 @@ endfunction(prepare) # function(process_arch TARGETSYSTEM) - set(CURRSYS "${SYSID_${TARGETSYSTEM}}") - set(ARCH_BINARY_DIR "${CMAKE_BINARY_DIR}/${CURRSYS}") - file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}") + # The "BUILD_CONFIG" is a list of items to uniquely identify this build + # The first element in the list is the toolchain name, followed by config name(s) + set(BUILD_CONFIG ${BUILD_CONFIG_${TARGETSYSTEM}}) + list(GET BUILD_CONFIG 0 ARCH_TOOLCHAIN_NAME) + list(REMOVE_AT BUILD_CONFIG 0) + # convert to a the string which is safe for a directory name + string(REGEX REPLACE "[^A-Za-z0-9]" "_" ARCH_CONFIG_NAME "${BUILD_CONFIG}") + set(ARCH_BINARY_DIR "${CMAKE_BINARY_DIR}/${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}") + file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}" "${ARCH_BINARY_DIR}/inc") - message(STATUS "Configuring for system arch: ${CURRSYS}") + message(STATUS "Configuring for system arch: ${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}") # Note - A warning is issued if you pass CMAKE_TOOLCHAIN_FILE to an already-configured build area # so an extra check is added to see if this is an initial run or a re-run by checking for a CMakeCache file. - if (NOT CURRSYS STREQUAL "native" AND NOT EXISTS "${ARCH_BINARY_DIR}/CMakeCache.txt") + if (NOT ARCH_TOOLCHAIN_NAME STREQUAL "native" AND NOT EXISTS "${ARCH_BINARY_DIR}/CMakeCache.txt") # Find the toolchain file - allow a file in the mission defs dir to supercede one in the compile dir - if (EXISTS ${MISSION_DEFS}/toolchain-${CURRSYS}.cmake) - set(TOOLCHAIN_FILE ${MISSION_DEFS}/toolchain-${CURRSYS}.cmake) - elseif(EXISTS ${CFE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake) - set(TOOLCHAIN_FILE ${CFE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake) + if (EXISTS "${MISSION_DEFS}/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") + set(TOOLCHAIN_FILE "${MISSION_DEFS}/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") + elseif(EXISTS "${CFE_SOURCE_DIR}/cmake/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") + set(TOOLCHAIN_FILE "${CFE_SOURCE_DIR}/cmake/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") else() - message(FATAL_ERROR "Unable to find toolchain file for ${CURRSYS}") + message(FATAL_ERROR "Unable to find toolchain file for ${ARCH_TOOLCHAIN_NAME}") endif() set(SELECTED_TOOLCHAIN_FILE "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}") else() @@ -342,6 +377,38 @@ function(process_arch TARGETSYSTEM) set(SELECTED_TOOLCHAIN_FILE) endif () + # Generate wrapper file for the requisite cfe_platform_cfg.h file + generate_config_includefile( + OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" + FILE_NAME "cfe_msgids.h" + MATCH_SUFFIX "msgids.h" + PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} + ) + generate_config_includefile( + OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" + FILE_NAME "cfe_platform_cfg.h" + MATCH_SUFFIX "platform_cfg.h" + PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} + ) + + # Create wrappers for any files provided in an "fsw/platform_inc" subdirectory of each app + # These may be optionally overridden by providing a file of the same name in the defs directory + foreach(APP_NAME ${MISSION_APPS}) + set(APP_PLATFORM_CONFIG_DIR "${${APP_NAME}_MISSION_DIR}/fsw/platform_inc") + if (IS_DIRECTORY "${APP_PLATFORM_CONFIG_DIR}") + file(GLOB APP_PLATFORM_CONFIG_FILES RELATIVE "${APP_PLATFORM_CONFIG_DIR}" "${APP_PLATFORM_CONFIG_DIR}/*.h") + foreach(CONFIG_FILE ${APP_PLATFORM_CONFIG_FILES}) + generate_config_includefile( + OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" + FILE_NAME "${CONFIG_FILE}" + FALLBACK_FILE "${APP_PLATFORM_CONFIG_DIR}/${CONFIG_FILE}" + MATCH_SUFFIX "${CONFIG_FILE}" + PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} + ) + endforeach() + endif() + endforeach() + # Execute CMake subprocess to create a binary build tree for the specific CPU architecture execute_process( COMMAND ${CMAKE_COMMAND} @@ -358,24 +425,24 @@ function(process_arch TARGETSYSTEM) RESULT ) if (NOT RESULT EQUAL 0) - message(FATAL_ERROR "Failed to configure ${CURRSYS}") + message(FATAL_ERROR "Failed to configure ${TARGETSYSTEM}") endif (NOT RESULT EQUAL 0) # Hook the "make all", "make clean", and "make install" targets for the subordinate build # to top-level build targets prefixed by the CPU architecture. - add_custom_target(${CURRSYS}-all + add_custom_target(${TARGETSYSTEM}-all COMMAND $(MAKE) all WORKING_DIRECTORY "${ARCH_BINARY_DIR}" ) - add_custom_target(${CURRSYS}-clean + add_custom_target(${TARGETSYSTEM}-clean COMMAND $(MAKE) clean WORKING_DIRECTORY "${ARCH_BINARY_DIR}" ) - add_custom_target(${CURRSYS}-install + add_custom_target(${TARGETSYSTEM}-install COMMAND $(MAKE) install WORKING_DIRECTORY @@ -383,12 +450,12 @@ function(process_arch TARGETSYSTEM) ) # All subordinate builds depend on the generated files being present first - add_dependencies(${CURRSYS}-install mission-prebuild) - add_dependencies(${CURRSYS}-all mission-prebuild) + add_dependencies(${TARGETSYSTEM}-install mission-prebuild) + add_dependencies(${TARGETSYSTEM}-all mission-prebuild) - add_dependencies(mission-all ${CURRSYS}-all) - add_dependencies(mission-clean ${CURRSYS}-clean) - add_dependencies(mission-install ${CURRSYS}-install) + add_dependencies(mission-all ${TARGETSYSTEM}-all) + add_dependencies(mission-clean ${TARGETSYSTEM}-clean) + add_dependencies(mission-install ${TARGETSYSTEM}-install) endfunction(process_arch TARGETSYSTEM) diff --git a/cmake/target/CMakeLists.txt b/cmake/target/CMakeLists.txt index 903b9a45c..b71591c64 100644 --- a/cmake/target/CMakeLists.txt +++ b/cmake/target/CMakeLists.txt @@ -12,11 +12,6 @@ project(CFETARGET C) -# The CFE core target to link to MUST be given -if (NOT CFE_CORE_TARGET) - message(FATAL_ERROR "CFE_CORE_TARGET must be defined to link a final exe") -endif (NOT CFE_CORE_TARGET) - # Create a file for the statically-linked module list for this target # do this for both PSP and CFS static modules file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/psp_module_list.inc.tmp" @@ -43,9 +38,6 @@ file (REMOVE "${CMAKE_CURRENT_BINARY_DIR}/cfs_static_symbol_list.inc.tmp") # Include the current binary dir for the driver list include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# Include the CFE core-specific configuration -include_directories(${CMAKE_BINARY_DIR}/${CFE_CORE_TARGET}/inc) - # The CPU ID and name are defined by the build scripts for this target if (DEFINED TGTID) add_definitions(-DCFE_CPU_ID_VALUE=${TGTID}) @@ -109,8 +101,8 @@ endif (TGT${TGTID}_APPLIST) # Collect any additional libraries that should be included on the link line # This depends on whether any special features are included or not set(CFE_LINK_WHOLE_LIBS - ${CFE_CORE_TARGET} ${MISSION_CORE_MODULES} + cfe-core psp-${CFE_SYSTEM_PSPNAME} osal ) diff --git a/fsw/cfe-core/CMakeLists.txt b/fsw/cfe-core/CMakeLists.txt index d7337425e..f9480a9e2 100644 --- a/fsw/cfe-core/CMakeLists.txt +++ b/fsw/cfe-core/CMakeLists.txt @@ -13,29 +13,19 @@ # ################################################################## -cmake_minimum_required(VERSION 2.6.4) project(CFECORE C) -# The CFE core target to generate MUST be given -# this allows more than one cfe core target per architecture -if (NOT CFE_CORE_TARGET) - message(FATAL_ERROR "CFE_CORE_TARGET must be defined to build cFE core") -endif (NOT CFE_CORE_TARGET) - -# The cmake CURRENT binary include dir will have the generated platform config file (cfe_platform_cfg.h) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/inc) - # Define the "_CFE_CORE_" macro during compilation of all CFE core sources add_definitions(-D_CFE_CORE_) set(CFE_CORE_MODULES es sb evs tbl time fs) set(CFE_ALL_MODULE_SRCS) -foreach(MODULE ${CFE_CORE_MODULES} config shared) +foreach(MODULE ${CFE_CORE_MODULES}) aux_source_directory(src/${MODULE} CFE_ALL_MODULE_SRCS) endforeach(MODULE ${CFE_CORE_MODULES}) -add_library(${CFE_CORE_TARGET} STATIC ${CFE_ALL_MODULE_SRCS}) +add_library(cfe-core STATIC ${CFE_ALL_MODULE_SRCS}) if (ENABLE_UNIT_TESTS) add_subdirectory(unit-test) diff --git a/fsw/cfe-core/unit-test/CMakeLists.txt b/fsw/cfe-core/unit-test/CMakeLists.txt index 3aebb52fe..3c90521c4 100644 --- a/fsw/cfe-core/unit-test/CMakeLists.txt +++ b/fsw/cfe-core/unit-test/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories( ) # CFE needs a supplemental test support hook library -add_library(ut_${CFE_CORE_TARGET}_support STATIC +add_library(ut_cfe-core_support STATIC ut_support.c ut_osprintf_stubs.c ) @@ -35,7 +35,7 @@ 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(UT_TARGET_NAME "cfe-core_${MODULE}") set(CFE_MODULE_FILES) aux_source_directory(${cfe-core_MISSION_DIR}/src/${MODULE} CFE_MODULE_FILES) @@ -64,7 +64,7 @@ foreach(MODULE ${CFE_CORE_MODULES}) # This should enable coverage analysis on platforms that support this target_link_libraries(${UT_TARGET_NAME}_UT ${UT_COVERAGE_LINK_FLAGS} - ut_${CFE_CORE_TARGET}_support + ut_cfe-core_support ut_cfe-core_stubs ut_assert) From aea76b9122d983d6b24d35cc6aff8b8d35b9b750 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 19 Jun 2020 16:53:44 -0400 Subject: [PATCH 03/14] Fix #746, simplify dependency handling Put more dependencies into the "mission_defaults.cmake" file for more visibility and ease of configuration. This now includes all "implicit" modules such as cfe-core, osal, and psp. Also push the calls to "generate_config_includefile" to a sub-script which can be distributed with each app and evaluated as part of the build. This reduces dependencies on special naming conventions like "fsw/mission_inc" and "fsw/platform_inc", and apps can explicitly manage the files that users are expected to override. --- cmake/arch_build.cmake | 72 +++++++++---------- cmake/global_functions.cmake | 8 ++- cmake/mission_build.cmake | 117 ++++++------------------------- cmake/mission_defaults.cmake | 7 +- cmake/sample_defs/targets.cmake | 2 +- cmake/target/CMakeLists.txt | 8 +-- cmake/version.cmake | 2 +- fsw/cfe-core/CMakeLists.txt | 2 +- fsw/cfe-core/arch_build.cmake | 25 +++++++ fsw/cfe-core/mission_build.cmake | 24 +++++++ 10 files changed, 123 insertions(+), 144 deletions(-) create mode 100644 fsw/cfe-core/arch_build.cmake create mode 100644 fsw/cfe-core/mission_build.cmake diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index 04984f8b3..8cea4fc95 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -294,6 +294,19 @@ function(prepare) # Truncate the global TGTSYS_LIST to be only the target architecture set(TGTSYS_LIST ${TARGETSYSTEM} PARENT_SCOPE) + + # set the BUILD_CONFIG variable from the cached data + set(BUILD_CONFIG ${BUILD_CONFIG_${TARGETSYSTEM}}) + list(REMOVE_AT BUILD_CONFIG 0) + set(BUILD_CONFIG ${BUILD_CONFIG} PARENT_SCOPE) + + # Pull in any application-specific platform-scope configuration + # This may include user configuration files such as cfe_platform_cfg.h, + # or any other configuration/preparation that needs to happen at + # platform/arch scope. + foreach(DEP_NAME ${MISSION_DEPS}) + include("${${DEP_NAME}_MISSION_DIR}/arch_build.cmake" OPTIONAL) + endforeach(DEP_NAME ${MISSION_DEPS}) endfunction(prepare) @@ -344,7 +357,7 @@ function(process_arch SYSVAR) include_directories(${CMAKE_BINARY_DIR}/inc) # Configure OSAL target first, as it also determines important compiler flags - add_subdirectory(${MISSION_SOURCE_DIR}/osal osal) + add_subdirectory("${osal_MISSION_DIR}" osal) # The OSAL displays its selected OS, so it is logical to display the selected PSP # This can help with debugging if things go wrong. @@ -393,45 +406,40 @@ function(process_arch SYSVAR) set(INSTALL_SUBDIR cf) endif (NOT INSTALL_SUBDIR) - # Add any dependencies which MIGHT be required for subsequent apps/libs/tools - # The cfe-core and osal are handled explicitly since these have special extra config - foreach(DEP ${MISSION_DEPS}) - if (NOT DEP STREQUAL "cfe-core" AND - NOT DEP STREQUAL "osal") - add_subdirectory(${${DEP}_MISSION_DIR} ${DEP}) - endif() - endforeach(DEP ${MISSION_DEPS}) + # Add all core modules + # The osal is handled explicitly (above) since this has special extra config + foreach(DEP ${MISSION_CORE_MODULES}) + if(NOT DEP STREQUAL "osal") + message(STATUS "Building Core Module: ${DEP}") + add_subdirectory("${${DEP}_MISSION_DIR}" ${DEP}) + endif(NOT DEP STREQUAL "osal") + endforeach(DEP ${MISSION_CORE_MODULES}) + + # For the PSP it may define the FSW as either + # "psp-${CFE_SYSTEM_PSPNAME}" or just simply "psp" + if (NOT TARGET psp) + add_library(psp ALIAS psp-${CFE_SYSTEM_PSPNAME}) + endif (NOT TARGET psp) - # Clear the app lists - set(ARCH_APP_SRCS) - foreach(APP ${TGTSYS_${SYSVAR}_APPS}) - set(TGTLIST_${APP}) - endforeach() - foreach(DRV ${TGTSYS_${SYSVAR}_DRIVERS}) - set(TGTLIST_DRV_${DRV}) - endforeach() - # Process each PSP module that is referenced on this system architecture (any cpu) foreach(PSPMOD ${TGTSYS_${SYSVAR}_PSPMODULES}) message(STATUS "Building PSP Module: ${PSPMOD}") - add_subdirectory(${${PSPMOD}_MISSION_DIR} psp/${PSPMOD}) + add_subdirectory("${${PSPMOD}_MISSION_DIR}" psp/${PSPMOD}) endforeach() # Process each app that is used on this system architecture set(APP_INSTALL_LIST) foreach(APP ${TGTSYS_${SYSVAR}_STATICAPPS}) message(STATUS "Building Static App: ${APP}") - add_subdirectory(${${APP}_MISSION_DIR} apps/${APP}) + add_subdirectory("${${APP}_MISSION_DIR}" apps/${APP}) endforeach() - # Configure the selected PSP - # The naming convention allows more than one PSP per arch, - # however in practice this gets too complicated so it is - # currently a 1:1 relationship. This may change at some point. - add_subdirectory(${MISSION_SOURCE_DIR}/psp psp/${CFE_SYSTEM_PSPNAME}) - # Process each target that shares this system architecture # First Pass: Assemble the list of apps that should be compiled + foreach(APP ${TGTSYS_${SYSVAR}_APPS}) + set(TGTLIST_${APP}) + endforeach() + foreach(TGTID ${TGTSYS_${SYSVAR}}) set(TGTNAME ${TGT${TGTID}_NAME}) @@ -451,19 +459,11 @@ function(process_arch SYSVAR) foreach(APP ${TGTSYS_${SYSVAR}_APPS}) set(APP_INSTALL_LIST ${TGTLIST_${APP}}) message(STATUS "Building App: ${APP} install=${APP_INSTALL_LIST}") - add_subdirectory(${${APP}_MISSION_DIR} apps/${APP}) + add_subdirectory("${${APP}_MISSION_DIR}" apps/${APP}) endforeach() - # Actual core library is a subdirectory - add_subdirectory(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core cfe-core) - - # If unit test is enabled, build a generic ut stub library for CFE - if (ENABLE_UNIT_TESTS) - add_subdirectory(${cfe-core_MISSION_DIR}/ut-stubs ut_cfe_core_stubs) - endif (ENABLE_UNIT_TESTS) - # Process each target that shares this system architecture - # Second Pass: Build cfe-core and link final target executable + # Second Pass: Build and link final target executable foreach(TGTID ${TGTSYS_${SYSVAR}}) set(TGTNAME ${TGT${TGTID}_NAME}) diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index 8bcc91595..71813f397 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -65,7 +65,6 @@ endfunction(generate_c_headerfile) # source file for the wrapper. # # This function now accepts named parameters: -# OUTPUT_DIRECTORY - where the generated file will be written # FILE_NAME - the name of the file to write # FALLBACK_FILE - if no files are found in "defs" using the name match, this file will be used instead. # MATCH_SUFFIX - the suffix to match in the "defs" directory (optional) @@ -74,6 +73,9 @@ endfunction(generate_c_headerfile) function(generate_config_includefile) cmake_parse_arguments(GENCONFIG_ARG "" "OUTPUT_DIRECTORY;FILE_NAME;FALLBACK_FILE;MATCH_SUFFIX" "PREFIXES" ${ARGN} ) + if (NOT GENCONFIG_ARG_OUTPUT_DIRECTORY) + set(GENCONFIG_ARG_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc") + endif (NOT GENCONFIG_ARG_OUTPUT_DIRECTORY) set(WRAPPER_FILE_CONTENT) set(ITEM_FOUND FALSE) @@ -103,11 +105,15 @@ function(generate_config_includefile) # If _no_ files were found in the above loop, # then check for and use the fallback file. # (if specified by the caller it should always exist) + # Also produce a message on the console showing whether mission config or fallback was used if (NOT ITEM_FOUND AND GENCONFIG_ARG_FALLBACK_FILE) file(TO_NATIVE_PATH "${GENCONFIG_ARG_FALLBACK_FILE}" SRC_NATIVE_PATH) list(APPEND WRAPPER_FILE_CONTENT "\n\n/* No configuration for ${GENCONFIG_ARG_FILE_NAME}, using fallback */\n" "#include \"${GENCONFIG_ARG_FALLBACK_FILE}\"\n") + message(STATUS "Using ${GENCONFIG_ARG_FALLBACK_FILE} for ${GENCONFIG_ARG_FILE_NAME}") + else() + message(STATUS "Generated ${GENCONFIG_ARG_FILE_NAME} from ${MISSION_DEFS} configuration") endif() # Generate a header file diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 6cdbaa067..66b0d43c1 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -73,31 +73,6 @@ function(initialize_globals) endfunction(initialize_globals) -################################################################## -# -# FUNCTION: add_static_dependencies -# -# Adds an entry to the depedency list during app search -# (Note apps can depend on other apps/libs) -# -function(add_static_dependencies TGT_DEPS) - - set(FULLDEPS ${MISSION_DEPS} ${FIND_DEP_LIST}) - set(NEWDEPS) - foreach(DEP ${TGT_DEPS} ${ARGN}) - list(FIND FULLDEPS ${DEP} DEPIDX) - if (DEPIDX LESS 0) - list(APPEND NEWDEPS ${DEP}) - list(APPEND FULLDEPS ${DEP}) - endif() - endforeach() - - set(FIND_DEP_LIST ${FIND_DEP_LIST} ${NEWDEPS} PARENT_SCOPE) - -endfunction(add_static_dependencies) - - - ################################################################## # # FUNCTION: prepare @@ -126,15 +101,19 @@ function(prepare) ) string(REPLACE ":" ";" CFS_APP_PATH "${CFS_APP_PATH}") set(MISSION_MODULE_SEARCH_PATH ${CFS_APP_PATH} ${MISSION_MODULE_SEARCH_PATH}) - - set(MISSION_DEPS "cfe-core" "osal" ${MISSION_CORE_MODULES}) + + # The "MISSION_DEPS" list is the complete set of all dependencies used in the build. + # 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(APP_MISSING_COUNT 0) message(STATUS "Search path for modules: ${MISSION_MODULE_SEARCH_PATH}") # Now search for the rest of CFS applications/libraries/modules - these may exist in # any directory within the search path. - foreach(APP ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) + foreach(APP ${MISSION_DEPS}) set (APPFOUND FALSE) foreach(APPSRC ${MISSION_MODULE_SEARCH_PATH} ${${APP}_SEARCH_PATH}) if (NOT IS_ABSOLUTE "${APPSRC}") @@ -147,7 +126,6 @@ function(prepare) endforeach() if (APPFOUND) get_filename_component(${APP}_MISSION_DIR "${APPFOUND}" ABSOLUTE) - include("${APPFOUND}/mission_build.cmake" OPTIONAL) message(STATUS "Module '${APP}' found at ${${APP}_MISSION_DIR}") else() message("** Module ${APP} NOT found **") @@ -162,7 +140,7 @@ function(prepare) # Export the full set of dependencies to the parent build # including the individual dependency paths to each component set(MISSION_DEPS ${MISSION_DEPS} PARENT_SCOPE) - foreach(DEP ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) + foreach(DEP ${MISSION_DEPS}) set(${DEP}_MISSION_DIR ${${DEP}_MISSION_DIR} PARENT_SCOPE) endforeach(DEP ${MISSION_DEPS}) @@ -180,7 +158,7 @@ function(prepare) list(APPEND MISSION_DOXYFILE_USER_CONTENT "@INCLUDE = ${MISSION_SOURCE_DIR}/doc/Doxyfile\n") endif (EXISTS "${MISSION_SOURCE_DIR}/doc/Doxyfile") - foreach(APP ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) + foreach(APP ${MISSION_DEPS}) # OSAL is handled specially, as only part of it is used if (NOT APP STREQUAL "osal" AND NOT APP STREQUAL "cfe-core") if (EXISTS "${${APP}_MISSION_DIR}/docs/${APP}.doxyfile.in") @@ -246,39 +224,14 @@ function(prepare) add_custom_target(osalguide doxygen osalguide.doxyfile WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc") - - # Generate the cfe_mission_cfg.h wrapper file - generate_config_includefile( - OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" - FILE_NAME "cfe_mission_cfg.h" - MATCH_SUFFIX "mission_cfg.h" - PREFIXES ${MISSIONCONFIG} # May be a list of items - ) - generate_config_includefile( - OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" - FILE_NAME "cfe_perfids.h" - MATCH_SUFFIX "perfids.h" - PREFIXES ${MISSIONCONFIG} # May be a list of items - ) - - # Create wrappers for any files provided in an "fsw/mission_inc" subdirectory of each app - # These may be optionally overridden by providing a file of the same name in the defs directory - foreach(APP_NAME ${MISSION_APPS}) - set(APP_MISSION_CONFIG_DIR "${${APP_NAME}_MISSION_DIR}/fsw/mission_inc") - if (IS_DIRECTORY "${APP_MISSION_CONFIG_DIR}") - file(GLOB APP_MISSION_CONFIG_FILES RELATIVE "${APP_MISSION_CONFIG_DIR}" "${APP_MISSION_CONFIG_DIR}/*.h") - foreach(CONFIG_FILE ${APP_MISSION_CONFIG_FILES}) - generate_config_includefile( - OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" - FILE_NAME "${CONFIG_FILE}" - FALLBACK_FILE "${APP_MISSION_CONFIG_DIR}/${CONFIG_FILE}" - MATCH_SUFFIX "${CONFIG_FILE}" - PREFIXES ${MISSIONCONFIG} - ) - endforeach() - endif() - endforeach() + # Pull in any application-specific mission-scope configuration + # This may include user configuration files such as cfe_mission_cfg.h, + # msgid definitions, or any other configuration/preparation that needs to + # happen at mission/global scope. + foreach(DEP_NAME ${MISSION_DEPS}) + include("${${DEP_NAME}_MISSION_DIR}/mission_build.cmake" OPTIONAL) + endforeach(DEP_NAME ${MISSION_DEPS}) # Certain runtime variables need to be "exported" to the subordinate build, such as # the specific arch settings and the location of all the apps. This is done by creating @@ -297,10 +250,14 @@ function(prepare) "MISSION_DEPS" "ENABLE_UNIT_TESTS" ) - foreach(APP ${MISSION_APPS} ${MISSION_PSPMODULES} ${MISSION_DEPS}) + foreach(APP ${MISSION_DEPS}) list(APPEND VARLIST "${APP}_MISSION_DIR") endforeach(APP ${MISSION_APPS}) + foreach(SYSVAR ${TGTSYS_LIST}) + list(APPEND VARLIST "BUILD_CONFIG_${SYSVAR}") + endforeach(SYSVAR ${TGTSYS_LIST}) + set(MISSION_VARCACHE) foreach(VARL ${VARLIST}) # It is important to avoid putting any blank lines in the output, @@ -377,38 +334,6 @@ function(process_arch TARGETSYSTEM) set(SELECTED_TOOLCHAIN_FILE) endif () - # Generate wrapper file for the requisite cfe_platform_cfg.h file - generate_config_includefile( - OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" - FILE_NAME "cfe_msgids.h" - MATCH_SUFFIX "msgids.h" - PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} - ) - generate_config_includefile( - OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" - FILE_NAME "cfe_platform_cfg.h" - MATCH_SUFFIX "platform_cfg.h" - PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} - ) - - # Create wrappers for any files provided in an "fsw/platform_inc" subdirectory of each app - # These may be optionally overridden by providing a file of the same name in the defs directory - foreach(APP_NAME ${MISSION_APPS}) - set(APP_PLATFORM_CONFIG_DIR "${${APP_NAME}_MISSION_DIR}/fsw/platform_inc") - if (IS_DIRECTORY "${APP_PLATFORM_CONFIG_DIR}") - file(GLOB APP_PLATFORM_CONFIG_FILES RELATIVE "${APP_PLATFORM_CONFIG_DIR}" "${APP_PLATFORM_CONFIG_DIR}/*.h") - foreach(CONFIG_FILE ${APP_PLATFORM_CONFIG_FILES}) - generate_config_includefile( - OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" - FILE_NAME "${CONFIG_FILE}" - FALLBACK_FILE "${APP_PLATFORM_CONFIG_DIR}/${CONFIG_FILE}" - MATCH_SUFFIX "${CONFIG_FILE}" - PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} - ) - endforeach() - endif() - endforeach() - # Execute CMake subprocess to create a binary build tree for the specific CPU architecture execute_process( COMMAND ${CMAKE_COMMAND} diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake index f00faeb5b..8f49d54d5 100644 --- a/cmake/mission_defaults.cmake +++ b/cmake/mission_defaults.cmake @@ -10,7 +10,11 @@ # 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. -set(MISSION_CORE_MODULES) +set(MISSION_CORE_MODULES + "cfe-core" + "osal" + "psp" +) # The "MISSION_GLOBAL_APPLIST" is a set of apps/libs that will be built # for every defined and target. These are built as dynamic modules @@ -40,3 +44,4 @@ set(MISSION_MODULE_SEARCH_PATH # of the standard search path. set(cfe-core_SEARCH_PATH "cfe/fsw") set(osal_SEARCH_PATH ".") +set(psp_SEARCH_PATH ".") diff --git a/cmake/sample_defs/targets.cmake b/cmake/sample_defs/targets.cmake index 961b93d54..d43dcac02 100644 --- a/cmake/sample_defs/targets.cmake +++ b/cmake/sample_defs/targets.cmake @@ -78,7 +78,7 @@ SET(SPACECRAFT_ID 42) # 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. -set(MISSION_CORE_MODULES) +#list(APPEND MISSION_CORE_MODULES mymodule) # The "MISSION_GLOBAL_APPLIST" is a set of apps/libs that will be built # for every defined and target. These are built as dynamic modules diff --git a/cmake/target/CMakeLists.txt b/cmake/target/CMakeLists.txt index b71591c64..35935cb4a 100644 --- a/cmake/target/CMakeLists.txt +++ b/cmake/target/CMakeLists.txt @@ -102,18 +102,12 @@ endif (TGT${TGTID}_APPLIST) # This depends on whether any special features are included or not set(CFE_LINK_WHOLE_LIBS ${MISSION_CORE_MODULES} - cfe-core - psp-${CFE_SYSTEM_PSPNAME} - osal ) set(CFE_LINK_NORMAL_LIBS ${TGT${TGTID}_PSP_MODULELIST} + ${TGT${TGTID}_STATIC_APPLIST} ) -foreach(STATICAPP ${TGT${TGTID}_STATIC_APPLIST}) - list(APPEND CFE_LINK_NORMAL_LIBS ${STATICAPP}) -endforeach(STATICAPP ${TGT${TGTID}_STATIC_APPLIST}) - # Handle the list of "embedded files" that should be linked into CFE. # These are arbitrary files in the mission config that are converted # into C data structures and linked with the executable. This is diff --git a/cmake/version.cmake b/cmake/version.cmake index a80a80a30..5a0bdb8c7 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -71,7 +71,7 @@ file(WRITE ${BIN}/cfecfs_version_info.h.in "#define MISSION_NAME \"\@MISSION_NAME\@\"\n") # Get version for all mission apps/dependencies (they may be different) -foreach(DEP "MISSION" ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) +foreach(DEP "MISSION" ${MISSION_DEPS}) get_version(${DEP}) string(TOUPPER ${${DEP}_NAME} MACRONAME) string(REGEX REPLACE "[^A-Z0-9_]+" "_" MACRONAME "${MACRONAME}") diff --git a/fsw/cfe-core/CMakeLists.txt b/fsw/cfe-core/CMakeLists.txt index f9480a9e2..4aa275555 100644 --- a/fsw/cfe-core/CMakeLists.txt +++ b/fsw/cfe-core/CMakeLists.txt @@ -28,7 +28,7 @@ endforeach(MODULE ${CFE_CORE_MODULES}) add_library(cfe-core STATIC ${CFE_ALL_MODULE_SRCS}) if (ENABLE_UNIT_TESTS) + add_subdirectory(ut-stubs) add_subdirectory(unit-test) endif (ENABLE_UNIT_TESTS) - diff --git a/fsw/cfe-core/arch_build.cmake b/fsw/cfe-core/arch_build.cmake new file mode 100644 index 000000000..2f2f0d5d3 --- /dev/null +++ b/fsw/cfe-core/arch_build.cmake @@ -0,0 +1,25 @@ +########################################################### +# +# CFE arch/platform build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# Generate the "cfe_platform_cfg.h" and "cfe_msgids.h" header files +# these must come from mission config + +generate_config_includefile( + FILE_NAME "cfe_platform_cfg.h" + MATCH_SUFFIX "platform_cfg.h" + PREFIXES ${BUILD_CONFIG} +) + +generate_config_includefile( + FILE_NAME "cfe_msgids.h" + MATCH_SUFFIX "msgids.h" + PREFIXES ${BUILD_CONFIG} +) + diff --git a/fsw/cfe-core/mission_build.cmake b/fsw/cfe-core/mission_build.cmake new file mode 100644 index 000000000..83b78a6aa --- /dev/null +++ b/fsw/cfe-core/mission_build.cmake @@ -0,0 +1,24 @@ +########################################################### +# +# CFE mission build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# Generate the "cfe_mission_cfg.h" and "cfe_perfids.h" header files +# these must come from mission config +generate_config_includefile( + FILE_NAME "cfe_mission_cfg.h" + MATCH_SUFFIX "mission_cfg.h" + PREFIXES ${MISSIONCONFIG} +) + +generate_config_includefile( + FILE_NAME "cfe_perfids.h" + MATCH_SUFFIX "perfids.h" + PREFIXES ${MISSIONCONFIG} +) + From 68e9655759b238e71b8f3ba8ad536895ef80033a Mon Sep 17 00:00:00 2001 From: Alan Gibson Date: Wed, 17 Jun 2020 17:22:42 -0400 Subject: [PATCH 04/14] Fix #747, CFE_SB_TimeStampMsg in does not record MsgPtr argument value In ut_sb_stubs.c, update CFE_SB_TimeStampMsg to save the message pointer argument with UT_Stub_CopyFromLocal so that unit tests can check it --- fsw/cfe-core/ut-stubs/ut_sb_stubs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c index 1de4d0889..523084d99 100644 --- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c @@ -668,6 +668,7 @@ int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) { UT_DEFAULT_IMPL(CFE_SB_TimeStampMsg); + UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TimeStampMsg), &MsgPtr, sizeof(MsgPtr)); } /*****************************************************************************/ From 43bbb74a0f6a9634ad4e943e3da3d15dfdce3e80 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 26 Jun 2020 11:00:28 -0400 Subject: [PATCH 05/14] Fix #762, scrub of all CFE UT stub functions Scrubs all CFE unit test functions to ensure that: 1. All functions in the CFE public API have a stub function implemented 2. All parameters to the stub function are registered in the context object, so the values will be available to hook functions. 3. The names of all parameters match the prototype/documentation, so hook functions that use name-based argument value retrieval will work. --- fsw/cfe-core/ut-stubs/ut_es_stubs.c | 272 ++++++++++++++++++++++--- fsw/cfe-core/ut-stubs/ut_evs_stubs.c | 68 +++++-- fsw/cfe-core/ut-stubs/ut_fs_stubs.c | 24 ++- fsw/cfe-core/ut-stubs/ut_sb_stubs.c | 282 +++++++++++++++++++++++--- fsw/cfe-core/ut-stubs/ut_tbl_stubs.c | 163 ++++++++++++++- fsw/cfe-core/ut-stubs/ut_time_stubs.c | 204 ++++++++++++++++++- 6 files changed, 928 insertions(+), 85 deletions(-) diff --git a/fsw/cfe-core/ut-stubs/ut_es_stubs.c b/fsw/cfe-core/ut-stubs/ut_es_stubs.c index ae8b40721..9e2aeb976 100644 --- a/fsw/cfe-core/ut-stubs/ut_es_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_es_stubs.c @@ -90,10 +90,15 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, uint32 Priority, uint32 Flags) { - int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_ES_CreateChildTask), TaskIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_ES_CreateChildTask), TaskName); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CreateChildTask), FunctionPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_CreateChildTask), StackPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CreateChildTask), StackSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CreateChildTask), Priority); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CreateChildTask), Flags); + + int32 status; status = UT_DEFAULT_IMPL(CFE_ES_CreateChildTask); @@ -120,8 +125,10 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, ** Returns either a user-defined status flag or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppID(uint32 *pAppID) +int32 CFE_ES_GetAppID(uint32 *AppIdPtr) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppID), AppIdPtr); + int32 status; uint32 *IdBuff; uint32 BuffSize; @@ -132,13 +139,13 @@ int32 CFE_ES_GetAppID(uint32 *pAppID) if (status >= 0) { UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppID), (void **)&IdBuff, &BuffSize, &Position); - if (IdBuff != NULL && BuffSize == sizeof(*pAppID)) + if (IdBuff != NULL && BuffSize == sizeof(*AppIdPtr)) { - *pAppID = *IdBuff; + *AppIdPtr = *IdBuff; } else { - *pAppID = 0; + *AppIdPtr = 0; } } @@ -166,37 +173,38 @@ int32 CFE_ES_GetAppID(uint32 *pAppID) ** Returns either CFE_ES_ERR_APPNAME or CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppIDByName(uint32 *pAppID, const char *pAppName) +int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppIdPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppName); + uint32 UserBuffSize; uint32 BuffPosition; const char *NameBuff; uint32 *IdBuff; int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), pAppID); - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), pAppName); status = UT_DEFAULT_IMPL(CFE_ES_GetAppIDByName); if (status >= 0) { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetAppIDByName), (uint8*)pAppID, sizeof(*pAppID)) < sizeof(*pAppID)) + if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetAppIDByName), (uint8*)AppIdPtr, sizeof(*AppIdPtr)) < sizeof(*AppIdPtr)) { IdBuff = NULL; UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppName), (void**)&NameBuff, &UserBuffSize, &BuffPosition); if (NameBuff != NULL && UserBuffSize > 0 && - strncmp(NameBuff, pAppName, UserBuffSize) == 0) + strncmp(NameBuff, AppName, UserBuffSize) == 0) { UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppID), (void**)&IdBuff, &UserBuffSize, &BuffPosition); } - if (IdBuff != NULL && UserBuffSize == sizeof(*pAppID)) + if (IdBuff != NULL && UserBuffSize == sizeof(*AppIdPtr)) { - *pAppID = *IdBuff; + *AppIdPtr = *IdBuff; } else { - *pAppID = 0; + *AppIdPtr = 0; } } } @@ -221,8 +229,12 @@ int32 CFE_ES_GetAppIDByName(uint32 *pAppID, const char *pAppName) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_GetAppName(char *pAppName, uint32 AppID, uint32 BufferLength) +int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppName), AppName); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), AppId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppName), BufferLength); + uint32 UserBuffSize; uint32 BuffPosition; const char *NameBuff; @@ -248,8 +260,8 @@ int32 CFE_ES_GetAppName(char *pAppName, uint32 AppID, uint32 BufferLength) BuffPosition = BufferLength - 1; } - strncpy(pAppName, NameBuff, BuffPosition); - pAppName[BuffPosition] = 0; + strncpy(AppName, NameBuff, BuffPosition); + AppName[BuffPosition] = 0; } return status; @@ -330,20 +342,20 @@ int32 CFE_ES_RegisterChildTask(void) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_ES_WriteToSysLog(const char *pSpecString, ...) +int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_WriteToSysLog), SpecStringPtr); + int32 status; va_list va; - UT_Stub_RegisterContext(UT_KEY(CFE_ES_WriteToSysLog), pSpecString); // allow this input to be used by hook functions - - va_start(va,pSpecString); + va_start(va,SpecStringPtr); status = UT_DEFAULT_IMPL_VARARGS(CFE_ES_WriteToSysLog, va); va_end(va); if (status >= 0) { - UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_WriteToSysLog), (const uint8*)pSpecString, strlen(pSpecString)); + UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_WriteToSysLog), (const uint8*)SpecStringPtr, strlen(SpecStringPtr)); } return status; @@ -375,6 +387,10 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t HandlePtr, uint32 Size) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetPoolBuf), BufPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBuf), HandlePtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBuf), Size); + static union { uint32 Start; @@ -479,6 +495,10 @@ int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, ******************************************************************************/ int32 CFE_ES_PoolCreate(cpuaddr *HandlePtr, uint8 *MemPtr, uint32 Size) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreate), HandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreate), MemPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PoolCreate), Size); + int32 status; status = UT_DEFAULT_IMPL(CFE_ES_PoolCreate); @@ -510,6 +530,10 @@ int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateNoSem), HandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateNoSem), MemPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PoolCreateNoSem), Size); + int32 status; status = UT_DEFAULT_IMPL(CFE_ES_PoolCreateNoSem); @@ -549,6 +573,13 @@ int32 CFE_ES_PoolCreateEx(cpuaddr *HandlePtr, uint32 *BlockSizes, uint16 UseMutex) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateEx), HandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateEx), MemPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PoolCreateEx), Size); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PoolCreateEx), NumBlockSizes); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateEx), BlockSizes); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PoolCreateEx), UseMutex); + int32 status = CFE_SUCCESS; status = UT_DEFAULT_IMPL(CFE_ES_PoolCreateEx); @@ -581,6 +612,9 @@ int32 CFE_ES_PoolCreateEx(cpuaddr *HandlePtr, ******************************************************************************/ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PutPoolBuf), HandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_PutPoolBuf), BufPtr); + int32 status; status = UT_DEFAULT_IMPL_RC(CFE_ES_PutPoolBuf, 16); @@ -610,6 +644,9 @@ int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr) ******************************************************************************/ int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBufInfo), HandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetPoolBufInfo), BufPtr); + int32 status; status = UT_DEFAULT_IMPL_RC(CFE_ES_GetPoolBufInfo, 16); @@ -634,8 +671,8 @@ int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr) ******************************************************************************/ void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit) { - UT_Stub_RegisterContext(UT_KEY(CFE_ES_PerfLogAdd), &Marker); - UT_Stub_RegisterContext(UT_KEY(CFE_ES_PerfLogAdd), &EntryExit); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PerfLogAdd), Marker); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PerfLogAdd), EntryExit); UT_DEFAULT_IMPL(CFE_ES_PerfLogAdd); } @@ -661,6 +698,11 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 InputCRC, uint32 TypeCRC) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_CalculateCRC), DataPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CalculateCRC), DataLength); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CalculateCRC), InputCRC); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CalculateCRC), TypeCRC); + uint32 result; UT_DEFAULT_IMPL(CFE_ES_CalculateCRC); @@ -697,6 +739,9 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, ******************************************************************************/ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskInfo), TaskInfo); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetTaskInfo), TaskId); + int32 status = CFE_SUCCESS; status = UT_DEFAULT_IMPL(CFE_ES_GetTaskInfo); @@ -736,7 +781,8 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) ******************************************************************************/ void CFE_ES_ExitApp(uint32 ExitStatus) { - UT_Stub_RegisterContext(UT_KEY(CFE_ES_ExitApp), &ExitStatus); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ExitApp), ExitStatus); + UT_DEFAULT_IMPL(CFE_ES_ExitApp); UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_ExitApp), (uint8*)&ExitStatus, sizeof(ExitStatus)); } @@ -912,6 +958,8 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) ******************************************************************************/ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetResetType), ResetSubtypePtr); + int32 status = CFE_SUCCESS; status = UT_DEFAULT_IMPL(CFE_ES_GetResetType); @@ -944,8 +992,11 @@ void CFE_ES_IncrementTaskCounter(void) UT_DEFAULT_IMPL(CFE_ES_IncrementTaskCounter); } -int32 CFE_ES_WaitForSystemState(uint32 State, uint32 Timeout) +int32 CFE_ES_WaitForSystemState(uint32 MinSystemState, uint32 TimeOutMilliseconds) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_WaitForSystemState), MinSystemState); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_WaitForSystemState), TimeOutMilliseconds); + int32 status = CFE_SUCCESS; status = UT_DEFAULT_IMPL(CFE_ES_WaitForSystemState); @@ -968,20 +1019,185 @@ int32 CFE_ES_WaitForSystemState(uint32 State, uint32 Timeout) ** This function does not return a value. ** ******************************************************************************/ -void CFE_ES_WaitForStartupSync(uint32 Timeout) +void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_WaitForStartupSync), TimeOutMilliseconds); + UT_DEFAULT_IMPL(CFE_ES_WaitForStartupSync); } bool CFE_ES_RunLoop(uint32 *ExitStatus) { + UT_Stub_RegisterContext(UT_KEY(CFE_ES_RunLoop), ExitStatus); + return UT_DEFAULT_IMPL(CFE_ES_RunLoop) != 0; } -UT_DEFAULT_STUB(CFE_ES_RegisterCDS, (CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name)) +int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterCDS), HandlePtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RegisterCDS), BlockSize); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterCDS), Name); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_RegisterCDS); + + return status; +} void CFE_ES_ExitChildTask(void) { UT_DEFAULT_IMPL(CFE_ES_ExitChildTask); } +int32 CFE_ES_DeleteApp(uint32 AppID) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteApp), AppID); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_DeleteApp); + + return status; +} + +int32 CFE_ES_DeleteChildTask(uint32 TaskId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteChildTask), TaskId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_DeleteChildTask); + + return status; +} + +int32 CFE_ES_DeleteGenCounter(uint32 CounterId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_DeleteGenCounter), CounterId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_DeleteGenCounter); + + return status; +} + +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppInfo), AppInfo); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetAppInfo), AppId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_GetAppInfo); + + return status; +} + +int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetGenCount), CounterId); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCount), Count); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_GetGenCount); + + return status; +} + +int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterIdPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetGenCounterIDByName), CounterName); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_GetGenCounterIDByName); + + return status; +} + +int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetMemPoolStats), BufPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetMemPoolStats), Handle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_GetMemPoolStats); + + return status; +} + +int32 CFE_ES_IncrementGenCounter(uint32 CounterId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_IncrementGenCounter), CounterId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_IncrementGenCounter); + + return status; +} + +int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterIdPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_RegisterGenCounter), CounterName); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_RegisterGenCounter); + + return status; +} + +int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ReloadApp), AppID); + UT_Stub_RegisterContext(UT_KEY(CFE_ES_ReloadApp), AppFileName); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_ReloadApp); + + return status; +} + +int32 CFE_ES_ResetCFE(uint32 ResetType) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_ResetCFE), ResetType); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_ResetCFE); + + return status; +} + +int32 CFE_ES_RestartApp(uint32 AppID) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RestartApp), AppID); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_RestartApp); + + return status; +} + +int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), CounterId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_SetGenCount), Count); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_ES_SetGenCount); + + return status; +} + diff --git a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c index c5019fefd..c3711b2a7 100644 --- a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_evs_stubs.c @@ -108,12 +108,13 @@ int32 CFE_EVS_SendEvent(uint16 EventID, const char *Spec, ...) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendEvent), EventID); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendEvent), EventType); + UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), Spec); + int32 status; va_list va; - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &EventID); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &EventType); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), Spec); va_start(va, Spec); status = UT_DEFAULT_IMPL_VARARGS(CFE_EVS_SendEvent, va); va_end(va); @@ -147,13 +148,21 @@ int32 CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, const char *Spec, ...) { + /* + * NOTE: These args are out of order so that Arg[0] and Arg[1] will + * be the same as they are for other EVS calls. This keeps it + * compatible with old/existing UT hook routines. + * Newly-implemented hooks should use the name-based argument + * retrieval so it is independent of the order. + */ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendTimedEvent), EventID); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendTimedEvent), EventType); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendTimedEvent), Time); + UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendTimedEvent), Spec); + int32 status; va_list va; - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &EventID); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &EventType); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &Time); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), Spec); va_start(va, Spec); status = UT_DefaultStubImplWithArgs(__func__, UT_KEY(CFE_EVS_SendTimedEvent), CFE_SUCCESS, va); va_end(va); @@ -187,9 +196,13 @@ int32 CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, ** ******************************************************************************/ int32 CFE_EVS_Register(void *Filters, - uint16 NumEventFilters, + uint16 NumFilteredEvents, uint16 FilterScheme) { + UT_Stub_RegisterContext(UT_KEY(CFE_EVS_Register), Filters); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_Register), NumFilteredEvents); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_Register), FilterScheme); + int32 status; status = UT_DEFAULT_IMPL(CFE_EVS_Register); @@ -226,13 +239,14 @@ int32 CFE_EVS_SendEventWithAppID(uint16 EventID, const char *Spec, ...) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendEventWithAppID), EventID); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendEventWithAppID), EventType); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_SendEventWithAppID), AppID); + UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEventWithAppID), Spec); + int32 status; va_list va; - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &EventID); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &EventType); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), &AppID); - UT_Stub_RegisterContext(UT_KEY(CFE_EVS_SendEvent), Spec); va_start(va, Spec); status = UT_DefaultStubImplWithArgs(__func__, UT_KEY(CFE_EVS_SendEventWithAppID), CFE_SUCCESS, va); va_end(va); @@ -275,4 +289,32 @@ int32 CFE_EVS_CleanUpApp(uint32 AppId) return status; } -UT_DEFAULT_STUB(CFE_EVS_ResetAllFilters, ( void )) +int32 CFE_EVS_ResetAllFilters(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_EVS_ResetAllFilters); + + return status; +} + +int32 CFE_EVS_ResetFilter(int16 EventID) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_EVS_ResetFilter), EventID); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_EVS_ResetFilter); + + return status; +} + +int32 CFE_EVS_Unregister(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_EVS_Unregister); + + return status; +} + diff --git a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c b/fsw/cfe-core/ut-stubs/ut_fs_stubs.c index 4324f5bd4..f1e87de4a 100644 --- a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_fs_stubs.c @@ -55,11 +55,13 @@ ** None ** ******************************************************************************/ -void CFE_FS_InitHeader(CFE_FS_Header_t *hdr, const char *Description, uint32 SubType) +void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 SubType) { - memset(hdr,0,sizeof(CFE_FS_Header_t)); - UT_Stub_RegisterContext(UT_KEY(CFE_FS_InitHeader), hdr); + UT_Stub_RegisterContext(UT_KEY(CFE_FS_InitHeader), Hdr); UT_Stub_RegisterContext(UT_KEY(CFE_FS_InitHeader), Description); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_InitHeader), SubType); + + memset(Hdr,0,sizeof(CFE_FS_Header_t)); UT_DEFAULT_IMPL(CFE_FS_InitHeader); } @@ -85,15 +87,18 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *hdr, const char *Description, uint32 Sub ** CFE_FS_Header_t structure in bytes. ** ******************************************************************************/ -int32 CFE_FS_WriteHeader(int32 filedes, CFE_FS_Header_t *hdr) +int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_WriteHeader), FileDes); + UT_Stub_RegisterContext(UT_KEY(CFE_FS_WriteHeader), Hdr); + int32 status; status = UT_DEFAULT_IMPL_RC(CFE_FS_WriteHeader, sizeof(CFE_FS_Header_t)); if (status > 0) { - UT_Stub_CopyFromLocal(UT_KEY(CFE_FS_WriteHeader), (const uint8*)hdr, status); + UT_Stub_CopyFromLocal(UT_KEY(CFE_FS_WriteHeader), (const uint8*)Hdr, status); } return status; @@ -123,6 +128,9 @@ int32 CFE_FS_WriteHeader(int32 filedes, CFE_FS_Header_t *hdr) ******************************************************************************/ int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) { + UT_Stub_RegisterContext(UT_KEY(CFE_FS_ReadHeader), Hdr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ReadHeader), FileDes); + int32 status; status = UT_DEFAULT_IMPL_RC(CFE_FS_ReadHeader, sizeof(CFE_FS_Header_t)); @@ -157,6 +165,9 @@ int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) ******************************************************************************/ int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_SetTimestamp), FileDes); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_SetTimestamp), NewTimestamp); + int32 status; status = UT_DEFAULT_IMPL(CFE_FS_SetTimestamp); @@ -213,6 +224,9 @@ int32 CFE_FS_EarlyInit(void) ******************************************************************************/ int32 CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnly) { + UT_Stub_RegisterContext(UT_KEY(CFE_FS_ExtractFilenameFromPath), OriginalPath); + UT_Stub_RegisterContext(UT_KEY(CFE_FS_ExtractFilenameFromPath), FileNameOnly); + int i,j; int StringLength; int DirMarkIdx; diff --git a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c index 523084d99..304d835c8 100644 --- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_sb_stubs.c @@ -39,7 +39,8 @@ typedef struct { CFE_SB_MsgId_t MsgId; - uint16 Length; + uint32 UserLength; + uint32 TotalLength; uint16 CommandCode; CFE_TIME_SysTime_t TimeStamp; @@ -146,6 +147,10 @@ void CFE_SB_TaskMain(void) int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_CreatePipe), PipeIdPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_CreatePipe), Depth); + UT_Stub_RegisterContext(UT_KEY(CFE_SB_CreatePipe), PipeName); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_CreatePipe); @@ -175,6 +180,8 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, ******************************************************************************/ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_DeletePipe), PipeId); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_DeletePipe); @@ -206,6 +213,10 @@ int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) ******************************************************************************/ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetPipeName), PipeNameBuf); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetPipeName), PipeNameSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetPipeName), PipeId); + uint32 UserBuffSize; uint32 BuffPosition; const char *NameBuff; @@ -261,10 +272,11 @@ int32 CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t ******************************************************************************/ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) { - int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetPipeIdByName), PipeIdPtr); UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetPipeIdByName), PipeName); + + int32 status; + status = UT_DEFAULT_IMPL(CFE_SB_GetPipeIdByName); if (status >= 0) @@ -300,6 +312,8 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) ******************************************************************************/ uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetCmdCode), MsgPtr); + int32 status; uint16 cmdcode = 0; @@ -334,6 +348,8 @@ uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) ******************************************************************************/ CFE_SB_MsgId_t CFE_SB_GetMsgId(const CFE_SB_Msg_t *MsgPtr) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetMsgId), MsgPtr); + CFE_SB_MsgId_t Result; UT_DEFAULT_IMPL(CFE_SB_GetMsgId); @@ -366,6 +382,11 @@ void CFE_SB_InitMsg(void *MsgPtr, uint16 Length, bool Clear) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_InitMsg), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_InitMsg), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_InitMsg), Length); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_InitMsg), Clear); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_InitMsg); @@ -373,7 +394,7 @@ void CFE_SB_InitMsg(void *MsgPtr, if (status >= 0) { CFE_SB_StubMsg_GetMetaData(MsgPtr)->MsgId = MsgId; - CFE_SB_StubMsg_GetMetaData(MsgPtr)->Length = Length; + CFE_SB_StubMsg_GetMetaData(MsgPtr)->TotalLength = Length; UT_Stub_CopyToLocal(UT_KEY(CFE_SB_InitMsg), (uint8*)MsgPtr, Length); } @@ -399,6 +420,10 @@ int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_RcvMsg), BufPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_RcvMsg), PipeId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_RcvMsg), TimeOut); + int32 status; static union { @@ -448,20 +473,21 @@ int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, */ int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_SendMsg), MsgPtr); + int32 status = CFE_SUCCESS; /* * Create a context entry so a hook function * could do something useful with the message */ - UT_Stub_RegisterContext(UT_KEY(CFE_SB_SendMsg), MsgPtr); status = UT_DEFAULT_IMPL(CFE_SB_SendMsg); if (status >= 0) { UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_SendMsg), MsgPtr->Byte, - CFE_SB_StubMsg_GetMetaData(MsgPtr)->Length); + CFE_SB_StubMsg_GetMetaData(MsgPtr)->TotalLength); } return status; @@ -484,6 +510,9 @@ int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) ******************************************************************************/ int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetCmdCode), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetCmdCode), CmdCode); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_SetCmdCode); @@ -513,6 +542,9 @@ int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) ******************************************************************************/ void CFE_SB_SetMsgId(CFE_SB_MsgPtr_t MsgPtr, CFE_SB_MsgId_t MsgId) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetMsgId), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetMsgId), MsgId); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_SetMsgId); @@ -540,15 +572,18 @@ void CFE_SB_SetMsgId(CFE_SB_MsgPtr_t MsgPtr, CFE_SB_MsgId_t MsgId) ** Returns CFE_SUCCESS. ** ******************************************************************************/ -int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, CFE_TIME_SysTime_t time) +int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, CFE_TIME_SysTime_t Time) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetMsgTime), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetMsgTime), Time); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_SetMsgTime); if (status == 0) { - CFE_SB_StubMsg_GetMetaData(MsgPtr)->TimeStamp = time; + CFE_SB_StubMsg_GetMetaData(MsgPtr)->TimeStamp = Time; } return status; @@ -577,10 +612,13 @@ int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, CFE_TIME_SysTime_t time) int32 CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, uint16 MsgLim) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeEx), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeEx), PipeId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeEx), Quality); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeEx), MsgLim); + int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_SB_SubscribeEx), &MsgId); - UT_Stub_RegisterContext(UT_KEY(CFE_SB_SubscribeEx), &PipeId); status = UT_DEFAULT_IMPL(CFE_SB_SubscribeEx); return status; @@ -608,10 +646,11 @@ int32 CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, ******************************************************************************/ int32 CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_Subscribe), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_Subscribe), PipeId); + int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_SB_Subscribe), &MsgId); - UT_Stub_RegisterContext(UT_KEY(CFE_SB_Subscribe), &PipeId); status = UT_DEFAULT_IMPL(CFE_SB_Subscribe); return status; @@ -641,10 +680,12 @@ int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint16 MsgLim) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeLocal), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeLocal), PipeId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SubscribeLocal), MsgLim); + int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_SB_SubscribeLocal), &MsgId); - UT_Stub_RegisterContext(UT_KEY(CFE_SB_SubscribeLocal), &PipeId); status = UT_DEFAULT_IMPL(CFE_SB_SubscribeLocal); return status; @@ -667,6 +708,8 @@ int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, ******************************************************************************/ void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_TimeStampMsg), MsgPtr); + UT_DEFAULT_IMPL(CFE_SB_TimeStampMsg); UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TimeStampMsg), &MsgPtr, sizeof(MsgPtr)); } @@ -689,6 +732,8 @@ void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) ******************************************************************************/ uint16 CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) { + UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetTotalMsgLength), MsgPtr); + int32 status; uint16 result; @@ -700,7 +745,7 @@ uint16 CFE_SB_GetTotalMsgLength(const CFE_SB_Msg_t *MsgPtr) } else { - result = CFE_SB_StubMsg_GetMetaData(MsgPtr)->Length; + result = CFE_SB_StubMsg_GetMetaData(MsgPtr)->TotalLength; } return result; } @@ -737,10 +782,13 @@ int32 CFE_SB_CleanUpApp(uint32 AppId) */ int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, uint32 DestMaxSize, uint32 SourceMaxSize) { - int32 status; - UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), DestStringPtr); UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), SourceStringPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), DefaultString); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_MessageStringGet), DestMaxSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_MessageStringGet), SourceMaxSize); + + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_MessageStringGet); @@ -773,7 +821,6 @@ int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, return status; } - /****************************************************************************** ** Function: CFE_SB_MessageStringSet() ** @@ -782,10 +829,12 @@ int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, */ int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, uint32 DestMaxSize, uint32 SourceMaxSize) { - int32 status; + UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringSet), DestStringPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringSet), SourceStringPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_MessageStringSet), DestMaxSize); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_MessageStringSet), SourceMaxSize); - UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), DestStringPtr); - UT_Stub_RegisterContext(UT_KEY(CFE_SB_MessageStringGet), SourceStringPtr); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_MessageStringSet); @@ -813,7 +862,17 @@ int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, return status; } -UT_DEFAULT_STUB(CFE_SB_Unsubscribe, (CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId)) +int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_Unsubscribe), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_Unsubscribe), PipeId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_Unsubscribe); + + return status; +} /****************************************************************************** ** Function: CFE_SB_GetMsgTime() @@ -830,6 +889,8 @@ UT_DEFAULT_STUB(CFE_SB_Unsubscribe, (CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI */ CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetMsgTime), MsgPtr); + CFE_TIME_SysTime_t TimeFromMsg; UT_DEFAULT_IMPL(CFE_SB_GetMsgTime); @@ -845,6 +906,8 @@ CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) bool CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ValidateChecksum), MsgPtr); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_ValidateChecksum); @@ -854,6 +917,8 @@ bool CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr) void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetUserData), MsgPtr); + uint8 *BytePtr; void *Result; uint16 HdrSize; @@ -880,6 +945,9 @@ void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr) void CFE_SB_SetTotalMsgLength (CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetTotalMsgLength), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetTotalMsgLength), TotalLength); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_SetTotalMsgLength); @@ -887,12 +955,14 @@ void CFE_SB_SetTotalMsgLength (CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength) if (status == 0) { UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_SetTotalMsgLength), &TotalLength, sizeof(TotalLength)); - CFE_SB_StubMsg_GetMetaData(MsgPtr)->Length = TotalLength; + CFE_SB_StubMsg_GetMetaData(MsgPtr)->TotalLength = TotalLength; } } uint32 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetPktType), MsgId); + int32 status; status = UT_DEFAULT_IMPL(CFE_SB_GetPktType); @@ -900,3 +970,169 @@ uint32 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId) return status; } +void CFE_SB_GenerateChecksum(CFE_SB_MsgPtr_t MsgPtr) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GenerateChecksum), MsgPtr); + + UT_DEFAULT_IMPL(CFE_SB_GenerateChecksum); +} + +uint16 CFE_SB_GetChecksum(CFE_SB_MsgPtr_t MsgPtr) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetChecksum), MsgPtr); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_GetChecksum); + + return status; +} + +uint32 CFE_SB_GetLastSenderId(CFE_SB_SenderId_t **Ptr, CFE_SB_PipeId_t PipeId) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetLastSenderId), Ptr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetLastSenderId), PipeId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_GetLastSenderId); + + return status; +} + +int32 CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptPtr) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetPipeOpts), PipeId); + UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetPipeOpts), OptPtr); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_GetPipeOpts); + + return status; +} + +uint16 CFE_SB_GetUserDataLength(const CFE_SB_Msg_t *MsgPtr) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_SB_GetUserDataLength), MsgPtr); + + int32 status; + + status = UT_DEFAULT_IMPL_RC(CFE_SB_GetUserDataLength, -1); + if (status < 0) + { + status = CFE_SB_StubMsg_GetMetaData(MsgPtr)->UserLength; + } + + return status; +} + +bool CFE_SB_IsValidMsgId(CFE_SB_MsgId_t MsgId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_IsValidMsgId), MsgId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_IsValidMsgId); + + return status; +} + +int32 CFE_SB_PassMsg(CFE_SB_Msg_t *MsgPtr) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_SB_PassMsg), MsgPtr); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_PassMsg); + + return status; +} + +int32 CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetPipeOpts), PipeId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetPipeOpts), Opts); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_SetPipeOpts); + + return status; +} + +void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr, uint16 DataLength) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetUserDataLength), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_SetUserDataLength), DataLength); + + UT_DEFAULT_IMPL(CFE_SB_SetUserDataLength); + CFE_SB_StubMsg_GetMetaData(MsgPtr)->UserLength = DataLength; +} + +int32 CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_UnsubscribeLocal), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_UnsubscribeLocal), PipeId); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_UnsubscribeLocal); + + return status; +} + +CFE_SB_Msg_t* CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, CFE_SB_ZeroCopyHandle_t *BufferHandle) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ZeroCopyGetPtr), MsgSize); + UT_Stub_RegisterContext(UT_KEY(CFE_SB_ZeroCopyGetPtr), BufferHandle); + + int32 status; + CFE_SB_Msg_t* MsgPtr; + + MsgPtr = NULL; + status = UT_DEFAULT_IMPL(CFE_SB_ZeroCopyGetPtr); + if (status == CFE_SUCCESS) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_SB_ZeroCopyGetPtr), &MsgPtr, sizeof(MsgPtr)); + } + + return MsgPtr; +} + +int32 CFE_SB_ZeroCopyPass(CFE_SB_Msg_t *MsgPtr, CFE_SB_ZeroCopyHandle_t BufferHandle) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_SB_ZeroCopyPass), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ZeroCopyPass), BufferHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_ZeroCopyPass); + + return status; +} + +int32 CFE_SB_ZeroCopyReleasePtr(CFE_SB_Msg_t *Ptr2Release, CFE_SB_ZeroCopyHandle_t BufferHandle) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_SB_ZeroCopyReleasePtr), Ptr2Release); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ZeroCopyReleasePtr), BufferHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_ZeroCopyReleasePtr); + + return status; +} + +int32 CFE_SB_ZeroCopySend(CFE_SB_Msg_t *MsgPtr, CFE_SB_ZeroCopyHandle_t BufferHandle) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_SB_ZeroCopySend), MsgPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ZeroCopySend), BufferHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_SB_ZeroCopySend); + + return status; +} + diff --git a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c index a939df970..32a3b2144 100644 --- a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c @@ -105,6 +105,12 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Ret uint16 TblOptionFlags, /* Tbl Options Settings */ CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ) /* Ptr to func that validates tbl */ { + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_Register), TblHandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_Register), Name); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Register), Size); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Register), TblOptionFlags); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Register), TblValidationFuncPtr); + int32 status; status = UT_DEFAULT_IMPL(CFE_TBL_Register); @@ -118,6 +124,9 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Ret int32 CFE_TBL_GetAddress (void **TblPtr, CFE_TBL_Handle_t TblHandle) { + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_GetAddress), TblPtr); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_GetAddress), TblHandle); + int32 status; int32 ForceValue; @@ -130,28 +139,138 @@ int32 CFE_TBL_GetAddress (void **TblPtr, CFE_TBL_Handle_t TblHandle) return status; } -UT_DEFAULT_STUB(CFE_TBL_Load, (CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr)) +int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Load), TblHandle); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Load), SrcType); + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_Load), SrcDataPtr); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_Load); + + return status; +} -UT_DEFAULT_STUB(CFE_TBL_Unregister, (CFE_TBL_Handle_t TblHandle)) +int32 CFE_TBL_Unregister( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Unregister), TblHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_Unregister); + + return status; +} + +int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Manage), TblHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_Manage); + + return status; +} + +int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_ReleaseAddress), TblHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_ReleaseAddress); + + return status; +} + +int32 CFE_TBL_ReleaseAddresses( uint16 NumTables, const CFE_TBL_Handle_t TblHandles[] ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_ReleaseAddresses), NumTables); + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_ReleaseAddresses), TblHandles); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_ReleaseAddresses); + + return status; +} + +int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, uint16 CommandCode, uint32 Parameter) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_NotifyByMessage), TblHandle); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_NotifyByMessage), MsgId); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_NotifyByMessage), CommandCode); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_NotifyByMessage), Parameter); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_NotifyByMessage); + + return status; +} -UT_DEFAULT_STUB(CFE_TBL_Manage, (CFE_TBL_Handle_t TblHandle)) +int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Modified), TblHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_Modified); + + return status; +} + +int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_GetStatus), TblHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_GetStatus); + + return status; +} + +int32 CFE_TBL_DumpToBuffer( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_DumpToBuffer), TblHandle); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_DumpToBuffer); + + return status; +} + +int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Validate), TblHandle); -UT_DEFAULT_STUB(CFE_TBL_ReleaseAddress, (CFE_TBL_Handle_t TblHandle)) + int32 status; -UT_DEFAULT_STUB(CFE_TBL_NotifyByMessage, (CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, uint16 CommandCode, uint32 Parameter)) + status = UT_DEFAULT_IMPL(CFE_TBL_Validate); -UT_DEFAULT_STUB(CFE_TBL_Modified, (CFE_TBL_Handle_t TblHandle )) + return status; +} -UT_DEFAULT_STUB(CFE_TBL_GetStatus, ( CFE_TBL_Handle_t TblHandle )) +int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Update), TblHandle); -UT_DEFAULT_STUB(CFE_TBL_DumpToBuffer, ( CFE_TBL_Handle_t TblHandle )) + int32 status; -UT_DEFAULT_STUB(CFE_TBL_Validate, ( CFE_TBL_Handle_t TblHandle )) + status = UT_DEFAULT_IMPL(CFE_TBL_Update); -UT_DEFAULT_STUB(CFE_TBL_Update, ( CFE_TBL_Handle_t TblHandle )) + return status; +} int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ) { + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_GetInfo), TblInfoPtr); + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_GetInfo), TblName); + int32 status; status = UT_DEFAULT_IMPL(CFE_TBL_GetInfo); @@ -165,4 +284,28 @@ int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ) return status; } +int32 CFE_TBL_GetAddresses( void **TblPtrs[], uint16 NumTables, const CFE_TBL_Handle_t TblHandles[] ) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_GetAddresses), TblPtrs); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_GetAddresses), NumTables); + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_GetAddresses), TblHandles); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_GetAddresses); + + return status; +} + +int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, const char *TblName ) +{ + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_Share), TblHandlePtr); + UT_Stub_RegisterContext(UT_KEY(CFE_TBL_Share), TblName); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TBL_Share); + + return status; +} diff --git a/fsw/cfe-core/ut-stubs/ut_time_stubs.c b/fsw/cfe-core/ut-stubs/ut_time_stubs.c index 495193646..48508d43f 100644 --- a/fsw/cfe-core/ut-stubs/ut_time_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_time_stubs.c @@ -101,14 +101,15 @@ void CFE_TIME_TaskMain(void) ******************************************************************************/ void CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) { + UT_Stub_RegisterContext(UT_KEY(CFE_TIME_Print), PrintBuffer); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Print), TimeToPrint); + snprintf(PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE, "UT %u.%u -", (unsigned int)TimeToPrint.Seconds, (unsigned int)TimeToPrint.Subseconds); - UT_Stub_RegisterContext(UT_KEY(CFE_TIME_Print), PrintBuffer); - UT_Stub_RegisterContext(UT_KEY(CFE_TIME_Print), &TimeToPrint); UT_DEFAULT_IMPL(CFE_TIME_Print); } @@ -181,6 +182,9 @@ int32 CFE_TIME_CleanUpApp(uint32 AppId) CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_t TimeB) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Compare), TimeA); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Compare), TimeB); + int32 status; status = UT_DEFAULT_IMPL(CFE_TIME_Compare); @@ -190,6 +194,9 @@ CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_ CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Add), Time1); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Add), Time2); + static CFE_TIME_SysTime_t SimTime = { 0 }; CFE_TIME_SysTime_t Result = { 0 }; int32 status; @@ -211,6 +218,8 @@ CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Ti uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Sub2MicroSecs), SubSeconds); + int32 status; status = UT_DEFAULT_IMPL(CFE_TIME_Sub2MicroSecs); @@ -218,14 +227,197 @@ uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds) return (uint32) status; } -uint32 CFE_TIME_FS2CFESeconds(uint32 SecondsFS) +int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_UnregisterSynchCallback), CallbackFuncPtr); + int32 status; - status = UT_DEFAULT_IMPL(CFE_TIME_FS2CFESeconds); + status = UT_DEFAULT_IMPL(CFE_TIME_UnregisterSynchCallback); - return (uint32) status; + return status; +} + +void CFE_TIME_ExternalGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_ExternalGPS), NewTime); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_ExternalGPS), NewLeaps); + + UT_DEFAULT_IMPL(CFE_TIME_ExternalGPS); +} + +void CFE_TIME_ExternalMET(CFE_TIME_SysTime_t NewMET) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_ExternalMET), NewMET); + + UT_DEFAULT_IMPL(CFE_TIME_ExternalMET); +} + +void CFE_TIME_ExternalTime(CFE_TIME_SysTime_t NewTime) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_ExternalTime), NewTime); + + UT_DEFAULT_IMPL(CFE_TIME_ExternalTime); +} + +void CFE_TIME_ExternalTone(void) +{ + UT_DEFAULT_IMPL(CFE_TIME_ExternalTone); +} + +uint16 CFE_TIME_GetClockInfo(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetClockInfo); + + return status; +} + +CFE_TIME_ClockState_Enum_t CFE_TIME_GetClockState(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetClockState); + + return status; +} + +int16 CFE_TIME_GetLeapSeconds(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetLeapSeconds); + + return status; +} + +CFE_TIME_SysTime_t CFE_TIME_GetMET(void) +{ + int32 status; + CFE_TIME_SysTime_t Result = { 0 }; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetMET); + if (status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetMET), &Result, sizeof(Result)); + } + + return Result; +} + +uint32 CFE_TIME_GetMETseconds(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetMETseconds); + + return status; +} + +uint32 CFE_TIME_GetMETsubsecs(void) +{ + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetMETsubsecs); + + return status; +} + +CFE_TIME_SysTime_t CFE_TIME_GetSTCF(void) +{ + int32 status; + CFE_TIME_SysTime_t Result = { 0 }; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetSTCF); + if (status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetSTCF), &Result, sizeof(Result)); + } + + return Result; +} + +CFE_TIME_SysTime_t CFE_TIME_GetTAI(void) +{ + int32 status; + CFE_TIME_SysTime_t Result = { 0 }; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetTAI); + if (status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetTAI), &Result, sizeof(Result)); + } + + return Result; +} + +CFE_TIME_SysTime_t CFE_TIME_GetUTC(void) +{ + int32 status; + CFE_TIME_SysTime_t Result = { 0 }; + + status = UT_DEFAULT_IMPL(CFE_TIME_GetUTC); + if (status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetUTC), &Result, sizeof(Result)); + } + + return Result; +} + +CFE_TIME_SysTime_t CFE_TIME_MET2SCTime(CFE_TIME_SysTime_t METTime) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_MET2SCTime), METTime); + + int32 status; + CFE_TIME_SysTime_t Result = { 0 }; + + status = UT_DEFAULT_IMPL(CFE_TIME_MET2SCTime); + if (status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_MET2SCTime), &Result, sizeof(Result)); + } + + return Result; +} + +uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Micro2SubSecs), MicroSeconds); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_Micro2SubSecs); + + return status; +} + +int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_RegisterSynchCallback), CallbackFuncPtr); + + int32 status; + + status = UT_DEFAULT_IMPL(CFE_TIME_RegisterSynchCallback); + + return status; } -UT_DEFAULT_STUB(CFE_TIME_UnregisterSynchCallback, (CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr)) +CFE_TIME_SysTime_t CFE_TIME_Subtract(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) +{ + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Subtract), Time1); + UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Subtract), Time2); + + int32 status; + CFE_TIME_SysTime_t Result = { 0 }; + + status = UT_DEFAULT_IMPL(CFE_TIME_Subtract); + if (status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_Subtract), &Result, sizeof(Result)); + } + + return Result; +} From 03b5343fc5fd5e4636a2b68761026264ef99bd83 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 2 Jul 2020 15:59:58 -0400 Subject: [PATCH 06/14] HOTFIX: correct computation of OSAL_CONFIGURATION_FILE Now that TARGETSYSTEM is a list, it needs to do a foreach on each list component to work the same as it did before. --- cmake/arch_build.cmake | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index 8cea4fc95..1ab843c5d 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -261,15 +261,12 @@ function(prepare) # Choose the configuration file to use for OSAL on this system set(OSAL_CONFIGURATION_FILE) - if (EXISTS "${MISSION_DEFS}/default_osconfig.cmake") - list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/default_osconfig.cmake") - endif() - if (DEFINED OSAL_SYSTEM_OSCONFIG AND EXISTS "${MISSION_DEFS}/${OSAL_SYSTEM_OSCONFIG}_osconfig.cmake") - list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/${OSAL_SYSTEM_OSCONFIG}_osconfig.cmake") - endif() - if (EXISTS "${MISSION_DEFS}/${TARGETSYSTEM}_osconfig.cmake") - list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/${TARGETSYSTEM}_osconfig.cmake") - endif() + foreach(CONFIG ${BUILD_CONFIG_${TARGETSYSTEM}} ${OSAL_SYSTEM_OSCONFIG}) + if (EXISTS "${MISSION_DEFS}/${CONFIG}_osconfig.cmake") + list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/${CONFIG}_osconfig.cmake") + endif() + endforeach() + list(REVERSE OSAL_CONFIGURATION_FILE) set(OSAL_CONFIGURATION_FILE ${OSAL_CONFIGURATION_FILE} PARENT_SCOPE) # Allow sources to "ifdef" certain things if running on simulated hardware From 609f4b4e7c7abb8d7f8f226f7ed11fcd515934b4 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 2 Jul 2020 08:46:30 -0400 Subject: [PATCH 07/14] Fix #752, use OS_READ_ONLY, not O_RDONLY Calls to OS_open() must use the OSAL-defined symbol, not the POSIX symbol. This was a long-standing bug but happened to work because they are both zero. --- fsw/cfe-core/src/es/cfe_es_apps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index 442ce1d4e..abf4e929c 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -94,7 +94,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) /* ** Open the file in the volatile disk. */ - AppFile = OS_open( CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE, O_RDONLY, 0); + AppFile = OS_open( CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE, OS_READ_ONLY, 0); if ( AppFile >= 0 ) { @@ -119,7 +119,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) /* ** Try to Open the file passed in to the cFE start. */ - AppFile = OS_open( (const char *)StartFilePath, O_RDONLY, 0); + AppFile = OS_open( (const char *)StartFilePath, OS_READ_ONLY, 0); if ( AppFile >= 0 ) { From 20935613cf49f932befa3a20c25357c8679a6c0d Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 1 Jul 2020 13:29:29 -0400 Subject: [PATCH 08/14] Fix 766, Add to table search path --- cmake/arch_build.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index 1ab843c5d..143e5c6e2 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -133,6 +133,8 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) set(TBL_SRC "${MISSION_DEFS}/tables/${TBLWE}.c") elseif (EXISTS "${MISSION_SOURCE_DIR}/tables/${TBLWE}.c") set(TBL_SRC "${MISSION_SOURCE_DIR}/tables/${TBLWE}.c") + elseif (EXISTS "${MISSION_DEFS}/${TGT}/tables/${TBLWE}.c") + set(TBL_SRC "${MISSION_DEFS}/${TGT}/tables/${TBLWE}.c") elseif (IS_ABSOLUTE "${TBL}") set(TBL_SRC "${TBL}") else() From 05751157845021f8c06ca29807ffc7da6d9f27d8 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 8 Jul 2020 12:31:56 -0400 Subject: [PATCH 09/14] HOTFIX: confirm that MISSION_DIR is set for all dependencies Adding a subdirectory with an empty/undefined string is interpreted as the current directory, which ends up triggering an infinite loop. This can occur if the variables/lists were modified in an unexpected manner. --- cmake/arch_build.cmake | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index 143e5c6e2..db99d03e9 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -404,7 +404,22 @@ function(process_arch SYSVAR) if (NOT INSTALL_SUBDIR) set(INSTALL_SUBDIR cf) endif (NOT INSTALL_SUBDIR) - + + # confirm that all dependencies have a MISSION_DIR defined that indicates the source. + # This should have been set up by the parent script. However, if any dir is not set, + # 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_MODULES} + ${TGTSYS_${SYSVAR}_PSPMODULES} + ${TGTSYS_${SYSVAR}_STATICAPPS} + ${TGTSYS_${SYSVAR}_APPS}) + if(NOT DEFINED ${DEP}_MISSION_DIR) + message(FATAL_ERROR "ERROR: core module ${DEP} has no MISSION_DIR defined") + endif() + endforeach() + + # Add all core modules # The osal is handled explicitly (above) since this has special extra config foreach(DEP ${MISSION_CORE_MODULES}) From 187adb29ce2e12df30cd8c5847d6f24c0ea9241d Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 9 Jul 2020 17:54:47 -0400 Subject: [PATCH 10/14] Fix #774, trigger error if no include files found Report an error if no files are available to fulfill an include file requirement, rather than leaving an empty file. --- cmake/global_functions.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index 71813f397..45db32955 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -106,14 +106,17 @@ function(generate_config_includefile) # then check for and use the fallback file. # (if specified by the caller it should always exist) # Also produce a message on the console showing whether mission config or fallback was used - if (NOT ITEM_FOUND AND GENCONFIG_ARG_FALLBACK_FILE) + if (ITEM_FOUND) + message(STATUS "Generated ${GENCONFIG_ARG_FILE_NAME} from ${MISSION_DEFS} configuration") + elseif (GENCONFIG_ARG_FALLBACK_FILE) file(TO_NATIVE_PATH "${GENCONFIG_ARG_FALLBACK_FILE}" SRC_NATIVE_PATH) list(APPEND WRAPPER_FILE_CONTENT "\n\n/* No configuration for ${GENCONFIG_ARG_FILE_NAME}, using fallback */\n" "#include \"${GENCONFIG_ARG_FALLBACK_FILE}\"\n") message(STATUS "Using ${GENCONFIG_ARG_FALLBACK_FILE} for ${GENCONFIG_ARG_FILE_NAME}") else() - message(STATUS "Generated ${GENCONFIG_ARG_FILE_NAME} from ${MISSION_DEFS} configuration") + message("ERROR: No implementation for ${GENCONFIG_ARG_FILE_NAME} found") + message(FATAL_ERROR "Tested: ${CHECK_PATH_LIST}") endif() # Generate a header file From 9a5b2a95ebde56b95380cd66c889145e01b9135c Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 9 Jul 2020 09:41:12 -0400 Subject: [PATCH 11/14] Fix #710, allow setting of processor ID in targets.cmake Add support for a TGTx_PROCESSOR_ID directive, which allows one to set the default value returned by CFE_PSP_GetProcessorId() function, rather than assuming the index value from CMake. --- cmake/sample_defs/targets.cmake | 8 ++++++-- cmake/target/CMakeLists.txt | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/sample_defs/targets.cmake b/cmake/sample_defs/targets.cmake index d43dcac02..9ba78bbbb 100644 --- a/cmake/sample_defs/targets.cmake +++ b/cmake/sample_defs/targets.cmake @@ -5,11 +5,15 @@ # This file indicates the architecture and configuration of the # target boards that will run core flight software. # -# The following variables are defined per board, where is the -# CPU number starting with 1: +# The following variables are defined per board, where is a +# sequential index number starting with 1: # # TGT_NAME : the user-friendly name of the cpu. Should be simple # word with no punctuation. This MUST be specified. +# TGT_PROCESSORID : the default numeric ID for this processor at +# runtime. If not specified, then the sequential index number is +# used. This translates to the numeric value returned by +# CFE_PSP_GetProcessorId() at runtime. # TGT_APPLIST : list of applications to build and install on the CPU. # These are built as dynamically-loaded applications and installed # as files in the non-volatile storage of the target, and loaded diff --git a/cmake/target/CMakeLists.txt b/cmake/target/CMakeLists.txt index 35935cb4a..309981d78 100644 --- a/cmake/target/CMakeLists.txt +++ b/cmake/target/CMakeLists.txt @@ -40,7 +40,11 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) # The CPU ID and name are defined by the build scripts for this target if (DEFINED TGTID) - add_definitions(-DCFE_CPU_ID_VALUE=${TGTID}) + if (DEFINED TGT${TGTID}_PROCESSORID) + add_definitions(-DCFE_CPU_ID_VALUE=${TGT${TGTID}_PROCESSORID}) + else() + add_definitions(-DCFE_CPU_ID_VALUE=${TGTID}) + endif() endif() if (DEFINED SPACECRAFT_ID) add_definitions(-DCFE_SPACECRAFT_ID_VALUE=${SPACECRAFT_ID}) From ca77c53b73c616f0976e08645f0f3ccc29f71a78 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Mon, 6 Jul 2020 16:02:19 -0400 Subject: [PATCH 12/14] Resolve #770, Add baseline and build number (#771) Update Version Numbers description to remove statement on Revision number increases with development build Add description for build name and build number. Add buildnumber macro Add CFE_VERSION Add CFE_VERSION_STRING macro Use CFE_VERSION to event messages for different services Check for OSAL_VERSION and CFE_PSP_VERSION macros and populate them with version numbers if they don't exist. Add CFS_VERSIONS macro Use new version string in event messages Use new macros in evs and tbl startup events --- fsw/cfe-core/src/es/cfe_es_task.c | 39 +++++-- fsw/cfe-core/src/evs/cfe_evs_task.c | 7 +- fsw/cfe-core/src/inc/cfe_version.h | 135 +++++++++++++++++++---- fsw/cfe-core/src/sb/cfe_sb_task.c | 3 +- fsw/cfe-core/src/tbl/cfe_tbl_task.c | 3 +- fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c | 3 +- fsw/cfe-core/src/time/cfe_time_task.c | 3 +- 7 files changed, 146 insertions(+), 47 deletions(-) diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 1f7a3aa5d..6423ea9b3 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -351,13 +351,21 @@ int32 CFE_ES_TaskInit(void) return(Status); } - Status = CFE_EVS_SendEvent(CFE_ES_INITSTATS_INF_EID, - CFE_EVS_EventType_INFORMATION, - "Versions:cFE %d.%d.%d.%d, OSAL %d.%d.%d.%d, PSP %d.%d.%d.%d, chksm %d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV, - OS_MAJOR_VERSION,OS_MINOR_VERSION,OS_REVISION,OS_MISSION_REV, - CFE_PSP_MAJOR_VERSION,CFE_PSP_MINOR_VERSION,CFE_PSP_REVISION,CFE_PSP_MISSION_REV, - (int)CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum); +#ifdef CFE_PSP_VERSION + + Status = CFE_EVS_SendEvent(CFE_ES_INITSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, + "\n%s%s\n cFE chksm %d", + CFS_VERSIONS, CFE_PSP_VERSION, (int)CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum); + +#else /* if CFE_PSP_VERSION not defined use integer version macros*/ + Status = CFE_EVS_SendEvent(CFE_ES_INITSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, + "\n%sv%d.%d.%d.%d\n cFE chksm %d", + CFS_VERSIONS, + CFE_PSP_MAJOR_VERSION, CFE_PSP_MINOR_VERSION, CFE_PSP_REVISION, CFE_PSP_MISSION_REV, + (int)CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum); + +#endif /* CFE_PSP_VERSION */ + if ( Status != CFE_SUCCESS ) { CFE_ES_WriteToSysLog("ES:Error sending version event:RC=0x%08X\n", (unsigned int)Status); @@ -788,12 +796,21 @@ int32 CFE_ES_NoopCmd(const CFE_ES_Noop_t *Cmd) ** This command will always succeed. */ CFE_ES_TaskData.CommandCounter++; + + +#ifdef CFE_PSP_VERSION + CFE_EVS_SendEvent(CFE_ES_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, + "No-op command:\n %s%s", + CFS_VERSIONS, CFE_PSP_VERSION); + +#else /* CFE_PSP_VERSION */ + CFE_EVS_SendEvent(CFE_ES_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, - "No-op command. Versions:cFE %d.%d.%d.%d, OSAL %d.%d.%d.%d, PSP %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV, - OS_MAJOR_VERSION,OS_MINOR_VERSION,OS_REVISION,OS_MISSION_REV, - CFE_PSP_MAJOR_VERSION,CFE_PSP_MINOR_VERSION,CFE_PSP_REVISION,CFE_PSP_MISSION_REV); + "No-op command:\n %sv%d.%d.%d.%d", + CFS_VERSIONS, + CFE_PSP_MAJOR_VERSION, CFE_PSP_MINOR_VERSION, CFE_PSP_REVISION, CFE_PSP_MISSION_REV); +#endif /* CFE_PSP_VERSION */ return CFE_SUCCESS; } /* End of CFE_ES_NoopCmd() */ diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index fe9bed2e4..ad5d9e4dc 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -333,8 +333,7 @@ int32 CFE_EVS_TaskInit ( void ) /* Write the AppID to the global location, now that the rest of initialization is done */ CFE_EVS_GlobalData.EVS_AppID = AppID; - EVS_SendEvent(CFE_EVS_STARTUP_EID, CFE_EVS_EventType_INFORMATION, "cFE EVS Initialized. cFE Version %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV); + EVS_SendEvent(CFE_EVS_STARTUP_EID, CFE_EVS_EventType_INFORMATION, "cFE EVS Initialized.\n%s", CFE_VERSION_STRING); return CFE_SUCCESS; @@ -644,8 +643,8 @@ bool CFE_EVS_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength) */ int32 CFE_EVS_NoopCmd(const CFE_EVS_Noop_t *data) { - EVS_SendEvent(CFE_EVS_NOOP_EID, CFE_EVS_EventType_INFORMATION,"No-op command. cFE Version %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV); + EVS_SendEvent(CFE_EVS_NOOP_EID, CFE_EVS_EventType_INFORMATION,"No-op command. %s", + CFE_VERSION_STRING); return CFE_SUCCESS; } diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index 10844e7d0..5e7643bfe 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -19,40 +19,42 @@ */ /* -** File: cfe_version.h -** -** Purpose: -** Provide version identifiers for the cFE core. -*/ + * File: cfe_version.h + * + * Purpose: + * Provide version identifiers for the cFE core. + */ -/** +/* * \page cfeversion Version Numbers * *

Version Number Semantics

* * The version number is a sequence of four numbers, generally separated by dots when written. These are, in order, - * the Major number, the Minor number, the Implementation Revision number, and the Mission Revision number. At + * the Major number, the Minor number, the Revision number, and the Mission Revision number. At * their option, Missions may modify the Mission Revision information as needed to suit their needs. * - * The Major number shall be incremented on release to indicate when there is a change to an API - * that may cause existing correctly-written cFS components to stop working. It may also be incremented for a + * It is important to note that Major, Minor, and Revision numbers are only updated upon official releases of tagged + * versions, \b NOT on development builds. + * + * The MAJOR number shall be incremented on release to indicate when there is a change to an API + * that may cause existing, correctly-written cFS components to stop working. It may also be incremented for a * release that contains changes deemed to be of similar impact, even if there are no actual changes to the API. * - * The Minor number shall be incremented on release to indicate the addition of features to the API, + * The MINOR number shall be incremented on release to indicate the addition of features to the API * which do not break the existing code. It may also be incremented for a release that contains changes deemed * to be of similar impact, even if there are no actual updates to the API. * - * The Implementation Revision Version number shall be incremented on changes to software in the master branch, - * or other changes that benefit from unique identification. It is used for identifying open source development - * versions. It is important to note that Major and Minor numbers are only updated upon official releases - * of tagged versions (see the release tab), \b NOT on development version updates in the master branch. + * The REVISION number shall be incremented on changes that benefit from unique identification such as bug fixes or + * major documentation updates. The Revision number may also be updated if there are other changes contained within a + * release that make it desirable for applications to distinguish one release from another. * - * The Major, Minor, and Implementation Revision numbers are provided in this header file as part of the API + * The Major, Minor, and Revision numbers are provided in this header file as part of the API * definition; this macro must expand to a simple integer value, so that it can be used in simple if directives * by the macro preprocessor. * * The Mission Version number shall be set to zero in all officially released packages, and is entirely reserved - * for the use of the mission. The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h + * for the use of the mission. The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h * header file. * *

Version Number Flexibility

@@ -63,20 +65,29 @@ * The minor number may increment when there have been no augmentations to the API, if changes are as significant as * additions to the public API. * - * The revision numbers may update in implementations where no actual implementation-specific code has changed, if + * The revision numbers may increment in implementations where no actual implementation-specific code has changed, if * there are other changes within the release with similar significance. * *

How and Where Defined

* * The Major, Minor, and Revision components of the version are provided as simple macros defined in the cfe_version.h - * header file as part of the API definition; these macros must expand to simple integer values, so that they can be used - * in simple if directives by the macro preprocessor. + * header file as part of the API definition; these macros must expand to simple integer values, so that they can be + * used in simple if directives by the macro preprocessor. * * The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h header file. As delivered in * official releases, these macros must expand to simple integer values, so that they can be used in simple macro * preprocessor conditions, but delivered code should not prevent a mission from, for example, deciding that the Mission * Version is actually a text string. * + *

Identification of development builds

+ * + * In order to distinguish between development versions, we also provide a BUILDNUMBER. + * + * The BUILD_NUMBER reflects the number of commits since the BUILD_BASELINE, a baseline git tag, for each particular + * component. The BUILD_NUMBER integer increases monotonically for a given development cycle. The development cycle can + * be identified by the BUILD_BASELINE git tag baseline which looks like vX.Y.Z+dev, or by the codename in the version + * string. When a new baseline tag and codename are created, the the BUILD_NUMBER resets to zero and begins increasing + * from that new epoch. */ #ifndef _cfe_version_ @@ -90,12 +101,88 @@ #include + +/* Development Build Macro Definitions */ +#define CFE_BUILD_NUMBER 295 /* Number of commits since baseline */ +#define CFE_BUILD_BASELINE "v6.7.0+dev" /* Number of commits since baseline */ + /* -** Macro Definitions +* Version Macro Definitions +* ONLY APPLY for OFFICIAL releases +*/ +#define CFE_MAJOR_VERSION 6 /**< @brief Major version number */ +#define CFE_MINOR_VERSION 7 /**< @brief Minor version number */ +#define CFE_REVISION 0 /**< @brief Revision number */ +#define CFE_MISSION_REV 0 /**< @brief Mission revision */ + +/* Helper functions to concatenate strings from integer macros */ +#define CFE_STR_HELPER(x) #x +#define CFE_STR(x) CFE_STR_HELPER(x) + +/* Baseling git tag + Number of commits since baseline */ +#define CFE_VERSION CFE_BUILD_BASELINE CFE_STR(CFE_BUILD_NUMBER) + +/* Used to report the full version */ +#define CFE_VERSION_STRING \ + " cFE Development Build\n " \ + CFE_VERSION " (Codename: Bootes)" /* Codename for current development */ \ + "\n Last Offical Release: cfe v6.7.0" /* For full support please use this version */ + + +/* TEMPLATES for Official Releases */ + +/* Official Release format for CFE_VERSION */ + /* + #define CFE_VERSION \ + CFE_STR(CFE_MAJOR_VERSION) "." \ + CFE_STR(CFE_MINOR_VERSION) "." \ + CFE_STR(CFE_REVISION) "." \ + CFE_STR(CFE_MISSION_REV) + */ + + /* Official Release OS_VERSION_STRING Format */ + /* + #define CFE_VERSION_STRING "cFE version " CFE_VERSION + */ + +/* END TEMPLATES */ + + +/* Component Version Definitions */ +/* Here for backwards compatibility for integration test */ -#define CFE_MAJOR_VERSION 6 -#define CFE_MINOR_VERSION 7 -#define CFE_REVISION 21 +#ifndef OS_VERSION /* This will be defined by osal in the future */ +#define OS_VERSION \ + CFE_STR(OS_MAJOR_VERSION) "." \ + CFE_STR(OS_MINOR_VERSION) "." \ + CFE_STR(OS_REVISION) "." \ + CFE_STR(OS_MISSION_REV) +#endif + +/* Combined string with formated combination of all major component versions */ +/* Keeping as a conditional definition based on PSP intricacies */ +#define CFS_VERSIONS \ +"cFS Versions \n" \ + " cfe: " CFE_VERSION "\n" \ + " osal: " OS_VERSION "\n" \ + " psp: " /* CFE_PSP_VERSION is defined at runtime */ + +/* Use the following templates for Official Releases ONLY */ + /* Official Release format for CFE_VERSION */ + /* + #define CFE_VERSION "v" \ + CFE_STR(CFE_MAJOR_VERSION) "." \ + CFE_STR(CFE_MINOR_VERSION) "." \ + CFE_STR(CFE_REVISION) "." \ + CFE_STR(CFE_MISSION_REV) + */ + + /* Official Release format for CFE_VERSION_STRING */ + /* + #define CFE_VERSION_STRING "cFE " CFE_VERSION + */ +/* END TEMPLATES */ + -#endif /* _cfe_version_ */ +#endif /* _cfe_version_ */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/fsw/cfe-core/src/sb/cfe_sb_task.c index 9a1bc200c..b36d2f173 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/fsw/cfe-core/src/sb/cfe_sb_task.c @@ -490,8 +490,7 @@ void CFE_SB_ProcessCmdPipePkt(void) { int32 CFE_SB_NoopCmd(const CFE_SB_Noop_t *data) { CFE_EVS_SendEvent(CFE_SB_CMD0_RCVD_EID,CFE_EVS_EventType_INFORMATION, - "No-op Cmd Rcvd. cFE Version %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV); + "No-op Cmd Rcvd. %s", CFE_VERSION_STRING); CFE_SB.HKTlmMsg.Payload.CommandCounter++; return CFE_SUCCESS; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.c b/fsw/cfe-core/src/tbl/cfe_tbl_task.c index 337ece94f..792917cba 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.c @@ -214,8 +214,7 @@ int32 CFE_TBL_TaskInit(void) /* ** Task startup event message */ - Status = CFE_EVS_SendEvent(CFE_TBL_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "cFE TBL Initialized. cFE Version %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV); + Status = CFE_EVS_SendEvent(CFE_TBL_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "cFE TBL Initialized.\n%s", CFE_VERSION_STRING); if(Status != CFE_SUCCESS) { diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c index 3fad56d95..4c3bc3c81 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -328,8 +328,7 @@ void CFE_TBL_GetTblRegData(void) int32 CFE_TBL_NoopCmd(const CFE_TBL_Noop_t *data) { /* Acknowledge receipt of NOOP with Event Message */ - CFE_EVS_SendEvent(CFE_TBL_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. cFE Version %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV); + CFE_EVS_SendEvent(CFE_TBL_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. %s", CFE_VERSION_STRING); return CFE_TBL_INC_CMD_CTR; diff --git a/fsw/cfe-core/src/time/cfe_time_task.c b/fsw/cfe-core/src/time/cfe_time_task.c index 000073363..98fb4cf47 100644 --- a/fsw/cfe-core/src/time/cfe_time_task.c +++ b/fsw/cfe-core/src/time/cfe_time_task.c @@ -815,8 +815,7 @@ int32 CFE_TIME_NoopCmd(const CFE_TIME_Noop_t *data) CFE_TIME_TaskData.CommandCounter++; CFE_EVS_SendEvent(CFE_TIME_NOOP_EID, CFE_EVS_EventType_INFORMATION, - "No-op command. cFE Version %d.%d.%d.%d", - CFE_MAJOR_VERSION,CFE_MINOR_VERSION,CFE_REVISION,CFE_MISSION_REV); + "No-op command. %s", CFE_VERSION_STRING); return CFE_SUCCESS; From ed0d59f0793a031f44532481ac82e1b5bec62673 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" Date: Mon, 20 Jul 2020 18:50:15 -0400 Subject: [PATCH 13/14] HOTFIX IC-20200624, Move version documentation to doxygen file and other fixes Moved documentation and version code template from cfe_version.h to cfs_versions.dox Rename CFE_VERSION to CFE_SRC_VERSION to avoid conflict with cmake-generated git-based enhanced versioning. Fix doxygen comment structure error. --- cmake/cfe-common.doxyfile.in | 1 + cmake/osal-common.doxyfile.in | 1 + docs/src/cfs_versions.dox | 94 ++++++++++++++++ docs/src/main.dox | 2 +- fsw/cfe-core/src/es/cfe_es_task.c | 4 +- fsw/cfe-core/src/inc/cfe_version.h | 168 ++++++----------------------- 6 files changed, 132 insertions(+), 138 deletions(-) create mode 100644 docs/src/cfs_versions.dox diff --git a/cmake/cfe-common.doxyfile.in b/cmake/cfe-common.doxyfile.in index c06c38697..0fe72ca2f 100644 --- a/cmake/cfe-common.doxyfile.in +++ b/cmake/cfe-common.doxyfile.in @@ -60,6 +60,7 @@ STRIP_FROM_PATH = @MISSION_SOURCE_DIR@ # This is applicable to both users guide and detail design outputs IMAGE_PATH += @MISSION_SOURCE_DIR@/cfe/docs/src INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfe_glossary.dox +INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfs_versions.dox INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfe_api.dox INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfe_es.dox INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfe_evs.dox diff --git a/cmake/osal-common.doxyfile.in b/cmake/osal-common.doxyfile.in index 79cc593f8..4525e2477 100644 --- a/cmake/osal-common.doxyfile.in +++ b/cmake/osal-common.doxyfile.in @@ -36,6 +36,7 @@ STRIP_FROM_PATH = @MISSION_SOURCE_DIR@ # Always include a standard set of CFE documentation in the input set # This is applicable to both users guide and detail design outputs +INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/cfs_versions.dox INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/osal_fs.dox INPUT += @MISSION_SOURCE_DIR@/cfe/docs/src/osal_timer.dox diff --git a/docs/src/cfs_versions.dox b/docs/src/cfs_versions.dox new file mode 100644 index 000000000..d936a6a74 --- /dev/null +++ b/docs/src/cfs_versions.dox @@ -0,0 +1,94 @@ +/** + \page cfsversions Version Numbers + +

Version Number Semantics

+ + The version number is a sequence of four numbers, generally separated by dots when written. These are, in order, + the Major number, the Minor number, the Revision number, and the Mission Revision number. Missions may modify the Mission Revision information as needed to suit their needs. + + It is important to note that Major, Minor, and Revision numbers are only updated upon official releases of tagged + versions, \b NOT on development builds. We aim to follow the Semantic Versioning v2.0 specification with our versioning. + + The MAJOR number shall be incremented on release to indicate when there is a change to an API + that may cause existing, correctly-written cFS components to stop working. It may also be incremented for a + release that contains changes deemed to be of similar impact, even if there are no actual changes to the API. + + The MINOR number shall be incremented on release to indicate the addition of features to the API + which do not break the existing code. It may also be incremented for a release that contains changes deemed + to be of similar impact, even if there are no actual updates to the API. + + The REVISION number shall be incremented on changes that benefit from unique identification such as bug fixes or major documentation updates. The Revision number may also be updated if there are other changes contained within a release that make it desirable for applications to distinguish one release from another. + + The Major, Minor, and Revision numbers are provided in this header file as part of the API + definition; this macro must expand to a simple integer value, so that it can be used in simple if directives by the macro preprocessor. + + The Mission Version number shall be set to zero in all officially released packages, and is entirely reserved for the use of the mission. The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h header file. + +

Version Number Flexibility

+ + The major number may increment when there is no breaking change to the API, if the changes are significant enough to + warrant the same level of attention as a breaking API change. + + The minor number may increment when there have been no augmentations to the API, if changes are as significant as + additions to the public API. + + The revision numbers may increment in implementations where no actual implementation-specific code has changed, if + there are other changes within the release with similar significance. + +

How and Where Defined

+ + The Major, Minor, and Revision components of the version are provided as simple macros defined in the cfe_version.h header file as part of the API definition; these macros must expand to simple integer values, so that they can be used in simple if directives by the macro preprocessor. + + The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h header file. As delivered in official releases, these macros must expand to simple integer values, so that they can be used in simple macro preprocessor conditions, but delivered code should not prevent a mission from, for example, deciding that the Mission Version is actually a text string. + +

Identification of development builds

+ + In order to distinguish between development versions, we also provide a BUILDNUMBER. + + The BUILD_NUMBER reflects the number of commits since the BUILD_BASELINE, a baseline git tag, for each particular + component. The BUILD_NUMBER integer increases monotonically for a given development cycle. The BUILD_BASELINE identifies the current development cycle and is a git tag with format vX.Y.Z. The Codename used in the version string also refers to the current development cycle. When a new baseline tag and codename are created, the the BUILD_NUMBER resets to zero and begins increasing + from a new baseline. + +

Templates for the version and version string

+ + The following templates are the code to be used in cfe_version.h for either official releases or development builds. The apps and repositories follow the same pattern by replacing the CFE_ prefix with the appropriate name; for example, osal uses OS_, psp uses CFE_PSP_IMPL, and so on. + +

Template for Official Releases

+ + \verbatim + + /* Template for Development Builds + + \verbatim + + /*! @brief Development Build Version Number. + * Baseline git tag + Number of commits since baseline. @n + * See cfs_versions.dox for format differences between development and release versions. + */ + #define CFE_SRC_VERSION \ + CFE_BUILD_BASELINE CFE_STR(CFE_BUILD_NUMBER) + + /*! @brief Development Build Version String. + * Reports the current development build's baseline, number, and name. Also includes a note about the latest official version. @n + * See cfs_versions.dox for format differences between development and release versions. + */ + #define CFE_VERSION_STRING \ + " cFE Development Build\n " \ + CFE_SRC_VERSION " (Codename: CONSTELLATION_NAME)" /* Codename for current development */ \ + "\n Last Offical Release: cfe vX.Y.Z" /* For full support please use this version */ + + \endverbatim + +**/ diff --git a/docs/src/main.dox b/docs/src/main.dox index 068aac3cc..d606c38db 100644 --- a/docs/src/main.dox +++ b/docs/src/main.dox @@ -6,7 +6,7 @@
  • \subpage cfebackground
  • \subpage cfeappdocs -
  • \subpage cfeversion +
  • \subpage cfsversions
  • \subpage cfedependencies
  • \subpage cfeacronyms
  • \ref cfeglossary diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 6423ea9b3..8e2f10989 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -388,7 +388,7 @@ int32 CFE_ES_TaskInit(void) Remaining = sizeof(EventBuffer)-strlen(EventBuffer)-1; if(Remaining > 0 && strcmp(GLOBAL_CONFIGDATA.MissionVersion, GLOBAL_CONFIGDATA.CfeVersion)) { - snprintf(VersionBuffer, sizeof(VersionBuffer), ", CFE: %s", + snprintf(VersionBuffer, sizeof(VersionBuffer), ", CFE git version: %s", GLOBAL_CONFIGDATA.CfeVersion); VersionBuffer[Remaining] = 0; strcat(EventBuffer, VersionBuffer); @@ -396,7 +396,7 @@ int32 CFE_ES_TaskInit(void) } if(Remaining > 0 && strcmp(GLOBAL_CONFIGDATA.MissionVersion, GLOBAL_CONFIGDATA.OsalVersion)) { - snprintf(VersionBuffer, sizeof(VersionBuffer), ", OSAL: %s", + snprintf(VersionBuffer, sizeof(VersionBuffer), ", OSAL git version: %s", GLOBAL_CONFIGDATA.OsalVersion); VersionBuffer[Remaining] = 0; strcat(EventBuffer, VersionBuffer); diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index 5e7643bfe..b05c5b5e1 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -18,140 +18,57 @@ ** limitations under the License. */ -/* - * File: cfe_version.h - * - * Purpose: - * Provide version identifiers for the cFE core. - */ - -/* - * \page cfeversion Version Numbers - * - *

    Version Number Semantics

    - * - * The version number is a sequence of four numbers, generally separated by dots when written. These are, in order, - * the Major number, the Minor number, the Revision number, and the Mission Revision number. At - * their option, Missions may modify the Mission Revision information as needed to suit their needs. - * - * It is important to note that Major, Minor, and Revision numbers are only updated upon official releases of tagged - * versions, \b NOT on development builds. - * - * The MAJOR number shall be incremented on release to indicate when there is a change to an API - * that may cause existing, correctly-written cFS components to stop working. It may also be incremented for a - * release that contains changes deemed to be of similar impact, even if there are no actual changes to the API. - * - * The MINOR number shall be incremented on release to indicate the addition of features to the API - * which do not break the existing code. It may also be incremented for a release that contains changes deemed - * to be of similar impact, even if there are no actual updates to the API. - * - * The REVISION number shall be incremented on changes that benefit from unique identification such as bug fixes or - * major documentation updates. The Revision number may also be updated if there are other changes contained within a - * release that make it desirable for applications to distinguish one release from another. - * - * The Major, Minor, and Revision numbers are provided in this header file as part of the API - * definition; this macro must expand to a simple integer value, so that it can be used in simple if directives - * by the macro preprocessor. - * - * The Mission Version number shall be set to zero in all officially released packages, and is entirely reserved - * for the use of the mission. The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h - * header file. - * - *

    Version Number Flexibility

    - * - * The major number may increment when there is no breaking change to the API, if the changes are significant enough to - * warrant the same level of attention as a breaking API change. - * - * The minor number may increment when there have been no augmentations to the API, if changes are as significant as - * additions to the public API. - * - * The revision numbers may increment in implementations where no actual implementation-specific code has changed, if - * there are other changes within the release with similar significance. - * - *

    How and Where Defined

    - * - * The Major, Minor, and Revision components of the version are provided as simple macros defined in the cfe_version.h - * header file as part of the API definition; these macros must expand to simple integer values, so that they can be - * used in simple if directives by the macro preprocessor. - * - * The Mission Version is provided as a simple macro defined in the cfe_platform_cfg.h header file. As delivered in - * official releases, these macros must expand to simple integer values, so that they can be used in simple macro - * preprocessor conditions, but delivered code should not prevent a mission from, for example, deciding that the Mission - * Version is actually a text string. - * - *

    Identification of development builds

    - * - * In order to distinguish between development versions, we also provide a BUILDNUMBER. - * - * The BUILD_NUMBER reflects the number of commits since the BUILD_BASELINE, a baseline git tag, for each particular - * component. The BUILD_NUMBER integer increases monotonically for a given development cycle. The development cycle can - * be identified by the BUILD_BASELINE git tag baseline which looks like vX.Y.Z+dev, or by the codename in the version - * string. When a new baseline tag and codename are created, the the BUILD_NUMBER resets to zero and begins increasing - * from that new epoch. - */ - #ifndef _cfe_version_ #define _cfe_version_ -/* - * The target config contains extended version information within it. +/*! @file cfe_version.h + * @brief Purpose: + * Provide version identifiers for the cFE core. + * + * target_config.h contains extended version information within it. * This information is generated automatically by the build using * git to determine the most recent tag and commit id. + * */ #include /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 295 /* Number of commits since baseline */ -#define CFE_BUILD_BASELINE "v6.7.0+dev" /* Number of commits since baseline */ +#define CFE_BUILD_NUMBER 295 /*!< Development Build: Number of commits since baseline */ +#define CFE_BUILD_BASELINE "v6.7.0" /*!< Development Build: git tag that is the base for the current development */ -/* -* Version Macro Definitions -* ONLY APPLY for OFFICIAL releases -*/ -#define CFE_MAJOR_VERSION 6 /**< @brief Major version number */ -#define CFE_MINOR_VERSION 7 /**< @brief Minor version number */ -#define CFE_REVISION 0 /**< @brief Revision number */ -#define CFE_MISSION_REV 0 /**< @brief Mission revision */ +/* Version Macro Definitions */ -/* Helper functions to concatenate strings from integer macros */ -#define CFE_STR_HELPER(x) #x -#define CFE_STR(x) CFE_STR_HELPER(x) +#define CFE_MAJOR_VERSION 6 /*!< @brief ONLY APPLY for OFFICIAL releases. Major version number. */ +#define CFE_MINOR_VERSION 7 /*!< @brief ONLY APPLY for OFFICIAL releases. Minor version number. */ +#define CFE_REVISION 0 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. */ +#define CFE_MISSION_REV 0 /*!< @brief ONLY USED by MISSION Implementations. Mission revision */ -/* Baseling git tag + Number of commits since baseline */ -#define CFE_VERSION CFE_BUILD_BASELINE CFE_STR(CFE_BUILD_NUMBER) +#define CFE_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer macros */ +#define CFE_STR(x) CFE_STR_HELPER(x) /*!< @brief Helper function to concatenate strings from integer macros */ -/* Used to report the full version */ +/*! @brief Development Build Version Number. + * @details Baseline git tag + Number of commits since baseline. @n + * See @ref cfsversions for format differences between development and release versions. + */ +#define CFE_SRC_VERSION CFE_BUILD_BASELINE "+dev" CFE_STR(CFE_BUILD_NUMBER) + +/*! @brief Development Build Version String. + * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest official version. @n + * See @ref cfsversions for format differences between development and release versions. +*/ #define CFE_VERSION_STRING \ " cFE Development Build\n " \ - CFE_VERSION " (Codename: Bootes)" /* Codename for current development */ \ + CFE_SRC_VERSION " (Codename: Bootes)" /* Codename for current development */ \ "\n Last Offical Release: cfe v6.7.0" /* For full support please use this version */ -/* TEMPLATES for Official Releases */ - -/* Official Release format for CFE_VERSION */ - /* - #define CFE_VERSION \ - CFE_STR(CFE_MAJOR_VERSION) "." \ - CFE_STR(CFE_MINOR_VERSION) "." \ - CFE_STR(CFE_REVISION) "." \ - CFE_STR(CFE_MISSION_REV) - */ - - /* Official Release OS_VERSION_STRING Format */ - /* - #define CFE_VERSION_STRING "cFE version " CFE_VERSION - */ - -/* END TEMPLATES */ - - -/* Component Version Definitions */ -/* Here for backwards compatibility for integration test -*/ -#ifndef OS_VERSION /* This will be defined by osal in the future */ +/*! @brief OSAL Version Definitions. + * @details Allows for backwards compatibility. @n + * This will be defined by osal in the future + */ +#ifndef OS_VERSION #define OS_VERSION \ CFE_STR(OS_MAJOR_VERSION) "." \ CFE_STR(OS_MINOR_VERSION) "." \ @@ -159,30 +76,11 @@ CFE_STR(OS_MISSION_REV) #endif -/* Combined string with formated combination of all major component versions */ -/* Keeping as a conditional definition based on PSP intricacies */ +/*! @brief Combined string with formatted combination of all cFS component versions */ #define CFS_VERSIONS \ "cFS Versions \n" \ - " cfe: " CFE_VERSION "\n" \ + " cfe: " CFE_SRC_VERSION "\n" \ " osal: " OS_VERSION "\n" \ " psp: " /* CFE_PSP_VERSION is defined at runtime */ - -/* Use the following templates for Official Releases ONLY */ - /* Official Release format for CFE_VERSION */ - /* - #define CFE_VERSION "v" \ - CFE_STR(CFE_MAJOR_VERSION) "." \ - CFE_STR(CFE_MINOR_VERSION) "." \ - CFE_STR(CFE_REVISION) "." \ - CFE_STR(CFE_MISSION_REV) - */ - - /* Official Release format for CFE_VERSION_STRING */ - /* - #define CFE_VERSION_STRING "cFE " CFE_VERSION - */ -/* END TEMPLATES */ - - #endif /* _cfe_version_ */ From 343f60d2299e66252dc2903733e2cfe9a524c912 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" Date: Mon, 20 Jul 2020 18:50:15 -0400 Subject: [PATCH 14/14] Increase build number to 289 and update Readme --- README.md | 15 +++++++++++++++ fsw/cfe-core/src/inc/cfe_version.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f0d7c6fb..9fead4740 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,21 @@ The detailed cFE user's guide can be viewed at + ### Development Build: 6.7.21 - If a string is exactly the size of the field when using the `CFE_TBL_FILEDEF()` macro it will produce a compiler error diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index b05c5b5e1..9ae2607b5 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -35,7 +35,7 @@ /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 295 /*!< Development Build: Number of commits since baseline */ +#define CFE_BUILD_NUMBER 289 /*!< Development Build: Number of commits since baseline */ #define CFE_BUILD_BASELINE "v6.7.0" /*!< Development Build: git tag that is the base for the current development */ /* Version Macro Definitions */