Skip to content

Commit

Permalink
DTNN-653 Initial v7 rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sara-gb committed Jul 18, 2024
1 parent 2097e8e commit f4577e0
Show file tree
Hide file tree
Showing 165 changed files with 474 additions and 32,743 deletions.
51 changes: 15 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,20 @@ 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)
add_subdirectory(cla)
add_subdirectory(aa/as)


# 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>
$<TARGET_OBJECTS:bplib_cla>
$<TARGET_OBJECTS:bplib_as>
)

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>
$<TARGET_PROPERTY:bplib_cla,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>

)

# If building as part of CFE/CFS, then the "IS_CFS_ARCH_BUILD" should be set
Expand All @@ -122,8 +110,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 +118,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 @@ -185,13 +168,13 @@ 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
bplib_cla bplib_as
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)
foreach(TGT bplib bplib_cla bplib_as)
target_compile_features(${TGT} PRIVATE c_std_99)
target_compile_options(${TGT} PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})
endforeach()
Expand All @@ -207,12 +190,8 @@ target_include_directories(bplib PUBLIC
$<INSTALL_INTERFACE:include/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
if (NOT IS_CFS_ARCH_BUILD)
add_subdirectory(ut-functional)
endif (NOT IS_CFS_ARCH_BUILD)
endif (BPLIB_ENABLE_UNIT_TESTS)
# 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 AND NOT IS_CFS_ARCH_BUILD)
add_subdirectory(ut-functional)
endif ()
21 changes: 21 additions & 0 deletions aa/as/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 Admin Statistics (AS) module
#
##################################################################

add_library(bplib_as OBJECT
src/bplib_as.c
)

target_include_directories(bplib_as 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)
27 changes: 14 additions & 13 deletions common/ut-stubs/crc_stub_objs.c → aa/as/inc/bplib_as.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
*
*/

/**
* @file
*
* Auto-Generated stub implementations for functions defined in crc header
*/
#ifndef BPLIB_AS_H
#define BPLIB_AS_H

/*
** Includes
*/

#include "crc.h"
#include "bplib.h"


/*
** Function Definitions
*/

struct bplib_crc_parameters
{
uint32_t stub;
};
int BPLib_AS_Init(void);

bplib_crc_parameters_t BPLIB_CRC_NONE = {0};
bplib_crc_parameters_t BPLIB_CRC16_X25 = {1};
bplib_crc_parameters_t BPLIB_CRC32_CASTAGNOLI = {2};
#endif /* BPLIB_AS_H */
24 changes: 10 additions & 14 deletions v7/inc/v7_codec.h → aa/as/src/bplib_as.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@
*
*/

#ifndef V7_CODEC_H
#define V7_CODEC_H
/*
** Includes
*/

/******************************************************************************
INCLUDES
******************************************************************************/
#include "bplib_as.h"

#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);
/*
** Function Definitions
*/

#endif /* V7_CODEC_H */
int BPLib_AS_Init(void) {
return BP_SUCCESS;
}
55 changes: 55 additions & 0 deletions aa/as/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
##################################################################
#
# 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.
#
##################################################################

add_library(utobj_bplib_as OBJECT
../src/bplib_as.c
)

target_compile_definitions(utobj_bplib_as PRIVATE
$<TARGET_PROPERTY:bplib_as,COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_COMPILE_DEFINITIONS>
)

target_compile_options(utobj_bplib_as PRIVATE
$<TARGET_PROPERTY:bplib_as,COMPILE_OPTIONS>
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_COMPILE_OPTIONS>
)

target_include_directories(utobj_bplib_as PRIVATE
$<TARGET_PROPERTY:bplib_as,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_INCLUDE_DIRECTORIES>
)

# Add executable
add_executable(coverage-bplib_as-testrunner
utilities/bplib_as_test_utils.c
bplib_as_test.c
$<TARGET_OBJECTS:utobj_bplib_as>
)

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

target_link_libraries(coverage-bplib_as-testrunner PUBLIC
ut_coverage_link
ut_assert
)

add_test(coverage-bplib_as-testrunner coverage-bplib_as-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_as-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
endforeach()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,19 @@
/*
* Includes
*/
#include "test_bplib_v7.h"
#include "bplib_as_test_utils.h"

void test_v7_decode_bp_bundle_age_block(void)
/*
** Test function for
** int BPLib_AS_Init()
*/
void Test_BPLib_AS_Init(void)
{
/* Test function for:
* void v7_decode_bp_bundle_age_block(v7_decode_state_t *dec, bp_bundle_age_block_t *v)
*/
v7_decode_state_t dec;
bp_bundle_age_block_t v;

memset(&dec, 0, sizeof(v7_decode_state_t));
memset(&v, 0, sizeof(bp_bundle_age_block_t));
dec.error = true;

UtAssert_VOIDCALL(v7_decode_bp_bundle_age_block(&dec, &v));
UtAssert_INT32_EQ(BPLib_AS_Init(), BP_SUCCESS);
}

void TestBpV7BundleAgeBlock_Register(void)

void TestBplibAs_Register(void)
{
UtTest_Add(test_v7_decode_bp_bundle_age_block, NULL, NULL, "Test v7_decode_bp_bundle_age_block");
UtTest_Add(Test_BPLib_AS_Init, NULL, NULL, "Test_BPLib_AS_Init");
}
19 changes: 19 additions & 0 deletions aa/as/unit-test/stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##################################################################
#
# Bundle Protocol Library (BPLib) CMake build recipe
#
# This is for the "as" stub functions
#
##################################################################

add_library(bplib_as_stubs STATIC
bplib_as_stubs.c
)

target_include_directories(bplib_as_stubs PUBLIC
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
)

target_link_libraries(bplib_as_stubs PUBLIC
ut_assert
)
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_as header
*/

/* UT includes */
#include "uttest.h"
#include "utstubs.h"
#include "bplib_as.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_AS_Init()
* ----------------------------------------------------
*/
int BPLib_AS_Init(void)
{
int32 StatusCode;
uint64_t Result;

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

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

UT_Stub_SetReturnValue(FuncKey, Result);
return UT_GenStub_GetReturnValue(BPLib_AS_Init, int);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@
************************************************************************/

/*
* Includes
*/
#include "test_bplib_v7.h"
** Includes
*/

void test_v7_decode_bp_custody_tracking_block(void)
{
/* Test function for:
* void v7_decode_bp_custody_tracking_block(v7_decode_state_t *dec, bp_custody_tracking_block_t *v)
*/
v7_decode_state_t dec;
bp_custody_tracking_block_t v;
CborValue cval;
#include "bplib_as_test_utils.h"

/*
** Function Definitions
*/

memset(&dec, 0, sizeof(v7_decode_state_t));
memset(&v, 0, sizeof(bp_custody_tracking_block_t));
memset(&cval, 0, sizeof(CborValue));
void BPLib_AS_Test_Setup(void)
{
/* Initialize test environment to default state for every test */
UT_ResetState(0);
}

dec.cbor = &cval;
UtAssert_VOIDCALL(v7_decode_bp_custody_tracking_block(&dec, &v));
void BPLib_AS_Test_Teardown(void)
{
/* Clean up test environment */
}

void TestV7CustodyTrackingRecord_Rgister(void)
void UtTest_Setup(void)
{
UtTest_Add(test_v7_decode_bp_custody_tracking_block, NULL, NULL, "Test v7_decode_bp_custody_tracking_block");
TestBplibAs_Register();
}
Loading

0 comments on commit f4577e0

Please sign in to comment.