Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTNN-653 Rebaseline for v7 development #261

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
8 changes: 6 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ jobs:
uses: nasa/cFS/.github/workflows/static-analysis.yml@main
with:
strict-dir-list:
-Iinc -Icache/inc -Icommon/inc -Ilib/inc -Impool/inc -Ios/inc -Iv7/inc
cache/src common/src lib/src mpool/src os/src v7/src store
-Iaa/arp/inc -Iaa/as/inc -Iaa/fwp/inc -Iaa/ndc/inc -Ibpa/bi/inc -Ibpa/ct/inc
-Ibpa/ebp/inc -Ibpa/pdb/inc -Ibpa/pi/inc -Ibpa/stor/inc -Ici/cbor/inc -Ici/em/inc
-Ici/job/inc -Ici/mem/inc -Ici/pl/inc -Ici/time/inc -Icla/inc -Iinc
aa/arp/src aa/as/src aa/fwp/src aa/ndc/src bpa/bi/src bpa/ct/src
bpa/ebp/src bpa/pdc/src bpa/pi/src bpa/stor/src ci/cbor/src ci/em/src
ci/job/src ci/mem/src ci/pl/src ci/time/src cla/src
89 changes: 49 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,40 @@ if (BPLIB_ENABLE_UNIT_TESTS AND BPLIB_STANDALONE_BUILD_MODE AND NOT CMAKE_CROSSC
enable_testing()
endif()

add_subdirectory(os)
add_subdirectory(common)
add_subdirectory(lib)
add_subdirectory(mpool)
add_subdirectory(cache)
add_subdirectory(v7)

# v7 implementation parts
list(APPEND BPLIB_SRC
store/file_offload.c

$<TARGET_OBJECTS:bplib_os>
$<TARGET_OBJECTS:bplib_common>
$<TARGET_OBJECTS:bplib_cache>
$<TARGET_OBJECTS:bplib_v7>
$<TARGET_OBJECTS:bplib_mpool>
$<TARGET_OBJECTS:bplib_base>
add_subdirectory(cla)
add_subdirectory(aa/arp)
add_subdirectory(aa/as)
add_subdirectory(aa/fwp)
add_subdirectory(aa/ndc)
add_subdirectory(bpa/bi)
add_subdirectory(bpa/ct)
add_subdirectory(bpa/ebp)
add_subdirectory(bpa/pdb)
add_subdirectory(bpa/pi)
add_subdirectory(bpa/stor)
add_subdirectory(ci/cbor)
add_subdirectory(ci/em)
add_subdirectory(ci/job)
add_subdirectory(ci/mem)
add_subdirectory(ci/pl)
add_subdirectory(ci/time)

list(APPEND BPLIB_COMPONENTS
bplib_cla bplib_arp bplib_as bplib_fwp bplib_ndc
bplib_bi bplib_ct bplib_ebp bplib_pdb bplib_pi bplib_stor
bplib_cbor bplib_em bplib_job bplib_mem bplib_pl bplib_time
)

list(APPEND BPLIB_PRIVATE_INCLUDE_DIRS
$<TARGET_PROPERTY:bplib_os,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bplib_base,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bplib_v7,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bplib_mpool,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bplib_cache,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bplib_common,INTERFACE_INCLUDE_DIRECTORIES>
)
foreach(COMPONENT ${BPLIB_COMPONENTS})
list(APPEND BPLIB_SRC
$<TARGET_OBJECTS:${COMPONENT}>
)

list(APPEND BPLIB_PRIVATE_INCLUDE_DIRS
$<TARGET_PROPERTY:${COMPONENT},INTERFACE_INCLUDE_DIRECTORIES>
)

endforeach()

# If building as part of CFE/CFS, then the "IS_CFS_ARCH_BUILD" should be set
# this allows simply dropping this module into a CFS project
Expand All @@ -122,8 +129,6 @@ if (IS_CFS_ARCH_BUILD)
# The CFE build system determines whether to create a shared or static object inside this routine
add_cfe_app(bplib ${BPLIB_SRC})

target_link_libraries(bplib ${TINYCBOR_LDFLAGS})

else()

# Building as a standalone library
Expand All @@ -132,9 +137,6 @@ else()
# This directory may be built twice, setting this option differently to build both flavors
add_library(bplib ${BPLIB_SRC})

# link with the requisite dependencies
target_link_libraries(bplib ${TINYCBOR_LDFLAGS})

# Add in the required link libraries based on OS adapter selection
# this should preferably be in OS subdirectory, but it needs to be done
# at the bplib target which is created here.
Expand Down Expand Up @@ -184,18 +186,18 @@ endif()

get_target_property(IS_PIC bplib POSITION_INDEPENDENT_CODE)
if (IS_PIC)
set_target_properties(
bplib_base bplib_common bplib_mpool bplib_cache bplib_v7 bplib_os
PROPERTIES POSITION_INDEPENDENT_CODE ${IS_PIC}
)
set_target_properties(${BPLIB_COMPONENTS} PROPERTIES POSITION_INDEPENDENT_CODE ${IS_PIC})
endif()

# Set the standard compile options for all submodules (c99, full warnings)
foreach(TGT bplib bplib_base bplib_common bplib_mpool bplib_cache bplib_v7 bplib_os)
target_compile_features(${TGT} PRIVATE c_std_99)
target_compile_options(${TGT} PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})
foreach(COMPONENT ${BPLIB_COMPONENTS})
target_compile_features(${COMPONENT} PRIVATE c_std_99)
target_compile_options(${COMPONENT} PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})
endforeach()

target_compile_features(bplib PRIVATE c_std_99)
target_compile_options(bplib PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})

# Internal/private header files exist within the implementation directories
target_include_directories(bplib PRIVATE ${BPLIB_PRIVATE_INCLUDE_DIRS})

Expand All @@ -207,12 +209,19 @@ target_include_directories(bplib PUBLIC
$<INSTALL_INTERFACE:include/bplib>
)

# BPLib Sanity checks are only for standalone builds, sanity checks
# for CFE/CFS builds should be part of the BP app, as opposed to BPLib
if (BPLIB_ENABLE_UNIT_TESTS)
add_subdirectory(ut-stubs)

# BPLib Sanity checks are only for standalone builds, sanity checks
# for CFE/CFS builds should be part of the BP app, as opposed to BPLib
# Link all stubs into single library
add_library(coverage-bplib-stubs INTERFACE)

foreach(COMPONENT ${BPLIB_COMPONENTS})
target_link_libraries(coverage-bplib-stubs INTERFACE ${COMPONENT}_stubs)
endforeach()

if (NOT IS_CFS_ARCH_BUILD)
add_subdirectory(ut-functional)
endif (NOT IS_CFS_ARCH_BUILD)

endif (BPLIB_ENABLE_UNIT_TESTS)
21 changes: 21 additions & 0 deletions aa/arp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
##################################################################
#
# Bundle Protocol Library (BPLib) CMake build recipe
#
# This is for the ARP module
#
##################################################################

add_library(bplib_arp OBJECT
src/bplib_arp.c
)

target_include_directories(bplib_arp PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc
$<TARGET_PROPERTY:bplib,INTERFACE_INCLUDE_DIRECTORIES>
)

# Add unit tests
if(BPLIB_ENABLE_UNIT_TESTS)
add_subdirectory(unit-test)
endif(BPLIB_ENABLE_UNIT_TESTS)
37 changes: 24 additions & 13 deletions v7/inc/v7_codec.h → aa/arp/inc/bplib_arp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,32 @@
*
*/

#ifndef V7_CODEC_H
#define V7_CODEC_H
#ifndef BPLIB_ARP_H
#define BPLIB_ARP_H

/******************************************************************************
INCLUDES
******************************************************************************/
/*
** Includes
*/

#include "bplib.h"
#include "v7_mpool.h"
#include "v7_types.h"
#include "v7_decode.h"
#include "v7_encode.h"

size_t v7_compute_full_bundle_size(bplib_mpool_bblock_primary_t *cpb);
size_t v7_copy_full_bundle_out(bplib_mpool_bblock_primary_t *cpb, void *buffer, size_t buf_sz);
size_t v7_copy_full_bundle_in(bplib_mpool_bblock_primary_t *cpb, const void *buffer, size_t buf_sz);

#endif /* V7_CODEC_H */
/*
** Exported Functions
*/

/**
* \brief Admin Records Processor initialization
*
* \par Description
* ARP initialization function
*
* \par Assumptions, External Events, and Notes:
* None
*
* \return Execution status
* \retval BP_SUCCESS Initialization was successful
*/
int BPLib_ARP_Init(void);

#endif /* BPLIB_ARP_H */
34 changes: 34 additions & 0 deletions aa/arp/src/bplib_arp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
* System Application (BP) v6.5”
*
* Copyright © 2020 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.
*
*/

/*
** Include
*/

#include "bplib_arp.h"


/*
** Function Definitions
*/

int BPLib_ARP_Init(void) {
return BP_SUCCESS;
}
67 changes: 67 additions & 0 deletions aa/arp/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
##################################################################
#
# Coverage test build recipe
#
# This CMake file contains the recipe for building the coverage tests.
# It is invoked from the parent directory when unit tests are enabled.
#
##################################################################

# Create stubs (for external use)
add_library(bplib_arp_stubs STATIC
stubs/bplib_arp_stubs.c
)

target_include_directories(bplib_arp_stubs PUBLIC
$<TARGET_PROPERTY:bplib_arp,INTERFACE_INCLUDE_DIRECTORIES>
)

target_link_libraries(bplib_arp_stubs ut_assert ut_core_api_stubs)

# Create unit test object
add_library(utobj_bplib_arp OBJECT
../src/bplib_arp.c
)

target_compile_definitions(utobj_bplib_arp PRIVATE
$<TARGET_PROPERTY:bplib_arp,COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_COMPILE_DEFINITIONS>
)

target_compile_options(utobj_bplib_arp PRIVATE
$<TARGET_PROPERTY:bplib_arp,COMPILE_OPTIONS>
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_COMPILE_OPTIONS>
)

target_include_directories(utobj_bplib_arp PRIVATE
$<TARGET_PROPERTY:bplib_arp,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_INCLUDE_DIRECTORIES>
)

# Create test runner executable
add_executable(coverage-bplib_arp-testrunner
utilities/bplib_arp_test_utils.c
bplib_arp_test.c
$<TARGET_OBJECTS:utobj_bplib_arp>
)

target_include_directories(coverage-bplib_arp-testrunner PRIVATE
../src
utilities/
${CMAKE_CURRENT_SOURCE_DIR}/inc
$<TARGET_PROPERTY:bplib_arp,INTERFACE_INCLUDE_DIRECTORIES>
)

target_link_libraries(coverage-bplib_arp-testrunner PUBLIC
ut_coverage_link
ut_assert
)

add_test(coverage-bplib_arp-testrunner coverage-bplib_arp-testrunner)

# Install the executables to a staging area for test in cross environments
if (INSTALL_TARGET_LIST)
foreach(TGT ${INSTALL_TARGET_LIST})
install(TARGETS coverage-bplib_arp-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
endforeach()
endif()
40 changes: 40 additions & 0 deletions aa/arp/unit-test/bplib_arp_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* NASA Docket No. GSC-18,587-1 and identified as “The Bundle Protocol Core Flight
* System Application (BP) v6.5”
*
* Copyright © 2020 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.
*
*/

/*
** Include
*/

#include "bplib_arp_test_utils.h"

/*
** Test function for
** int BPLib_ARP_Init()
*/
void Test_BPLib_ARP_Init(void)
{
UtAssert_INT32_EQ(BPLib_ARP_Init(), BP_SUCCESS);
}


void TestBplibArp_Register(void)
{
UtTest_Add(Test_BPLib_ARP_Init, BPLib_ARP_Test_Setup, BPLib_ARP_Test_Teardown, "Test_BPLib_ARP_Init");
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,22 @@
/**
* @file
*
* Handler companions for generated BPLib OS stubs
* Auto-Generated stub implementations for functions defined in bplib_arp header
*/

/* UT includes */
#include "uttest.h"
#include "utstubs.h"
#include "bplib_arp.h"
#include "utgenstub.h"

/*----------------------------------------------------------------
*
* This just translates the 32-bit return status into a 64-bit
*
*-----------------------------------------------------------------*/
void UT_DefaultHandler_bplib_os_get_dtntime_ms(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
/*
* ----------------------------------------------------
* Generated stub function for BPLib_ARP_Init()
* ----------------------------------------------------
*/
int BPLib_ARP_Init(void)
{
int32 StatusCode;
uint64_t Result;

UT_Stub_GetInt32StatusCode(Context, &StatusCode);
UT_GenStub_SetupReturnBuffer(BPLib_ARP_Init, int);

Result = StatusCode;
UT_GenStub_Execute(BPLib_ARP_Init, Basic, NULL);

UT_Stub_SetReturnValue(FuncKey, Result);
return UT_GenStub_GetReturnValue(BPLib_ARP_Init, int);
}
Loading
Loading