From 439a33d70a6d852fbc897fd9071dcc52e48650db Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 30 Apr 2021 08:53:54 -0400 Subject: [PATCH] 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 | 20 ++++++ modules/core_private/ut-stubs/CMakeLists.txt | 1 + .../ut-stubs/src/cfe_fs_core_internal_hooks.c | 62 +++++++++++++++++++ .../ut-stubs/src/cfe_fs_core_internal_stubs.c | 19 ++++++ modules/es/fsw/src/cfe_es_backgroundtask.c | 1 + 8 files changed, 103 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 ee1f8768d..d59b450de 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,26 @@ ******************************************************************************/ 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..57f3153a9 --- /dev/null +++ b/modules/core_private/ut-stubs/src/cfe_fs_core_internal_hooks.c @@ -0,0 +1,62 @@ +/* +** 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 046c1545c..5ef70b872 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"