From bbc4ff69da5f401f58feaa6c18566e9f94dbb41b Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 29 Apr 2021 10:24:21 -0400 Subject: [PATCH 1/9] Fix #1343, OSAL config file simplification The CFE framework build uses mostly default values for OSAL compile time configuration. There are just a few exceptions where the CFE build is tuned for a more debug-friendly result. This updates the configuration files in "sample_defs" to reflect only those values which are set to a non-default value, along with information about why the configurable item is changed. Currently, these are only items related to debugging. This change also includes more documentation/comments about how this configuration facility works and where to find information on the complete set of options available (which is OSAL version dependent). --- cmake/sample_defs/default_osconfig.cmake | 222 ++++------------------- cmake/sample_defs/native_osconfig.cmake | 38 +++- 2 files changed, 69 insertions(+), 191 deletions(-) diff --git a/cmake/sample_defs/default_osconfig.cmake b/cmake/sample_defs/default_osconfig.cmake index e2767e689..cd33da641 100644 --- a/cmake/sample_defs/default_osconfig.cmake +++ b/cmake/sample_defs/default_osconfig.cmake @@ -1,210 +1,54 @@ ########################################################################## # -# CFE configuration options for OSAL +# CFE-specific configuration options for OSAL # -# This file specifies the default values for various compile-time options -# supported by OSAL. These options can be further tuned by the specific -# OSAL and BSP selection, as well as the user application. +# This file specifies the CFE-specific values for various compile options +# supported by OSAL. # -########################################################################## - - -############################################################## -# Code/Feature Selection Options for the OSAL implementation -############################################################## - - -# OSAL_CONFIG_INCLUDE_NETWORK -# ---------------------------------- -# -# Whether to include the Network API -# -# If set TRUE, the the socket abstraction (if applicable on the platform) -# will be included. If set FALSE, then all calls to the network API will -# return OS_ERR_NOT_IMPLEMENTED. -# -# This can be set FALSE for platforms which do not have a network or -# IP stack available, or to save code space if the application does -# not use network resources. -# -set(OSAL_CONFIG_INCLUDE_NETWORK TRUE) - - -# -# OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER -# ---------------------------------- -# -# Whether to include the capability of loading dynamic code objects -# -# This is normally set TRUE to support modularized applications on -# platforms which have this capability. +# OSAL has many configuration options, which may vary depending on the +# specific version of OSAL in use. The complete list of OSAL options, +# along with a description of each, can be found OSAL source in the file: # -# For deployments which are always statically linked, this may be set -# FALSE for a smaller library size and reduced linking requirements. +# osal/default_config.cmake # -set(OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER TRUE) - - +# A CFE framework build utilizes mostly the OSAL default configuration. +# This file only contains a few specific overrides that tune for a debug +# environment, rather than a deployment environment. # -# OSAL_CONFIG_INCLUDE_STATIC_LOADER -# ---------------------------------- +# ALSO NOTE: There is also an arch-specific addendum to this file +# to allow further tuning on a per-arch basis, in the form of: # -# Whether to include a compatibility "loader" for statically-linked objects +# ${TOOLCHAIN_NAME}_osconfig.cmake # -# This feature allows applications normally written for dynamic module loading -# operate transparently in a static link environment. If this is set TRUE, -# then the application must supply an object named "OS_STATIC_SYMBOL_TABLE" that -# contains the names and addresses of statically-linked symbols that should -# be known to the lookup/load functions. +# See "native_osconfig.cmake" for options which apply only to "native" builds. # -# Note that modules "loaded" using this abstraction are still assigned a -# module ID and still require a slot in the module table even though -# no actual runtime loading is performed (see OSAL_CONFIG_MAX_MODULES). -# -set(OSAL_CONFIG_INCLUDE_STATIC_LOADER TRUE) +########################################################################## # -# OSAL_CONFIG_INCLUDE_SHELL -# ---------------------------------- -# -# Whether to include features which utilize the operating system shell. +# OSAL_CONFIG_DEBUG_PRINTF +# ------------------------ # -# Remote Shell commands can be very powerful tool for remotely diagnosing -# and mitigating runtime issues in the field, but also have significant -# security implications. If this is set to "false" then shell functionality -# is disabled and OSAL functions which invoke the shell will return -# OS_ERR_NOT_IMPLEMENTED. +# For CFE builds this can be helpful during debugging as it will display more +# specific error messages for various OSAL error/warning events, such as if a +# module cannot be loaded or a file cannot be opened for some reason. # -set(OSAL_CONFIG_INCLUDE_SHELL FALSE) - +set(OSAL_CONFIG_DEBUG_PRINTF TRUE) -# -# OSAL_CONFIG_DEBUG_PERMISSIVE_MODE -# ---------------------------------- -# -# The OSAL_CONFIG_DEBUG_PERMISSIVE_MODE option controls how privileged operations -# are handled by the OSAL in the event that the user does not have sufficient permission. -# In particular this applies to task priorities and message queues. -# -# If set FALSE, then all permissions are enforced, and a failure due to lack of permission -# will cause a failure of the overall operation, which is passed back to the application. -# -# If set to TRUE, this will treat some errors non-fatal and enable a graceful fallback, -# allowing the overall operation to complete in a reduced form. This makes the -# OSAL library compatible with a non-root (normal user mode) environment. -# -# In the PC-Linux/Posix build, this means: -# - A message queue deeper than the maximum system limit will be silently truncated -# to the maximum system limit (no error). -# - If the user does not have permission to create elevated priority tasks, then the tasks will -# be created at the default priority (no error). -# -set(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE FALSE) # -# OSAL_CONFIG_DEBUG_PRINTF -# ---------------------------------- +# OSAL_CONFIG_UTILITYTASK_PRIORITY +# -------------------------------- # -# Controls inclusion of OS_DEBUG statements in the code +# Elevate the priority level of the console output helper task # -# If set FALSE, all OS_DEBUG statements are compiled out. +# By default OSAL uses a low-priority utility task to write +# "OS_printf" messages in a deferred manner. However this deferred +# write can potentially cause the messages to appear on the console +# out of sync with the events they are related to. # -# If set TRUE, all the "OS_DEBUG" statements will be compiled in and displayed -# on the debug console. The statements may still be suppressed at runtime. +# Raising the priority of this task from its default to be _higher_ +# than the CFE core tasks means that OS_printf() messages should +# appear on the console in a timely manner, which helps during debug. +# However for a flight deployment this may cause undesired delays. # -set(OSAL_CONFIG_DEBUG_PRINTF TRUE) - - -############################################# -# Resource Limits for the OS API -############################################# - -# The maximum number of concurrently-running tasks to support -set(OSAL_CONFIG_MAX_TASKS 64) - -# The maximum number of queues to support -set(OSAL_CONFIG_MAX_QUEUES 64) - -# The maximum number of counting semaphores to support -set(OSAL_CONFIG_MAX_COUNT_SEMAPHORES 20) - -# The maximum number of binary semaphores to support -set(OSAL_CONFIG_MAX_BIN_SEMAPHORES 20) - -# The maximum number of mutexes to support -set(OSAL_CONFIG_MAX_MUTEXES 20) - -# The maximum number of loadable modules to support -# Note that emulating module loading for statically-linked objects also -# requires a slot in this table, as it still assigns an OSAL ID. -set(OSAL_CONFIG_MAX_MODULES 20) - -# The maximum number of time base objects (reference for timers) -set(OSAL_CONFIG_MAX_TIMEBASES 5) - -# The maximum number of user timers / app callbacks that can be registered -set(OSAL_CONFIG_MAX_TIMERS 10) - -# The maximum number of concurrently open file descriptors to support -set(OSAL_CONFIG_MAX_NUM_OPEN_FILES 50) - -# The maximum number of concurrently open directory descriptors to support -set(OSAL_CONFIG_MAX_NUM_OPEN_DIRS 4) - -# The maximum number of file systems that can be managed by OSAL -set(OSAL_CONFIG_MAX_FILE_SYSTEMS 14) - -# The maximum length for a file name, including any extension -# (This does not include the directory part) -# This length must include an extra character for NULL termination. -set(OSAL_CONFIG_MAX_FILE_NAME 20) - -# Maximum length for an virtual path name (virtual directory + file) -# This length must include an extra character for NULL termination. -set(OSAL_CONFIG_MAX_PATH_LEN 64) - -# Maximum length allowed for a object (task,queue....) name -# This length must include an extra character for NULL termination. -set(OSAL_CONFIG_MAX_API_NAME 20) - -# Maximum length of a symbol name for OS_SymbolLookup() -# This length must include an extra character for NULL termination. -set(OSAL_CONFIG_MAX_SYM_LEN 64) - -# Maximum length of a network socket address -# This is only relevant if network support is included, and the -# required length depends on the address families in use -set(OSAL_CONFIG_SOCKADDR_MAX_LEN 28) - -# Maximum length of a single message produced by OS_printf() -set(OSAL_CONFIG_PRINTF_BUFFER_SIZE 172) - -# Maximum number of OS_printf() messages that will be buffered -set(OSAL_CONFIG_PRINTF_BUFFER_DEPTH 100) - -# Priority level of a console output helper task -# -# Set logically low (high number) to maximize performance. -# - Messages from OS_printf() may show on the console with some delay -# but should have minimal impact to real time tasks. -# -# Set logically high (low number) for debugging -# - Messages from OS_printf() will have more timely output, but may -# adversely impact real time tasks. -set(OSAL_CONFIG_UTILITYTASK_PRIORITY 245) - -# Stack size of console output task. -# -# This applies to RTOS layers with precise stack control, -# normally not necessary to change this unless the task implementation -# changes. -set(OSAL_CONFIG_UTILITYTASK_STACK_SIZE 2048) - -# The size of a command that can be passed to the underlying OS -# This length must include an extra character for NULL termination. -set(OSAL_CONFIG_MAX_CMD_LEN 1000) - -# The maximum depth of an OSAL message queue. -# On some implementations this may affect the overall OSAL memory footprint -# so it may be beneficial to set this limit accordingly. -set(OSAL_CONFIG_QUEUE_MAX_DEPTH 50) +set(OSAL_CONFIG_UTILITYTASK_PRIORITY 10) diff --git a/cmake/sample_defs/native_osconfig.cmake b/cmake/sample_defs/native_osconfig.cmake index 2ddb5f8ed..0e560738a 100644 --- a/cmake/sample_defs/native_osconfig.cmake +++ b/cmake/sample_defs/native_osconfig.cmake @@ -1,5 +1,39 @@ +########################################################################## # -# OSAL configuration addendum when building with SIMULATION=native -# In this mode, enable the PERMISSIVE option, which allows for easier testing. +# CPU/Arch-specific configuration options for OSAL +# +# This file specifies the CFE-specific values for various compile options +# that are used only when compiling using a specific toolchain. +# +# OSAL has many configuration options, which may vary depending on the +# specific version of OSAL in use. The complete list of OSAL options, +# along with a description of each, can be found OSAL source in the file: +# +# osal/default_config.cmake +# +# This file is an addendum to the CFE-specific overrides that will be +# used/enabled when building with the "SIMULATION=native" mode. +# +# See "default_osconfig.cmake" for options which apply only to all builds, +# regardless of toolchain in use. +# +########################################################################## + +# +# OSAL_CONFIG_DEBUG_PERMISSIVE_MODE +# --------------------------------- +# +# When building with SIMULATION=native, enable the PERMISSIVE option, +# which allows for easier testing. This option causes the OSAL to +# continue through certain privleged operations (ignores errors) when +# running as a standard/non-root user. +# +# Typically a regular user on a default Linux workstation configuration +# would not have permission to create realtime priority threads or FIFO +# queues deeper than the soft limit in /proc/sys/fs/mqueue/msg_max. +# +# Note that even with this enabled, OSAL will still _attempt_ to create +# resources as requested, this only makes it so the overall request will +# continue, regardless of whether the privileged operation succeeded or not. # set(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE TRUE) From 63d11eb692b756510f292ff370f5e21c8ad6cc0e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 5 May 2021 14:42:29 -0400 Subject: [PATCH 2/9] Update #1343, Move priority to "native" config file By setting OSAL_CONFIG_UTILITYTASK_PRIORITY in the "native_osconfig" file instead of the default file, it will only apply when building with SIMULATION=native. Deployment builds will use the low priority default value. --- cmake/sample_defs/default_osconfig.cmake | 19 ------------------- cmake/sample_defs/native_osconfig.cmake | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cmake/sample_defs/default_osconfig.cmake b/cmake/sample_defs/default_osconfig.cmake index cd33da641..63be1639a 100644 --- a/cmake/sample_defs/default_osconfig.cmake +++ b/cmake/sample_defs/default_osconfig.cmake @@ -33,22 +33,3 @@ # module cannot be loaded or a file cannot be opened for some reason. # set(OSAL_CONFIG_DEBUG_PRINTF TRUE) - - -# -# OSAL_CONFIG_UTILITYTASK_PRIORITY -# -------------------------------- -# -# Elevate the priority level of the console output helper task -# -# By default OSAL uses a low-priority utility task to write -# "OS_printf" messages in a deferred manner. However this deferred -# write can potentially cause the messages to appear on the console -# out of sync with the events they are related to. -# -# Raising the priority of this task from its default to be _higher_ -# than the CFE core tasks means that OS_printf() messages should -# appear on the console in a timely manner, which helps during debug. -# However for a flight deployment this may cause undesired delays. -# -set(OSAL_CONFIG_UTILITYTASK_PRIORITY 10) diff --git a/cmake/sample_defs/native_osconfig.cmake b/cmake/sample_defs/native_osconfig.cmake index 0e560738a..07e53ea59 100644 --- a/cmake/sample_defs/native_osconfig.cmake +++ b/cmake/sample_defs/native_osconfig.cmake @@ -37,3 +37,22 @@ # continue, regardless of whether the privileged operation succeeded or not. # set(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE TRUE) + + +# +# OSAL_CONFIG_UTILITYTASK_PRIORITY +# -------------------------------- +# +# Elevate the priority level of the console output helper task +# +# By default OSAL uses a low-priority utility task to write +# "OS_printf" messages in a deferred manner. However this deferred +# write can potentially cause the messages to appear on the console +# out of sync with the events they are related to. +# +# Raising the priority of this task from its default to be _higher_ +# than the CFE core tasks means that OS_printf() messages should +# appear on the console in a timely manner, which helps during debug. +# However for a flight deployment this may cause undesired delays. +# +set(OSAL_CONFIG_UTILITYTASK_PRIORITY 10) From 972516c6e8da5eab12fc83c7bbf5bd6977b1a01f Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 29 Apr 2021 20:17:13 -0400 Subject: [PATCH 3/9] Fix #1417, generated coverage stubs for CFE core Update CFE core stub libraries to use generated stubs, using the generator script now part of UT Assert. All existing stub logic is converted to a default handler routine. This also entailed moving all of the internal API prototypes to be in the "core_private" interface lib rather than in "core_api". The only reason this was not done earlier was due to issues with the stubs, but that is alleviated when using generated stubs. --- modules/core_api/fsw/inc/cfe_fs.h | 1 + modules/core_api/ut-stubs/CMakeLists.txt | 24 +- modules/core_api/ut-stubs/src/cfe_es_hooks.c | 596 ++++++++ modules/core_api/ut-stubs/src/cfe_es_stubs.c | 957 ++++++++++++ modules/core_api/ut-stubs/src/cfe_evs_hooks.c | 112 ++ modules/core_api/ut-stubs/src/cfe_evs_stubs.c | 164 +++ modules/core_api/ut-stubs/src/cfe_fs_hooks.c | 333 +++++ modules/core_api/ut-stubs/src/cfe_fs_stubs.c | 246 ++++ modules/core_api/ut-stubs/src/cfe_msg_hooks.c | 362 +++++ modules/core_api/ut-stubs/src/cfe_msg_stubs.c | 624 ++++++++ .../ut-stubs/src/cfe_resourceid_hooks.c | 147 ++ .../ut-stubs/src/cfe_resourceid_stubs.c | 102 ++ modules/core_api/ut-stubs/src/cfe_sb_hooks.c | 438 ++++++ modules/core_api/ut-stubs/src/cfe_sb_stubs.c | 450 ++++++ modules/core_api/ut-stubs/src/cfe_tbl_hooks.c | 87 ++ modules/core_api/ut-stubs/src/cfe_tbl_stubs.c | 302 ++++ .../core_api/ut-stubs/src/cfe_time_hooks.c | 223 +++ .../core_api/ut-stubs/src/cfe_time_stubs.c | 381 +++++ modules/core_api/ut-stubs/src/ut_es_stubs.c | 1296 ----------------- modules/core_api/ut-stubs/src/ut_evs_stubs.c | 313 ---- modules/core_api/ut-stubs/src/ut_fs_stubs.c | 453 ------ modules/core_api/ut-stubs/src/ut_msg_stubs.c | 705 --------- .../ut-stubs/src/ut_resourceid_stubs.c | 120 -- modules/core_api/ut-stubs/src/ut_sb_stubs.c | 774 ---------- modules/core_api/ut-stubs/src/ut_tbl_stubs.c | 311 ---- modules/core_api/ut-stubs/src/ut_time_hooks.c | 229 +++ modules/core_api/ut-stubs/src/ut_time_stubs.c | 419 ------ .../fsw/inc/cfe_es_core_internal.h | 0 .../fsw/inc/cfe_evs_core_internal.h | 0 .../fsw/inc/cfe_fs_core_internal.h | 0 .../fsw/inc/cfe_sb_core_internal.h | 0 modules/core_private/fsw/inc/cfe_sbr.h | 1 + .../fsw/inc/cfe_tbl_core_internal.h | 0 .../fsw/inc/cfe_time_core_internal.h | 0 modules/core_private/ut-stubs/CMakeLists.txt | 7 + .../ut-stubs/src/cfe_es_core_internal_hooks.c | 75 + .../ut-stubs/src/cfe_es_core_internal_stubs.c | 91 ++ .../src/cfe_evs_core_internal_stubs.c | 69 + .../ut-stubs/src/cfe_fs_core_internal_stubs.c | 42 + .../ut-stubs/src/cfe_sb_core_internal_stubs.c | 69 + .../src/cfe_tbl_core_internal_stubs.c | 69 + .../src/cfe_time_core_internal_stubs.c | 69 + .../core_private/ut-stubs/src/ut_support.c | 11 +- 43 files changed, 6263 insertions(+), 4409 deletions(-) create mode 100644 modules/core_api/ut-stubs/src/cfe_es_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_es_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_evs_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_evs_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_fs_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_fs_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_msg_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_msg_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_resourceid_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_resourceid_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_sb_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_sb_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_tbl_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_tbl_stubs.c create mode 100644 modules/core_api/ut-stubs/src/cfe_time_hooks.c create mode 100644 modules/core_api/ut-stubs/src/cfe_time_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_es_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_evs_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_fs_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_msg_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_resourceid_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_sb_stubs.c delete mode 100644 modules/core_api/ut-stubs/src/ut_tbl_stubs.c create mode 100644 modules/core_api/ut-stubs/src/ut_time_hooks.c delete mode 100644 modules/core_api/ut-stubs/src/ut_time_stubs.c rename modules/{core_api => core_private}/fsw/inc/cfe_es_core_internal.h (100%) rename modules/{core_api => core_private}/fsw/inc/cfe_evs_core_internal.h (100%) rename modules/{core_api => core_private}/fsw/inc/cfe_fs_core_internal.h (100%) rename modules/{core_api => core_private}/fsw/inc/cfe_sb_core_internal.h (100%) rename modules/{core_api => core_private}/fsw/inc/cfe_tbl_core_internal.h (100%) rename modules/{core_api => core_private}/fsw/inc/cfe_time_core_internal.h (100%) create mode 100644 modules/core_private/ut-stubs/src/cfe_es_core_internal_hooks.c create mode 100644 modules/core_private/ut-stubs/src/cfe_es_core_internal_stubs.c create mode 100644 modules/core_private/ut-stubs/src/cfe_evs_core_internal_stubs.c create mode 100644 modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c create mode 100644 modules/core_private/ut-stubs/src/cfe_sb_core_internal_stubs.c create mode 100644 modules/core_private/ut-stubs/src/cfe_tbl_core_internal_stubs.c create mode 100644 modules/core_private/ut-stubs/src/cfe_time_core_internal_stubs.c diff --git a/modules/core_api/fsw/inc/cfe_fs.h b/modules/core_api/fsw/inc/cfe_fs.h index 6bca3f5c4..339480b7e 100644 --- a/modules/core_api/fsw/inc/cfe_fs.h +++ b/modules/core_api/fsw/inc/cfe_fs.h @@ -39,6 +39,7 @@ #include "cfe_error.h" #include "cfe_fs_api_typedefs.h" #include "cfe_fs_extern_typedefs.h" +#include "cfe_time_api_typedefs.h" /** @defgroup CFEAPIFSHeader cFE File Header Management APIs * @{ diff --git a/modules/core_api/ut-stubs/CMakeLists.txt b/modules/core_api/ut-stubs/CMakeLists.txt index c7bb0548d..c7e5847d0 100644 --- a/modules/core_api/ut-stubs/CMakeLists.txt +++ b/modules/core_api/ut-stubs/CMakeLists.txt @@ -16,14 +16,22 @@ include_directories(${osal_MISSION_DIR}/ut_assert/inc) # Create the generic stubs library # add_library(ut_core_api_stubs STATIC - src/ut_es_stubs.c - src/ut_evs_stubs.c - src/ut_msg_stubs.c - src/ut_resourceid_stubs.c - src/ut_sb_stubs.c - src/ut_tbl_stubs.c - src/ut_time_stubs.c - src/ut_fs_stubs.c + src/cfe_es_hooks.c + src/cfe_es_stubs.c + src/cfe_evs_hooks.c + src/cfe_evs_stubs.c + src/cfe_fs_hooks.c + src/cfe_fs_stubs.c + src/cfe_msg_hooks.c + src/cfe_msg_stubs.c + src/cfe_resourceid_hooks.c + src/cfe_resourceid_stubs.c + src/cfe_sb_hooks.c + src/cfe_sb_stubs.c + src/cfe_tbl_hooks.c + src/cfe_tbl_stubs.c + src/cfe_time_hooks.c + src/cfe_time_stubs.c ) # Define _CFE_CORE_ within stubs to also reveal internal APIs in header diff --git a/modules/core_api/ut-stubs/src/cfe_es_hooks.c b/modules/core_api/ut-stubs/src/cfe_es_hooks.c new file mode 100644 index 000000000..3c58fc82c --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_es_hooks.c @@ -0,0 +1,596 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_es_stubs.c +** +** Purpose: +** Unit test stubs for Executive Service routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include "cfe_es.h" +#include "cfe_resourceid.h" +#include "cfe_resourceid_basevalue.h" + +#include "utstubs.h" +#include "utassert.h" + +/* + * Assign ID base values for UT + */ +enum +{ + UT_CFE_ES_TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x21), + UT_CFE_ES_APPID_BASE = CFE_RESOURCEID_MAKE_BASE(0x22), + UT_CFE_ES_LIBID_BASE = CFE_RESOURCEID_MAKE_BASE(0x23), + UT_CFE_ES_COUNTID_BASE = CFE_RESOURCEID_MAKE_BASE(0x24), + UT_CFE_ES_POOLID_BASE = CFE_RESOURCEID_MAKE_BASE(0x25), + UT_CFE_ES_CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x26) +}; + +struct UT_AlignTest +{ + char Byte; + CFE_ES_PoolAlign_t Align; +}; + +/* + * Determine the actual alignment of the CFE_ES_PoolAlign_t structure. + * This is done by checking the offset of a struct member of that type following a single byte. + */ +static const cpuaddr UT_ESPOOL_ALIGN_MASK = ((cpuaddr) & ((struct UT_AlignTest *)0)->Align) - 1; + +/* + * Unit-test stub definitions/limits + * + * Note these limits only apply to the ES _stubs_ and not + * the normal implementation. It should not be necessary + * to configure these on a deployment basis. + */ + +/* + * Maximum block size for ES pool requests + * + * This is only for pool block requests where the test + * case does _not_ register its own buffer, and therefore + * gets serviced from the default (static) pool buffer. + * + * This fixed value should be enough for most simple test + * cases. If a test case requires a larger block, it should + * register its own simulated pool using UT_SetDataBuffer, + * rather than changing this value. + */ +#define CFE_UT_ES_POOL_STATIC_BLOCK_SIZE 4096 + +/* + * Default value to return from calls that output an App ID, if the + * test case does not provide a value + */ +#define CFE_UT_ES_DEFAULT_APPID CFE_ES_APPID_C(CFE_ResourceId_FromInteger(UT_CFE_ES_APPID_BASE + 1)) + +/* + * Default value to return from calls that output a Task ID, if the + * test case does not provide a value + */ +#define CFE_UT_ES_DEFAULT_TASKID CFE_ES_TASKID_C(CFE_ResourceId_FromInteger(UT_CFE_ES_TASKID_BASE + 1)) + +/* + * Default value to return from calls that output a CDS ID, if the + * test case does not provide a value + */ +#define CFE_UT_ES_DEFAULT_CDSID CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(UT_CFE_ES_CDSBLOCKID_BASE + 1)) + +/* + * Invalid value to output from calls as resource ID for the + * calls that return failure. If subsequently used by application code, + * it will likely induce a segfault or other noticeably bad behavior. + */ +#define CFE_UT_ES_ID_INVALID CFE_ResourceId_FromInteger(0xDEADBEEF) + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetAppID coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetAppID(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_AppId_t *AppIdPtr = UT_Hook_GetArgValueByName(Context, "AppIdPtr", CFE_ES_AppId_t *); + int32 status; + CFE_ES_AppId_t *IdBuff; + size_t BuffSize; + size_t Position; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppID), (void **)&IdBuff, &BuffSize, &Position); + if (IdBuff != NULL && BuffSize == sizeof(*AppIdPtr)) + { + *AppIdPtr = *IdBuff; + } + else + { + *AppIdPtr = CFE_UT_ES_DEFAULT_APPID; + } + } + + if (status < 0) + { + *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetTaskID coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetTaskID(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_TaskId_t *TaskIdPtr = UT_Hook_GetArgValueByName(Context, "TaskIdPtr", CFE_ES_TaskId_t *); + int32 status; + CFE_ES_TaskId_t *IdBuff; + size_t BuffSize; + size_t Position; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_ES_GetTaskID), (void **)&IdBuff, &BuffSize, &Position); + if (IdBuff != NULL && BuffSize == sizeof(*TaskIdPtr)) + { + *TaskIdPtr = *IdBuff; + } + else + { + *TaskIdPtr = CFE_UT_ES_DEFAULT_TASKID; + } + } + + if (status < 0) + { + *TaskIdPtr = CFE_ES_TASKID_C(CFE_UT_ES_ID_INVALID); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetAppIDByName coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetAppIDByName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_AppId_t *AppIdPtr = UT_Hook_GetArgValueByName(Context, "AppIdPtr", CFE_ES_AppId_t *); + const char * AppName = UT_Hook_GetArgValueByName(Context, "AppName", const char *); + + size_t UserBuffSize; + size_t BuffPosition; + const char * NameBuff; + CFE_ES_AppId_t *IdBuff; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetAppIDByName), 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, AppName, UserBuffSize) == 0) + { + UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppID), (void **)&IdBuff, &UserBuffSize, &BuffPosition); + } + + if (IdBuff != NULL && UserBuffSize == sizeof(*AppIdPtr)) + { + *AppIdPtr = *IdBuff; + } + else + { + *AppIdPtr = CFE_UT_ES_DEFAULT_APPID; + } + } + } + + if (status < 0) + { + *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetAppName coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetAppName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + char * AppName = UT_Hook_GetArgValueByName(Context, "AppName", char *); + size_t BufferLength = UT_Hook_GetArgValueByName(Context, "BufferLength", size_t); + + size_t UserBuffSize; + size_t BuffPosition; + const char *NameBuff; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0 && BufferLength > 0) + { + UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppName), (void **)&NameBuff, &UserBuffSize, &BuffPosition); + if (NameBuff == NULL || UserBuffSize == 0) + { + NameBuff = "UT"; + UserBuffSize = 2; + } + + if (UserBuffSize < BufferLength) + { + BuffPosition = UserBuffSize; + } + else + { + BuffPosition = BufferLength - 1; + } + + strncpy(AppName, NameBuff, BuffPosition); + AppName[BuffPosition] = 0; + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_WriteToSysLog coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_WriteToSysLog(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, + va_list va) +{ + const char *SpecStringPtr = UT_Hook_GetArgValueByName(Context, "SpecStringPtr", const char *); + + int32 status; + char str[128]; + char *newline; + + vsnprintf(str, sizeof(str), SpecStringPtr, va); + + /* Replace newline since UtDebug already adds one */ + newline = strchr(str, '\n'); + if (newline != NULL) + { + *newline = '\0'; + } + + UtDebug("CFE_ES_WriteToSysLog: %s", str); + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_WriteToSysLog), SpecStringPtr, strlen(SpecStringPtr)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetPoolBuf coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetPoolBuf(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_MemPoolBuf_t *BufPtr = UT_Hook_GetArgValueByName(Context, "BufPtr", CFE_ES_MemPoolBuf_t *); + size_t Size = UT_Hook_GetArgValueByName(Context, "Size", size_t); + + static union + { + uint32 Start; + CFE_ES_PoolAlign_t Align; + uint8 Bytes[CFE_UT_ES_POOL_STATIC_BLOCK_SIZE]; + } Buffer; + + size_t PoolSize; + size_t PositionStart; + size_t PositionEnd; + void * PoolPtr; + cpuaddr BufAddrStart; + cpuaddr BufAddrEnd; + int32 status; + + if (!UT_Stub_GetInt32StatusCode(Context, &status)) + { + status = Size; + } + + if (status > 0) + { + Size = status; + + UT_GetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), (void **)&PoolPtr, &PoolSize, &PositionStart); + if (PoolSize == 0) + { + /* + * This means the test case did not register a buffer. + * Use the static buffer to fulfill the request. + */ + PoolPtr = Buffer.Bytes; + PoolSize = sizeof(Buffer); + PositionStart = 0; + } + + BufAddrStart = (cpuaddr)PoolPtr + PositionStart; + BufAddrStart = (BufAddrStart + UT_ESPOOL_ALIGN_MASK) & ~UT_ESPOOL_ALIGN_MASK; + BufAddrEnd = (BufAddrStart + Size + UT_ESPOOL_ALIGN_MASK) & ~UT_ESPOOL_ALIGN_MASK; + PositionEnd = BufAddrEnd - (cpuaddr)PoolPtr; + + if (PositionEnd <= PoolSize) + { + *BufPtr = CFE_ES_MEMPOOLBUF_C(BufAddrStart); + memset((void *)BufAddrStart, 0x55, Size); + + /* + * Unfortunately the UT assert stub library is missing + * the ability to set the buffer position, the only way + * to do it is by calling CopyFromLocal to advance the position. + */ + Size = PositionEnd - PositionStart; + while (Size > sizeof(Buffer)) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), &Buffer, sizeof(Buffer)); + Size -= sizeof(Buffer); + } + UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), &Buffer, Size); + } + else + { + /* + * This a a bug in the test case. + * + * The buffer is insufficient, so the test case must + * use UT_SetDataBuffer() to register a pool buffer that is + * sufficient for the code under test. + */ + UtAssert_Failed("Pool buffer empty in %s: need at least %lu bytes, given %lu", __func__, + (unsigned long)PositionEnd, (unsigned long)PoolSize); + } + } + + UT_Stub_SetReturnValue(FuncKey, status); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_PoolCreate coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_PoolCreate(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_MemHandle_t *PoolID = UT_Hook_GetArgValueByName(Context, "PoolID", CFE_ES_MemHandle_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_ES_PoolCreate), PoolID, sizeof(*PoolID)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_PoolCreateNoSem coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_PoolCreateNoSem(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_MemHandle_t *PoolID = UT_Hook_GetArgValueByName(Context, "PoolID", CFE_ES_MemHandle_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_ES_PoolCreateNoSem), PoolID, sizeof(*PoolID)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetTaskInfo coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetTaskInfo(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_TaskInfo_t *TaskInfo = UT_Hook_GetArgValueByName(Context, "TaskInfo", CFE_ES_TaskInfo_t *); + + int32 status = CFE_SUCCESS; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetTaskInfo), (uint8 *)TaskInfo, sizeof(*TaskInfo)) < sizeof(*TaskInfo)) + { + memset(TaskInfo, 0, sizeof(*TaskInfo)); + TaskInfo->AppId = CFE_UT_ES_DEFAULT_APPID; + strncpy((char *)&TaskInfo->AppName, "UT", sizeof(TaskInfo->AppName)); + strncpy((char *)&TaskInfo->TaskName, "UT", sizeof(TaskInfo->TaskName)); + } + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_ExitApp coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_ExitApp(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + uint32 ExitStatus = UT_Hook_GetArgValueByName(Context, "ExitStatus", uint32); + + UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_ExitApp), &ExitStatus, sizeof(ExitStatus)); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_RunLoop coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_RunLoop(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + bool return_value; + + UT_Stub_GetInt32StatusCode(Context, &status); + + return_value = (status != 0); + + UT_Stub_SetReturnValue(FuncKey, return_value); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_CopyToCDS coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_CopyToCDS(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + void *DataToCopy = UT_Hook_GetArgValueByName(Context, "DataToCopy", void *); + + int32 status; + size_t CdsBufferSize; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + /* query the size of the supplied data buffer, if any */ + UT_GetDataBuffer(UT_KEY(CFE_ES_CopyToCDS), NULL, &CdsBufferSize, NULL); + if (CdsBufferSize > 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_CopyToCDS), DataToCopy, CdsBufferSize); + } + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_RestoreFromCDS coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_RestoreFromCDS(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + void *RestoreToMemory = UT_Hook_GetArgValueByName(Context, "RestoreToMemory", void *); + + int32 status; + size_t CdsBufferSize; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + /* query the size of the supplied data buffer, if any */ + UT_GetDataBuffer(UT_KEY(CFE_ES_RestoreFromCDS), NULL, &CdsBufferSize, NULL); + if (CdsBufferSize > 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory, CdsBufferSize); + } + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_GetResetType coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_GetResetType(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + uint32 *ResetSubtypePtr = UT_Hook_GetArgValueByName(Context, "ResetSubtypePtr", uint32 *); + int32 status = CFE_SUCCESS; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetResetType), ResetSubtypePtr, sizeof(*ResetSubtypePtr)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_AppID_ToIndex coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_AppID_ToIndex(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_AppId_t AppID = UT_Hook_GetArgValueByName(Context, "AppID", CFE_ES_AppId_t); + uint32 * Idx = UT_Hook_GetArgValueByName(Context, "Idx", uint32 *); + int32 return_code; + + UT_Stub_GetInt32StatusCode(Context, &return_code); + + if (return_code != CFE_SUCCESS) + { + *Idx = 0xDEADBEEFU; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_AppID_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) + { + *Idx = CFE_RESOURCEID_TO_ULONG(AppID) & 0xFFFF; + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_TaskID_ToIndex coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_TaskID_ToIndex(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_TaskId_t TaskID = UT_Hook_GetArgValueByName(Context, "TaskID", CFE_ES_TaskId_t); + uint32 * Idx = UT_Hook_GetArgValueByName(Context, "Idx", uint32 *); + int32 return_code; + + UT_Stub_GetInt32StatusCode(Context, &return_code); + + if (return_code != CFE_SUCCESS) + { + *Idx = 0xDEADBEEFU; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_TaskID_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) + { + *Idx = CFE_RESOURCEID_TO_ULONG(TaskID) & 0xFFFF; + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_es_stubs.c b/modules/core_api/ut-stubs/src/cfe_es_stubs.c new file mode 100644 index 000000000..e4c84be40 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_es_stubs.c @@ -0,0 +1,957 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_es header + */ + +#include + +#include "cfe_es.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_ES_AppID_ToIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_CopyToCDS(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_ExitApp(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetAppID(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetAppIDByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetAppName(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetPoolBuf(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetResetType(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetTaskID(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_GetTaskInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_PoolCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_PoolCreateNoSem(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_RestoreFromCDS(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_RunLoop(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_TaskID_ToIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ES_WriteToSysLog(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_AppID_ToIndex() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_AppID_ToIndex, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_AppID_ToIndex, CFE_ES_AppId_t, AppID); + UT_GenStub_AddParam(CFE_ES_AppID_ToIndex, uint32 *, Idx); + + UT_GenStub_Execute(CFE_ES_AppID_ToIndex, Basic, UT_DefaultHandler_CFE_ES_AppID_ToIndex); + + return UT_GenStub_GetReturnValue(CFE_ES_AppID_ToIndex, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_BackgroundWakeup() + * ---------------------------------------------------- + */ +void CFE_ES_BackgroundWakeup(void) +{ + + UT_GenStub_Execute(CFE_ES_BackgroundWakeup, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_CalculateCRC() + * ---------------------------------------------------- + */ +uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputCRC, uint32 TypeCRC) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_CalculateCRC, uint32); + + UT_GenStub_AddParam(CFE_ES_CalculateCRC, const void *, DataPtr); + UT_GenStub_AddParam(CFE_ES_CalculateCRC, size_t, DataLength); + UT_GenStub_AddParam(CFE_ES_CalculateCRC, uint32, InputCRC); + UT_GenStub_AddParam(CFE_ES_CalculateCRC, uint32, TypeCRC); + + UT_GenStub_Execute(CFE_ES_CalculateCRC, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_CalculateCRC, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_CopyToCDS() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_CopyToCDS, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_CopyToCDS, CFE_ES_CDSHandle_t, Handle); + UT_GenStub_AddParam(CFE_ES_CopyToCDS, void *, DataToCopy); + + UT_GenStub_Execute(CFE_ES_CopyToCDS, Basic, UT_DefaultHandler_CFE_ES_CopyToCDS); + + return UT_GenStub_GetReturnValue(CFE_ES_CopyToCDS, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_CounterID_ToIndex() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterID, uint32 *Idx) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_CounterID_ToIndex, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_CounterID_ToIndex, CFE_ES_CounterId_t, CounterID); + UT_GenStub_AddParam(CFE_ES_CounterID_ToIndex, uint32 *, Idx); + + UT_GenStub_Execute(CFE_ES_CounterID_ToIndex, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_CounterID_ToIndex, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_CreateChildTask() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, + CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, + size_t StackSize, CFE_ES_TaskPriority_Atom_t Priority, uint32 Flags) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_CreateChildTask, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_CreateChildTask, CFE_ES_TaskId_t *, TaskIdPtr); + UT_GenStub_AddParam(CFE_ES_CreateChildTask, const char *, TaskName); + UT_GenStub_AddParam(CFE_ES_CreateChildTask, CFE_ES_ChildTaskMainFuncPtr_t, FunctionPtr); + UT_GenStub_AddParam(CFE_ES_CreateChildTask, CFE_ES_StackPointer_t, StackPtr); + UT_GenStub_AddParam(CFE_ES_CreateChildTask, size_t, StackSize); + UT_GenStub_AddParam(CFE_ES_CreateChildTask, CFE_ES_TaskPriority_Atom_t, Priority); + UT_GenStub_AddParam(CFE_ES_CreateChildTask, uint32, Flags); + + UT_GenStub_Execute(CFE_ES_CreateChildTask, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_CreateChildTask, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_DeleteApp() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_DeleteApp, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_DeleteApp, CFE_ES_AppId_t, AppID); + + UT_GenStub_Execute(CFE_ES_DeleteApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_DeleteApp, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_DeleteChildTask() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_DeleteChildTask, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_DeleteChildTask, CFE_ES_TaskId_t, TaskId); + + UT_GenStub_Execute(CFE_ES_DeleteChildTask, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_DeleteChildTask, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_DeleteGenCounter() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_DeleteGenCounter, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_DeleteGenCounter, CFE_ES_CounterId_t, CounterId); + + UT_GenStub_Execute(CFE_ES_DeleteGenCounter, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_DeleteGenCounter, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_ExitApp() + * ---------------------------------------------------- + */ +void CFE_ES_ExitApp(uint32 ExitStatus) +{ + UT_GenStub_AddParam(CFE_ES_ExitApp, uint32, ExitStatus); + + UT_GenStub_Execute(CFE_ES_ExitApp, Basic, UT_DefaultHandler_CFE_ES_ExitApp); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_ExitChildTask() + * ---------------------------------------------------- + */ +void CFE_ES_ExitChildTask(void) +{ + + UT_GenStub_Execute(CFE_ES_ExitChildTask, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetAppID() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetAppID, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetAppID, CFE_ES_AppId_t *, AppIdPtr); + + UT_GenStub_Execute(CFE_ES_GetAppID, Basic, UT_DefaultHandler_CFE_ES_GetAppID); + + return UT_GenStub_GetReturnValue(CFE_ES_GetAppID, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetAppIDByName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetAppIDByName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetAppIDByName, CFE_ES_AppId_t *, AppIdPtr); + UT_GenStub_AddParam(CFE_ES_GetAppIDByName, const char *, AppName); + + UT_GenStub_Execute(CFE_ES_GetAppIDByName, Basic, UT_DefaultHandler_CFE_ES_GetAppIDByName); + + return UT_GenStub_GetReturnValue(CFE_ES_GetAppIDByName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetAppInfo() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetAppInfo, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetAppInfo, CFE_ES_AppInfo_t *, AppInfo); + UT_GenStub_AddParam(CFE_ES_GetAppInfo, CFE_ES_AppId_t, AppId); + + UT_GenStub_Execute(CFE_ES_GetAppInfo, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetAppInfo, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetAppName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetAppName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetAppName, char *, AppName); + UT_GenStub_AddParam(CFE_ES_GetAppName, CFE_ES_AppId_t, AppId); + UT_GenStub_AddParam(CFE_ES_GetAppName, size_t, BufferLength); + + UT_GenStub_Execute(CFE_ES_GetAppName, Basic, UT_DefaultHandler_CFE_ES_GetAppName); + + return UT_GenStub_GetReturnValue(CFE_ES_GetAppName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetCDSBlockIDByName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_CDSHandle_t *BlockIdPtr, const char *BlockName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetCDSBlockIDByName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetCDSBlockIDByName, CFE_ES_CDSHandle_t *, BlockIdPtr); + UT_GenStub_AddParam(CFE_ES_GetCDSBlockIDByName, const char *, BlockName); + + UT_GenStub_Execute(CFE_ES_GetCDSBlockIDByName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetCDSBlockIDByName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetCDSBlockName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_CDSHandle_t BlockId, size_t BufferLength) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetCDSBlockName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetCDSBlockName, char *, BlockName); + UT_GenStub_AddParam(CFE_ES_GetCDSBlockName, CFE_ES_CDSHandle_t, BlockId); + UT_GenStub_AddParam(CFE_ES_GetCDSBlockName, size_t, BufferLength); + + UT_GenStub_Execute(CFE_ES_GetCDSBlockName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetCDSBlockName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetGenCount() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetGenCount, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetGenCount, CFE_ES_CounterId_t, CounterId); + UT_GenStub_AddParam(CFE_ES_GetGenCount, uint32 *, Count); + + UT_GenStub_Execute(CFE_ES_GetGenCount, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetGenCount, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetGenCounterIDByName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetGenCounterIDByName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetGenCounterIDByName, CFE_ES_CounterId_t *, CounterIdPtr); + UT_GenStub_AddParam(CFE_ES_GetGenCounterIDByName, const char *, CounterName); + + UT_GenStub_Execute(CFE_ES_GetGenCounterIDByName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetGenCounterIDByName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetGenCounterName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_CounterId_t CounterId, size_t BufferLength) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetGenCounterName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetGenCounterName, char *, CounterName); + UT_GenStub_AddParam(CFE_ES_GetGenCounterName, CFE_ES_CounterId_t, CounterId); + UT_GenStub_AddParam(CFE_ES_GetGenCounterName, size_t, BufferLength); + + UT_GenStub_Execute(CFE_ES_GetGenCounterName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetGenCounterName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetLibIDByName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetLibIDByName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetLibIDByName, CFE_ES_LibId_t *, LibIdPtr); + UT_GenStub_AddParam(CFE_ES_GetLibIDByName, const char *, LibName); + + UT_GenStub_Execute(CFE_ES_GetLibIDByName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetLibIDByName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetLibInfo() + * ---------------------------------------------------- + */ +int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_LibId_t LibId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetLibInfo, int32); + + UT_GenStub_AddParam(CFE_ES_GetLibInfo, CFE_ES_AppInfo_t *, LibInfo); + UT_GenStub_AddParam(CFE_ES_GetLibInfo, CFE_ES_LibId_t, LibId); + + UT_GenStub_Execute(CFE_ES_GetLibInfo, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetLibInfo, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetLibName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t BufferLength) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetLibName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetLibName, char *, LibName); + UT_GenStub_AddParam(CFE_ES_GetLibName, CFE_ES_LibId_t, LibId); + UT_GenStub_AddParam(CFE_ES_GetLibName, size_t, BufferLength); + + UT_GenStub_Execute(CFE_ES_GetLibName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetLibName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetMemPoolStats() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetMemPoolStats, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetMemPoolStats, CFE_ES_MemPoolStats_t *, BufPtr); + UT_GenStub_AddParam(CFE_ES_GetMemPoolStats, CFE_ES_MemHandle_t, Handle); + + UT_GenStub_Execute(CFE_ES_GetMemPoolStats, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetMemPoolStats, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetModuleInfo() + * ---------------------------------------------------- + */ +int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t ResourceId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetModuleInfo, int32); + + UT_GenStub_AddParam(CFE_ES_GetModuleInfo, CFE_ES_AppInfo_t *, ModuleInfo); + UT_GenStub_AddParam(CFE_ES_GetModuleInfo, CFE_ResourceId_t, ResourceId); + + UT_GenStub_Execute(CFE_ES_GetModuleInfo, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetModuleInfo, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetPoolBuf() + * ---------------------------------------------------- + */ +int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, CFE_ES_MemHandle_t PoolID, size_t Size) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetPoolBuf, int32); + + UT_GenStub_AddParam(CFE_ES_GetPoolBuf, CFE_ES_MemPoolBuf_t *, BufPtr); + UT_GenStub_AddParam(CFE_ES_GetPoolBuf, CFE_ES_MemHandle_t, PoolID); + UT_GenStub_AddParam(CFE_ES_GetPoolBuf, size_t, Size); + + UT_GenStub_Execute(CFE_ES_GetPoolBuf, Basic, UT_DefaultHandler_CFE_ES_GetPoolBuf); + + return UT_GenStub_GetReturnValue(CFE_ES_GetPoolBuf, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetPoolBufInfo() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t PoolID, CFE_ES_MemPoolBuf_t BufPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetPoolBufInfo, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetPoolBufInfo, CFE_ES_MemHandle_t, PoolID); + UT_GenStub_AddParam(CFE_ES_GetPoolBufInfo, CFE_ES_MemPoolBuf_t, BufPtr); + + UT_GenStub_Execute(CFE_ES_GetPoolBufInfo, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetPoolBufInfo, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetResetType() + * ---------------------------------------------------- + */ +int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetResetType, int32); + + UT_GenStub_AddParam(CFE_ES_GetResetType, uint32 *, ResetSubtypePtr); + + UT_GenStub_Execute(CFE_ES_GetResetType, Basic, UT_DefaultHandler_CFE_ES_GetResetType); + + return UT_GenStub_GetReturnValue(CFE_ES_GetResetType, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetTaskID() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetTaskID, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetTaskID, CFE_ES_TaskId_t *, TaskIdPtr); + + UT_GenStub_Execute(CFE_ES_GetTaskID, Basic, UT_DefaultHandler_CFE_ES_GetTaskID); + + return UT_GenStub_GetReturnValue(CFE_ES_GetTaskID, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetTaskIDByName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetTaskIDByName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetTaskIDByName, CFE_ES_TaskId_t *, TaskIdPtr); + UT_GenStub_AddParam(CFE_ES_GetTaskIDByName, const char *, TaskName); + + UT_GenStub_Execute(CFE_ES_GetTaskIDByName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetTaskIDByName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetTaskInfo() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetTaskInfo, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetTaskInfo, CFE_ES_TaskInfo_t *, TaskInfo); + UT_GenStub_AddParam(CFE_ES_GetTaskInfo, CFE_ES_TaskId_t, TaskId); + + UT_GenStub_Execute(CFE_ES_GetTaskInfo, Basic, UT_DefaultHandler_CFE_ES_GetTaskInfo); + + return UT_GenStub_GetReturnValue(CFE_ES_GetTaskInfo, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_GetTaskName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_GetTaskName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_GetTaskName, char *, TaskName); + UT_GenStub_AddParam(CFE_ES_GetTaskName, CFE_ES_TaskId_t, TaskId); + UT_GenStub_AddParam(CFE_ES_GetTaskName, size_t, BufferLength); + + UT_GenStub_Execute(CFE_ES_GetTaskName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_GetTaskName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_IncrementGenCounter() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_IncrementGenCounter, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_IncrementGenCounter, CFE_ES_CounterId_t, CounterId); + + UT_GenStub_Execute(CFE_ES_IncrementGenCounter, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_IncrementGenCounter, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_IncrementTaskCounter() + * ---------------------------------------------------- + */ +void CFE_ES_IncrementTaskCounter(void) +{ + + UT_GenStub_Execute(CFE_ES_IncrementTaskCounter, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_LibID_ToIndex() + * ---------------------------------------------------- + */ +int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibID, uint32 *Idx) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_LibID_ToIndex, int32); + + UT_GenStub_AddParam(CFE_ES_LibID_ToIndex, CFE_ES_LibId_t, LibID); + UT_GenStub_AddParam(CFE_ES_LibID_ToIndex, uint32 *, Idx); + + UT_GenStub_Execute(CFE_ES_LibID_ToIndex, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_LibID_ToIndex, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_Main() + * ---------------------------------------------------- + */ +void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath) +{ + UT_GenStub_AddParam(CFE_ES_Main, uint32, StartType); + UT_GenStub_AddParam(CFE_ES_Main, uint32, StartSubtype); + UT_GenStub_AddParam(CFE_ES_Main, uint32, ModeId); + UT_GenStub_AddParam(CFE_ES_Main, const char *, StartFilePath); + + UT_GenStub_Execute(CFE_ES_Main, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_PerfLogAdd() + * ---------------------------------------------------- + */ +void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit) +{ + UT_GenStub_AddParam(CFE_ES_PerfLogAdd, uint32, Marker); + UT_GenStub_AddParam(CFE_ES_PerfLogAdd, uint32, EntryExit); + + UT_GenStub_Execute(CFE_ES_PerfLogAdd, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_PoolCreate() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_PoolCreate, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_PoolCreate, CFE_ES_MemHandle_t *, PoolID); + UT_GenStub_AddParam(CFE_ES_PoolCreate, void *, MemPtr); + UT_GenStub_AddParam(CFE_ES_PoolCreate, size_t, Size); + + UT_GenStub_Execute(CFE_ES_PoolCreate, Basic, UT_DefaultHandler_CFE_ES_PoolCreate); + + return UT_GenStub_GetReturnValue(CFE_ES_PoolCreate, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_PoolCreateEx() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size, uint16 NumBlockSizes, + const size_t *BlockSizes, bool UseMutex) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_PoolCreateEx, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_PoolCreateEx, CFE_ES_MemHandle_t *, PoolID); + UT_GenStub_AddParam(CFE_ES_PoolCreateEx, void *, MemPtr); + UT_GenStub_AddParam(CFE_ES_PoolCreateEx, size_t, Size); + UT_GenStub_AddParam(CFE_ES_PoolCreateEx, uint16, NumBlockSizes); + UT_GenStub_AddParam(CFE_ES_PoolCreateEx, const size_t *, BlockSizes); + UT_GenStub_AddParam(CFE_ES_PoolCreateEx, bool, UseMutex); + + UT_GenStub_Execute(CFE_ES_PoolCreateEx, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_PoolCreateEx, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_PoolCreateNoSem() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_PoolCreateNoSem, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_PoolCreateNoSem, CFE_ES_MemHandle_t *, PoolID); + UT_GenStub_AddParam(CFE_ES_PoolCreateNoSem, void *, MemPtr); + UT_GenStub_AddParam(CFE_ES_PoolCreateNoSem, size_t, Size); + + UT_GenStub_Execute(CFE_ES_PoolCreateNoSem, Basic, UT_DefaultHandler_CFE_ES_PoolCreateNoSem); + + return UT_GenStub_GetReturnValue(CFE_ES_PoolCreateNoSem, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_PoolDelete() + * ---------------------------------------------------- + */ +int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_PoolDelete, int32); + + UT_GenStub_AddParam(CFE_ES_PoolDelete, CFE_ES_MemHandle_t, PoolID); + + UT_GenStub_Execute(CFE_ES_PoolDelete, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_PoolDelete, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_ProcessAsyncEvent() + * ---------------------------------------------------- + */ +void CFE_ES_ProcessAsyncEvent(void) +{ + + UT_GenStub_Execute(CFE_ES_ProcessAsyncEvent, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_PutPoolBuf() + * ---------------------------------------------------- + */ +int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t PoolID, CFE_ES_MemPoolBuf_t BufPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_PutPoolBuf, int32); + + UT_GenStub_AddParam(CFE_ES_PutPoolBuf, CFE_ES_MemHandle_t, PoolID); + UT_GenStub_AddParam(CFE_ES_PutPoolBuf, CFE_ES_MemPoolBuf_t, BufPtr); + + UT_GenStub_Execute(CFE_ES_PutPoolBuf, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_PutPoolBuf, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_RegisterCDS() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t BlockSize, const char *Name) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_RegisterCDS, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_RegisterCDS, CFE_ES_CDSHandle_t *, HandlePtr); + UT_GenStub_AddParam(CFE_ES_RegisterCDS, size_t, BlockSize); + UT_GenStub_AddParam(CFE_ES_RegisterCDS, const char *, Name); + + UT_GenStub_Execute(CFE_ES_RegisterCDS, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_RegisterCDS, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_RegisterGenCounter() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_RegisterGenCounter, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_RegisterGenCounter, CFE_ES_CounterId_t *, CounterIdPtr); + UT_GenStub_AddParam(CFE_ES_RegisterGenCounter, const char *, CounterName); + + UT_GenStub_Execute(CFE_ES_RegisterGenCounter, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_RegisterGenCounter, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_ReloadApp() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_ReloadApp, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_ReloadApp, CFE_ES_AppId_t, AppID); + UT_GenStub_AddParam(CFE_ES_ReloadApp, const char *, AppFileName); + + UT_GenStub_Execute(CFE_ES_ReloadApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_ReloadApp, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_ResetCFE() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_ResetCFE(uint32 ResetType) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_ResetCFE, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_ResetCFE, uint32, ResetType); + + UT_GenStub_Execute(CFE_ES_ResetCFE, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_ResetCFE, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_RestartApp() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_RestartApp(CFE_ES_AppId_t AppID) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_RestartApp, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_RestartApp, CFE_ES_AppId_t, AppID); + + UT_GenStub_Execute(CFE_ES_RestartApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_RestartApp, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_RestoreFromCDS() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_RestoreFromCDS, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_RestoreFromCDS, void *, RestoreToMemory); + UT_GenStub_AddParam(CFE_ES_RestoreFromCDS, CFE_ES_CDSHandle_t, Handle); + + UT_GenStub_Execute(CFE_ES_RestoreFromCDS, Basic, UT_DefaultHandler_CFE_ES_RestoreFromCDS); + + return UT_GenStub_GetReturnValue(CFE_ES_RestoreFromCDS, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_RunLoop() + * ---------------------------------------------------- + */ +bool CFE_ES_RunLoop(uint32 *ExitStatus) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_RunLoop, bool); + + UT_GenStub_AddParam(CFE_ES_RunLoop, uint32 *, ExitStatus); + + UT_GenStub_Execute(CFE_ES_RunLoop, Basic, UT_DefaultHandler_CFE_ES_RunLoop); + + return UT_GenStub_GetReturnValue(CFE_ES_RunLoop, bool); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_SetGenCount() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_SetGenCount, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_SetGenCount, CFE_ES_CounterId_t, CounterId); + UT_GenStub_AddParam(CFE_ES_SetGenCount, uint32, Count); + + UT_GenStub_Execute(CFE_ES_SetGenCount, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_SetGenCount, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_TaskID_ToIndex() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_TaskID_ToIndex, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_TaskID_ToIndex, CFE_ES_TaskId_t, TaskID); + UT_GenStub_AddParam(CFE_ES_TaskID_ToIndex, uint32 *, Idx); + + UT_GenStub_Execute(CFE_ES_TaskID_ToIndex, Basic, UT_DefaultHandler_CFE_ES_TaskID_ToIndex); + + return UT_GenStub_GetReturnValue(CFE_ES_TaskID_ToIndex, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_WaitForStartupSync() + * ---------------------------------------------------- + */ +void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds) +{ + UT_GenStub_AddParam(CFE_ES_WaitForStartupSync, uint32, TimeOutMilliseconds); + + UT_GenStub_Execute(CFE_ES_WaitForStartupSync, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_WaitForSystemState() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_WaitForSystemState(uint32 MinSystemState, uint32 TimeOutMilliseconds) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_WaitForSystemState, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_WaitForSystemState, uint32, MinSystemState); + UT_GenStub_AddParam(CFE_ES_WaitForSystemState, uint32, TimeOutMilliseconds); + + UT_GenStub_Execute(CFE_ES_WaitForSystemState, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_WaitForSystemState, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_WriteToSysLog() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(CFE_ES_WriteToSysLog, CFE_Status_t); + + UT_GenStub_AddParam(CFE_ES_WriteToSysLog, const char *, SpecStringPtr); + + va_start(UtStub_ArgList, SpecStringPtr); + UT_GenStub_Execute(CFE_ES_WriteToSysLog, Va, UT_DefaultHandler_CFE_ES_WriteToSysLog, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(CFE_ES_WriteToSysLog, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/cfe_evs_hooks.c b/modules/core_api/ut-stubs/src/cfe_evs_hooks.c new file mode 100644 index 000000000..922946286 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_evs_hooks.c @@ -0,0 +1,112 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_evs_stubs.c +** +** Purpose: +** Unit test stubs for Event Service routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include "cfe_evs.h" + +#include "utstubs.h" +#include "uttools.h" + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_EVS_SendEvent coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_EVS_SendEvent(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, + va_list va) +{ + uint16 EventID = UT_Hook_GetArgValueByName(Context, "EventID", uint16); + const char *Spec = UT_Hook_GetArgValueByName(Context, "Spec", const char *); + + int32 status; + + UtDebug("CFE_EVS_SendEvent: %u - %s", EventID, Spec); + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_EVS_SendEvent), (uint8 *)&EventID, sizeof(EventID)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_EVS_SendTimedEvent coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_EVS_SendTimedEvent(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, + va_list va) +{ + uint16 EventID = UT_Hook_GetArgValueByName(Context, "EventID", uint16); + const char *Spec = UT_Hook_GetArgValueByName(Context, "Spec", const char *); + + int32 status; + + UtDebug("CFE_EVS_SendTimedEvent: %u - %s", EventID, Spec); + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_EVS_SendTimedEvent), (uint8 *)&EventID, sizeof(EventID)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_EVS_SendEventWithAppID coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_EVS_SendEventWithAppID(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, + va_list va) +{ + uint16 EventID = UT_Hook_GetArgValueByName(Context, "EventID", uint16); + const char *Spec = UT_Hook_GetArgValueByName(Context, "Spec", const char *); + + int32 status; + + UtDebug("CFE_EVS_SendEventWithAppID: %u - %s", EventID, Spec); + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_EVS_SendEventWithAppID), (uint8 *)&EventID, sizeof(EventID)); + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_evs_stubs.c b/modules/core_api/ut-stubs/src/cfe_evs_stubs.c new file mode 100644 index 000000000..72fd2ec5c --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_evs_stubs.c @@ -0,0 +1,164 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_evs header + */ + +#include + +#include "cfe_evs.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_EVS_SendEvent(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); +extern void UT_DefaultHandler_CFE_EVS_SendEventWithAppID(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); +extern void UT_DefaultHandler_CFE_EVS_SendTimedEvent(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_Register() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_Register(const void *Filters, uint16 NumFilteredEvents, uint16 FilterScheme) +{ + UT_GenStub_SetupReturnBuffer(CFE_EVS_Register, CFE_Status_t); + + UT_GenStub_AddParam(CFE_EVS_Register, const void *, Filters); + UT_GenStub_AddParam(CFE_EVS_Register, uint16, NumFilteredEvents); + UT_GenStub_AddParam(CFE_EVS_Register, uint16, FilterScheme); + + UT_GenStub_Execute(CFE_EVS_Register, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_EVS_Register, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_ResetAllFilters() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_ResetAllFilters(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_EVS_ResetAllFilters, CFE_Status_t); + + UT_GenStub_Execute(CFE_EVS_ResetAllFilters, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_EVS_ResetAllFilters, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_ResetFilter() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_ResetFilter(int16 EventID) +{ + UT_GenStub_SetupReturnBuffer(CFE_EVS_ResetFilter, CFE_Status_t); + + UT_GenStub_AddParam(CFE_EVS_ResetFilter, int16, EventID); + + UT_GenStub_Execute(CFE_EVS_ResetFilter, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_EVS_ResetFilter, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_SendEvent() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(CFE_EVS_SendEvent, CFE_Status_t); + + UT_GenStub_AddParam(CFE_EVS_SendEvent, uint16, EventID); + UT_GenStub_AddParam(CFE_EVS_SendEvent, uint16, EventType); + UT_GenStub_AddParam(CFE_EVS_SendEvent, const char *, Spec); + + va_start(UtStub_ArgList, Spec); + UT_GenStub_Execute(CFE_EVS_SendEvent, Va, UT_DefaultHandler_CFE_EVS_SendEvent, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(CFE_EVS_SendEvent, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_SendEventWithAppID() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_SendEventWithAppID(uint16 EventID, uint16 EventType, CFE_ES_AppId_t AppID, const char *Spec, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(CFE_EVS_SendEventWithAppID, CFE_Status_t); + + UT_GenStub_AddParam(CFE_EVS_SendEventWithAppID, uint16, EventID); + UT_GenStub_AddParam(CFE_EVS_SendEventWithAppID, uint16, EventType); + UT_GenStub_AddParam(CFE_EVS_SendEventWithAppID, CFE_ES_AppId_t, AppID); + UT_GenStub_AddParam(CFE_EVS_SendEventWithAppID, const char *, Spec); + + va_start(UtStub_ArgList, Spec); + UT_GenStub_Execute(CFE_EVS_SendEventWithAppID, Va, UT_DefaultHandler_CFE_EVS_SendEventWithAppID, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(CFE_EVS_SendEventWithAppID, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_SendTimedEvent() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(CFE_EVS_SendTimedEvent, CFE_Status_t); + + UT_GenStub_AddParam(CFE_EVS_SendTimedEvent, CFE_TIME_SysTime_t, Time); + UT_GenStub_AddParam(CFE_EVS_SendTimedEvent, uint16, EventID); + UT_GenStub_AddParam(CFE_EVS_SendTimedEvent, uint16, EventType); + UT_GenStub_AddParam(CFE_EVS_SendTimedEvent, const char *, Spec); + + va_start(UtStub_ArgList, Spec); + UT_GenStub_Execute(CFE_EVS_SendTimedEvent, Va, UT_DefaultHandler_CFE_EVS_SendTimedEvent, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(CFE_EVS_SendTimedEvent, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_Unregister() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_EVS_Unregister(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_EVS_Unregister, CFE_Status_t); + + UT_GenStub_Execute(CFE_EVS_Unregister, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_EVS_Unregister, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/cfe_fs_hooks.c b/modules/core_api/ut-stubs/src/cfe_fs_hooks.c new file mode 100644 index 000000000..4781f0d82 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_fs_hooks.c @@ -0,0 +1,333 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_fs_stubs.c +** +** Purpose: +** Unit test stubs for File Service routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include "cfe.h" +#include "utstubs.h" + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_GetDefaultMountPoint coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_GetDefaultMountPoint(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + int32 Status; + static const char DEFAULT_MOUNTPOINT[] = "/ut"; + const char * Result; + + UT_Stub_GetInt32StatusCode(Context, &Status); + Result = NULL; + + if (Status == CFE_SUCCESS) + { + /* If the test case supplied a buffer, return it, otherwise return fixed value */ + UT_GetDataBuffer(UT_KEY(CFE_FS_GetDefaultMountPoint), (void **)&Result, NULL, NULL); + if (Result == NULL) + { + Result = DEFAULT_MOUNTPOINT; + } + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_GetDefaultExtension coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_GetDefaultExtension(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 Status; + static const char DEFAULT_EXTENSION[] = ".ut"; + const char * Result; + + UT_Stub_GetInt32StatusCode(Context, &Status); + Result = NULL; + + if (Status == CFE_SUCCESS) + { + /* If the test case supplied a buffer, return it, otherwise return fixed value */ + UT_GetDataBuffer(UT_KEY(CFE_FS_GetDefaultExtension), (void **)&Result, NULL, NULL); + if (Result == NULL) + { + Result = DEFAULT_EXTENSION; + } + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_WriteHeader coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_WriteHeader(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_FS_Header_t *Hdr = UT_Hook_GetArgValueByName(Context, "Hdr", CFE_FS_Header_t *); + + int32 status; + + if (!UT_Stub_GetInt32StatusCode(Context, &status)) + { + status = sizeof(CFE_FS_Header_t); + UT_Stub_SetReturnValue(FuncKey, status); + } + + if (status > 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_FS_WriteHeader), Hdr, status); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_ReadHeader coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_ReadHeader(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_FS_Header_t *Hdr = UT_Hook_GetArgValueByName(Context, "Hdr", CFE_FS_Header_t *); + + int32 status; + + if (!UT_Stub_GetInt32StatusCode(Context, &status)) + { + status = sizeof(CFE_FS_Header_t); + UT_Stub_SetReturnValue(FuncKey, status); + } + + if (status > 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ReadHeader), Hdr, status); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_RunBackgroundFileDump coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_RunBackgroundFileDump(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + int32 status; + bool return_value; + + UT_Stub_GetInt32StatusCode(Context, &status); + + return_value = status; + + UT_Stub_SetReturnValue(FuncKey, return_value); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_ParseInputFileNameEx coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_ParseInputFileNameEx(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + char * OutputBuffer = UT_Hook_GetArgValueByName(Context, "OutputBuffer", char *); + size_t OutputBufSize = UT_Hook_GetArgValueByName(Context, "OutputBufSize", size_t); + const char *DefaultInput = UT_Hook_GetArgValueByName(Context, "DefaultInput", const char *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + /* Copy any specific output supplied by test case */ + if (status >= 0 && UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ParseInputFileNameEx), OutputBuffer, OutputBufSize) == 0 && + OutputBufSize > 0 && DefaultInput != NULL) + { + /* Otherwise fall back to simple copy */ + strncpy(OutputBuffer, DefaultInput, OutputBufSize); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_ParseInputFileName coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_ParseInputFileName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + char * OutputBuffer = UT_Hook_GetArgValueByName(Context, "OutputBuffer", char *); + size_t OutputBufSize = UT_Hook_GetArgValueByName(Context, "OutputBufSize", size_t); + const char *InputName = UT_Hook_GetArgValueByName(Context, "InputName", const char *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + /* Copy any specific output supplied by test case */ + if (status >= 0 && UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ParseInputFileName), OutputBuffer, OutputBufSize) == 0 && + OutputBufSize > 0) + { + /* Otherwise fall back to simple copy */ + strncpy(OutputBuffer, InputName, OutputBufSize); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_ExtractFilenameFromPath coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_ExtractFilenameFromPath(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + const char *OriginalPath = UT_Hook_GetArgValueByName(Context, "OriginalPath", const char *); + char * FileNameOnly = UT_Hook_GetArgValueByName(Context, "FileNameOnly", char *); + + int i, j; + int StringLength; + int DirMarkIdx; + int32 status; + uint32 UserBuffLen; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (OriginalPath == NULL || FileNameOnly == NULL) + { + status = CFE_FS_BAD_ARGUMENT; + } + else + { + UserBuffLen = UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ExtractFilenameFromPath), FileNameOnly, OS_MAX_FILE_NAME); + + if (UserBuffLen >= OS_MAX_FILE_NAME) + { + FileNameOnly[OS_MAX_FILE_NAME - 1] = 0; + } + else if (UserBuffLen > 0) + { + /* Just ensure that the output is null terminated */ + FileNameOnly[UserBuffLen] = 0; + } + else + { + /* Get the string length of the original file path */ + StringLength = strlen(OriginalPath); + + /* Extract the filename from the Path: + Find the last '/' Character */ + DirMarkIdx = -1; + + for (i = 0; i < StringLength; i++) + { + if (OriginalPath[i] == '/') + { + DirMarkIdx = i; + } + } + + /* Verify the filename isn't too long */ + if ((StringLength - (DirMarkIdx + 1)) < OS_MAX_PATH_LEN) + { + /* Extract the filename portion */ + if (DirMarkIdx > 0) + { + /* Extract the filename portion */ + j = 0; + + for (i = DirMarkIdx + 1; i < StringLength; i++) + { + FileNameOnly[j] = OriginalPath[i]; + j++; + } + + FileNameOnly[j] = '\0'; + } + else + { + status = CFE_FS_INVALID_PATH; + } + } + else + { + status = CFE_FS_FNAME_TOO_LONG; + } + } + } + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_BackgroundFileDumpIsPending coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_BackgroundFileDumpIsPending(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + int32 status; + bool return_value; + + UT_Stub_GetInt32StatusCode(Context, &status); + + return_value = status; + + UT_Stub_SetReturnValue(FuncKey, return_value); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_BackgroundFileDumpRequest coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_BackgroundFileDumpRequest(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + CFE_FS_FileWriteMetaData_t *Meta = UT_Hook_GetArgValueByName(Context, "Meta", CFE_FS_FileWriteMetaData_t *); + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status == CFE_SUCCESS) + { + /* Snapshot the request, in case the UT test case wants to look */ + UT_Stub_CopyFromLocal(UT_KEY(CFE_FS_BackgroundFileDumpRequest), Meta, sizeof(*Meta)); + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_fs_stubs.c b/modules/core_api/ut-stubs/src/cfe_fs_stubs.c new file mode 100644 index 000000000..442649f57 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_fs_stubs.c @@ -0,0 +1,246 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_fs header + */ + +#include "cfe_fs.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_FS_BackgroundFileDumpIsPending(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_BackgroundFileDumpRequest(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_ExtractFilenameFromPath(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_GetDefaultExtension(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_GetDefaultMountPoint(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_ParseInputFileName(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_ParseInputFileNameEx(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_ReadHeader(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_RunBackgroundFileDump(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_FS_WriteHeader(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_BackgroundFileDumpIsPending() + * ---------------------------------------------------- + */ +bool CFE_FS_BackgroundFileDumpIsPending(const CFE_FS_FileWriteMetaData_t *Meta) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_BackgroundFileDumpIsPending, bool); + + UT_GenStub_AddParam(CFE_FS_BackgroundFileDumpIsPending, const CFE_FS_FileWriteMetaData_t *, Meta); + + UT_GenStub_Execute(CFE_FS_BackgroundFileDumpIsPending, Basic, UT_DefaultHandler_CFE_FS_BackgroundFileDumpIsPending); + + return UT_GenStub_GetReturnValue(CFE_FS_BackgroundFileDumpIsPending, bool); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_BackgroundFileDumpRequest() + * ---------------------------------------------------- + */ +int32 CFE_FS_BackgroundFileDumpRequest(CFE_FS_FileWriteMetaData_t *Meta) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_BackgroundFileDumpRequest, int32); + + UT_GenStub_AddParam(CFE_FS_BackgroundFileDumpRequest, CFE_FS_FileWriteMetaData_t *, Meta); + + UT_GenStub_Execute(CFE_FS_BackgroundFileDumpRequest, Basic, UT_DefaultHandler_CFE_FS_BackgroundFileDumpRequest); + + return UT_GenStub_GetReturnValue(CFE_FS_BackgroundFileDumpRequest, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_ExtractFilenameFromPath() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnly) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_ExtractFilenameFromPath, CFE_Status_t); + + UT_GenStub_AddParam(CFE_FS_ExtractFilenameFromPath, const char *, OriginalPath); + UT_GenStub_AddParam(CFE_FS_ExtractFilenameFromPath, char *, FileNameOnly); + + UT_GenStub_Execute(CFE_FS_ExtractFilenameFromPath, Basic, UT_DefaultHandler_CFE_FS_ExtractFilenameFromPath); + + return UT_GenStub_GetReturnValue(CFE_FS_ExtractFilenameFromPath, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_GetDefaultExtension() + * ---------------------------------------------------- + */ +const char *CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_t FileCategory) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_GetDefaultExtension, const char *); + + UT_GenStub_AddParam(CFE_FS_GetDefaultExtension, CFE_FS_FileCategory_t, FileCategory); + + UT_GenStub_Execute(CFE_FS_GetDefaultExtension, Basic, UT_DefaultHandler_CFE_FS_GetDefaultExtension); + + return UT_GenStub_GetReturnValue(CFE_FS_GetDefaultExtension, const char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_GetDefaultMountPoint() + * ---------------------------------------------------- + */ +const char *CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_t FileCategory) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_GetDefaultMountPoint, const char *); + + UT_GenStub_AddParam(CFE_FS_GetDefaultMountPoint, CFE_FS_FileCategory_t, FileCategory); + + UT_GenStub_Execute(CFE_FS_GetDefaultMountPoint, Basic, UT_DefaultHandler_CFE_FS_GetDefaultMountPoint); + + return UT_GenStub_GetReturnValue(CFE_FS_GetDefaultMountPoint, const char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_InitHeader() + * ---------------------------------------------------- + */ +void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 SubType) +{ + UT_GenStub_AddParam(CFE_FS_InitHeader, CFE_FS_Header_t *, Hdr); + UT_GenStub_AddParam(CFE_FS_InitHeader, const char *, Description); + UT_GenStub_AddParam(CFE_FS_InitHeader, uint32, SubType); + + UT_GenStub_Execute(CFE_FS_InitHeader, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_ParseInputFileName() + * ---------------------------------------------------- + */ +int32 CFE_FS_ParseInputFileName(char *OutputBuffer, const char *InputName, size_t OutputBufSize, + CFE_FS_FileCategory_t FileCategory) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_ParseInputFileName, int32); + + UT_GenStub_AddParam(CFE_FS_ParseInputFileName, char *, OutputBuffer); + UT_GenStub_AddParam(CFE_FS_ParseInputFileName, const char *, InputName); + UT_GenStub_AddParam(CFE_FS_ParseInputFileName, size_t, OutputBufSize); + UT_GenStub_AddParam(CFE_FS_ParseInputFileName, CFE_FS_FileCategory_t, FileCategory); + + UT_GenStub_Execute(CFE_FS_ParseInputFileName, Basic, UT_DefaultHandler_CFE_FS_ParseInputFileName); + + return UT_GenStub_GetReturnValue(CFE_FS_ParseInputFileName, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_ParseInputFileNameEx() + * ---------------------------------------------------- + */ +int32 CFE_FS_ParseInputFileNameEx(char *OutputBuffer, const char *InputBuffer, size_t OutputBufSize, + size_t InputBufSize, const char *DefaultInput, const char *DefaultPath, + const char *DefaultExtension) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_ParseInputFileNameEx, int32); + + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, char *, OutputBuffer); + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, const char *, InputBuffer); + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, size_t, OutputBufSize); + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, size_t, InputBufSize); + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, const char *, DefaultInput); + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, const char *, DefaultPath); + UT_GenStub_AddParam(CFE_FS_ParseInputFileNameEx, const char *, DefaultExtension); + + UT_GenStub_Execute(CFE_FS_ParseInputFileNameEx, Basic, UT_DefaultHandler_CFE_FS_ParseInputFileNameEx); + + return UT_GenStub_GetReturnValue(CFE_FS_ParseInputFileNameEx, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_ReadHeader() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_ReadHeader, CFE_Status_t); + + UT_GenStub_AddParam(CFE_FS_ReadHeader, CFE_FS_Header_t *, Hdr); + UT_GenStub_AddParam(CFE_FS_ReadHeader, osal_id_t, FileDes); + + UT_GenStub_Execute(CFE_FS_ReadHeader, Basic, UT_DefaultHandler_CFE_FS_ReadHeader); + + return UT_GenStub_GetReturnValue(CFE_FS_ReadHeader, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_RunBackgroundFileDump() + * ---------------------------------------------------- + */ +bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_RunBackgroundFileDump, bool); + + UT_GenStub_AddParam(CFE_FS_RunBackgroundFileDump, uint32, ElapsedTime); + UT_GenStub_AddParam(CFE_FS_RunBackgroundFileDump, void *, Arg); + + UT_GenStub_Execute(CFE_FS_RunBackgroundFileDump, Basic, UT_DefaultHandler_CFE_FS_RunBackgroundFileDump); + + return UT_GenStub_GetReturnValue(CFE_FS_RunBackgroundFileDump, bool); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_SetTimestamp() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_SetTimestamp, CFE_Status_t); + + UT_GenStub_AddParam(CFE_FS_SetTimestamp, osal_id_t, FileDes); + UT_GenStub_AddParam(CFE_FS_SetTimestamp, CFE_TIME_SysTime_t, NewTimestamp); + + UT_GenStub_Execute(CFE_FS_SetTimestamp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_FS_SetTimestamp, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_WriteHeader() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_WriteHeader, CFE_Status_t); + + UT_GenStub_AddParam(CFE_FS_WriteHeader, osal_id_t, FileDes); + UT_GenStub_AddParam(CFE_FS_WriteHeader, CFE_FS_Header_t *, Hdr); + + UT_GenStub_Execute(CFE_FS_WriteHeader, Basic, UT_DefaultHandler_CFE_FS_WriteHeader); + + return UT_GenStub_GetReturnValue(CFE_FS_WriteHeader, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/cfe_msg_hooks.c b/modules/core_api/ut-stubs/src/cfe_msg_hooks.c new file mode 100644 index 000000000..334a9b7da --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_msg_hooks.c @@ -0,0 +1,362 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_msg_stubs.c +** +** Purpose: +** Unit test stubs for MSG routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include "cfe.h" +#include "utstubs.h" +#include "uttools.h" + +/* +** Defines +*/ + +/* For reporting no value for get */ +#define UTASSERT_GETSTUB(Expression) \ + UtAssert_Type(TSF, Expression, "%s: Check for get value provided by test", __func__); + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetApId coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetApId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_ApId_t *ApId = UT_Hook_GetArgValueByName(Context, "ApId", CFE_MSG_ApId_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetApId), ApId, sizeof(*ApId)) == sizeof(*ApId)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetEDSVersion coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetEDSVersion(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_EDSVersion_t *Version = UT_Hook_GetArgValueByName(Context, "Version", CFE_MSG_EDSVersion_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetEDSVersion), Version, sizeof(*Version)) == + sizeof(*Version)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetEndian coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetEndian(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Endian_t *Endian = UT_Hook_GetArgValueByName(Context, "Endian", CFE_MSG_Endian_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetEndian), Endian, sizeof(*Endian)) == sizeof(*Endian)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetFcnCode coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetFcnCode(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_FcnCode_t *FcnCode = UT_Hook_GetArgValueByName(Context, "FcnCode", CFE_MSG_FcnCode_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetFcnCode), FcnCode, sizeof(*FcnCode)) == + sizeof(*FcnCode)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetHasSecondaryHeader coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetHasSecondaryHeader(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + bool *HasSecondary = UT_Hook_GetArgValueByName(Context, "HasSecondary", bool *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetHasSecondaryHeader), HasSecondary, + sizeof(*HasSecondary)) == sizeof(*HasSecondary)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetHeaderVersion coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetHeaderVersion(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_HeaderVersion_t *Version = UT_Hook_GetArgValueByName(Context, "Version", CFE_MSG_HeaderVersion_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetHeaderVersion), Version, sizeof(*Version)) == + sizeof(*Version)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetMsgId coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetMsgId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_MsgId_t *MsgId = UT_Hook_GetArgValueByName(Context, "MsgId", CFE_SB_MsgId_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetMsgId), MsgId, sizeof(*MsgId)) == sizeof(*MsgId)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetMsgTime coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetMsgTime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_TIME_SysTime_t *Time = UT_Hook_GetArgValueByName(Context, "Time", CFE_TIME_SysTime_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetMsgTime), Time, sizeof(*Time)) == sizeof(*Time)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetPlaybackFlag coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetPlaybackFlag(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_PlaybackFlag_t *PlayFlag = UT_Hook_GetArgValueByName(Context, "PlayFlag", CFE_MSG_PlaybackFlag_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetPlaybackFlag), PlayFlag, sizeof(*PlayFlag)) == + sizeof(*PlayFlag)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetSegmentationFlag coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetSegmentationFlag(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + CFE_MSG_SegmentationFlag_t *SegFlag = UT_Hook_GetArgValueByName(Context, "SegFlag", CFE_MSG_SegmentationFlag_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSegmentationFlag), SegFlag, sizeof(*SegFlag)) == + sizeof(*SegFlag)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetSequenceCount coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetSequenceCount(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_SequenceCount_t *SeqCnt = UT_Hook_GetArgValueByName(Context, "SeqCnt", CFE_MSG_SequenceCount_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSequenceCount), SeqCnt, sizeof(*SeqCnt)) == + sizeof(*SeqCnt)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetSize coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetSize(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Size_t *Size = UT_Hook_GetArgValueByName(Context, "Size", CFE_MSG_Size_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSize), Size, sizeof(*Size)) == sizeof(*Size)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetSubsystem coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetSubsystem(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Subsystem_t *Subsystem = UT_Hook_GetArgValueByName(Context, "Subsystem", CFE_MSG_Subsystem_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSubsystem), Subsystem, sizeof(*Subsystem)) == + sizeof(*Subsystem)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetSystem coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetSystem(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_System_t *System = UT_Hook_GetArgValueByName(Context, "System", CFE_MSG_System_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSystem), System, sizeof(*System)) == sizeof(*System)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetType coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetType(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Type_t *Type = UT_Hook_GetArgValueByName(Context, "Type", CFE_MSG_Type_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetType), Type, sizeof(*Type)) == sizeof(*Type)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_GetTypeFromMsgId coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_GetTypeFromMsgId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Type_t *Type = UT_Hook_GetArgValueByName(Context, "Type", CFE_MSG_Type_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetTypeFromMsgId), Type, sizeof(*Type)) == sizeof(*Type)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_ValidateChecksum coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_ValidateChecksum(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + bool *IsValid = UT_Hook_GetArgValueByName(Context, "IsValid", bool *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_ValidateChecksum), IsValid, sizeof(*IsValid)) == + sizeof(*IsValid)); + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_msg_stubs.c b/modules/core_api/ut-stubs/src/cfe_msg_stubs.c new file mode 100644 index 000000000..fcafc038c --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_msg_stubs.c @@ -0,0 +1,624 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_msg header + */ + +#include "cfe_msg.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_MSG_GetApId(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetEDSVersion(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetEndian(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetFcnCode(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetHasSecondaryHeader(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetHeaderVersion(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetMsgId(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetMsgTime(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetPlaybackFlag(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetSegmentationFlag(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetSequenceCount(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetSize(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetSubsystem(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetSystem(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetType(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_GetTypeFromMsgId(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_MSG_ValidateChecksum(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GenerateChecksum() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GenerateChecksum(CFE_MSG_Message_t *MsgPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GenerateChecksum, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GenerateChecksum, CFE_MSG_Message_t *, MsgPtr); + + UT_GenStub_Execute(CFE_MSG_GenerateChecksum, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_GenerateChecksum, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetApId() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetApId(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_ApId_t *ApId) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetApId, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetApId, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetApId, CFE_MSG_ApId_t *, ApId); + + UT_GenStub_Execute(CFE_MSG_GetApId, Basic, UT_DefaultHandler_CFE_MSG_GetApId); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetApId, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetEDSVersion() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetEDSVersion(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_EDSVersion_t *Version) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetEDSVersion, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetEDSVersion, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetEDSVersion, CFE_MSG_EDSVersion_t *, Version); + + UT_GenStub_Execute(CFE_MSG_GetEDSVersion, Basic, UT_DefaultHandler_CFE_MSG_GetEDSVersion); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetEDSVersion, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetEndian() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetEndian(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Endian_t *Endian) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetEndian, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetEndian, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetEndian, CFE_MSG_Endian_t *, Endian); + + UT_GenStub_Execute(CFE_MSG_GetEndian, Basic, UT_DefaultHandler_CFE_MSG_GetEndian); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetEndian, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetFcnCode() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetFcnCode(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t *FcnCode) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetFcnCode, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetFcnCode, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetFcnCode, CFE_MSG_FcnCode_t *, FcnCode); + + UT_GenStub_Execute(CFE_MSG_GetFcnCode, Basic, UT_DefaultHandler_CFE_MSG_GetFcnCode); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetFcnCode, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetHasSecondaryHeader() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetHasSecondaryHeader(const CFE_MSG_Message_t *MsgPtr, bool *HasSecondary) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetHasSecondaryHeader, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetHasSecondaryHeader, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetHasSecondaryHeader, bool *, HasSecondary); + + UT_GenStub_Execute(CFE_MSG_GetHasSecondaryHeader, Basic, UT_DefaultHandler_CFE_MSG_GetHasSecondaryHeader); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetHasSecondaryHeader, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetHeaderVersion() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetHeaderVersion(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_HeaderVersion_t *Version) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetHeaderVersion, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetHeaderVersion, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetHeaderVersion, CFE_MSG_HeaderVersion_t *, Version); + + UT_GenStub_Execute(CFE_MSG_GetHeaderVersion, Basic, UT_DefaultHandler_CFE_MSG_GetHeaderVersion); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetHeaderVersion, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetMsgId() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetMsgId(const CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t *MsgId) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetMsgId, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetMsgId, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetMsgId, CFE_SB_MsgId_t *, MsgId); + + UT_GenStub_Execute(CFE_MSG_GetMsgId, Basic, UT_DefaultHandler_CFE_MSG_GetMsgId); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetMsgId, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetMsgTime() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetMsgTime(const CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t *Time) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetMsgTime, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetMsgTime, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetMsgTime, CFE_TIME_SysTime_t *, Time); + + UT_GenStub_Execute(CFE_MSG_GetMsgTime, Basic, UT_DefaultHandler_CFE_MSG_GetMsgTime); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetMsgTime, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetPlaybackFlag() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetPlaybackFlag(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_PlaybackFlag_t *PlayFlag) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetPlaybackFlag, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetPlaybackFlag, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetPlaybackFlag, CFE_MSG_PlaybackFlag_t *, PlayFlag); + + UT_GenStub_Execute(CFE_MSG_GetPlaybackFlag, Basic, UT_DefaultHandler_CFE_MSG_GetPlaybackFlag); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetPlaybackFlag, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetSegmentationFlag() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetSegmentationFlag(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_SegmentationFlag_t *SegFlag) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetSegmentationFlag, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetSegmentationFlag, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetSegmentationFlag, CFE_MSG_SegmentationFlag_t *, SegFlag); + + UT_GenStub_Execute(CFE_MSG_GetSegmentationFlag, Basic, UT_DefaultHandler_CFE_MSG_GetSegmentationFlag); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetSegmentationFlag, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetSequenceCount() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetSequenceCount(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t *SeqCnt) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetSequenceCount, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetSequenceCount, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetSequenceCount, CFE_MSG_SequenceCount_t *, SeqCnt); + + UT_GenStub_Execute(CFE_MSG_GetSequenceCount, Basic, UT_DefaultHandler_CFE_MSG_GetSequenceCount); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetSequenceCount, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetSize() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetSize(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t *Size) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetSize, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetSize, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetSize, CFE_MSG_Size_t *, Size); + + UT_GenStub_Execute(CFE_MSG_GetSize, Basic, UT_DefaultHandler_CFE_MSG_GetSize); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetSize, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetSubsystem() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetSubsystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t *Subsystem) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetSubsystem, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetSubsystem, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetSubsystem, CFE_MSG_Subsystem_t *, Subsystem); + + UT_GenStub_Execute(CFE_MSG_GetSubsystem, Basic, UT_DefaultHandler_CFE_MSG_GetSubsystem); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetSubsystem, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetSystem() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetSystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t *System) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetSystem, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetSystem, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetSystem, CFE_MSG_System_t *, System); + + UT_GenStub_Execute(CFE_MSG_GetSystem, Basic, UT_DefaultHandler_CFE_MSG_GetSystem); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetSystem, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetType() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetType(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t *Type) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetType, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetType, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_GetType, CFE_MSG_Type_t *, Type); + + UT_GenStub_Execute(CFE_MSG_GetType, Basic, UT_DefaultHandler_CFE_MSG_GetType); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetType, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_GetTypeFromMsgId() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_GetTypeFromMsgId(CFE_SB_MsgId_t MsgId, CFE_MSG_Type_t *Type) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_GetTypeFromMsgId, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_GetTypeFromMsgId, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_MSG_GetTypeFromMsgId, CFE_MSG_Type_t *, Type); + + UT_GenStub_Execute(CFE_MSG_GetTypeFromMsgId, Basic, UT_DefaultHandler_CFE_MSG_GetTypeFromMsgId); + + return UT_GenStub_GetReturnValue(CFE_MSG_GetTypeFromMsgId, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_Init() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_MSG_Size_t Size) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_Init, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_Init, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_Init, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_MSG_Init, CFE_MSG_Size_t, Size); + + UT_GenStub_Execute(CFE_MSG_Init, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_Init, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetApId() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetApId(CFE_MSG_Message_t *MsgPtr, CFE_MSG_ApId_t ApId) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetApId, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetApId, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetApId, CFE_MSG_ApId_t, ApId); + + UT_GenStub_Execute(CFE_MSG_SetApId, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetApId, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetEDSVersion() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetEDSVersion(CFE_MSG_Message_t *MsgPtr, CFE_MSG_EDSVersion_t Version) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetEDSVersion, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetEDSVersion, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetEDSVersion, CFE_MSG_EDSVersion_t, Version); + + UT_GenStub_Execute(CFE_MSG_SetEDSVersion, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetEDSVersion, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetEndian() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetEndian(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Endian_t Endian) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetEndian, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetEndian, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetEndian, CFE_MSG_Endian_t, Endian); + + UT_GenStub_Execute(CFE_MSG_SetEndian, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetEndian, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetFcnCode() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetFcnCode(CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t FcnCode) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetFcnCode, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetFcnCode, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetFcnCode, CFE_MSG_FcnCode_t, FcnCode); + + UT_GenStub_Execute(CFE_MSG_SetFcnCode, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetFcnCode, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetHasSecondaryHeader() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetHasSecondaryHeader(CFE_MSG_Message_t *MsgPtr, bool HasSecondary) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetHasSecondaryHeader, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetHasSecondaryHeader, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetHasSecondaryHeader, bool, HasSecondary); + + UT_GenStub_Execute(CFE_MSG_SetHasSecondaryHeader, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetHasSecondaryHeader, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetHeaderVersion() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetHeaderVersion(CFE_MSG_Message_t *MsgPtr, CFE_MSG_HeaderVersion_t Version) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetHeaderVersion, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetHeaderVersion, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetHeaderVersion, CFE_MSG_HeaderVersion_t, Version); + + UT_GenStub_Execute(CFE_MSG_SetHeaderVersion, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetHeaderVersion, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetMsgId() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetMsgId, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetMsgId, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetMsgId, CFE_SB_MsgId_t, MsgId); + + UT_GenStub_Execute(CFE_MSG_SetMsgId, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetMsgId, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetMsgTime() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetMsgTime(CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t Time) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetMsgTime, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetMsgTime, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetMsgTime, CFE_TIME_SysTime_t, Time); + + UT_GenStub_Execute(CFE_MSG_SetMsgTime, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetMsgTime, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetPlaybackFlag() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetPlaybackFlag(CFE_MSG_Message_t *MsgPtr, CFE_MSG_PlaybackFlag_t PlayFlag) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetPlaybackFlag, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetPlaybackFlag, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetPlaybackFlag, CFE_MSG_PlaybackFlag_t, PlayFlag); + + UT_GenStub_Execute(CFE_MSG_SetPlaybackFlag, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetPlaybackFlag, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetSegmentationFlag() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetSegmentationFlag(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SegmentationFlag_t SegFlag) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetSegmentationFlag, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetSegmentationFlag, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetSegmentationFlag, CFE_MSG_SegmentationFlag_t, SegFlag); + + UT_GenStub_Execute(CFE_MSG_SetSegmentationFlag, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetSegmentationFlag, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetSequenceCount() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetSequenceCount(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetSequenceCount, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetSequenceCount, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetSequenceCount, CFE_MSG_SequenceCount_t, SeqCnt); + + UT_GenStub_Execute(CFE_MSG_SetSequenceCount, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetSequenceCount, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetSize() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetSize(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t Size) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetSize, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetSize, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetSize, CFE_MSG_Size_t, Size); + + UT_GenStub_Execute(CFE_MSG_SetSize, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetSize, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetSubsystem() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetSubsystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t Subsystem) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetSubsystem, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetSubsystem, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetSubsystem, CFE_MSG_Subsystem_t, Subsystem); + + UT_GenStub_Execute(CFE_MSG_SetSubsystem, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetSubsystem, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetSystem() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetSystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t System) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetSystem, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetSystem, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetSystem, CFE_MSG_System_t, System); + + UT_GenStub_Execute(CFE_MSG_SetSystem, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetSystem, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_SetType() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_SetType(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t Type) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_SetType, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_SetType, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_SetType, CFE_MSG_Type_t, Type); + + UT_GenStub_Execute(CFE_MSG_SetType, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_MSG_SetType, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_ValidateChecksum() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_ValidateChecksum(const CFE_MSG_Message_t *MsgPtr, bool *IsValid) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_ValidateChecksum, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_ValidateChecksum, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_ValidateChecksum, bool *, IsValid); + + UT_GenStub_Execute(CFE_MSG_ValidateChecksum, Basic, UT_DefaultHandler_CFE_MSG_ValidateChecksum); + + return UT_GenStub_GetReturnValue(CFE_MSG_ValidateChecksum, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/cfe_resourceid_hooks.c b/modules/core_api/ut-stubs/src/cfe_resourceid_hooks.c new file mode 100644 index 000000000..da74ae4e3 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_resourceid_hooks.c @@ -0,0 +1,147 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* + * Includes + */ +#include "osapi.h" +#include "cfe.h" +#include "utstubs.h" +#include "cfe_resourceid.h" +#include "cfe_resourceid_basevalue.h" + +/*------------------------------------------------------------ + * + * Default handler for CFE_ResourceId_GetBase coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ResourceId_GetBase(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ResourceId_t ResourceId = UT_Hook_GetArgValueByName(Context, "ResourceId", CFE_ResourceId_t); + int32 status; + uint32 base_value; + + /* If a return code value was set, return it directly */ + if (UT_Stub_GetInt32StatusCode(Context, &status)) + { + base_value = (uint32)status; + } + else + { + /* otherwise mimic a typical output (mask upper bits) */ + base_value = CFE_ResourceId_ToInteger(ResourceId) & ~((uint32)CFE_RESOURCEID_MAX); + } + + UT_Stub_SetReturnValue(FuncKey, base_value); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ResourceId_GetSerial coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ResourceId_GetSerial(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ResourceId_t ResourceId = UT_Hook_GetArgValueByName(Context, "ResourceId", CFE_ResourceId_t); + int32 status; + uint32 serial_value; + + /* If a return code value was set, return it directly */ + if (UT_Stub_GetInt32StatusCode(Context, &status)) + { + serial_value = (uint32)status; + } + else + { + /* otherwise mimic a typical output (mask lower bits) */ + serial_value = (CFE_ResourceId_ToInteger(ResourceId) & ((uint32)CFE_RESOURCEID_MAX)); + } + + UT_Stub_SetReturnValue(FuncKey, serial_value); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ResourceId_FindNext coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ResourceId_FindNext(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ResourceId_t StartId = UT_Hook_GetArgValueByName(Context, "StartId", CFE_ResourceId_t); + CFE_ResourceId_t NextId; + int32 status; + + /* Using "1" by default here produces a sequential result when called multiple times */ + if (!UT_Stub_GetInt32StatusCode(Context, &status)) + { + status = 1; + } + + if (status < 0) + { + NextId = CFE_RESOURCEID_UNDEFINED; + } + else + { + /* + * The test case may set the return code to indicate the offset from the start ID + */ + NextId = CFE_ResourceId_FromInteger(CFE_ResourceId_ToInteger(StartId) + status); + } + + UT_Stub_SetReturnValue(FuncKey, NextId); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_ResourceId_ToIndex coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ResourceId_ToIndex(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ResourceId_t Id = UT_Hook_GetArgValueByName(Context, "Id", CFE_ResourceId_t); + uint32 BaseValue = UT_Hook_GetArgValueByName(Context, "BaseValue", uint32); + uint32 TableSize = UT_Hook_GetArgValueByName(Context, "TableSize", uint32); + uint32 * Idx = UT_Hook_GetArgValueByName(Context, "Idx", uint32 *); + + int32 return_code; + + UT_Stub_GetInt32StatusCode(Context, &return_code); + + if (return_code < 0) + { + /* fill with a very bad value that should cause a problem if used */ + *Idx = 0xDEADBEEF; + } + else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ResourceId_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) + { + /* fill with default value if unspecified by test case */ + if (CFE_ResourceId_IsDefined(Id)) + { + *Idx = (CFE_ResourceId_ToInteger(Id) - BaseValue) % TableSize; + } + else + { + *Idx = 0xDEADBEEF; + return_code = CFE_ES_ERR_RESOURCEID_NOT_VALID; + UT_Stub_SetReturnValue(FuncKey, return_code); + } + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_resourceid_stubs.c b/modules/core_api/ut-stubs/src/cfe_resourceid_stubs.c new file mode 100644 index 000000000..7eb1c7c7b --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_resourceid_stubs.c @@ -0,0 +1,102 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_resourceid header + */ + +#include "cfe_resourceid.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_ResourceId_FindNext(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ResourceId_GetBase(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ResourceId_GetSerial(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_ResourceId_ToIndex(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ResourceId_FindNext() + * ---------------------------------------------------- + */ +CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, + bool (*CheckFunc)(CFE_ResourceId_t)) +{ + UT_GenStub_SetupReturnBuffer(CFE_ResourceId_FindNext, CFE_ResourceId_t); + + UT_GenStub_AddParam(CFE_ResourceId_FindNext, CFE_ResourceId_t, StartId); + UT_GenStub_AddParam(CFE_ResourceId_FindNext, uint32, TableSize); + + UT_GenStub_Execute(CFE_ResourceId_FindNext, Basic, UT_DefaultHandler_CFE_ResourceId_FindNext); + + return UT_GenStub_GetReturnValue(CFE_ResourceId_FindNext, CFE_ResourceId_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ResourceId_GetBase() + * ---------------------------------------------------- + */ +uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ResourceId_GetBase, uint32); + + UT_GenStub_AddParam(CFE_ResourceId_GetBase, CFE_ResourceId_t, ResourceId); + + UT_GenStub_Execute(CFE_ResourceId_GetBase, Basic, UT_DefaultHandler_CFE_ResourceId_GetBase); + + return UT_GenStub_GetReturnValue(CFE_ResourceId_GetBase, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ResourceId_GetSerial() + * ---------------------------------------------------- + */ +uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId) +{ + UT_GenStub_SetupReturnBuffer(CFE_ResourceId_GetSerial, uint32); + + UT_GenStub_AddParam(CFE_ResourceId_GetSerial, CFE_ResourceId_t, ResourceId); + + UT_GenStub_Execute(CFE_ResourceId_GetSerial, Basic, UT_DefaultHandler_CFE_ResourceId_GetSerial); + + return UT_GenStub_GetReturnValue(CFE_ResourceId_GetSerial, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ResourceId_ToIndex() + * ---------------------------------------------------- + */ +int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx) +{ + UT_GenStub_SetupReturnBuffer(CFE_ResourceId_ToIndex, int32); + + UT_GenStub_AddParam(CFE_ResourceId_ToIndex, CFE_ResourceId_t, Id); + UT_GenStub_AddParam(CFE_ResourceId_ToIndex, uint32, BaseValue); + UT_GenStub_AddParam(CFE_ResourceId_ToIndex, uint32, TableSize); + UT_GenStub_AddParam(CFE_ResourceId_ToIndex, uint32 *, Idx); + + UT_GenStub_Execute(CFE_ResourceId_ToIndex, Basic, UT_DefaultHandler_CFE_ResourceId_ToIndex); + + return UT_GenStub_GetReturnValue(CFE_ResourceId_ToIndex, int32); +} diff --git a/modules/core_api/ut-stubs/src/cfe_sb_hooks.c b/modules/core_api/ut-stubs/src/cfe_sb_hooks.c new file mode 100644 index 000000000..bd47cd9ae --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_sb_hooks.c @@ -0,0 +1,438 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_sb_stubs.c +** +** Purpose: +** Unit test stubs for Software Bus routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include "cfe_sb.h" +#include "cfe_time_extern_typedefs.h" + +#include "utstubs.h" + +typedef struct +{ + CFE_SB_MsgId_t MsgId; + uint32 UserLength; + uint32 TotalLength; + uint16 CommandCode; + CFE_TIME_SysTime_t TimeStamp; + +} CFE_SB_StubMsg_MetaData_t; + +static CFE_SB_StubMsg_MetaData_t *CFE_SB_StubMsg_GetMetaData(const CFE_MSG_Message_t *MsgPtr) +{ + CFE_SB_StubMsg_MetaData_t *MetaPtr; + CFE_SB_StubMsg_MetaData_t DefaultMeta; + size_t MetaSize; + UT_EntryKey_t MsgKey = (UT_EntryKey_t)MsgPtr; + + UT_GetDataBuffer(MsgKey, (void **)&MetaPtr, &MetaSize, NULL); + if (MetaPtr == NULL || MetaSize != sizeof(DefaultMeta)) + { + memset(&DefaultMeta, 0, sizeof(DefaultMeta)); + DefaultMeta.MsgId = CFE_SB_INVALID_MSG_ID; + UT_ResetState(MsgKey); + UT_SetDataBuffer(MsgKey, &DefaultMeta, sizeof(DefaultMeta), true); + + /* Because "allocate copy" is true above, this gets a pointer to the copy */ + UT_GetDataBuffer(MsgKey, (void **)&MetaPtr, &MetaSize, NULL); + } + + return MetaPtr; +} +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_CreatePipe coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_CreatePipe(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_PipeId_t *PipeIdPtr = UT_Hook_GetArgValueByName(Context, "PipeIdPtr", CFE_SB_PipeId_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_SB_CreatePipe), PipeIdPtr, sizeof(*PipeIdPtr)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_DeletePipe coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_DeletePipe(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_PipeId_t PipeId = UT_Hook_GetArgValueByName(Context, "PipeId", CFE_SB_PipeId_t); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_DeletePipe), &PipeId, sizeof(PipeId)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_GetPipeName coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_GetPipeName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + char * PipeNameBuf = UT_Hook_GetArgValueByName(Context, "PipeNameBuf", char *); + size_t PipeNameSize = UT_Hook_GetArgValueByName(Context, "PipeNameSize", size_t); + + size_t UserBuffSize; + size_t BuffPosition; + const char *NameBuff; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0 && PipeNameSize > 0) + { + UT_GetDataBuffer(UT_KEY(CFE_SB_GetPipeName), (void **)&NameBuff, &UserBuffSize, &BuffPosition); + if (NameBuff == NULL || UserBuffSize == 0) + { + NameBuff = "UT"; + UserBuffSize = 2; + } + + if (UserBuffSize < PipeNameSize) + { + BuffPosition = UserBuffSize; + } + else + { + BuffPosition = PipeNameSize - 1; + } + + strncpy(PipeNameBuf, NameBuff, BuffPosition); + PipeNameBuf[BuffPosition] = 0; + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_TimeStampMsg coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_TimeStampMsg(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Message_t *MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *); + UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TimeStampMsg), &MsgPtr, sizeof(MsgPtr)); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_GetPipeIdByName coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_GetPipeIdByName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_PipeId_t *PipeIdPtr = UT_Hook_GetArgValueByName(Context, "PipeIdPtr", CFE_SB_PipeId_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_SB_GetPipeIdByName), PipeIdPtr, sizeof(*PipeIdPtr)) == sizeof(*PipeIdPtr)) + { + status = CFE_SUCCESS; + } + else + { + status = CFE_SB_BAD_ARGUMENT; + *PipeIdPtr = CFE_SB_INVALID_PIPE; + } + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_ReceiveBuffer coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_ReceiveBuffer(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_Buffer_t **BufPtr = UT_Hook_GetArgValueByName(Context, "BufPtr", CFE_SB_Buffer_t **); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_SB_ReceiveBuffer), BufPtr, sizeof(*BufPtr)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_TransmitMsg coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_TransmitMsg(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Message_t *MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *); + + int32 status = CFE_SUCCESS; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TransmitMsg), &MsgPtr, sizeof(MsgPtr)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_TransmitBuffer coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_TransmitBuffer(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_SB_Buffer_t *BufPtr = UT_Hook_GetArgValueByName(Context, "BufPtr", CFE_SB_Buffer_t *); + + int32 status = CFE_SUCCESS; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TransmitBuffer), &BufPtr, sizeof(BufPtr)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_MessageStringGet coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_MessageStringGet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + + char * DestStringPtr = UT_Hook_GetArgValueByName(Context, "DestStringPtr", char *); + const char *SourceStringPtr = UT_Hook_GetArgValueByName(Context, "SourceStringPtr", const char *); + const char *DefaultString = UT_Hook_GetArgValueByName(Context, "DefaultString", const char *); + size_t DestMaxSize = UT_Hook_GetArgValueByName(Context, "DestMaxSize", size_t); + size_t SourceMaxSize = UT_Hook_GetArgValueByName(Context, "SourceMaxSize", size_t); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status == 0) + { + if (DestMaxSize == 0) + { + status = CFE_SB_BAD_ARGUMENT; + } + else + { + /* + * Check if should use the default, which is if + * the source string has zero length (first char is NUL). + */ + if (DefaultString != NULL && (SourceMaxSize == 0 || *SourceStringPtr == 0)) + { + SourceStringPtr = DefaultString; + SourceMaxSize = DestMaxSize; + } + + /* For the UT implementation, just call strncpy() */ + strncpy(DestStringPtr, SourceStringPtr, DestMaxSize - 1); + DestStringPtr[DestMaxSize - 1] = 0; + + status = strlen(DestStringPtr); + } + } + + UT_Stub_SetReturnValue(FuncKey, status); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_MessageStringSet coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_MessageStringSet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + + char * DestStringPtr = UT_Hook_GetArgValueByName(Context, "DestStringPtr", char *); + const char *SourceStringPtr = UT_Hook_GetArgValueByName(Context, "SourceStringPtr", const char *); + size_t DestMaxSize = UT_Hook_GetArgValueByName(Context, "DestMaxSize", size_t); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status == 0) + { + if (DestMaxSize == 0) + { + status = CFE_SB_BAD_ARGUMENT; + } + else + { + /* For the UT implementation, just call strncpy() */ + strncpy(DestStringPtr, SourceStringPtr, DestMaxSize); + if (DestStringPtr[DestMaxSize - 1] != 0) + { + status = DestMaxSize; + } + else + { + status = strlen(DestStringPtr); + } + } + } + + UT_Stub_SetReturnValue(FuncKey, status); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_GetUserData coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_GetUserData(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Message_t *MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *); + uint8 * BytePtr; + void * Result; + uint16 HdrSize; + + if (UT_Stub_CopyToLocal(UT_KEY(CFE_SB_GetUserData), &Result, sizeof(Result)) != sizeof(Result)) + { + BytePtr = (uint8 *)MsgPtr; + if ((MsgPtr->Byte[0] & 0x10) != 0) + { + HdrSize = sizeof(CFE_MSG_CommandHeader_t); + } + else + { + HdrSize = sizeof(CFE_MSG_TelemetryHeader_t); + } + + Result = (BytePtr + HdrSize); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_GetUserDataLength coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_GetUserDataLength(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + const CFE_MSG_Message_t *MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", const CFE_MSG_Message_t *); + int32 status; + size_t Result; + + if (UT_Stub_GetInt32StatusCode(Context, &status)) + { + Result = status; + } + else + { + Result = CFE_SB_StubMsg_GetMetaData(MsgPtr)->UserLength; + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_IsValidMsgId coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_IsValidMsgId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + bool return_value; + + UT_Stub_GetInt32StatusCode(Context, &status); + + return_value = status; + + UT_Stub_SetReturnValue(FuncKey, return_value); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_SetUserDataLength coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_SetUserDataLength(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_MSG_Message_t *MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *); + size_t DataLength = UT_Hook_GetArgValueByName(Context, "DataLength", size_t); + + CFE_SB_StubMsg_GetMetaData(MsgPtr)->UserLength = DataLength; +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_SB_AllocateMessageBuffer coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_SB_AllocateMessageBuffer(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + int32 status; + CFE_SB_Buffer_t *SBBufPtr = NULL; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status == CFE_SUCCESS) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_SB_AllocateMessageBuffer), &SBBufPtr, sizeof(SBBufPtr)); + } + + UT_Stub_SetReturnValue(FuncKey, SBBufPtr); +} diff --git a/modules/core_api/ut-stubs/src/cfe_sb_stubs.c b/modules/core_api/ut-stubs/src/cfe_sb_stubs.c new file mode 100644 index 000000000..35035222a --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_sb_stubs.c @@ -0,0 +1,450 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_sb header + */ + +#include "cfe_sb.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_SB_AllocateMessageBuffer(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_CreatePipe(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_DeletePipe(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_GetPipeIdByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_GetPipeName(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_GetUserData(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_GetUserDataLength(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_IsValidMsgId(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_MessageStringGet(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_MessageStringSet(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_ReceiveBuffer(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_SetUserDataLength(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_TimeStampMsg(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_TransmitBuffer(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_SB_TransmitMsg(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_AllocateMessageBuffer() + * ---------------------------------------------------- + */ +CFE_SB_Buffer_t *CFE_SB_AllocateMessageBuffer(size_t MsgSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_AllocateMessageBuffer, CFE_SB_Buffer_t *); + + UT_GenStub_AddParam(CFE_SB_AllocateMessageBuffer, size_t, MsgSize); + + UT_GenStub_Execute(CFE_SB_AllocateMessageBuffer, Basic, UT_DefaultHandler_CFE_SB_AllocateMessageBuffer); + + return UT_GenStub_GetReturnValue(CFE_SB_AllocateMessageBuffer, CFE_SB_Buffer_t *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_CreatePipe() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_CreatePipe, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_CreatePipe, CFE_SB_PipeId_t *, PipeIdPtr); + UT_GenStub_AddParam(CFE_SB_CreatePipe, uint16, Depth); + UT_GenStub_AddParam(CFE_SB_CreatePipe, const char *, PipeName); + + UT_GenStub_Execute(CFE_SB_CreatePipe, Basic, UT_DefaultHandler_CFE_SB_CreatePipe); + + return UT_GenStub_GetReturnValue(CFE_SB_CreatePipe, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_DeletePipe() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_DeletePipe, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_DeletePipe, CFE_SB_PipeId_t, PipeId); + + UT_GenStub_Execute(CFE_SB_DeletePipe, Basic, UT_DefaultHandler_CFE_SB_DeletePipe); + + return UT_GenStub_GetReturnValue(CFE_SB_DeletePipe, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_GetPipeIdByName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_GetPipeIdByName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_GetPipeIdByName, CFE_SB_PipeId_t *, PipeIdPtr); + UT_GenStub_AddParam(CFE_SB_GetPipeIdByName, const char *, PipeName); + + UT_GenStub_Execute(CFE_SB_GetPipeIdByName, Basic, UT_DefaultHandler_CFE_SB_GetPipeIdByName); + + return UT_GenStub_GetReturnValue(CFE_SB_GetPipeIdByName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_GetPipeName() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_GetPipeName, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_GetPipeName, char *, PipeNameBuf); + UT_GenStub_AddParam(CFE_SB_GetPipeName, size_t, PipeNameSize); + UT_GenStub_AddParam(CFE_SB_GetPipeName, CFE_SB_PipeId_t, PipeId); + + UT_GenStub_Execute(CFE_SB_GetPipeName, Basic, UT_DefaultHandler_CFE_SB_GetPipeName); + + return UT_GenStub_GetReturnValue(CFE_SB_GetPipeName, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_GetPipeOpts() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_GetPipeOpts, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_GetPipeOpts, CFE_SB_PipeId_t, PipeId); + UT_GenStub_AddParam(CFE_SB_GetPipeOpts, uint8 *, OptPtr); + + UT_GenStub_Execute(CFE_SB_GetPipeOpts, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_GetPipeOpts, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_GetUserData() + * ---------------------------------------------------- + */ +void *CFE_SB_GetUserData(CFE_MSG_Message_t *MsgPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_GetUserData, void *); + + UT_GenStub_AddParam(CFE_SB_GetUserData, CFE_MSG_Message_t *, MsgPtr); + + UT_GenStub_Execute(CFE_SB_GetUserData, Basic, UT_DefaultHandler_CFE_SB_GetUserData); + + return UT_GenStub_GetReturnValue(CFE_SB_GetUserData, void *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_GetUserDataLength() + * ---------------------------------------------------- + */ +size_t CFE_SB_GetUserDataLength(const CFE_MSG_Message_t *MsgPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_GetUserDataLength, size_t); + + UT_GenStub_AddParam(CFE_SB_GetUserDataLength, const CFE_MSG_Message_t *, MsgPtr); + + UT_GenStub_Execute(CFE_SB_GetUserDataLength, Basic, UT_DefaultHandler_CFE_SB_GetUserDataLength); + + return UT_GenStub_GetReturnValue(CFE_SB_GetUserDataLength, size_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_IsValidMsgId() + * ---------------------------------------------------- + */ +bool CFE_SB_IsValidMsgId(CFE_SB_MsgId_t MsgId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_IsValidMsgId, bool); + + UT_GenStub_AddParam(CFE_SB_IsValidMsgId, CFE_SB_MsgId_t, MsgId); + + UT_GenStub_Execute(CFE_SB_IsValidMsgId, Basic, UT_DefaultHandler_CFE_SB_IsValidMsgId); + + return UT_GenStub_GetReturnValue(CFE_SB_IsValidMsgId, bool); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_MessageStringGet() + * ---------------------------------------------------- + */ +int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, + size_t DestMaxSize, size_t SourceMaxSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_MessageStringGet, int32); + + UT_GenStub_AddParam(CFE_SB_MessageStringGet, char *, DestStringPtr); + UT_GenStub_AddParam(CFE_SB_MessageStringGet, const char *, SourceStringPtr); + UT_GenStub_AddParam(CFE_SB_MessageStringGet, const char *, DefaultString); + UT_GenStub_AddParam(CFE_SB_MessageStringGet, size_t, DestMaxSize); + UT_GenStub_AddParam(CFE_SB_MessageStringGet, size_t, SourceMaxSize); + + UT_GenStub_Execute(CFE_SB_MessageStringGet, Basic, UT_DefaultHandler_CFE_SB_MessageStringGet); + + return UT_GenStub_GetReturnValue(CFE_SB_MessageStringGet, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_MessageStringSet() + * ---------------------------------------------------- + */ +int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, + size_t SourceMaxSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_MessageStringSet, int32); + + UT_GenStub_AddParam(CFE_SB_MessageStringSet, char *, DestStringPtr); + UT_GenStub_AddParam(CFE_SB_MessageStringSet, const char *, SourceStringPtr); + UT_GenStub_AddParam(CFE_SB_MessageStringSet, size_t, DestMaxSize); + UT_GenStub_AddParam(CFE_SB_MessageStringSet, size_t, SourceMaxSize); + + UT_GenStub_Execute(CFE_SB_MessageStringSet, Basic, UT_DefaultHandler_CFE_SB_MessageStringSet); + + return UT_GenStub_GetReturnValue(CFE_SB_MessageStringSet, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_PipeId_ToIndex() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_PipeId_ToIndex(CFE_SB_PipeId_t PipeID, uint32 *Idx) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_PipeId_ToIndex, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_PipeId_ToIndex, CFE_SB_PipeId_t, PipeID); + UT_GenStub_AddParam(CFE_SB_PipeId_ToIndex, uint32 *, Idx); + + UT_GenStub_Execute(CFE_SB_PipeId_ToIndex, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_PipeId_ToIndex, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_ReceiveBuffer() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_ReceiveBuffer, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_ReceiveBuffer, CFE_SB_Buffer_t **, BufPtr); + UT_GenStub_AddParam(CFE_SB_ReceiveBuffer, CFE_SB_PipeId_t, PipeId); + UT_GenStub_AddParam(CFE_SB_ReceiveBuffer, int32, TimeOut); + + UT_GenStub_Execute(CFE_SB_ReceiveBuffer, Basic, UT_DefaultHandler_CFE_SB_ReceiveBuffer); + + return UT_GenStub_GetReturnValue(CFE_SB_ReceiveBuffer, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_ReleaseMessageBuffer() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_ReleaseMessageBuffer, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_ReleaseMessageBuffer, CFE_SB_Buffer_t *, BufPtr); + + UT_GenStub_Execute(CFE_SB_ReleaseMessageBuffer, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_ReleaseMessageBuffer, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_SetPipeOpts() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_SetPipeOpts, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_SetPipeOpts, CFE_SB_PipeId_t, PipeId); + UT_GenStub_AddParam(CFE_SB_SetPipeOpts, uint8, Opts); + + UT_GenStub_Execute(CFE_SB_SetPipeOpts, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_SetPipeOpts, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_SetUserDataLength() + * ---------------------------------------------------- + */ +void CFE_SB_SetUserDataLength(CFE_MSG_Message_t *MsgPtr, size_t DataLength) +{ + UT_GenStub_AddParam(CFE_SB_SetUserDataLength, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_SB_SetUserDataLength, size_t, DataLength); + + UT_GenStub_Execute(CFE_SB_SetUserDataLength, Basic, UT_DefaultHandler_CFE_SB_SetUserDataLength); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_Subscribe() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_Subscribe, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_Subscribe, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_SB_Subscribe, CFE_SB_PipeId_t, PipeId); + + UT_GenStub_Execute(CFE_SB_Subscribe, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_Subscribe, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_SubscribeEx() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, uint16 MsgLim) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_SubscribeEx, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_SubscribeEx, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_SB_SubscribeEx, CFE_SB_PipeId_t, PipeId); + UT_GenStub_AddParam(CFE_SB_SubscribeEx, CFE_SB_Qos_t, Quality); + UT_GenStub_AddParam(CFE_SB_SubscribeEx, uint16, MsgLim); + + UT_GenStub_Execute(CFE_SB_SubscribeEx, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_SubscribeEx, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_SubscribeLocal() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint16 MsgLim) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_SubscribeLocal, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_SubscribeLocal, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_SB_SubscribeLocal, CFE_SB_PipeId_t, PipeId); + UT_GenStub_AddParam(CFE_SB_SubscribeLocal, uint16, MsgLim); + + UT_GenStub_Execute(CFE_SB_SubscribeLocal, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_SubscribeLocal, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_TimeStampMsg() + * ---------------------------------------------------- + */ +void CFE_SB_TimeStampMsg(CFE_MSG_Message_t *MsgPtr) +{ + UT_GenStub_AddParam(CFE_SB_TimeStampMsg, CFE_MSG_Message_t *, MsgPtr); + + UT_GenStub_Execute(CFE_SB_TimeStampMsg, Basic, UT_DefaultHandler_CFE_SB_TimeStampMsg); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_TransmitBuffer() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IncrementSequenceCount) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitBuffer, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_TransmitBuffer, CFE_SB_Buffer_t *, BufPtr); + UT_GenStub_AddParam(CFE_SB_TransmitBuffer, bool, IncrementSequenceCount); + + UT_GenStub_Execute(CFE_SB_TransmitBuffer, Basic, UT_DefaultHandler_CFE_SB_TransmitBuffer); + + return UT_GenStub_GetReturnValue(CFE_SB_TransmitBuffer, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_TransmitMsg() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitMsg, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_TransmitMsg, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_SB_TransmitMsg, bool, IncrementSequenceCount); + + UT_GenStub_Execute(CFE_SB_TransmitMsg, Basic, UT_DefaultHandler_CFE_SB_TransmitMsg); + + return UT_GenStub_GetReturnValue(CFE_SB_TransmitMsg, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_Unsubscribe() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_Unsubscribe, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_Unsubscribe, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_SB_Unsubscribe, CFE_SB_PipeId_t, PipeId); + + UT_GenStub_Execute(CFE_SB_Unsubscribe, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_Unsubscribe, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_UnsubscribeLocal() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_UnsubscribeLocal, CFE_Status_t); + + UT_GenStub_AddParam(CFE_SB_UnsubscribeLocal, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_SB_UnsubscribeLocal, CFE_SB_PipeId_t, PipeId); + + UT_GenStub_Execute(CFE_SB_UnsubscribeLocal, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_UnsubscribeLocal, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/cfe_tbl_hooks.c b/modules/core_api/ut-stubs/src/cfe_tbl_hooks.c new file mode 100644 index 000000000..598694a3e --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_tbl_hooks.c @@ -0,0 +1,87 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** Includes +*/ +#include +#include "cfe_tbl.h" + +#include "utstubs.h" + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_TBL_Register coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TBL_Register(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_TBL_Handle_t *TblHandlePtr = UT_Hook_GetArgValueByName(Context, "TblHandlePtr", CFE_TBL_Handle_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TBL_Register), TblHandlePtr, sizeof(CFE_TBL_Handle_t)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TBL_GetAddress coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TBL_GetAddress(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + void **TblPtr = UT_Hook_GetArgValueByName(Context, "TblPtr", void **); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0 /* JPHFIX: && !UT_Stub_CheckDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), &ForceValue) */) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TBL_GetAddress), (uint8 *)TblPtr, sizeof(void *)); + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TBL_GetInfo coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TBL_GetInfo(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_TBL_Info_t *TblInfoPtr = UT_Hook_GetArgValueByName(Context, "TblInfoPtr", CFE_TBL_Info_t *); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0 && + UT_Stub_CopyToLocal(UT_KEY(CFE_TBL_GetInfo), TblInfoPtr, sizeof(*TblInfoPtr)) < sizeof(*TblInfoPtr)) + { + /* just clear the output struct */ + memset(TblInfoPtr, 0, sizeof(*TblInfoPtr)); + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_tbl_stubs.c b/modules/core_api/ut-stubs/src/cfe_tbl_stubs.c new file mode 100644 index 000000000..c0c28d727 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_tbl_stubs.c @@ -0,0 +1,302 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_tbl header + */ + +#include "cfe_tbl.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_TBL_GetAddress(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TBL_GetInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TBL_Register(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_DumpToBuffer() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_DumpToBuffer, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_DumpToBuffer, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_DumpToBuffer, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_DumpToBuffer, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_GetAddress() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_GetAddress(void **TblPtr, CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_GetAddress, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_GetAddress, void **, TblPtr); + UT_GenStub_AddParam(CFE_TBL_GetAddress, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_GetAddress, Basic, UT_DefaultHandler_CFE_TBL_GetAddress); + + return UT_GenStub_GetReturnValue(CFE_TBL_GetAddress, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_GetAddresses() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_GetAddresses(void **TblPtrs[], uint16 NumTables, const CFE_TBL_Handle_t TblHandles[]) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_GetAddresses, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_GetAddresses, uint16, NumTables); + + UT_GenStub_Execute(CFE_TBL_GetAddresses, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_GetAddresses, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_GetInfo() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_GetInfo, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_GetInfo, CFE_TBL_Info_t *, TblInfoPtr); + UT_GenStub_AddParam(CFE_TBL_GetInfo, const char *, TblName); + + UT_GenStub_Execute(CFE_TBL_GetInfo, Basic, UT_DefaultHandler_CFE_TBL_GetInfo); + + return UT_GenStub_GetReturnValue(CFE_TBL_GetInfo, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_GetStatus() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_GetStatus(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_GetStatus, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_GetStatus, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_GetStatus, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_GetStatus, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Load() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Load, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Load, CFE_TBL_Handle_t, TblHandle); + UT_GenStub_AddParam(CFE_TBL_Load, CFE_TBL_SrcEnum_t, SrcType); + UT_GenStub_AddParam(CFE_TBL_Load, const void *, SrcDataPtr); + + UT_GenStub_Execute(CFE_TBL_Load, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Load, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Manage() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Manage(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Manage, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Manage, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_Manage, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Manage, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Modified() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Modified(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Modified, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Modified, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_Modified, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Modified, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_NotifyByMessage() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, CFE_MSG_FcnCode_t CommandCode, + uint32 Parameter) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_NotifyByMessage, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_NotifyByMessage, CFE_TBL_Handle_t, TblHandle); + UT_GenStub_AddParam(CFE_TBL_NotifyByMessage, CFE_SB_MsgId_t, MsgId); + UT_GenStub_AddParam(CFE_TBL_NotifyByMessage, CFE_MSG_FcnCode_t, CommandCode); + UT_GenStub_AddParam(CFE_TBL_NotifyByMessage, uint32, Parameter); + + UT_GenStub_Execute(CFE_TBL_NotifyByMessage, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_NotifyByMessage, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Register() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, size_t Size, uint16 TblOptionFlags, + CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Register, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Register, CFE_TBL_Handle_t *, TblHandlePtr); + UT_GenStub_AddParam(CFE_TBL_Register, const char *, Name); + UT_GenStub_AddParam(CFE_TBL_Register, size_t, Size); + UT_GenStub_AddParam(CFE_TBL_Register, uint16, TblOptionFlags); + UT_GenStub_AddParam(CFE_TBL_Register, CFE_TBL_CallbackFuncPtr_t, TblValidationFuncPtr); + + UT_GenStub_Execute(CFE_TBL_Register, Basic, UT_DefaultHandler_CFE_TBL_Register); + + return UT_GenStub_GetReturnValue(CFE_TBL_Register, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_ReleaseAddress() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_ReleaseAddress(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_ReleaseAddress, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_ReleaseAddress, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_ReleaseAddress, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_ReleaseAddress, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_ReleaseAddresses() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_ReleaseAddresses(uint16 NumTables, const CFE_TBL_Handle_t TblHandles[]) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_ReleaseAddresses, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_ReleaseAddresses, uint16, NumTables); + + UT_GenStub_Execute(CFE_TBL_ReleaseAddresses, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_ReleaseAddresses, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Share() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Share(CFE_TBL_Handle_t *TblHandlePtr, const char *TblName) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Share, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Share, CFE_TBL_Handle_t *, TblHandlePtr); + UT_GenStub_AddParam(CFE_TBL_Share, const char *, TblName); + + UT_GenStub_Execute(CFE_TBL_Share, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Share, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Unregister() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Unregister(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Unregister, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Unregister, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_Unregister, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Unregister, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Update() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Update(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Update, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Update, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_Update, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Update, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_Validate() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TBL_Validate(CFE_TBL_Handle_t TblHandle) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_Validate, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TBL_Validate, CFE_TBL_Handle_t, TblHandle); + + UT_GenStub_Execute(CFE_TBL_Validate, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_Validate, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/cfe_time_hooks.c b/modules/core_api/ut-stubs/src/cfe_time_hooks.c new file mode 100644 index 000000000..6454bb727 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_time_hooks.c @@ -0,0 +1,223 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_time_stubs.c +** +** Purpose: +** Unit test stubs for Time routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include +#include "cfe_time.h" + +#include "utstubs.h" + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_Print coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_Print(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + char * PrintBuffer = UT_Hook_GetArgValueByName(Context, "PrintBuffer", char *); + CFE_TIME_SysTime_t TimeToPrint = UT_Hook_GetArgValueByName(Context, "TimeToPrint", CFE_TIME_SysTime_t); + + snprintf(PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE, "UT %u.%u -", (unsigned int)TimeToPrint.Seconds, + (unsigned int)TimeToPrint.Subseconds); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetTime coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetTime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + static CFE_TIME_SysTime_t SimTime = {0}; + CFE_TIME_SysTime_t Result = {0}; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetTime), &Result, sizeof(Result)) < sizeof(Result)) + { + SimTime.Seconds++; + SimTime.Subseconds++; + Result = SimTime; + } + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_Add coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_Add(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + static CFE_TIME_SysTime_t SimTime = {0}; + CFE_TIME_SysTime_t Result = {0}; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_Add), (uint8 *)&Result, sizeof(Result)) < sizeof(Result)) + { + SimTime.Seconds++; + SimTime.Subseconds++; + Result = SimTime; + } + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetMET coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetMET(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetMET), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetSTCF coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetSTCF(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetSTCF), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetTAI coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetTAI(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetTAI), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetUTC coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetUTC(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetUTC), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_MET2SCTime coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_MET2SCTime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_MET2SCTime), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_Subtract coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_Subtract(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_Subtract), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} diff --git a/modules/core_api/ut-stubs/src/cfe_time_stubs.c b/modules/core_api/ut-stubs/src/cfe_time_stubs.c new file mode 100644 index 000000000..722a176e2 --- /dev/null +++ b/modules/core_api/ut-stubs/src/cfe_time_stubs.c @@ -0,0 +1,381 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_time header + */ + +#include "cfe_time.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_TIME_Add(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_GetMET(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_GetSTCF(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_GetTAI(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_GetTime(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_GetUTC(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_MET2SCTime(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_Print(void *, UT_EntryKey_t, const UT_StubContext_t *); +extern void UT_DefaultHandler_CFE_TIME_Subtract(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Add() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_Add, CFE_TIME_SysTime_t); + + UT_GenStub_AddParam(CFE_TIME_Add, CFE_TIME_SysTime_t, Time1); + UT_GenStub_AddParam(CFE_TIME_Add, CFE_TIME_SysTime_t, Time2); + + UT_GenStub_Execute(CFE_TIME_Add, Basic, UT_DefaultHandler_CFE_TIME_Add); + + return UT_GenStub_GetReturnValue(CFE_TIME_Add, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Compare() + * ---------------------------------------------------- + */ +CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_t TimeB) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_Compare, CFE_TIME_Compare_t); + + UT_GenStub_AddParam(CFE_TIME_Compare, CFE_TIME_SysTime_t, TimeA); + UT_GenStub_AddParam(CFE_TIME_Compare, CFE_TIME_SysTime_t, TimeB); + + UT_GenStub_Execute(CFE_TIME_Compare, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_Compare, CFE_TIME_Compare_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_ExternalGPS() + * ---------------------------------------------------- + */ +void CFE_TIME_ExternalGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps) +{ + UT_GenStub_AddParam(CFE_TIME_ExternalGPS, CFE_TIME_SysTime_t, NewTime); + UT_GenStub_AddParam(CFE_TIME_ExternalGPS, int16, NewLeaps); + + UT_GenStub_Execute(CFE_TIME_ExternalGPS, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_ExternalMET() + * ---------------------------------------------------- + */ +void CFE_TIME_ExternalMET(CFE_TIME_SysTime_t NewMET) +{ + UT_GenStub_AddParam(CFE_TIME_ExternalMET, CFE_TIME_SysTime_t, NewMET); + + UT_GenStub_Execute(CFE_TIME_ExternalMET, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_ExternalTime() + * ---------------------------------------------------- + */ +void CFE_TIME_ExternalTime(CFE_TIME_SysTime_t NewTime) +{ + UT_GenStub_AddParam(CFE_TIME_ExternalTime, CFE_TIME_SysTime_t, NewTime); + + UT_GenStub_Execute(CFE_TIME_ExternalTime, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_ExternalTone() + * ---------------------------------------------------- + */ +void CFE_TIME_ExternalTone(void) +{ + + UT_GenStub_Execute(CFE_TIME_ExternalTone, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetClockInfo() + * ---------------------------------------------------- + */ +uint16 CFE_TIME_GetClockInfo(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetClockInfo, uint16); + + UT_GenStub_Execute(CFE_TIME_GetClockInfo, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetClockInfo, uint16); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetClockState() + * ---------------------------------------------------- + */ +CFE_TIME_ClockState_Enum_t CFE_TIME_GetClockState(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetClockState, CFE_TIME_ClockState_Enum_t); + + UT_GenStub_Execute(CFE_TIME_GetClockState, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetClockState, CFE_TIME_ClockState_Enum_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetLeapSeconds() + * ---------------------------------------------------- + */ +int16 CFE_TIME_GetLeapSeconds(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetLeapSeconds, int16); + + UT_GenStub_Execute(CFE_TIME_GetLeapSeconds, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetLeapSeconds, int16); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetMET() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_GetMET(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetMET, CFE_TIME_SysTime_t); + + UT_GenStub_Execute(CFE_TIME_GetMET, Basic, UT_DefaultHandler_CFE_TIME_GetMET); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetMET, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetMETseconds() + * ---------------------------------------------------- + */ +uint32 CFE_TIME_GetMETseconds(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetMETseconds, uint32); + + UT_GenStub_Execute(CFE_TIME_GetMETseconds, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetMETseconds, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetMETsubsecs() + * ---------------------------------------------------- + */ +uint32 CFE_TIME_GetMETsubsecs(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetMETsubsecs, uint32); + + UT_GenStub_Execute(CFE_TIME_GetMETsubsecs, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetMETsubsecs, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetSTCF() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_GetSTCF(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetSTCF, CFE_TIME_SysTime_t); + + UT_GenStub_Execute(CFE_TIME_GetSTCF, Basic, UT_DefaultHandler_CFE_TIME_GetSTCF); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetSTCF, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetTAI() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_GetTAI(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetTAI, CFE_TIME_SysTime_t); + + UT_GenStub_Execute(CFE_TIME_GetTAI, Basic, UT_DefaultHandler_CFE_TIME_GetTAI); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetTAI, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetTime() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_GetTime(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetTime, CFE_TIME_SysTime_t); + + UT_GenStub_Execute(CFE_TIME_GetTime, Basic, UT_DefaultHandler_CFE_TIME_GetTime); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetTime, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_GetUTC() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_GetUTC(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_GetUTC, CFE_TIME_SysTime_t); + + UT_GenStub_Execute(CFE_TIME_GetUTC, Basic, UT_DefaultHandler_CFE_TIME_GetUTC); + + return UT_GenStub_GetReturnValue(CFE_TIME_GetUTC, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Local1HzISR() + * ---------------------------------------------------- + */ +void CFE_TIME_Local1HzISR(void) +{ + + UT_GenStub_Execute(CFE_TIME_Local1HzISR, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_MET2SCTime() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_MET2SCTime(CFE_TIME_SysTime_t METTime) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_MET2SCTime, CFE_TIME_SysTime_t); + + UT_GenStub_AddParam(CFE_TIME_MET2SCTime, CFE_TIME_SysTime_t, METTime); + + UT_GenStub_Execute(CFE_TIME_MET2SCTime, Basic, UT_DefaultHandler_CFE_TIME_MET2SCTime); + + return UT_GenStub_GetReturnValue(CFE_TIME_MET2SCTime, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Micro2SubSecs() + * ---------------------------------------------------- + */ +uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_Micro2SubSecs, uint32); + + UT_GenStub_AddParam(CFE_TIME_Micro2SubSecs, uint32, MicroSeconds); + + UT_GenStub_Execute(CFE_TIME_Micro2SubSecs, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_Micro2SubSecs, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Print() + * ---------------------------------------------------- + */ +void CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) +{ + UT_GenStub_AddParam(CFE_TIME_Print, char *, PrintBuffer); + UT_GenStub_AddParam(CFE_TIME_Print, CFE_TIME_SysTime_t, TimeToPrint); + + UT_GenStub_Execute(CFE_TIME_Print, Basic, UT_DefaultHandler_CFE_TIME_Print); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_RegisterSynchCallback() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_RegisterSynchCallback, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TIME_RegisterSynchCallback, CFE_TIME_SynchCallbackPtr_t, CallbackFuncPtr); + + UT_GenStub_Execute(CFE_TIME_RegisterSynchCallback, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_RegisterSynchCallback, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Sub2MicroSecs() + * ---------------------------------------------------- + */ +uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_Sub2MicroSecs, uint32); + + UT_GenStub_AddParam(CFE_TIME_Sub2MicroSecs, uint32, SubSeconds); + + UT_GenStub_Execute(CFE_TIME_Sub2MicroSecs, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_Sub2MicroSecs, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_Subtract() + * ---------------------------------------------------- + */ +CFE_TIME_SysTime_t CFE_TIME_Subtract(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_Subtract, CFE_TIME_SysTime_t); + + UT_GenStub_AddParam(CFE_TIME_Subtract, CFE_TIME_SysTime_t, Time1); + UT_GenStub_AddParam(CFE_TIME_Subtract, CFE_TIME_SysTime_t, Time2); + + UT_GenStub_Execute(CFE_TIME_Subtract, Basic, UT_DefaultHandler_CFE_TIME_Subtract); + + return UT_GenStub_GetReturnValue(CFE_TIME_Subtract, CFE_TIME_SysTime_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_UnregisterSynchCallback() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_UnregisterSynchCallback, CFE_Status_t); + + UT_GenStub_AddParam(CFE_TIME_UnregisterSynchCallback, CFE_TIME_SynchCallbackPtr_t, CallbackFuncPtr); + + UT_GenStub_Execute(CFE_TIME_UnregisterSynchCallback, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_UnregisterSynchCallback, CFE_Status_t); +} diff --git a/modules/core_api/ut-stubs/src/ut_es_stubs.c b/modules/core_api/ut-stubs/src/ut_es_stubs.c deleted file mode 100644 index c1cdc24b7..000000000 --- a/modules/core_api/ut-stubs/src/ut_es_stubs.c +++ /dev/null @@ -1,1296 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** File: ut_es_stubs.c -** -** Purpose: -** Unit test stubs for Executive Service routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ -#include -#include "cfe_es.h" -#include "cfe_resourceid.h" -#include "cfe_resourceid_basevalue.h" - -#include "utstubs.h" -#include "utassert.h" - -/* - * Assign ID base values for UT - */ -enum -{ - UT_CFE_ES_TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x21), - UT_CFE_ES_APPID_BASE = CFE_RESOURCEID_MAKE_BASE(0x22), - UT_CFE_ES_LIBID_BASE = CFE_RESOURCEID_MAKE_BASE(0x23), - UT_CFE_ES_COUNTID_BASE = CFE_RESOURCEID_MAKE_BASE(0x24), - UT_CFE_ES_POOLID_BASE = CFE_RESOURCEID_MAKE_BASE(0x25), - UT_CFE_ES_CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x26) -}; - -/* - * Unit-test stub definitions/limits - * - * Note these limits only apply to the ES _stubs_ and not - * the normal implementation. It should not be necessary - * to configure these on a deployment basis. - */ - -/* - * Maximum block size for ES pool requests - * - * This is only for pool block requests where the test - * case does _not_ register its own buffer, and therefore - * gets serviced from the default (static) pool buffer. - * - * This fixed value should be enough for most simple test - * cases. If a test case requires a larger block, it should - * register its own simulated pool using UT_SetDataBuffer, - * rather than changing this value. - */ -#define CFE_UT_ES_POOL_STATIC_BLOCK_SIZE 4096 - -/* - * Default value to return from calls that output an App ID, if the - * test case does not provide a value - */ -#define CFE_UT_ES_DEFAULT_APPID CFE_ES_APPID_C(CFE_ResourceId_FromInteger(UT_CFE_ES_APPID_BASE + 1)) - -/* - * Default value to return from calls that output a Task ID, if the - * test case does not provide a value - */ -#define CFE_UT_ES_DEFAULT_TASKID CFE_ES_TASKID_C(CFE_ResourceId_FromInteger(UT_CFE_ES_TASKID_BASE + 1)) - -/* - * Default value to return from calls that output a CDS ID, if the - * test case does not provide a value - */ -#define CFE_UT_ES_DEFAULT_CDSID CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(UT_CFE_ES_CDSBLOCKID_BASE + 1)) - -/* - * Invalid value to output from calls as resource ID for the - * calls that return failure. If subsequently used by application code, - * it will likely induce a segfault or other noticeably bad behavior. - */ -#define CFE_UT_ES_ID_INVALID CFE_ResourceId_FromInteger(0xDEADBEEF) - -/* -** Functions -*/ -/*****************************************************************************/ -/** -** \brief CFE_ES_CreateChildTask stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_CreateChildTask. The user can adjust the response by setting -** the values in the ES_CreateChildRtn structure prior to this function -** being called. If the value ES_CreateChildRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value -** ES_CreateChildRtn.value. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, - CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, CFE_ES_StackPointer_t StackPtr, - size_t StackSize, CFE_ES_TaskPriority_Atom_t Priority, uint32 Flags) -{ - 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); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetAppID stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_GetAppID. The user can adjust the response by setting -** the values in the GetAppIDRtn structure prior to this function -** being called. If the value GetAppIDRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value GetAppIDRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppID), AppIdPtr); - - int32 status; - CFE_ES_AppId_t *IdBuff; - size_t BuffSize; - size_t Position; - - status = UT_DEFAULT_IMPL(CFE_ES_GetAppID); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppID), (void **)&IdBuff, &BuffSize, &Position); - if (IdBuff != NULL && BuffSize == sizeof(*AppIdPtr)) - { - *AppIdPtr = *IdBuff; - } - else - { - *AppIdPtr = CFE_UT_ES_DEFAULT_APPID; - } - } - - if (status < 0) - { - *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); - } - - return status; -} - -int32 CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetTaskID), TaskIdPtr); - - int32 status; - CFE_ES_TaskId_t *IdBuff; - size_t BuffSize; - size_t Position; - - status = UT_DEFAULT_IMPL(CFE_ES_GetTaskID); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_ES_GetTaskID), (void **)&IdBuff, &BuffSize, &Position); - if (IdBuff != NULL && BuffSize == sizeof(*TaskIdPtr)) - { - *TaskIdPtr = *IdBuff; - } - else - { - *TaskIdPtr = CFE_UT_ES_DEFAULT_TASKID; - } - } - - if (status < 0) - { - *TaskIdPtr = CFE_ES_TASKID_C(CFE_UT_ES_ID_INVALID); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetAppIDByName stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_GetAppIDByName. The user can adjust the response by setting -** the value of UT_appname prior to this function being called, then -** choosing specific values for the application name (pAppName) used -** when calling this function. The application ID returned is -** dependent on the application name provided. If application name -** doesn't match the expected values the function returns an error -** code. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either CFE_ES_ERR_NAME_NOT_FOUND or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppIdPtr); - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetAppIDByName), AppName); - - size_t UserBuffSize; - size_t BuffPosition; - const char * NameBuff; - CFE_ES_AppId_t *IdBuff; - int32 status; - - status = UT_DEFAULT_IMPL(CFE_ES_GetAppIDByName); - - if (status >= 0) - { - 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, AppName, UserBuffSize) == 0) - { - UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppID), (void **)&IdBuff, &UserBuffSize, &BuffPosition); - } - - if (IdBuff != NULL && UserBuffSize == sizeof(*AppIdPtr)) - { - *AppIdPtr = *IdBuff; - } - else - { - *AppIdPtr = CFE_UT_ES_DEFAULT_APPID; - } - } - } - - if (status < 0) - { - *AppIdPtr = CFE_ES_APPID_C(CFE_UT_ES_ID_INVALID); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetAppName stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_GetAppName. The user must set the value of UT_appname prior -** to this function being called. The function uses UT_appname for the -** retrieved application name and returns CFE_SUCCESS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t 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); - - size_t UserBuffSize; - size_t BuffPosition; - const char *NameBuff; - int32 status; - - status = UT_DEFAULT_IMPL(CFE_ES_GetAppName); - - if (status >= 0 && BufferLength > 0) - { - UT_GetDataBuffer(UT_KEY(CFE_ES_GetAppName), (void **)&NameBuff, &UserBuffSize, &BuffPosition); - if (NameBuff == NULL || UserBuffSize == 0) - { - NameBuff = "UT"; - UserBuffSize = 2; - } - - if (UserBuffSize < BufferLength) - { - BuffPosition = UserBuffSize; - } - else - { - BuffPosition = BufferLength - 1; - } - - strncpy(AppName, NameBuff, BuffPosition); - AppName[BuffPosition] = 0; - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_WriteToSysLog stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_WriteToSysLog. It always returns CFE_SUCCESS when called. -** The log message is compared to known CFE function responses and if -** a match is found the value WriteSysLogRtn.value is set to a -** specified constant value. WriteSysLogRtn.count is incremented to -** keep track of the number of messages logged. The unit test code -** compares the WriteSysLogRtn value and count variables against -** expected totals to ensure the proper response of other functions -** being tested. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_WriteToSysLog), SpecStringPtr); - - int32 status; - va_list va; - char str[128]; - char * newline; - - va_start(va, SpecStringPtr); - vsnprintf(str, sizeof(str), SpecStringPtr, va); - - /* Replace newline since UtDebug already adds one */ - newline = strchr(str, '\n'); - if (newline != NULL) - { - *newline = '\0'; - } - - UtDebug("CFE_ES_WriteToSysLog: %s", str); - va_end(va); - - 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 *)SpecStringPtr, strlen(SpecStringPtr)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetPoolBuf stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_GetPoolBuf. The user can adjust the response by setting -** the values in the GetPoolRtn structure prior to this function -** being called. If the value GetPoolRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value GetPoolRtn.value. -** Otherwise the buffer size is computed based on the Size value and -** returned. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined value, or the buffer size based on Size -** value (0xffffffff if Size exceeds maximum value allowed). -** -******************************************************************************/ -int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, CFE_ES_MemHandle_t PoolID, size_t Size) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_GetPoolBuf), BufPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBuf), PoolID); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBuf), Size); - - static union - { - uint32 Start; - CFE_ES_PoolAlign_t Align; - uint8 Bytes[CFE_UT_ES_POOL_STATIC_BLOCK_SIZE]; - } Buffer; - - size_t PoolSize; - size_t PositionStart; - size_t PositionEnd; - void * PoolPtr; - cpuaddr BufAddrStart; - cpuaddr BufAddrEnd; - int32 status; - - /* - * Determine the actual alignment of the CFE_ES_PoolAlign_t structure. - * This is done by checking the offset of a struct member of that type following a single byte. - */ - const cpuaddr AlignMask = ((cpuaddr) & ((struct { - char Byte; - CFE_ES_PoolAlign_t Align; - } *)0) - ->Align) - - 1; - - status = UT_DEFAULT_IMPL_RC(CFE_ES_GetPoolBuf, Size); - - if (status > 0) - { - Size = status; - - UT_GetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), (void **)&PoolPtr, &PoolSize, &PositionStart); - if (PoolSize == 0) - { - /* - * This means the test case did not register a buffer. - * Use the static buffer to fulfill the request. - */ - PoolPtr = Buffer.Bytes; - PoolSize = sizeof(Buffer); - PositionStart = 0; - } - - BufAddrStart = (cpuaddr)PoolPtr + PositionStart; - BufAddrStart = (BufAddrStart + AlignMask) & ~AlignMask; - BufAddrEnd = (BufAddrStart + Size + AlignMask) & ~AlignMask; - PositionEnd = BufAddrEnd - (cpuaddr)PoolPtr; - - if (PositionEnd <= PoolSize) - { - *BufPtr = CFE_ES_MEMPOOLBUF_C(BufAddrStart); - memset((void *)BufAddrStart, 0x55, Size); - - /* - * Unfortunately the UT assert stub library is missing - * the ability to set the buffer position, the only way - * to do it is by calling CopyFromLocal to advance the position. - */ - Size = PositionEnd - PositionStart; - while (Size > sizeof(Buffer)) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), &Buffer, sizeof(Buffer)); - Size -= sizeof(Buffer); - } - UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_GetPoolBuf), &Buffer, Size); - } - else - { - /* - * This a a bug in the test case. - * - * The buffer is insufficient, so the test case must - * use UT_SetDataBuffer() to register a pool buffer that is - * sufficient for the code under test. - */ - UtAssert_Failed("Pool buffer empty in %s: need at least %lu bytes, given %lu", __func__, - (unsigned long)PositionEnd, (unsigned long)PoolSize); - status = -1; - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_PoolCreate stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_PoolCreate. The user can adjust the response by setting -** the values in the CreatePoolRtn structure prior to this function -** being called. If the value CreatePoolRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value CreatePoolRtn.value. -** OS_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or OS_SUCCESS. -** -******************************************************************************/ -CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreate), PoolID); - 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); - - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_ES_PoolCreate), (uint8 *)PoolID, sizeof(*PoolID)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_PoolCreateNoSem stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_PoolCreateNoSem. It always returns OS_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns OS_SUCCESS. -** -******************************************************************************/ -CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateNoSem), PoolID); - 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); - - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_ES_PoolCreateNoSem), (uint8 *)PoolID, sizeof(*PoolID)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_PoolCreateEx stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_PoolCreateEx. The user can adjust the response by setting -** the values in the PoolCreateExRtn structure prior to this function -** being called. If the value PoolCreateExRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value PoolCreateExRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size, uint16 NumBlockSizes, - const size_t *BlockSizes, bool UseMutex) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_ES_PoolCreateEx), PoolID); - 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); - - return status; -} - -/*****************************************************************************/ -/** - * \brief CFE_ES_PoolDelete stub function - */ -int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PoolDelete), PoolID); - - int32 status = CFE_SUCCESS; - - status = UT_DEFAULT_IMPL(CFE_ES_PoolDelete); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_PutPoolBuf stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_PutPoolBuf. The user can adjust the response by setting -** the values in the PutPoolRtn structure prior to this function -** being called. If the value PutPoolRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value PutPoolRtn.value. -** Otherwise the return value is positive, indicating success, if the -** user sets UT_PutPool_Fail equal to zero prior to calling this -** function; if UT_PutPool_Fail is non-zero then -1 is returned, -** indicating failure. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag, 16, or -1. -** -******************************************************************************/ -int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t PoolID, CFE_ES_MemPoolBuf_t BufPtr) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PutPoolBuf), PoolID); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_PutPoolBuf), BufPtr); - - int32 status; - - status = UT_DEFAULT_IMPL_RC(CFE_ES_PutPoolBuf, 16); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetPoolBufInfo stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_GetPoolBufInfo. The user can adjust the response by setting -** the values in the GetPoolInfoRtn structure prior to this function -** being called. If the value GetPoolInfoRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value GetPoolInfoRtn.value. -** A positive value, indicating success, is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or 16. -** -******************************************************************************/ -int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t PoolID, CFE_ES_MemPoolBuf_t BufPtr) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBufInfo), PoolID); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_GetPoolBufInfo), BufPtr); - - int32 status; - - status = UT_DEFAULT_IMPL_RC(CFE_ES_GetPoolBufInfo, 16); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_PerfLogAdd stub function -** -** \par Description -** This function is used as a placeholder for the cFE ES function -** CFE_ES_PerfLogAdd. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_ES_PerfLogAdd(uint32 Marker, uint32 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); -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_CalculateCRC stub function -** -** \par Description -** This function is used as a placeholder for the cFE ES function -** CFE_ES_CalculateCRC. It is set to return a fixed CRC value for the -** unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, 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 status; - - status = UT_DEFAULT_IMPL(CFE_ES_CalculateCRC); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetTaskInfo stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_GetTaskInfo. The user can adjust the response by setting -** the values in the ES_GetTaskInfoRtn structure prior to this function -** being called. If the value ES_GetTaskInfoRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value ES_GetTaskInfoRtn.value. -** CFE_SUCCESS is returned otherwise. The user can adjust the -** application name and task name by setting the value of UT_appname -** prior to this function being called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t 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); - - if (status >= 0) - { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetTaskInfo), (uint8 *)TaskInfo, sizeof(*TaskInfo)) < sizeof(*TaskInfo)) - { - memset(TaskInfo, 0, sizeof(*TaskInfo)); - TaskInfo->AppId = CFE_UT_ES_DEFAULT_APPID; - strncpy((char *)&TaskInfo->AppName, "UT", sizeof(TaskInfo->AppName)); - strncpy((char *)&TaskInfo->TaskName, "UT", sizeof(TaskInfo->TaskName)); - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_ExitApp stub function -** -** \par Description -** This function is used as a placeholder for the cFE ES function -** CFE_ES_ExitApp. The value passed to the function, ExitStatus, is -** added to the variable ES_ExitAppRtn.value and the variable -** ES_ExitAppRtn.count is incremented each time this function is called. -** The unit tests compare these values to expected results to verify -** proper system response. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_ES_ExitApp(uint32 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)); -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_CopyToCDS stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_CopyToCDS. The user can adjust the response by setting -** the values in the ES_CopyToCDSRtn structure prior to this function -** being called. If the value ES_CopyToCDSRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value ES_CopyToCDSRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy) -{ - int32 status; - size_t CdsBufferSize; - - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_CopyToCDS), Handle); - UT_Stub_RegisterContext(UT_KEY(CFE_ES_CopyToCDS), DataToCopy); - status = UT_DEFAULT_IMPL(CFE_ES_CopyToCDS); - - if (status >= 0) - { - /* query the size of the supplied data buffer, if any */ - UT_GetDataBuffer(UT_KEY(CFE_ES_CopyToCDS), NULL, &CdsBufferSize, NULL); - if (CdsBufferSize > 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_ES_CopyToCDS), DataToCopy, CdsBufferSize); - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_RestoreFromCDS stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_RestoreFromCDS. The user can adjust the response by setting -** the values in the ES_RestoreFromCDSRtn structure prior to this -** function being called. If the value ES_RestoreFromCDSRtn.count is -** greater than zero then the counter is decremented; if it then equals -** zero the return value is set to the user-defined value -** ES_RestoreFromCDSRtn.value. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) -{ - int32 status; - size_t CdsBufferSize; - - UT_Stub_RegisterContext(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_RestoreFromCDS), Handle); - status = UT_DEFAULT_IMPL(CFE_ES_RestoreFromCDS); - - if (status >= 0) - { - /* query the size of the supplied data buffer, if any */ - UT_GetDataBuffer(UT_KEY(CFE_ES_RestoreFromCDS), NULL, &CdsBufferSize, NULL); - if (CdsBufferSize > 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_ES_RestoreFromCDS), RestoreToMemory, CdsBufferSize); - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_RegisterCDSEx stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_RegisterCDSEx. The user can adjust the response by setting -** the values in the ES_RegisterCDSRtn structure prior to this function -** being called. If the value ES_RegisterCDSRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value -** ES_RegisterCDSRtn.value. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl) -{ - int32 status = CFE_SUCCESS; - - status = UT_DEFAULT_IMPL(CFE_ES_RegisterCDSEx); - - if (status >= 0) - { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_RegisterCDSEx), (uint8 *)HandlePtr, sizeof(*HandlePtr)) < - sizeof(*HandlePtr)) - { - *HandlePtr = CFE_UT_ES_DEFAULT_CDSID; - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_DeleteCDS stub function -** -** \par Description -** This function is used to mimic the response of the cFE ES function -** CFE_ES_DeleteCDS. The user can adjust the response by setting -** the values in the ES_DeleteCDSRtn structure prior to this function -** being called. If the value ES_DeleteCDSRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value ES_DeleteCDSRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) -{ - int32 status = CFE_SUCCESS; - - status = UT_DEFAULT_IMPL(CFE_ES_DeleteCDS); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_GetResetType stub function -** -** \par Description -** This function is used as a placeholder for the cFE ES function -** CFE_ES_GetResetType. It returns the user-defined value, -** GetResetTypeRtn.value. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns a user-defined status flag. -** -******************************************************************************/ -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); - - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_ES_GetResetType), (uint8 *)ResetSubtypePtr, sizeof(*ResetSubtypePtr)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_IncrementTaskCounter stub function -** -** \par Description -** This function is used as a placeholder for the cFE ES function -** CFE_ES_IncrementTaskCounter. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_ES_IncrementTaskCounter(void) -{ - UT_DEFAULT_IMPL(CFE_ES_IncrementTaskCounter); -} - -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); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_ES_WaitForStartupSync stub function -** -** \par Description -** This function is used as a placeholder for the cFE ES function -** CFE_ES_WaitForStartupSync. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -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; -} - -CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t 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(CFE_ES_AppId_t 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(CFE_ES_TaskId_t 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(CFE_ES_CounterId_t 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, CFE_ES_AppId_t 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(CFE_ES_CounterId_t 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(CFE_ES_CounterId_t *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(CFE_ES_CounterId_t 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(CFE_ES_CounterId_t *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(CFE_ES_AppId_t 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(CFE_ES_AppId_t 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(CFE_ES_CounterId_t 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; -} - -int32 CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_AppID_ToIndex), AppID); - UT_Stub_RegisterContext(UT_KEY(CFE_ES_AppID_ToIndex), Idx); - - int32 return_code; - - *Idx = CFE_RESOURCEID_TO_ULONG(AppID) & 0xFFFF; - return_code = UT_DEFAULT_IMPL_RC(CFE_ES_AppID_ToIndex, 1); - - if (return_code == 1) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_ES_AppID_ToIndex), Idx, sizeof(*Idx)); - return_code = CFE_SUCCESS; - } - - if (return_code != CFE_SUCCESS) - { - *Idx = 0xDEADBEEFU; - } - - return return_code; -} - -int32 CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ES_TaskID_ToIndex), TaskID); - UT_Stub_RegisterContext(UT_KEY(CFE_ES_TaskID_ToIndex), Idx); - - int32 return_code; - - *Idx = CFE_RESOURCEID_TO_ULONG(TaskID) & 0xFFFF; - return_code = UT_DEFAULT_IMPL_RC(CFE_ES_TaskID_ToIndex, 1); - - if (return_code == 1) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_ES_TaskID_ToIndex), Idx, sizeof(*Idx)); - return_code = CFE_SUCCESS; - } - - if (return_code != CFE_SUCCESS) - { - *Idx = 0xDEADBEEFU; - } - - return return_code; -} - -void CFE_ES_BackgroundWakeup(void) -{ - UT_DEFAULT_IMPL(CFE_ES_BackgroundWakeup); -} diff --git a/modules/core_api/ut-stubs/src/ut_evs_stubs.c b/modules/core_api/ut-stubs/src/ut_evs_stubs.c deleted file mode 100644 index 1d0ff921a..000000000 --- a/modules/core_api/ut-stubs/src/ut_evs_stubs.c +++ /dev/null @@ -1,313 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** File: ut_evs_stubs.c -** -** Purpose: -** Unit test stubs for Event Service routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ -#include -#include "cfe_evs.h" - -#include "utstubs.h" -#include "uttools.h" - -/* -** Functions -*/ -/*****************************************************************************/ -/** -** \brief CFE_EVS_EarlyInit stub function -** -** \par Description -** This function is used to mimic the response of the cFE EVS function -** CFE_EVS_EarlyInit. It always returns CFE_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_EVS_EarlyInit(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_EVS_EarlyInit); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_EVS_TaskMain stub function -** -** \par Description -** This function is used as a placeholder for the cFE EVS function -** CFE_EVS_TaskMain. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_EVS_TaskMain(void) -{ - UT_DEFAULT_IMPL(CFE_EVS_TaskMain); -} - -/*****************************************************************************/ -/** -** \brief CFE_EVS_SendEvent stub function -** -** \par Description -** This function is used to mimic the response of the cFE EVS function -** CFE_EVS_SendEvent. The user can adjust the response by setting -** the values in the EVS_SendEventRtn structure prior to this function -** being called. If the value EVS_SendEventRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value EVS_SendEventRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, 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); - - UtDebug("CFE_EVS_SendEvent: %u - %s", EventID, Spec); - - int32 status; - va_list va; - - va_start(va, Spec); - status = UT_DEFAULT_IMPL_VARARGS(CFE_EVS_SendEvent, va); - va_end(va); - - if (status >= 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_EVS_SendEvent), (uint8 *)&EventID, sizeof(EventID)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_EVS_SendTimedEvent stub function -** -** \par Description -** This function is used to mimic the response of the cFE EVS function -** CFE_EVS_SendTimedEvent. It always returns CFE_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, 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; - - UtDebug("CFE_EVS_SendTimedEvent: %u - %s", EventID, Spec); - - va_start(va, Spec); - status = UT_DefaultStubImplWithArgs(__func__, UT_KEY(CFE_EVS_SendTimedEvent), CFE_SUCCESS, va); - va_end(va); - - if (status >= 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_EVS_SendTimedEvent), (uint8 *)&EventID, sizeof(EventID)); - } - - return CFE_SUCCESS; -} - -/*****************************************************************************/ -/** -** \brief CFE_EVS_Register stub function -** -** \par Description -** This function is used to mimic the response of the cFE EVS function -** CFE_EVS_Register. The user can adjust the response by setting -** the values in the EVS_RegisterRtn structure prior to this function -** being called. If the value EVS_RegisterRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value EVS_RegisterRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_EVS_Register(const void *Filters, 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); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_EVS_SendEventWithAppID stub function -** -** \par Description -** This function is used to mimic the response of the cFE EVS function -** CFE_EVS_SendEventWithAppID. The event ID, EventID, is added to the -** unit test' event history. The number of events can be retrieved by -** the unit tests for comparison to expected values in order to detect -** correct functionality. The user can adjust the response by setting -** the values in the EVS_SendEventRtn structure prior to this function -** being called. If the value EVS_SendEventRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value EVS_SendEventRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_EVS_SendEventWithAppID(uint16 EventID, uint16 EventType, CFE_ES_AppId_t AppID, 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; - - UtDebug("CFE_EVS_SendEventWithAppID: %u - %s", EventID, Spec); - - va_start(va, Spec); - status = UT_DefaultStubImplWithArgs(__func__, UT_KEY(CFE_EVS_SendEventWithAppID), CFE_SUCCESS, va); - va_end(va); - - if (status >= 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_EVS_SendEventWithAppID), (uint8 *)&EventID, sizeof(EventID)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_EVS_CleanUpApp stub function -** -** \par Description -** This function is used to mimic the response of the cFE EVS function -** CFE_EVS_CleanUpApp. The user can adjust the response by setting -** the values in the EVSCleanUpRtn structure prior to this function -** being called. If the value EVSCleanUpRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value EVSCleanUpRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_EVS_CleanUpApp); - - return status; -} - -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/modules/core_api/ut-stubs/src/ut_fs_stubs.c b/modules/core_api/ut-stubs/src/ut_fs_stubs.c deleted file mode 100644 index 1f9a1eafe..000000000 --- a/modules/core_api/ut-stubs/src/ut_fs_stubs.c +++ /dev/null @@ -1,453 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** File: ut_fs_stubs.c -** -** Purpose: -** Unit test stubs for File Service routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ -#include -#include "cfe.h" -#include "utstubs.h" - -/* -** Functions -*/ - -/* - * Stub for CFE_FS_GetDefaultMountPoint() - */ -const char *CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_t FileCategory) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_GetDefaultMountPoint), FileCategory); - - int32 Status; - static const char DEFAULT_MOUNTPOINT[] = "/ut"; - const char * Result; - - Status = UT_DEFAULT_IMPL(CFE_FS_GetDefaultMountPoint); - Result = NULL; - - if (Status == CFE_SUCCESS) - { - /* If the test case supplied a buffer, return it, otherwise return fixed value */ - UT_GetDataBuffer(UT_KEY(CFE_FS_GetDefaultMountPoint), (void **)&Result, NULL, NULL); - if (Result == NULL) - { - Result = DEFAULT_MOUNTPOINT; - } - } - - return Result; -} - -/* - * Stub for CFE_FS_GetDefaultExtension() - */ -const char *CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_t FileCategory) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_GetDefaultExtension), FileCategory); - - int32 Status; - static const char DEFAULT_EXTENSION[] = ".ut"; - const char * Result; - - Status = UT_DEFAULT_IMPL(CFE_FS_GetDefaultExtension); - Result = NULL; - - if (Status == CFE_SUCCESS) - { - /* If the test case supplied a buffer, return it, otherwise return fixed value */ - UT_GetDataBuffer(UT_KEY(CFE_FS_GetDefaultExtension), (void **)&Result, NULL, NULL); - if (Result == NULL) - { - Result = DEFAULT_EXTENSION; - } - } - - return Result; -} - -/*****************************************************************************/ -/** -** \brief CFE_FS_InitHeader stub function -** -** \par Description -** This function is used to mimic the response of the cFE FS function -** CFE_FS_InitHeader. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** None -** -******************************************************************************/ -void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 SubType) -{ - 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); -} - -/*****************************************************************************/ -/** -** \brief CFE_FS_WriteHeader stub function -** -** \par Description -** This function is used to mimic the response of the cFE FS function -** CFE_FS_WriteHeader. The user can adjust the response by setting -** the values in the FSWriteHdrRtn structure prior to this function -** being called. If the value FSWriteHdrRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value FSWriteHdrRtn.value. -** The size of the CFE_FS_Header_t structure, in bytes, is returned -** otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or the size of the -** CFE_FS_Header_t structure in bytes. -** -******************************************************************************/ -int32 CFE_FS_WriteHeader(osal_id_t 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); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_FS_ReadHeader stub function -** -** \par Description -** This function is used to mimic the response of the cFE FS function -** CFE_FS_ReadHeader. The user can adjust the response by setting -** the values in the FSReadHdrRtn structure prior to this function -** being called. If the value FSReadHdrRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value FSReadHdrRtn.value. -** The size of the CFE_FS_Header_t structure, in bytes, is returned -** otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or the size of the -** CFE_FS_Header_t structure in bytes. -** -******************************************************************************/ -int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t 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)); - - if (status > 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ReadHeader), (uint8 *)Hdr, status); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_FS_SetTimestamp stub function -** -** \par Description -** This function is used to mimic the response of the cFE FS function -** CFE_FS_SetTimestamp. The user can adjust the response by setting -** the values in the FSSetTimestampRtn structure prior to this function -** being called. If the value FSSetTimestampRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value -** FSSetTimestampRtn.value. OS_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_FS_SetTimestamp(osal_id_t 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); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_FS_EarlyInit stub function -** -** \par Description -** This function is used to mimic the response of the cFE FS function -** CFE_FS_EarlyInit. It always returns CFE_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_FS_EarlyInit(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_FS_EarlyInit); - - return status; -} - -/*****************************************************************************/ -/* - * Stub for CFE_FS_ParseInputFileNameEx - see prototype for description - */ -int32 CFE_FS_ParseInputFileNameEx(char *OutputBuffer, const char *InputBuffer, size_t OutputBufSize, - size_t InputBufSize, const char *DefaultInput, const char *DefaultPath, - const char *DefaultExtension) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), OutputBuffer); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), InputBuffer); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), OutputBufSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), InputBufSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), DefaultInput); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), DefaultPath); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileNameEx), DefaultExtension); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_FS_ParseInputFileNameEx); - - /* Copy any specific output supplied by test case */ - if (status >= 0 && UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ParseInputFileNameEx), OutputBuffer, OutputBufSize) == 0 && - OutputBufSize > 0 && DefaultInput != NULL) - { - /* Otherwise fall back to simple copy */ - strncpy(OutputBuffer, DefaultInput, OutputBufSize); - } - - return status; -} - -/*****************************************************************************/ -/* - * Stub for CFE_FS_ParseInputFileName - see prototype for description - */ -int32 CFE_FS_ParseInputFileName(char *OutputBuffer, const char *InputName, size_t OutputBufSize, - CFE_FS_FileCategory_t FileCategory) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileName), OutputBuffer); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileName), InputName); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileName), OutputBufSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_ParseInputFileName), FileCategory); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_FS_ParseInputFileName); - - /* Copy any specific output supplied by test case */ - if (status >= 0 && UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ParseInputFileName), OutputBuffer, OutputBufSize) == 0 && - OutputBufSize > 0) - { - /* Otherwise fall back to simple copy */ - strncpy(OutputBuffer, InputName, OutputBufSize); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_FS_ExtractFilenameFromPath stub function -** -** \par Description -** This function is used to mimic the response of the cFE FS function -** CFE_FS_ExtractFilenameFromPath. The user can adjust the response by -** setting the values in the FSExtractRtn structure prior to this -** function being called. If the value FSExtractRtn.count is greater -** than zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value FSExtractRtn.value. -** Otherwise returns CFE_SUCCESS or an error flag dependent on the -** function's input values. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag, CFE_FS_BAD_ARGUMENT, -** CFE_FS_INVALID_PATH, CFE_FS_FNAME_TOO_LONG, or CFE_SUCCESS. -** -******************************************************************************/ -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; - int32 status; - uint32 UserBuffLen; - - status = UT_DEFAULT_IMPL(CFE_FS_ExtractFilenameFromPath); - - if (status >= 0) - { - if (OriginalPath == NULL || FileNameOnly == NULL) - { - status = CFE_FS_BAD_ARGUMENT; - } - else - { - UserBuffLen = - UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ExtractFilenameFromPath), (uint8 *)FileNameOnly, OS_MAX_FILE_NAME); - - if (UserBuffLen >= OS_MAX_FILE_NAME) - { - FileNameOnly[OS_MAX_FILE_NAME - 1] = 0; - } - else if (UserBuffLen > 0) - { - /* Just ensure that the output is null terminated */ - FileNameOnly[UserBuffLen] = 0; - } - else - { - /* Get the string length of the original file path */ - StringLength = strlen(OriginalPath); - - /* Extract the filename from the Path: - Find the last '/' Character */ - DirMarkIdx = -1; - - for (i = 0; i < StringLength; i++) - { - if (OriginalPath[i] == '/') - { - DirMarkIdx = i; - } - } - - /* Verify the filename isn't too long */ - if ((StringLength - (DirMarkIdx + 1)) < OS_MAX_PATH_LEN) - { - /* Extract the filename portion */ - if (DirMarkIdx > 0) - { - /* Extract the filename portion */ - j = 0; - - for (i = DirMarkIdx + 1; i < StringLength; i++) - { - FileNameOnly[j] = OriginalPath[i]; - j++; - } - - FileNameOnly[j] = '\0'; - } - else - { - status = CFE_FS_INVALID_PATH; - } - } - else - { - status = CFE_FS_FNAME_TOO_LONG; - } - } - } - } - - return status; -} - -bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_RunBackgroundFileDump), ElapsedTime); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_RunBackgroundFileDump), Arg); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_FS_RunBackgroundFileDump); - - return status; -} - -int32 CFE_FS_BackgroundFileDumpRequest(CFE_FS_FileWriteMetaData_t *Meta) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_BackgroundFileDumpRequest), Meta); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_FS_BackgroundFileDumpRequest); - - if (status == CFE_SUCCESS) - { - /* Snapshot the request, in case the UT test case wants to look */ - UT_Stub_CopyFromLocal(UT_KEY(CFE_FS_BackgroundFileDumpRequest), Meta, sizeof(*Meta)); - } - - return status; -} - -bool CFE_FS_BackgroundFileDumpIsPending(const CFE_FS_FileWriteMetaData_t *Meta) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_FS_BackgroundFileDumpIsPending), Meta); - - return UT_DEFAULT_IMPL(CFE_FS_BackgroundFileDumpIsPending); -} diff --git a/modules/core_api/ut-stubs/src/ut_msg_stubs.c b/modules/core_api/ut-stubs/src/ut_msg_stubs.c deleted file mode 100644 index c7d4cc8a0..000000000 --- a/modules/core_api/ut-stubs/src/ut_msg_stubs.c +++ /dev/null @@ -1,705 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** File: ut_msg_stubs.c -** -** Purpose: -** Unit test stubs for MSG routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ -#include "cfe.h" -#include "utstubs.h" -#include "uttools.h" - -/* -** Defines -*/ - -/* For reporting no value for get */ -#define UTASSERT_GETSTUB(Expression) \ - UtAssert_Type(TSF, Expression, "%s: Check for get value provided by test", __func__); - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GenerateChecksum - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GenerateChecksum(CFE_MSG_Message_t *MsgPtr) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GenerateChecksum), MsgPtr); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GenerateChecksum); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetApId - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetApId(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_ApId_t *ApId) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetApId), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetApId), ApId); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetApId); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetApId), (uint8 *)ApId, sizeof(*ApId)) == sizeof(*ApId)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetEDSVersion - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetEDSVersion(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_EDSVersion_t *Version) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetEDSVersion), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetEDSVersion), Version); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetEDSVersion); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetEDSVersion), (uint8 *)Version, sizeof(*Version)) == - sizeof(*Version)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetEndian - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetEndian(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Endian_t *Endian) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetEndian), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetEndian), Endian); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetEndian); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetEndian), (uint8 *)Endian, sizeof(*Endian)) == - sizeof(*Endian)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetFcnCode - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetFcnCode(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t *FcnCode) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetFcnCode), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetFcnCode), FcnCode); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetFcnCode); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetFcnCode), (uint8 *)FcnCode, sizeof(*FcnCode)) == - sizeof(*FcnCode)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetHasSecondaryHeader - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetHasSecondaryHeader(const CFE_MSG_Message_t *MsgPtr, bool *HasSecondary) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetHasSecondaryHeader), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetHasSecondaryHeader), HasSecondary); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetHasSecondaryHeader); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetHasSecondaryHeader), (uint8 *)HasSecondary, - sizeof(*HasSecondary)) == sizeof(*HasSecondary)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetHeaderVersion - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetHeaderVersion(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_HeaderVersion_t *Version) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetHeaderVersion), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetHeaderVersion), Version); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetHeaderVersion); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetHeaderVersion), (uint8 *)Version, sizeof(*Version)) == - sizeof(*Version)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetMsgId - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetMsgId(const CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t *MsgId) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetMsgId), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetMsgId), MsgId); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetMsgId); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetMsgId), (uint8 *)MsgId, sizeof(*MsgId)) == - sizeof(*MsgId)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetMsgTime - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetMsgTime(const CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t *Time) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetMsgTime), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetMsgTime), Time); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetMsgTime); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetMsgTime), (uint8 *)Time, sizeof(*Time)) == - sizeof(*Time)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetPlaybackFlag - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetPlaybackFlag(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_PlaybackFlag_t *PlayFlag) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetPlaybackFlag), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetPlaybackFlag), PlayFlag); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetPlaybackFlag); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetPlaybackFlag), (uint8 *)PlayFlag, sizeof(*PlayFlag)) == - sizeof(*PlayFlag)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetSegmentationFlag - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetSegmentationFlag(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_SegmentationFlag_t *SegFlag) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSegmentationFlag), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSegmentationFlag), SegFlag); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetSegmentationFlag); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSegmentationFlag), (uint8 *)SegFlag, sizeof(*SegFlag)) == - sizeof(*SegFlag)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetSequenceCount - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetSequenceCount(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t *SeqCnt) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSequenceCount), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSequenceCount), SeqCnt); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetSequenceCount); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSequenceCount), (uint8 *)SeqCnt, sizeof(*SeqCnt)) == - sizeof(*SeqCnt)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetSize - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetSize(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t *Size) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSize), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSize), Size); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetSize); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSize), (uint8 *)Size, sizeof(*Size)) == sizeof(*Size)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetSubsystem - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetSubsystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t *Subsystem) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSubsystem), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSubsystem), Subsystem); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetSubsystem); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSubsystem), (uint8 *)Subsystem, sizeof(*Subsystem)) == - sizeof(*Subsystem)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetSystem - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetSystem(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t *System) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSystem), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetSystem), System); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetSystem); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetSystem), (uint8 *)System, sizeof(*System)) == - sizeof(*System)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetType - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetType(const CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t *Type) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetType), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetType), Type); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetType); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetType), (uint8 *)Type, sizeof(*Type)) == sizeof(*Type)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_GetTypeFromMsgId - * ----------------------------------------------------------- - */ -int32 CFE_MSG_GetTypeFromMsgId(CFE_SB_MsgId_t MsgId, CFE_MSG_Type_t *Type) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetTypeFromMsgId), MsgId); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_GetTypeFromMsgId), Type); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_GetTypeFromMsgId); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_GetTypeFromMsgId), (uint8 *)Type, sizeof(*Type)) == - sizeof(*Type)); - } - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_Init - * ----------------------------------------------------------- - */ -int32 CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_MSG_Size_t Size) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_Init), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_Init), MsgId); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_Init), Size); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_Init); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetApId - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetApId(CFE_MSG_Message_t *MsgPtr, CFE_MSG_ApId_t ApId) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetApId), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetApId), ApId); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetApId); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetEDSVersion - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetEDSVersion(CFE_MSG_Message_t *MsgPtr, CFE_MSG_EDSVersion_t Version) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetEDSVersion), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetEDSVersion), Version); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetEDSVersion); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetEndian - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetEndian(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Endian_t Endian) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetEndian), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetEndian), Endian); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetEndian); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetFcnCode - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetFcnCode(CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t FcnCode) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetFcnCode), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetFcnCode), FcnCode); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetFcnCode); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetHasSecondaryHeader - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetHasSecondaryHeader(CFE_MSG_Message_t *MsgPtr, bool HasSecondary) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetHasSecondaryHeader), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetHasSecondaryHeader), HasSecondary); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetHasSecondaryHeader); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetHeaderVersion - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetHeaderVersion(CFE_MSG_Message_t *MsgPtr, CFE_MSG_HeaderVersion_t Version) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetHeaderVersion), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetHeaderVersion), Version); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetHeaderVersion); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetMsgId - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetMsgId), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetMsgId), MsgId); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetMsgId); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetMsgTime - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetMsgTime(CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t Time) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetMsgTime), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetMsgTime), Time); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetMsgTime); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetPlaybackFlag - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetPlaybackFlag(CFE_MSG_Message_t *MsgPtr, CFE_MSG_PlaybackFlag_t PlayFlag) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetPlaybackFlag), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetPlaybackFlag), PlayFlag); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetPlaybackFlag); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetSegmentationFlag - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetSegmentationFlag(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SegmentationFlag_t SegFlag) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSegmentationFlag), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSegmentationFlag), SegFlag); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetSegmentationFlag); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetSequenceCount - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetSequenceCount(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSequenceCount), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSequenceCount), SeqCnt); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetSequenceCount); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetSize - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetSize(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t Size) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSize), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSize), Size); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetSize); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetSubsystem - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetSubsystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Subsystem_t Subsystem) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSubsystem), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSubsystem), Subsystem); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetSubsystem); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetSystem - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetSystem(CFE_MSG_Message_t *MsgPtr, CFE_MSG_System_t System) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSystem), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetSystem), System); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetSystem); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_SetType - * ----------------------------------------------------------- - */ -int32 CFE_MSG_SetType(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t Type) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetType), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_SetType), Type); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_SetType); - - return status; -} - -/* - * ----------------------------------------------------------- - * Stub implementation of CFE_MSG_ValidateChecksum - * ----------------------------------------------------------- - */ -int32 CFE_MSG_ValidateChecksum(const CFE_MSG_Message_t *MsgPtr, bool *IsValid) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_ValidateChecksum), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_MSG_ValidateChecksum), IsValid); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_MSG_ValidateChecksum); - if (status >= 0) - { - UTASSERT_GETSTUB(UT_Stub_CopyToLocal(UT_KEY(CFE_MSG_ValidateChecksum), (uint8 *)IsValid, sizeof(*IsValid)) == - sizeof(*IsValid)); - } - - return status; -} diff --git a/modules/core_api/ut-stubs/src/ut_resourceid_stubs.c b/modules/core_api/ut-stubs/src/ut_resourceid_stubs.c deleted file mode 100644 index 8c3831d45..000000000 --- a/modules/core_api/ut-stubs/src/ut_resourceid_stubs.c +++ /dev/null @@ -1,120 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* - * Includes - */ -#include "osapi.h" -#include "cfe.h" -#include "utstubs.h" -#include "cfe_resourceid.h" -#include "cfe_resourceid_basevalue.h" - -uint32 CFE_ResourceId_GetBase(CFE_ResourceId_t ResourceId) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_GetBase), ResourceId); - - int32 return_code; - - return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_GetBase, -1); - - /* If a return code value was set, return it directly */ - if (return_code >= 0) - { - return (uint32)return_code; - } - - /* otherwise mimic a typical output (mask upper bits) */ - return CFE_ResourceId_ToInteger(ResourceId) & ~((uint32)CFE_RESOURCEID_MAX); -} - -uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_GetSerial), ResourceId); - - int32 return_code; - - return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_GetSerial, -1); - - /* If a return code value was set, return it directly */ - if (return_code >= 0) - { - return (uint32)return_code; - } - - /* otherwise mimic a typical output (mask lower bits) */ - return (CFE_ResourceId_ToInteger(ResourceId) & ((uint32)CFE_RESOURCEID_MAX)); -} - -CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize, - bool (*CheckFunc)(CFE_ResourceId_t)) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), StartId); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), TableSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_FindNext), CheckFunc); - - int32 return_code; - - /* Using "1" by default here produces a sequential result when called multiple times */ - return_code = UT_DEFAULT_IMPL_RC(CFE_ResourceId_FindNext, 1); - - if (return_code < 0) - { - return CFE_RESOURCEID_UNDEFINED; - } - - /* - * The test case may set the return code to indicate the offset from the start ID - */ - return CFE_ResourceId_FromInteger(CFE_ResourceId_ToInteger(StartId) + return_code); -} - -int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 TableSize, uint32 *Idx) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), Id); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), BaseValue); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), TableSize); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_ResourceId_ToIndex), Idx); - - int32 return_code; - - return_code = UT_DEFAULT_IMPL(CFE_ResourceId_ToIndex); - - if (return_code < 0) - { - /* fill with a very bad value that should cause a problem if used */ - *Idx = 0xDEADBEEF; - } - else if (UT_Stub_CopyToLocal(UT_KEY(CFE_ResourceId_ToIndex), Idx, sizeof(*Idx)) < sizeof(*Idx)) - { - /* fill with default value if unspecified by test case */ - if (CFE_ResourceId_IsDefined(Id)) - { - *Idx = (CFE_ResourceId_ToInteger(Id) - BaseValue) % TableSize; - } - else - { - *Idx = 0xDEADBEEF; - return_code = CFE_ES_ERR_RESOURCEID_NOT_VALID; - } - } - - return return_code; -} diff --git a/modules/core_api/ut-stubs/src/ut_sb_stubs.c b/modules/core_api/ut-stubs/src/ut_sb_stubs.c deleted file mode 100644 index bb24b8d2f..000000000 --- a/modules/core_api/ut-stubs/src/ut_sb_stubs.c +++ /dev/null @@ -1,774 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** File: ut_sb_stubs.c -** -** Purpose: -** Unit test stubs for Software Bus routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ -#include -#include "cfe_sb.h" -#include "cfe_time_extern_typedefs.h" - -#include "utstubs.h" - -typedef struct -{ - CFE_SB_MsgId_t MsgId; - uint32 UserLength; - uint32 TotalLength; - uint16 CommandCode; - CFE_TIME_SysTime_t TimeStamp; - -} CFE_SB_StubMsg_MetaData_t; - -static CFE_SB_StubMsg_MetaData_t *CFE_SB_StubMsg_GetMetaData(const CFE_MSG_Message_t *MsgPtr) -{ - CFE_SB_StubMsg_MetaData_t *MetaPtr; - CFE_SB_StubMsg_MetaData_t DefaultMeta; - size_t MetaSize; - UT_EntryKey_t MsgKey = (UT_EntryKey_t)MsgPtr; - - UT_GetDataBuffer(MsgKey, (void **)&MetaPtr, &MetaSize, NULL); - if (MetaPtr == NULL || MetaSize != sizeof(DefaultMeta)) - { - memset(&DefaultMeta, 0, sizeof(DefaultMeta)); - DefaultMeta.MsgId = CFE_SB_INVALID_MSG_ID; - UT_ResetState(MsgKey); - UT_SetDataBuffer(MsgKey, &DefaultMeta, sizeof(DefaultMeta), true); - - /* Because "allocate copy" is true above, this gets a pointer to the copy */ - UT_GetDataBuffer(MsgKey, (void **)&MetaPtr, &MetaSize, NULL); - } - - return MetaPtr; -} -/* -** Functions -*/ -/*****************************************************************************/ -/** -** \brief CFE_SB_EarlyInit stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_EarlyInit. It always returns CFE_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_SB_EarlyInit(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_SB_EarlyInit); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_TaskMain stub function -** -** \par Description -** This function is used as a placeholder for the cFE SB function -** CFE_SB_TaskMain. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_SB_TaskMain(void) -{ - UT_DEFAULT_IMPL(CFE_SB_TaskMain); -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_CreatePipe stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_CreatePipe. The user can adjust the response by setting -** the values in the SB_CreatePipeRtn structure prior to this function -** being called. If the value SB_CreatePipeRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value SB_CreatePipeRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -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); - - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_SB_CreatePipe), (uint8 *)PipeIdPtr, sizeof(*PipeIdPtr)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_DeletePipe stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_DeletePipe. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -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); - - if (status >= 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_DeletePipe), &PipeId, sizeof(PipeId)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_GetPipeName stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_GetPipeName. The user should set the data buffer using UT_SetDataBuffer -** prior to this function being called. Otherwise, the dummy "UT" name will -** be copied to PipeNameBuf. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -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); - - size_t UserBuffSize; - size_t BuffPosition; - const char *NameBuff; - int32 status; - - status = UT_DEFAULT_IMPL(CFE_SB_GetPipeName); - - if (status >= 0 && PipeNameSize > 0) - { - UT_GetDataBuffer(UT_KEY(CFE_SB_GetPipeName), (void **)&NameBuff, &UserBuffSize, &BuffPosition); - if (NameBuff == NULL || UserBuffSize == 0) - { - NameBuff = "UT"; - UserBuffSize = 2; - } - - if (UserBuffSize < PipeNameSize) - { - BuffPosition = UserBuffSize; - } - else - { - BuffPosition = PipeNameSize - 1; - } - - strncpy(PipeNameBuf, NameBuff, BuffPosition); - PipeNameBuf[BuffPosition] = 0; - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_GetPipeIdByName stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_GetPipeIdByName. The user can adjust the response by setting -** the value of UT_pipename prior to this function being called, then -** choosing specific values for the pipe name (PipeName) used -** when calling this function. The Pipe ID returned is -** dependent on the pipe name provided. If pipe name -** doesn't match the expected values the function returns an error -** code. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either CFE_SB_BAD_ARGUMENT or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) -{ - 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) - { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_SB_GetPipeIdByName), (uint8 *)PipeIdPtr, sizeof(*PipeIdPtr)) == - sizeof(*PipeIdPtr)) - { - status = CFE_SUCCESS; - } - else - { - status = CFE_SB_BAD_ARGUMENT; - *PipeIdPtr = CFE_SB_INVALID_PIPE; - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_ReceiveBuffer stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_ReceiveBuffer. By default it will return the TIMEOUT error response, -** unless the test setup sequence has indicated otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS or overridden unit test value -** -******************************************************************************/ -int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_SB_ReceiveBuffer), BufPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ReceiveBuffer), PipeId); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ReceiveBuffer), TimeOut); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_SB_ReceiveBuffer); - - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_SB_ReceiveBuffer), (uint8 *)BufPtr, sizeof(*BufPtr)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_TransmitMsg stub function -** -** \par Description -** This function is implements the stub version of the real implementation. -** Adds the message pointer value to the test buffer if status is -** positive -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS or overridden unit test value -** -******************************************************************************/ -int32 CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_SB_TransmitMsg), MsgPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_TransmitMsg), IncrementSequenceCount); - - int32 status = CFE_SUCCESS; - - status = UT_DEFAULT_IMPL(CFE_SB_TransmitMsg); - - if (status >= 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TransmitMsg), &MsgPtr, sizeof(MsgPtr)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_TransmitBuffer stub function -** -** \par Description -** This function is implements the stub version of the real implementation. -** Adds the buffer pointer value to the test buffer if status is -** positive -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS or overridden unit test value -** -******************************************************************************/ -int32 CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IncrementSequenceCount) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_TransmitBuffer), BufPtr); - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_TransmitBuffer), IncrementSequenceCount); - - int32 status = CFE_SUCCESS; - - status = UT_DEFAULT_IMPL(CFE_SB_TransmitBuffer); - - if (status >= 0) - { - UT_Stub_CopyFromLocal(UT_KEY(CFE_SB_TransmitBuffer), &BufPtr, sizeof(BufPtr)); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_SubscribeEx stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_SubscribeEx. The user can adjust the response by setting -** the values in the SB_SubscribeExRtn structure prior to this function -** being called. If the value SB_SubscribeExRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value -** SB_SubscribeExRtn.value. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -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; - - status = UT_DEFAULT_IMPL(CFE_SB_SubscribeEx); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_Subscribe stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_Subscribe. The user can adjust the response by setting -** the values in the SB_SubscribeRtn structure prior to this function -** being called. If the value SB_SubscribeRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value SB_SubscribeRtn.value. -** CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -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; - - status = UT_DEFAULT_IMPL(CFE_SB_Subscribe); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_SubscribeLocal stub function -** -** \par Description -** This function is used to mimic the response of the cFE SB function -** CFE_SB_SubscribeLocal. The user can adjust the response by setting -** the values in the SB_SubscribeLocalRtn structure prior to this -** function being called. If the value SB_SubscribeLocalRtn.count is -** greater than zero then the counter is decremented; if it then equals -** zero the return value is set to the user-defined value -** SB_SubscribeLocalRtn.value. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -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; - - status = UT_DEFAULT_IMPL(CFE_SB_SubscribeLocal); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_TimeStampMsg stub function -** -** \par Description -** This function is used as a placeholder for the cFE SB function -** CFE_SB_TimeStampMsg. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_SB_TimeStampMsg(CFE_MSG_Message_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)); -} - -/*****************************************************************************/ -/** -** \brief CFE_SB_CleanUpApp stub function -** -** \par Description -** This function is used as a placeholder for the cFE SB function -** CFE_SB_CleanUpApp. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_SB_CleanUpApp); - - return status; -} - -/****************************************************************************** -** Function: CFE_SB_MessageStringGet() -** -** See function prototype for full description -** -*/ -int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, - size_t DestMaxSize, size_t SourceMaxSize) -{ - 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); - - if (status == 0) - { - if (DestMaxSize == 0) - { - status = CFE_SB_BAD_ARGUMENT; - } - else - { - /* - * Check if should use the default, which is if - * the source string has zero length (first char is NUL). - */ - if (DefaultString != NULL && (SourceMaxSize == 0 || *SourceStringPtr == 0)) - { - SourceStringPtr = DefaultString; - SourceMaxSize = DestMaxSize; - } - - /* For the UT implementation, just call strncpy() */ - strncpy(DestStringPtr, SourceStringPtr, DestMaxSize - 1); - DestStringPtr[DestMaxSize - 1] = 0; - - status = strlen(DestStringPtr); - } - } - - return status; -} - -/****************************************************************************** -** Function: CFE_SB_MessageStringSet() -** -** See function prototype for full description -** -*/ -int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, - size_t SourceMaxSize) -{ - 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); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_SB_MessageStringSet); - - if (status == 0) - { - if (DestMaxSize == 0) - { - status = CFE_SB_BAD_ARGUMENT; - } - else - { - /* For the UT implementation, just call strncpy() */ - strncpy(DestStringPtr, SourceStringPtr, DestMaxSize); - if (DestStringPtr[DestMaxSize - 1] != 0) - { - status = DestMaxSize; - } - else - { - status = strlen(DestStringPtr); - } - } - } - - return status; -} - -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; -} - -void *CFE_SB_GetUserData(CFE_MSG_Message_t *MsgPtr) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_GetUserData), MsgPtr); - - uint8 *BytePtr; - void * Result; - uint16 HdrSize; - - UT_DEFAULT_IMPL(CFE_SB_GetUserData); - - if (UT_Stub_CopyToLocal(UT_KEY(CFE_SB_GetUserData), &Result, sizeof(Result)) != sizeof(Result)) - { - BytePtr = (uint8 *)MsgPtr; - if ((MsgPtr->Byte[0] & 0x10) != 0) - { - HdrSize = sizeof(CFE_MSG_CommandHeader_t); - } - else - { - HdrSize = sizeof(CFE_MSG_TelemetryHeader_t); - } - - Result = (BytePtr + HdrSize); - } - - return Result; -} - -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; -} - -size_t CFE_SB_GetUserDataLength(const CFE_MSG_Message_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_MSG_Message_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_MSG_Message_t *MsgPtr, size_t 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_Buffer_t *CFE_SB_AllocateMessageBuffer(size_t MsgSize) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_AllocateMessageBuffer), MsgSize); - - int32 status; - CFE_SB_Buffer_t *SBBufPtr = NULL; - - status = UT_DEFAULT_IMPL(CFE_SB_AllocateMessageBuffer); - - if (status == CFE_SUCCESS) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_SB_AllocateMessageBuffer), &SBBufPtr, sizeof(SBBufPtr)); - } - - return SBBufPtr; -} - -int32 CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_SB_ReleaseMessageBuffer), BufPtr); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_SB_ReleaseMessageBuffer); - - return status; -} diff --git a/modules/core_api/ut-stubs/src/ut_tbl_stubs.c b/modules/core_api/ut-stubs/src/ut_tbl_stubs.c deleted file mode 100644 index e843e8d72..000000000 --- a/modules/core_api/ut-stubs/src/ut_tbl_stubs.c +++ /dev/null @@ -1,311 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** Includes -*/ -#include -#include "cfe_tbl.h" - -#include "utstubs.h" - -/* -** Functions -*/ -/*****************************************************************************/ -/** -** \brief CFE_TBL_EarlyInit stub function -** -** \par Description -** This function is used to mimic the response of the cFE TBL function -** CFE_TBL_EarlyInit. The user can adjust the response by setting -** the values in the TBLEarlyInitRtn structure prior to this function -** being called. If the value TBLEarlyInitRtn.count is non-zero then -** the return value is set to -1. CFE_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either -1 or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_TBL_EarlyInit(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TBL_EarlyInit); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_TBL_TaskMain stub function -** -** \par Description -** This function is used as a placeholder for the cFE TBL function -** CFE_TBL_TaskMain. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_TBL_TaskMain(void) -{ - UT_DEFAULT_IMPL(CFE_TBL_TaskMain); -} - -/*****************************************************************************/ -/** -** \brief CFE_TBL_CleanUpApp stub function -** -** \par Description -** This function is used to mimic the response of the cFE TBL function -** CFE_TBL_CleanUpApp. It always returns CFE_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TBL_CleanUpApp); - - return status; -} - -int32 CFE_TBL_Register(CFE_TBL_Handle_t * TblHandlePtr, /* Returned Handle */ - const char * Name, /* Application specific name */ - size_t Size, /* Size, in bytes, of table */ - 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); - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_TBL_Register), (uint8 *)TblHandlePtr, sizeof(CFE_TBL_Handle_t)); - } - - return status; -} - -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; - - status = UT_DEFAULT_IMPL(CFE_TBL_GetAddress); - if (status >= 0 && !UT_Stub_CheckDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), &ForceValue)) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_TBL_GetAddress), (uint8 *)TblPtr, sizeof(void *)); - } - - return status; -} - -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; -} - -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; -} - -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); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TBL_Validate); - - return status; -} - -int32 CFE_TBL_Update(CFE_TBL_Handle_t TblHandle) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TBL_Update), TblHandle); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TBL_Update); - - 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); - if (status >= 0 && - UT_Stub_CopyToLocal(UT_KEY(CFE_TBL_GetInfo), TblInfoPtr, sizeof(*TblInfoPtr)) < sizeof(*TblInfoPtr)) - { - /* just clear the output struct */ - memset(TblInfoPtr, 0, sizeof(*TblInfoPtr)); - } - - 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/modules/core_api/ut-stubs/src/ut_time_hooks.c b/modules/core_api/ut-stubs/src/ut_time_hooks.c new file mode 100644 index 000000000..1f6c9c13f --- /dev/null +++ b/modules/core_api/ut-stubs/src/ut_time_hooks.c @@ -0,0 +1,229 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_time_stubs.c +** +** Purpose: +** Unit test stubs for Time routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include +#include "cfe_time.h" + +#include "utstubs.h" + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_Print coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_Print(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + char * PrintBuffer = UT_Hook_GetArgValueByName(Context, "PrintBuffer", char *); + CFE_TIME_SysTime_t TimeToPrint = UT_Hook_GetArgValueByName(Context, "TimeToPrint", CFE_TIME_SysTime_t); + + snprintf(PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE, "UT %u.%u -", (unsigned int)TimeToPrint.Seconds, + (unsigned int)TimeToPrint.Subseconds); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetTime coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetTime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + static CFE_TIME_SysTime_t SimTime = {0}; + CFE_TIME_SysTime_t Result = {0}; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetTime), &Result, sizeof(Result)) < sizeof(Result)) + { + SimTime.Seconds++; + SimTime.Subseconds++; + Result = SimTime; + } + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_Add coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_Add(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_TIME_SysTime_t Time1 = UT_Hook_GetArgValueByName(Context, "Time1", CFE_TIME_SysTime_t); + CFE_TIME_SysTime_t Time2 = UT_Hook_GetArgValueByName(Context, "Time2", CFE_TIME_SysTime_t); + + static CFE_TIME_SysTime_t SimTime = {0}; + CFE_TIME_SysTime_t Result = {0}; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_Add), (uint8 *)&Result, sizeof(Result)) < sizeof(Result)) + { + SimTime.Seconds++; + SimTime.Subseconds++; + Result = SimTime; + } + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetMET coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetMET(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetMET), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetSTCF coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetSTCF(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetSTCF), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetTAI coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetTAI(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetTAI), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_GetUTC coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_GetUTC(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetUTC), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_MET2SCTime coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_MET2SCTime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_MET2SCTime), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_TIME_Subtract coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_TIME_Subtract(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_TIME_SysTime_t Time1 = UT_Hook_GetArgValueByName(Context, "Time1", CFE_TIME_SysTime_t); + CFE_TIME_SysTime_t Time2 = UT_Hook_GetArgValueByName(Context, "Time2", CFE_TIME_SysTime_t); + + int32 status; + CFE_TIME_SysTime_t Result = {0}; + + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_Subtract), &Result, sizeof(Result)); + } + + UT_Stub_SetReturnValue(FuncKey, Result); +} diff --git a/modules/core_api/ut-stubs/src/ut_time_stubs.c b/modules/core_api/ut-stubs/src/ut_time_stubs.c deleted file mode 100644 index 172621b2e..000000000 --- a/modules/core_api/ut-stubs/src/ut_time_stubs.c +++ /dev/null @@ -1,419 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* -** File: ut_time_stubs.c -** -** Purpose: -** Unit test stubs for Time routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ -#include -#include -#include "cfe_time.h" - -#include "utstubs.h" - -/* -** Functions -*/ -/*****************************************************************************/ -/** -** \brief CFE_TIME_EarlyInit stub function -** -** \par Description -** This function is used to mimic the response of the cFE TIME function -** CFE_TIME_EarlyInit. It always returns OS_SUCCESS when called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_TIME_EarlyInit(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TIME_EarlyInit); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_TIME_TaskMain stub function -** -** \par Description -** This function is used as a placeholder for the cFE TIME function -** CFE_TIME_TaskMain. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_TIME_TaskMain(void) -{ - UT_DEFAULT_IMPL(CFE_TIME_TaskMain); -} - -/*****************************************************************************/ -/** -** \brief CFE_TIME_Print stub function -** -** \par Description -** This function is used to mimic the response of the cFE TIME function -** CFE_TIME_Print. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -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_DEFAULT_IMPL(CFE_TIME_Print); -} - -/*****************************************************************************/ -/** -** \brief CFE_TIME_GetTime stub function -** -** \par Description -** This function is used to mimic the response of the cFE TIME function -** CFE_TIME_GetTime. It increments the time structure values each time -** it's called to provide a non-static time value for the unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns the time structure. -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_GetTime(void) -{ - static CFE_TIME_SysTime_t SimTime = {0}; - CFE_TIME_SysTime_t Result = {0}; - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TIME_GetTime); - - if (status >= 0) - { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_GetTime), (uint8 *)&Result, sizeof(Result)) < sizeof(Result)) - { - SimTime.Seconds++; - SimTime.Subseconds++; - Result = SimTime; - } - } - - return Result; -} - -/*****************************************************************************/ -/** -** \brief CFE_TIME_CleanUpApp stub function -** -** \par Description -** This function is used to mimic the response of the cFE TIME function -** CFE_TIME_CleanUpApp. The user can adjust the response by setting -** the values in the TIMECleanUpRtn structure prior to this function -** being called. If the value TIMECleanUpRtn.count is greater than -** zero then the counter is decremented; if it then equals zero the -** return value is set to the user-defined value TIMECleanUpRtn.value. -** A positive value, indicating success, is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or CFE_SUCCESS. -** -******************************************************************************/ -int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TIME_CleanUpApp); - - return status; -} - -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); - - return (CFE_TIME_Compare_t)status; -} - -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; - - status = UT_DEFAULT_IMPL(CFE_TIME_Add); - - if (status >= 0) - { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_TIME_Add), (uint8 *)&Result, sizeof(Result)) < sizeof(Result)) - { - SimTime.Seconds++; - SimTime.Subseconds++; - Result = SimTime; - } - } - - return Result; -} - -uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(CFE_TIME_Sub2MicroSecs), SubSeconds); - - int32 status; - - status = UT_DEFAULT_IMPL(CFE_TIME_Sub2MicroSecs); - - return (uint32)status; -} - -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_UnregisterSynchCallback); - - 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; -} - -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; -} diff --git a/modules/core_api/fsw/inc/cfe_es_core_internal.h b/modules/core_private/fsw/inc/cfe_es_core_internal.h similarity index 100% rename from modules/core_api/fsw/inc/cfe_es_core_internal.h rename to modules/core_private/fsw/inc/cfe_es_core_internal.h diff --git a/modules/core_api/fsw/inc/cfe_evs_core_internal.h b/modules/core_private/fsw/inc/cfe_evs_core_internal.h similarity index 100% rename from modules/core_api/fsw/inc/cfe_evs_core_internal.h rename to modules/core_private/fsw/inc/cfe_evs_core_internal.h diff --git a/modules/core_api/fsw/inc/cfe_fs_core_internal.h b/modules/core_private/fsw/inc/cfe_fs_core_internal.h similarity index 100% rename from modules/core_api/fsw/inc/cfe_fs_core_internal.h rename to modules/core_private/fsw/inc/cfe_fs_core_internal.h diff --git a/modules/core_api/fsw/inc/cfe_sb_core_internal.h b/modules/core_private/fsw/inc/cfe_sb_core_internal.h similarity index 100% rename from modules/core_api/fsw/inc/cfe_sb_core_internal.h rename to modules/core_private/fsw/inc/cfe_sb_core_internal.h diff --git a/modules/core_private/fsw/inc/cfe_sbr.h b/modules/core_private/fsw/inc/cfe_sbr.h index a35d5f4c2..efee0e056 100644 --- a/modules/core_private/fsw/inc/cfe_sbr.h +++ b/modules/core_private/fsw/inc/cfe_sbr.h @@ -36,6 +36,7 @@ #include "cfe_sbr_api_typedefs.h" #include "cfe_msg_api_typedefs.h" #include "cfe_sb_destination_typedef.h" +#include "cfe_sb_api_typedefs.h" #include "cfe_platform_cfg.h" diff --git a/modules/core_api/fsw/inc/cfe_tbl_core_internal.h b/modules/core_private/fsw/inc/cfe_tbl_core_internal.h similarity index 100% rename from modules/core_api/fsw/inc/cfe_tbl_core_internal.h rename to modules/core_private/fsw/inc/cfe_tbl_core_internal.h diff --git a/modules/core_api/fsw/inc/cfe_time_core_internal.h b/modules/core_private/fsw/inc/cfe_time_core_internal.h similarity index 100% rename from modules/core_api/fsw/inc/cfe_time_core_internal.h rename to modules/core_private/fsw/inc/cfe_time_core_internal.h diff --git a/modules/core_private/ut-stubs/CMakeLists.txt b/modules/core_private/ut-stubs/CMakeLists.txt index d943c7e6f..31a07a3dc 100644 --- a/modules/core_private/ut-stubs/CMakeLists.txt +++ b/modules/core_private/ut-stubs/CMakeLists.txt @@ -13,6 +13,13 @@ # Create the generic stubs library # add_library(ut_core_private_stubs STATIC + src/cfe_es_core_internal_hooks.c + src/cfe_es_core_internal_stubs.c + src/cfe_evs_core_internal_stubs.c + src/cfe_fs_core_internal_stubs.c + src/cfe_sb_core_internal_stubs.c + src/cfe_tbl_core_internal_stubs.c + src/cfe_time_core_internal_stubs.c src/ut_osprintf_stubs.c src/ut_support.c ) diff --git a/modules/core_private/ut-stubs/src/cfe_es_core_internal_hooks.c b/modules/core_private/ut-stubs/src/cfe_es_core_internal_hooks.c new file mode 100644 index 000000000..b4830665e --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_es_core_internal_hooks.c @@ -0,0 +1,75 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_es_stubs.c +** +** Purpose: +** Unit test stubs for Executive Service routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include "cfe_es_core_internal.h" +#include "cfe_resourceid.h" +#include "cfe_resourceid_basevalue.h" + +#include "utstubs.h" +#include "utassert.h" + +/* + * Assign ID base values for UT + */ +enum +{ + UT_CFE_ES_CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x26) +}; + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_ES_RegisterCDSEx coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_ES_RegisterCDSEx(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CFE_ES_CDSHandle_t *HandlePtr = UT_Hook_GetArgValueByName(Context, "HandlePtr", CFE_ES_CDSHandle_t *); + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_ES_RegisterCDSEx), HandlePtr, sizeof(*HandlePtr)) < sizeof(*HandlePtr)) + { + *HandlePtr = + (CFE_ES_CDSHandle_t)CFE_RESOURCEID_WRAP(CFE_ResourceId_FromInteger(UT_CFE_ES_CDSBLOCKID_BASE + 1)); + } + } +} diff --git a/modules/core_private/ut-stubs/src/cfe_es_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_es_core_internal_stubs.c new file mode 100644 index 000000000..c3f75ef0f --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_es_core_internal_stubs.c @@ -0,0 +1,91 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_es_core_internal header + */ + +#include "cfe_es_core_internal.h" +#include "utgenstub.h" + +extern void UT_DefaultHandler_CFE_ES_RegisterCDSEx(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_CDS_EarlyInit() + * ---------------------------------------------------- + */ +int32 CFE_ES_CDS_EarlyInit(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_CDS_EarlyInit, int32); + + UT_GenStub_Execute(CFE_ES_CDS_EarlyInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_CDS_EarlyInit, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_DeleteCDS() + * ---------------------------------------------------- + */ +int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_DeleteCDS, int32); + + UT_GenStub_AddParam(CFE_ES_DeleteCDS, const char *, CDSName); + UT_GenStub_AddParam(CFE_ES_DeleteCDS, bool, CalledByTblServices); + + UT_GenStub_Execute(CFE_ES_DeleteCDS, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_ES_DeleteCDS, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_RegisterCDSEx() + * ---------------------------------------------------- + */ +int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl) +{ + UT_GenStub_SetupReturnBuffer(CFE_ES_RegisterCDSEx, int32); + + UT_GenStub_AddParam(CFE_ES_RegisterCDSEx, CFE_ES_CDSHandle_t *, HandlePtr); + UT_GenStub_AddParam(CFE_ES_RegisterCDSEx, size_t, UserBlockSize); + UT_GenStub_AddParam(CFE_ES_RegisterCDSEx, const char *, Name); + UT_GenStub_AddParam(CFE_ES_RegisterCDSEx, bool, CriticalTbl); + + UT_GenStub_Execute(CFE_ES_RegisterCDSEx, Basic, UT_DefaultHandler_CFE_ES_RegisterCDSEx); + + return UT_GenStub_GetReturnValue(CFE_ES_RegisterCDSEx, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_ES_TaskMain() + * ---------------------------------------------------- + */ +void CFE_ES_TaskMain(void) +{ + + UT_GenStub_Execute(CFE_ES_TaskMain, Basic, NULL); +} diff --git a/modules/core_private/ut-stubs/src/cfe_evs_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_evs_core_internal_stubs.c new file mode 100644 index 000000000..035f7ae43 --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_evs_core_internal_stubs.c @@ -0,0 +1,69 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_evs_core_internal header + */ + +#include "cfe_evs_core_internal.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_CleanUpApp() + * ---------------------------------------------------- + */ +int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId) +{ + UT_GenStub_SetupReturnBuffer(CFE_EVS_CleanUpApp, int32); + + UT_GenStub_AddParam(CFE_EVS_CleanUpApp, CFE_ES_AppId_t, AppId); + + UT_GenStub_Execute(CFE_EVS_CleanUpApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_EVS_CleanUpApp, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_EarlyInit() + * ---------------------------------------------------- + */ +int32 CFE_EVS_EarlyInit(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_EVS_EarlyInit, int32); + + UT_GenStub_Execute(CFE_EVS_EarlyInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_EVS_EarlyInit, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_EVS_TaskMain() + * ---------------------------------------------------- + */ +void CFE_EVS_TaskMain(void) +{ + + UT_GenStub_Execute(CFE_EVS_TaskMain, Basic, NULL); +} diff --git a/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c new file mode 100644 index 000000000..4b18c480a --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c @@ -0,0 +1,42 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_fs_core_internal header + */ + +#include "cfe_fs_core_internal.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_EarlyInit() + * ---------------------------------------------------- + */ +int32 CFE_FS_EarlyInit(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_EarlyInit, int32); + + UT_GenStub_Execute(CFE_FS_EarlyInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_FS_EarlyInit, int32); +} diff --git a/modules/core_private/ut-stubs/src/cfe_sb_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_sb_core_internal_stubs.c new file mode 100644 index 000000000..0c3ed80b2 --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_sb_core_internal_stubs.c @@ -0,0 +1,69 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_sb_core_internal header + */ + +#include "cfe_sb_core_internal.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_CleanUpApp() + * ---------------------------------------------------- + */ +int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_CleanUpApp, int32); + + UT_GenStub_AddParam(CFE_SB_CleanUpApp, CFE_ES_AppId_t, AppId); + + UT_GenStub_Execute(CFE_SB_CleanUpApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_CleanUpApp, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_EarlyInit() + * ---------------------------------------------------- + */ +int32 CFE_SB_EarlyInit(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_SB_EarlyInit, int32); + + UT_GenStub_Execute(CFE_SB_EarlyInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_SB_EarlyInit, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_SB_TaskMain() + * ---------------------------------------------------- + */ +void CFE_SB_TaskMain(void) +{ + + UT_GenStub_Execute(CFE_SB_TaskMain, Basic, NULL); +} diff --git a/modules/core_private/ut-stubs/src/cfe_tbl_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_tbl_core_internal_stubs.c new file mode 100644 index 000000000..088239884 --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_tbl_core_internal_stubs.c @@ -0,0 +1,69 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_tbl_core_internal header + */ + +#include "cfe_tbl_core_internal.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_CleanUpApp() + * ---------------------------------------------------- + */ +int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_CleanUpApp, int32); + + UT_GenStub_AddParam(CFE_TBL_CleanUpApp, CFE_ES_AppId_t, AppId); + + UT_GenStub_Execute(CFE_TBL_CleanUpApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_CleanUpApp, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_EarlyInit() + * ---------------------------------------------------- + */ +int32 CFE_TBL_EarlyInit(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TBL_EarlyInit, int32); + + UT_GenStub_Execute(CFE_TBL_EarlyInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TBL_EarlyInit, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TBL_TaskMain() + * ---------------------------------------------------- + */ +void CFE_TBL_TaskMain(void) +{ + + UT_GenStub_Execute(CFE_TBL_TaskMain, Basic, NULL); +} diff --git a/modules/core_private/ut-stubs/src/cfe_time_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_time_core_internal_stubs.c new file mode 100644 index 000000000..697edc5ac --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_time_core_internal_stubs.c @@ -0,0 +1,69 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_time_core_internal header + */ + +#include "cfe_time_core_internal.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_CleanUpApp() + * ---------------------------------------------------- + */ +int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_CleanUpApp, int32); + + UT_GenStub_AddParam(CFE_TIME_CleanUpApp, CFE_ES_AppId_t, AppId); + + UT_GenStub_Execute(CFE_TIME_CleanUpApp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_CleanUpApp, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_EarlyInit() + * ---------------------------------------------------- + */ +int32 CFE_TIME_EarlyInit(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_TIME_EarlyInit, int32); + + UT_GenStub_Execute(CFE_TIME_EarlyInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_TIME_EarlyInit, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_TIME_TaskMain() + * ---------------------------------------------------- + */ +void CFE_TIME_TaskMain(void) +{ + + UT_GenStub_Execute(CFE_TIME_TaskMain, Basic, NULL); +} diff --git a/modules/core_private/ut-stubs/src/ut_support.c b/modules/core_private/ut-stubs/src/ut_support.c index abbf61223..a8ddc15e3 100644 --- a/modules/core_private/ut-stubs/src/ut_support.c +++ b/modules/core_private/ut-stubs/src/ut_support.c @@ -244,16 +244,7 @@ void UT_CallTaskPipe(void (*TaskPipeFunc)(CFE_SB_Buffer_t *), CFE_MSG_Message_t int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { UT_SoftwareBusSnapshot_Entry_t *Snapshot = UserObj; - const CFE_MSG_Message_t * MsgPtr; - - if (Context->ArgCount > 0) - { - MsgPtr = Context->ArgPtr[0]; - } - else - { - MsgPtr = NULL; - } + const CFE_MSG_Message_t * MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *); if (MsgPtr != NULL && Snapshot != NULL) { From 5d3996ed2388ae77ab86bb1f13b62d9645945529 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 30 Apr 2021 08:53:54 -0400 Subject: [PATCH 4/9] Fix #1393, Move CFE_FS_RunBackgroundFileDump to internal API This function should only be called internally from ES and therefore does not need to be in public API. --- modules/core_api/fsw/inc/cfe_fs.h | 19 ------ modules/core_api/ut-stubs/src/cfe_fs_hooks.c | 18 ------ modules/core_api/ut-stubs/src/cfe_fs_stubs.c | 18 ------ .../fsw/inc/cfe_fs_core_internal.h | 19 ++++++ modules/core_private/ut-stubs/CMakeLists.txt | 1 + .../ut-stubs/src/cfe_fs_core_internal_hooks.c | 61 +++++++++++++++++++ .../ut-stubs/src/cfe_fs_core_internal_stubs.c | 19 ++++++ modules/es/fsw/src/cfe_es_backgroundtask.c | 1 + 8 files changed, 101 insertions(+), 55 deletions(-) create mode 100644 modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c diff --git a/modules/core_api/fsw/inc/cfe_fs.h b/modules/core_api/fsw/inc/cfe_fs.h index 339480b7e..0354bd95c 100644 --- a/modules/core_api/fsw/inc/cfe_fs.h +++ b/modules/core_api/fsw/inc/cfe_fs.h @@ -321,25 +321,6 @@ int32 CFE_FS_BackgroundFileDumpRequest(CFE_FS_FileWriteMetaData_t *Meta); ******************************************************************************/ bool CFE_FS_BackgroundFileDumpIsPending(const CFE_FS_FileWriteMetaData_t *Meta); -/*****************************************************************************/ -/** -** \brief Execute the background file write job(s) -** -** \par Description -** Runs the state machine associated with background file write requests -** -** \par Assumptions, External Events, and Notes: -** This should only be invoked as a background job from the ES background task, -** it should not be invoked directly. -** -** \param[in] ElapsedTime The amount of time passed since last invocation (ms) -** \param[in] Arg Not used/ignored -** -** \return true if jobs are pending, false if idle -** -******************************************************************************/ -bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg); - /**@}*/ #endif /* CFE_FS_H */ diff --git a/modules/core_api/ut-stubs/src/cfe_fs_hooks.c b/modules/core_api/ut-stubs/src/cfe_fs_hooks.c index 4781f0d82..42b70e6d0 100644 --- a/modules/core_api/ut-stubs/src/cfe_fs_hooks.c +++ b/modules/core_api/ut-stubs/src/cfe_fs_hooks.c @@ -141,24 +141,6 @@ void UT_DefaultHandler_CFE_FS_ReadHeader(void *UserObj, UT_EntryKey_t FuncKey, c } } -/*------------------------------------------------------------ - * - * Default handler for CFE_FS_RunBackgroundFileDump coverage stub function - * - *------------------------------------------------------------*/ -void UT_DefaultHandler_CFE_FS_RunBackgroundFileDump(void *UserObj, UT_EntryKey_t FuncKey, - const UT_StubContext_t *Context) -{ - int32 status; - bool return_value; - - UT_Stub_GetInt32StatusCode(Context, &status); - - return_value = status; - - UT_Stub_SetReturnValue(FuncKey, return_value); -} - /*------------------------------------------------------------ * * Default handler for CFE_FS_ParseInputFileNameEx coverage stub function diff --git a/modules/core_api/ut-stubs/src/cfe_fs_stubs.c b/modules/core_api/ut-stubs/src/cfe_fs_stubs.c index 442649f57..7e447664e 100644 --- a/modules/core_api/ut-stubs/src/cfe_fs_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_fs_stubs.c @@ -35,7 +35,6 @@ extern void UT_DefaultHandler_CFE_FS_GetDefaultMountPoint(void *, UT_EntryKey_t, extern void UT_DefaultHandler_CFE_FS_ParseInputFileName(void *, UT_EntryKey_t, const UT_StubContext_t *); extern void UT_DefaultHandler_CFE_FS_ParseInputFileNameEx(void *, UT_EntryKey_t, const UT_StubContext_t *); extern void UT_DefaultHandler_CFE_FS_ReadHeader(void *, UT_EntryKey_t, const UT_StubContext_t *); -extern void UT_DefaultHandler_CFE_FS_RunBackgroundFileDump(void *, UT_EntryKey_t, const UT_StubContext_t *); extern void UT_DefaultHandler_CFE_FS_WriteHeader(void *, UT_EntryKey_t, const UT_StubContext_t *); /* @@ -194,23 +193,6 @@ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) return UT_GenStub_GetReturnValue(CFE_FS_ReadHeader, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CFE_FS_RunBackgroundFileDump() - * ---------------------------------------------------- - */ -bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) -{ - UT_GenStub_SetupReturnBuffer(CFE_FS_RunBackgroundFileDump, bool); - - UT_GenStub_AddParam(CFE_FS_RunBackgroundFileDump, uint32, ElapsedTime); - UT_GenStub_AddParam(CFE_FS_RunBackgroundFileDump, void *, Arg); - - UT_GenStub_Execute(CFE_FS_RunBackgroundFileDump, Basic, UT_DefaultHandler_CFE_FS_RunBackgroundFileDump); - - return UT_GenStub_GetReturnValue(CFE_FS_RunBackgroundFileDump, bool); -} - /* * ---------------------------------------------------- * Generated stub function for CFE_FS_SetTimestamp() diff --git a/modules/core_private/fsw/inc/cfe_fs_core_internal.h b/modules/core_private/fsw/inc/cfe_fs_core_internal.h index 472cb2351..2a1d11b1f 100644 --- a/modules/core_private/fsw/inc/cfe_fs_core_internal.h +++ b/modules/core_private/fsw/inc/cfe_fs_core_internal.h @@ -55,6 +55,25 @@ ******************************************************************************/ extern int32 CFE_FS_EarlyInit(void); +/*****************************************************************************/ +/** +** \brief Execute the background file write job(s) +** +** \par Description +** Runs the state machine associated with background file write requests +** +** \par Assumptions, External Events, and Notes: +** This should only be invoked as a background job from the ES background task, +** it should not be invoked directly. +** +** \param[in] ElapsedTime The amount of time passed since last invocation (ms) +** \param[in] Arg Not used/ignored +** +** \return true if jobs are pending, false if idle +** +******************************************************************************/ +bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg); + /**@}*/ #endif /* CFE_FS_CORE_INTERNAL_H */ diff --git a/modules/core_private/ut-stubs/CMakeLists.txt b/modules/core_private/ut-stubs/CMakeLists.txt index 31a07a3dc..58b97e238 100644 --- a/modules/core_private/ut-stubs/CMakeLists.txt +++ b/modules/core_private/ut-stubs/CMakeLists.txt @@ -16,6 +16,7 @@ add_library(ut_core_private_stubs STATIC src/cfe_es_core_internal_hooks.c src/cfe_es_core_internal_stubs.c src/cfe_evs_core_internal_stubs.c + src/cfe_fs_core_internal_hooks.c src/cfe_fs_core_internal_stubs.c src/cfe_sb_core_internal_stubs.c src/cfe_tbl_core_internal_stubs.c diff --git a/modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c new file mode 100644 index 000000000..c4dd9a96b --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c @@ -0,0 +1,61 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_es_stubs.c +** +** Purpose: +** Unit test stubs for Executive Service routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include +#include "cfe_fs_core_internal.h" + +#include "utstubs.h" +#include "utassert.h" + +/* +** Functions +*/ + +/*------------------------------------------------------------ + * + * Default handler for CFE_FS_RunBackgroundFileDump coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_FS_RunBackgroundFileDump(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + int32 status; + bool return_value; + + UT_Stub_GetInt32StatusCode(Context, &status); + + return_value = status; + + UT_Stub_SetReturnValue(FuncKey, return_value); +} diff --git a/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c index 4b18c480a..8b4c3e176 100644 --- a/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c +++ b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_stubs.c @@ -27,6 +27,8 @@ #include "cfe_fs_core_internal.h" #include "utgenstub.h" +extern void UT_DefaultHandler_CFE_FS_RunBackgroundFileDump(void *, UT_EntryKey_t, const UT_StubContext_t *); + /* * ---------------------------------------------------- * Generated stub function for CFE_FS_EarlyInit() @@ -40,3 +42,20 @@ int32 CFE_FS_EarlyInit(void) return UT_GenStub_GetReturnValue(CFE_FS_EarlyInit, int32); } + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_FS_RunBackgroundFileDump() + * ---------------------------------------------------- + */ +bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) +{ + UT_GenStub_SetupReturnBuffer(CFE_FS_RunBackgroundFileDump, bool); + + UT_GenStub_AddParam(CFE_FS_RunBackgroundFileDump, uint32, ElapsedTime); + UT_GenStub_AddParam(CFE_FS_RunBackgroundFileDump, void *, Arg); + + UT_GenStub_Execute(CFE_FS_RunBackgroundFileDump, Basic, UT_DefaultHandler_CFE_FS_RunBackgroundFileDump); + + return UT_GenStub_GetReturnValue(CFE_FS_RunBackgroundFileDump, bool); +} diff --git a/modules/es/fsw/src/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c index 5909b321f..593e69e94 100644 --- a/modules/es/fsw/src/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -36,6 +36,7 @@ #include #include "cfe_es_module_all.h" +#include "cfe_fs_core_internal.h" #define CFE_ES_BACKGROUND_SEM_NAME "ES_BG_SEM" #define CFE_ES_BACKGROUND_CHILD_NAME "ES_BG_TASK" From 2d2a7f9152065988c371f4b808761642f00dc087 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 May 2021 09:03:48 -0400 Subject: [PATCH 5/9] Update #1463, rename hooks files to handler CCB 2021-05-05 review item, matches name used in code. --- modules/core_api/ut-stubs/CMakeLists.txt | 16 ++++++++-------- .../src/{cfe_es_hooks.c => cfe_es_handlers.c} | 0 .../src/{cfe_evs_hooks.c => cfe_evs_handlers.c} | 0 .../src/{cfe_fs_hooks.c => cfe_fs_handlers.c} | 0 .../src/{cfe_msg_hooks.c => cfe_msg_handlers.c} | 0 ...ourceid_hooks.c => cfe_resourceid_handlers.c} | 0 .../src/{cfe_sb_hooks.c => cfe_sb_handlers.c} | 0 .../src/{cfe_tbl_hooks.c => cfe_tbl_handlers.c} | 0 .../{cfe_time_hooks.c => cfe_time_handlers.c} | 0 .../src/{ut_time_hooks.c => ut_time_handlers.c} | 0 modules/core_private/ut-stubs/CMakeLists.txt | 4 ++-- ...l_hooks.c => cfe_es_core_internal_handlers.c} | 0 ...l_hooks.c => cfe_fs_core_internal_handlers.c} | 0 13 files changed, 10 insertions(+), 10 deletions(-) rename modules/core_api/ut-stubs/src/{cfe_es_hooks.c => cfe_es_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_evs_hooks.c => cfe_evs_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_fs_hooks.c => cfe_fs_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_msg_hooks.c => cfe_msg_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_resourceid_hooks.c => cfe_resourceid_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_sb_hooks.c => cfe_sb_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_tbl_hooks.c => cfe_tbl_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{cfe_time_hooks.c => cfe_time_handlers.c} (100%) rename modules/core_api/ut-stubs/src/{ut_time_hooks.c => ut_time_handlers.c} (100%) rename modules/core_private/ut-stubs/src/{cfe_es_core_internal_hooks.c => cfe_es_core_internal_handlers.c} (100%) rename modules/core_private/ut-stubs/src/{cfe_fs_core_internal_hooks.c => cfe_fs_core_internal_handlers.c} (100%) diff --git a/modules/core_api/ut-stubs/CMakeLists.txt b/modules/core_api/ut-stubs/CMakeLists.txt index c7e5847d0..3d74005e5 100644 --- a/modules/core_api/ut-stubs/CMakeLists.txt +++ b/modules/core_api/ut-stubs/CMakeLists.txt @@ -16,21 +16,21 @@ include_directories(${osal_MISSION_DIR}/ut_assert/inc) # Create the generic stubs library # add_library(ut_core_api_stubs STATIC - src/cfe_es_hooks.c + src/cfe_es_handlers.c src/cfe_es_stubs.c - src/cfe_evs_hooks.c + src/cfe_evs_handlers.c src/cfe_evs_stubs.c - src/cfe_fs_hooks.c + src/cfe_fs_handlers.c src/cfe_fs_stubs.c - src/cfe_msg_hooks.c + src/cfe_msg_handlers.c src/cfe_msg_stubs.c - src/cfe_resourceid_hooks.c + src/cfe_resourceid_handlers.c src/cfe_resourceid_stubs.c - src/cfe_sb_hooks.c + src/cfe_sb_handlers.c src/cfe_sb_stubs.c - src/cfe_tbl_hooks.c + src/cfe_tbl_handlers.c src/cfe_tbl_stubs.c - src/cfe_time_hooks.c + src/cfe_time_handlers.c src/cfe_time_stubs.c ) diff --git a/modules/core_api/ut-stubs/src/cfe_es_hooks.c b/modules/core_api/ut-stubs/src/cfe_es_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_es_hooks.c rename to modules/core_api/ut-stubs/src/cfe_es_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_evs_hooks.c b/modules/core_api/ut-stubs/src/cfe_evs_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_evs_hooks.c rename to modules/core_api/ut-stubs/src/cfe_evs_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_fs_hooks.c b/modules/core_api/ut-stubs/src/cfe_fs_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_fs_hooks.c rename to modules/core_api/ut-stubs/src/cfe_fs_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_msg_hooks.c b/modules/core_api/ut-stubs/src/cfe_msg_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_msg_hooks.c rename to modules/core_api/ut-stubs/src/cfe_msg_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_resourceid_hooks.c b/modules/core_api/ut-stubs/src/cfe_resourceid_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_resourceid_hooks.c rename to modules/core_api/ut-stubs/src/cfe_resourceid_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_sb_hooks.c b/modules/core_api/ut-stubs/src/cfe_sb_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_sb_hooks.c rename to modules/core_api/ut-stubs/src/cfe_sb_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_tbl_hooks.c b/modules/core_api/ut-stubs/src/cfe_tbl_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_tbl_hooks.c rename to modules/core_api/ut-stubs/src/cfe_tbl_handlers.c diff --git a/modules/core_api/ut-stubs/src/cfe_time_hooks.c b/modules/core_api/ut-stubs/src/cfe_time_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/cfe_time_hooks.c rename to modules/core_api/ut-stubs/src/cfe_time_handlers.c diff --git a/modules/core_api/ut-stubs/src/ut_time_hooks.c b/modules/core_api/ut-stubs/src/ut_time_handlers.c similarity index 100% rename from modules/core_api/ut-stubs/src/ut_time_hooks.c rename to modules/core_api/ut-stubs/src/ut_time_handlers.c diff --git a/modules/core_private/ut-stubs/CMakeLists.txt b/modules/core_private/ut-stubs/CMakeLists.txt index 58b97e238..7e55ac114 100644 --- a/modules/core_private/ut-stubs/CMakeLists.txt +++ b/modules/core_private/ut-stubs/CMakeLists.txt @@ -13,10 +13,10 @@ # Create the generic stubs library # add_library(ut_core_private_stubs STATIC - src/cfe_es_core_internal_hooks.c + src/cfe_es_core_internal_handlers.c src/cfe_es_core_internal_stubs.c src/cfe_evs_core_internal_stubs.c - src/cfe_fs_core_internal_hooks.c + src/cfe_fs_core_internal_handlers.c src/cfe_fs_core_internal_stubs.c src/cfe_sb_core_internal_stubs.c src/cfe_tbl_core_internal_stubs.c diff --git a/modules/core_private/ut-stubs/src/cfe_es_core_internal_hooks.c b/modules/core_private/ut-stubs/src/cfe_es_core_internal_handlers.c similarity index 100% rename from modules/core_private/ut-stubs/src/cfe_es_core_internal_hooks.c rename to modules/core_private/ut-stubs/src/cfe_es_core_internal_handlers.c diff --git a/modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_handlers.c similarity index 100% rename from modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c rename to modules/core_private/ut-stubs/src/cfe_fs_core_internal_handlers.c From 8d6aad832fb64cd3726f5ad35e3e534a5cbd4488 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 6 May 2021 15:30:13 +0000 Subject: [PATCH 6/9] Fix #1486, Remove broken travis-ci script --- .travis.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5ed0addd0..000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -os: linux -dist: bionic -language: c -compiler: - - gcc -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - cmake - -before_install: - - sudo apt-get install cppcheck - -script: - # Check versions - - cppcheck --version - - #cppcheck flight software fsw/cfe-core/src and modules - - cppcheck --force --inline-suppr --std=c99 --language=c --error-exitcode=1 --enable=warning,performance,portability,style --suppress=variableScope --inconclusive fsw/cfe-core/src modules 2>cppcheck_flight_cfe.txt - - | - if [[ -s cppcheck_flight_cfe.txt ]]; then - echo "You must fix cppcheck errors before submitting a pull request" - echo "" - cat cppcheck_flight_cfe.txt - exit -1 - fi - From 8ecaeadea3a40c68597dc9d5ec773beff82cb243 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 6 May 2021 15:44:53 +0000 Subject: [PATCH 7/9] Fix #1488, Report files checked in cppcheck action --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 14b2c16e2..9baebd176 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -32,7 +32,7 @@ jobs: - name: Run bundle cppcheck if: ${{matrix.cppcheck =='all'}} - run: cppcheck --force --inline-suppr --quiet . 2> ${{matrix.cppcheck}}_cppcheck_err.txt + run: cppcheck --force --inline-suppr . 2> ${{matrix.cppcheck}}_cppcheck_err.txt # Run strict static analysis for embedded portions of cfe - name: cfe strict cppcheck From 73fc3d695da6631dfb4696df2e439910ba78aeee Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 28 Apr 2021 13:42:11 -0400 Subject: [PATCH 8/9] Fix #1436, table object file name This uses a sub-script to call elf2cfetbl which avoid relying on a shell glob. More complicated but should be more robust if/when someone renames a table. Note: A proper/simpler fix would still be to use TARGET_OBJECTS generator expression, but that can't happen until Ubuntu 18.04 (w/ ver 3.10) or older versions are no longer supported. --- cmake/arch_build.cmake | 10 ++++---- cmake/generate_table.cmake | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 cmake/generate_table.cmake diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index b45e5c192..ce7513fc9 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -197,9 +197,6 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) add_library(${TGT}_${TBLWE}-obj STATIC ${TBL_SRC}) target_link_libraries(${TGT}_${TBLWE}-obj PRIVATE core_api) - get_filename_component(TBLOBJ ${TBL} NAME) - string(APPEND TBLOBJ ${CMAKE_C_OUTPUT_EXTENSION}) - # IMPORTANT: This rule assumes that the output filename of elf2cfetbl matches # the input file name but with a different extension (.o -> .tbl) # The actual output filename is embedded in the source file (.c), however @@ -208,8 +205,11 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) # current content of a dependency (rightfully so). add_custom_command( OUTPUT "${TABLE_DESTDIR}/${TBLWE}.tbl" - COMMAND ${CMAKE_AR} x $ - COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl "${TBLOBJ}" + COMMAND ${CMAKE_COMMAND} + -DCMAKE_AR=${CMAKE_AR} + -DTBLTOOL=${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl + -DLIB=$ + -P ${CFE_SOURCE_DIR}/cmake/generate_table.cmake DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TGT}_${TBLWE}-obj WORKING_DIRECTORY ${TABLE_DESTDIR} ) diff --git a/cmake/generate_table.cmake b/cmake/generate_table.cmake new file mode 100644 index 000000000..521fd1a1a --- /dev/null +++ b/cmake/generate_table.cmake @@ -0,0 +1,48 @@ +################################################################## +# +# Sub-script to generate a table file via elf2cfetbl +# +# This small script runs at build time (as opposed to prep time) +# which converts a static library (.a) with a single object into a +# table (.tbl) file +# +################################################################## + +# +# Required passed in values: +# CMAKE_AR => path to "ar" utility for working with static lib files +# TBLTOOL => path to "elf2cfetbl" utility +# LIB => name of library file to convert +# +# This assumes/requires that the static library has a single object in it. +# Note, In newer versions of CMake an object library can be used. This workaround +# is intended to also be compatible with older CMake versions. +# + +# First run "ar t" to get the object file name, there should be only 1 file. +execute_process(COMMAND ${CMAKE_AR} t "${LIB}" + OUTPUT_VARIABLE OBJNAME + RESULT_VARIABLE RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if (NOT RESULT EQUAL 0) + message(FATAL_ERROR "Failure running ${CMAKE_AR} t ${LIB}") +endif() + +# Next run "ar x" to extract that file. +execute_process(COMMAND ${CMAKE_AR} x "${LIB}" "${OBJNAME}" + RESULT_VARIABLE RESULT +) +if (NOT RESULT EQUAL 0) + message(FATAL_ERROR "Failure running ${CMAKE_AR} x ${LIB} ${OBJNAME}") +endif() + +# Finally invoke the table tool (elf2cfetbl) on the object +execute_process(COMMAND ${TBLTOOL} "${OBJNAME}" + RESULT_VARIABLE RESULT +) +if (NOT RESULT EQUAL 0) + message(FATAL_ERROR "Failure running ${TBLTOOL}") +endif() + +message("Successfully converted ${LIB} to a CFE table") From babfaadf14cf9bf584fd92d19995d56b0a069042 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Wed, 12 May 2021 11:28:30 -0400 Subject: [PATCH 9/9] IC:2021-05-11, Bump to v6.8.0-rc1+dev575 --- README.md | 13 +++++++++++++ modules/core_api/fsw/inc/cfe_version.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b74cae42b..48ca73e69 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,19 @@ The detailed cFE user's guide can be viewed at