Skip to content

Commit f4577e0

Browse files
committed
DTNN-653 Initial v7 rebase
1 parent 2097e8e commit f4577e0

File tree

165 files changed

+474
-32743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+474
-32743
lines changed

CMakeLists.txt

+15-36
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,20 @@ if (BPLIB_ENABLE_UNIT_TESTS AND BPLIB_STANDALONE_BUILD_MODE AND NOT CMAKE_CROSSC
8585
enable_testing()
8686
endif()
8787

88-
add_subdirectory(os)
89-
add_subdirectory(common)
90-
add_subdirectory(lib)
91-
add_subdirectory(mpool)
92-
add_subdirectory(cache)
93-
add_subdirectory(v7)
88+
add_subdirectory(cla)
89+
add_subdirectory(aa/as)
90+
9491

9592
# v7 implementation parts
9693
list(APPEND BPLIB_SRC
97-
store/file_offload.c
98-
99-
$<TARGET_OBJECTS:bplib_os>
100-
$<TARGET_OBJECTS:bplib_common>
101-
$<TARGET_OBJECTS:bplib_cache>
102-
$<TARGET_OBJECTS:bplib_v7>
103-
$<TARGET_OBJECTS:bplib_mpool>
104-
$<TARGET_OBJECTS:bplib_base>
94+
$<TARGET_OBJECTS:bplib_cla>
95+
$<TARGET_OBJECTS:bplib_as>
10596
)
10697

10798
list(APPEND BPLIB_PRIVATE_INCLUDE_DIRS
108-
$<TARGET_PROPERTY:bplib_os,INTERFACE_INCLUDE_DIRECTORIES>
109-
$<TARGET_PROPERTY:bplib_base,INTERFACE_INCLUDE_DIRECTORIES>
110-
$<TARGET_PROPERTY:bplib_v7,INTERFACE_INCLUDE_DIRECTORIES>
111-
$<TARGET_PROPERTY:bplib_mpool,INTERFACE_INCLUDE_DIRECTORIES>
112-
$<TARGET_PROPERTY:bplib_cache,INTERFACE_INCLUDE_DIRECTORIES>
113-
$<TARGET_PROPERTY:bplib_common,INTERFACE_INCLUDE_DIRECTORIES>
99+
$<TARGET_PROPERTY:bplib_cla,INTERFACE_INCLUDE_DIRECTORIES>
100+
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
101+
114102
)
115103

116104
# If building as part of CFE/CFS, then the "IS_CFS_ARCH_BUILD" should be set
@@ -122,8 +110,6 @@ if (IS_CFS_ARCH_BUILD)
122110
# The CFE build system determines whether to create a shared or static object inside this routine
123111
add_cfe_app(bplib ${BPLIB_SRC})
124112

125-
target_link_libraries(bplib ${TINYCBOR_LDFLAGS})
126-
127113
else()
128114

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

135-
# link with the requisite dependencies
136-
target_link_libraries(bplib ${TINYCBOR_LDFLAGS})
137-
138121
# Add in the required link libraries based on OS adapter selection
139122
# this should preferably be in OS subdirectory, but it needs to be done
140123
# at the bplib target which is created here.
@@ -185,13 +168,13 @@ endif()
185168
get_target_property(IS_PIC bplib POSITION_INDEPENDENT_CODE)
186169
if (IS_PIC)
187170
set_target_properties(
188-
bplib_base bplib_common bplib_mpool bplib_cache bplib_v7 bplib_os
171+
bplib_cla bplib_as
189172
PROPERTIES POSITION_INDEPENDENT_CODE ${IS_PIC}
190173
)
191174
endif()
192175

193176
# Set the standard compile options for all submodules (c99, full warnings)
194-
foreach(TGT bplib bplib_base bplib_common bplib_mpool bplib_cache bplib_v7 bplib_os)
177+
foreach(TGT bplib bplib_cla bplib_as)
195178
target_compile_features(${TGT} PRIVATE c_std_99)
196179
target_compile_options(${TGT} PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})
197180
endforeach()
@@ -207,12 +190,8 @@ target_include_directories(bplib PUBLIC
207190
$<INSTALL_INTERFACE:include/bplib>
208191
)
209192

210-
if (BPLIB_ENABLE_UNIT_TESTS)
211-
add_subdirectory(ut-stubs)
212-
213-
# BPLib Sanity checks are only for standalone builds, sanity checks
214-
# for CFE/CFS builds should be part of the BP app, as opposed to BPLib
215-
if (NOT IS_CFS_ARCH_BUILD)
216-
add_subdirectory(ut-functional)
217-
endif (NOT IS_CFS_ARCH_BUILD)
218-
endif (BPLIB_ENABLE_UNIT_TESTS)
193+
# BPLib Sanity checks are only for standalone builds, sanity checks
194+
# for CFE/CFS builds should be part of the BP app, as opposed to BPLib
195+
if (BPLIB_ENABLE_UNIT_TESTS AND NOT IS_CFS_ARCH_BUILD)
196+
add_subdirectory(ut-functional)
197+
endif ()

aa/as/CMakeLists.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
##################################################################
2+
#
3+
# Bundle Protocol Library (BPLib) CMake build recipe
4+
#
5+
# This is for the Admin Statistics (AS) module
6+
#
7+
##################################################################
8+
9+
add_library(bplib_as OBJECT
10+
src/bplib_as.c
11+
)
12+
13+
target_include_directories(bplib_as PUBLIC
14+
${CMAKE_CURRENT_SOURCE_DIR}/inc
15+
$<TARGET_PROPERTY:bplib,INTERFACE_INCLUDE_DIRECTORIES>
16+
)
17+
18+
# Add unit tests
19+
if(BPLIB_ENABLE_UNIT_TESTS)
20+
add_subdirectory(unit-test)
21+
endif(BPLIB_ENABLE_UNIT_TESTS)

common/ut-stubs/crc_stub_objs.c aa/as/inc/bplib_as.h

+14-13
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
*
1919
*/
2020

21-
/**
22-
* @file
23-
*
24-
* Auto-Generated stub implementations for functions defined in crc header
25-
*/
21+
#ifndef BPLIB_AS_H
22+
#define BPLIB_AS_H
23+
24+
/*
25+
** Includes
26+
*/
2627

27-
#include "crc.h"
28+
#include "bplib.h"
29+
30+
31+
/*
32+
** Function Definitions
33+
*/
2834

29-
struct bplib_crc_parameters
30-
{
31-
uint32_t stub;
32-
};
35+
int BPLib_AS_Init(void);
3336

34-
bplib_crc_parameters_t BPLIB_CRC_NONE = {0};
35-
bplib_crc_parameters_t BPLIB_CRC16_X25 = {1};
36-
bplib_crc_parameters_t BPLIB_CRC32_CASTAGNOLI = {2};
37+
#endif /* BPLIB_AS_H */

v7/inc/v7_codec.h aa/as/src/bplib_as.c

+10-14
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@
1818
*
1919
*/
2020

21-
#ifndef V7_CODEC_H
22-
#define V7_CODEC_H
21+
/*
22+
** Includes
23+
*/
2324

24-
/******************************************************************************
25-
INCLUDES
26-
******************************************************************************/
25+
#include "bplib_as.h"
2726

28-
#include "bplib.h"
29-
#include "v7_mpool.h"
30-
#include "v7_types.h"
31-
#include "v7_decode.h"
32-
#include "v7_encode.h"
3327

34-
size_t v7_compute_full_bundle_size(bplib_mpool_bblock_primary_t *cpb);
35-
size_t v7_copy_full_bundle_out(bplib_mpool_bblock_primary_t *cpb, void *buffer, size_t buf_sz);
36-
size_t v7_copy_full_bundle_in(bplib_mpool_bblock_primary_t *cpb, const void *buffer, size_t buf_sz);
28+
/*
29+
** Function Definitions
30+
*/
3731

38-
#endif /* V7_CODEC_H */
32+
int BPLib_AS_Init(void) {
33+
return BP_SUCCESS;
34+
}

aa/as/unit-test/CMakeLists.txt

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
##################################################################
2+
#
3+
# coverage test build recipe
4+
#
5+
# This CMake file contains the recipe for building the coverage tests.
6+
# It is invoked from the parent directory when unit tests are enabled.
7+
#
8+
##################################################################
9+
10+
add_library(utobj_bplib_as OBJECT
11+
../src/bplib_as.c
12+
)
13+
14+
target_compile_definitions(utobj_bplib_as PRIVATE
15+
$<TARGET_PROPERTY:bplib_as,COMPILE_DEFINITIONS>
16+
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_COMPILE_DEFINITIONS>
17+
)
18+
19+
target_compile_options(utobj_bplib_as PRIVATE
20+
$<TARGET_PROPERTY:bplib_as,COMPILE_OPTIONS>
21+
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_COMPILE_OPTIONS>
22+
)
23+
24+
target_include_directories(utobj_bplib_as PRIVATE
25+
$<TARGET_PROPERTY:bplib_as,INCLUDE_DIRECTORIES>
26+
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_INCLUDE_DIRECTORIES>
27+
)
28+
29+
# Add executable
30+
add_executable(coverage-bplib_as-testrunner
31+
utilities/bplib_as_test_utils.c
32+
bplib_as_test.c
33+
$<TARGET_OBJECTS:utobj_bplib_as>
34+
)
35+
36+
target_include_directories(coverage-bplib_as-testrunner PRIVATE
37+
../src
38+
${CMAKE_CURRENT_SOURCE_DIR}/inc
39+
utilities/
40+
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
41+
)
42+
43+
target_link_libraries(coverage-bplib_as-testrunner PUBLIC
44+
ut_coverage_link
45+
ut_assert
46+
)
47+
48+
add_test(coverage-bplib_as-testrunner coverage-bplib_as-testrunner)
49+
50+
# Install the executables to a staging area for test in cross environments
51+
if (INSTALL_TARGET_LIST)
52+
foreach(TGT ${INSTALL_TARGET_LIST})
53+
install(TARGETS coverage-bplib_as-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR})
54+
endforeach()
55+
endif()

v7/ut-coverage/test_v7_bp_bundle_age_block.c aa/as/unit-test/bplib_as_test.c

+10-15
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,19 @@
1919
/*
2020
* Includes
2121
*/
22-
#include "test_bplib_v7.h"
22+
#include "bplib_as_test_utils.h"
2323

24-
void test_v7_decode_bp_bundle_age_block(void)
24+
/*
25+
** Test function for
26+
** int BPLib_AS_Init()
27+
*/
28+
void Test_BPLib_AS_Init(void)
2529
{
26-
/* Test function for:
27-
* void v7_decode_bp_bundle_age_block(v7_decode_state_t *dec, bp_bundle_age_block_t *v)
28-
*/
29-
v7_decode_state_t dec;
30-
bp_bundle_age_block_t v;
31-
32-
memset(&dec, 0, sizeof(v7_decode_state_t));
33-
memset(&v, 0, sizeof(bp_bundle_age_block_t));
34-
dec.error = true;
35-
36-
UtAssert_VOIDCALL(v7_decode_bp_bundle_age_block(&dec, &v));
30+
UtAssert_INT32_EQ(BPLib_AS_Init(), BP_SUCCESS);
3731
}
3832

39-
void TestBpV7BundleAgeBlock_Register(void)
33+
34+
void TestBplibAs_Register(void)
4035
{
41-
UtTest_Add(test_v7_decode_bp_bundle_age_block, NULL, NULL, "Test v7_decode_bp_bundle_age_block");
36+
UtTest_Add(Test_BPLib_AS_Init, NULL, NULL, "Test_BPLib_AS_Init");
4237
}

aa/as/unit-test/stubs/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
##################################################################
2+
#
3+
# Bundle Protocol Library (BPLib) CMake build recipe
4+
#
5+
# This is for the "as" stub functions
6+
#
7+
##################################################################
8+
9+
add_library(bplib_as_stubs STATIC
10+
bplib_as_stubs.c
11+
)
12+
13+
target_include_directories(bplib_as_stubs PUBLIC
14+
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
15+
)
16+
17+
target_link_libraries(bplib_as_stubs PUBLIC
18+
ut_assert
19+
)

os/ut-stubs/bplib_os_handlers.c aa/as/unit-test/stubs/bplib_as_stubs.c

+11-16
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,22 @@
2121
/**
2222
* @file
2323
*
24-
* Handler companions for generated BPLib OS stubs
24+
* Auto-Generated stub implementations for functions defined in bplib_as header
2525
*/
2626

27-
/* UT includes */
28-
#include "uttest.h"
29-
#include "utstubs.h"
27+
#include "bplib_as.h"
3028
#include "utgenstub.h"
3129

32-
/*----------------------------------------------------------------
33-
*
34-
* This just translates the 32-bit return status into a 64-bit
35-
*
36-
*-----------------------------------------------------------------*/
37-
void UT_DefaultHandler_bplib_os_get_dtntime_ms(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
30+
/*
31+
* ----------------------------------------------------
32+
* Generated stub function for BPLib_AS_Init()
33+
* ----------------------------------------------------
34+
*/
35+
int BPLib_AS_Init(void)
3836
{
39-
int32 StatusCode;
40-
uint64_t Result;
41-
42-
UT_Stub_GetInt32StatusCode(Context, &StatusCode);
37+
UT_GenStub_SetupReturnBuffer(BPLib_AS_Init, int);
4338

44-
Result = StatusCode;
39+
UT_GenStub_Execute(BPLib_AS_Init, Basic, NULL);
4540

46-
UT_Stub_SetReturnValue(FuncKey, Result);
41+
return UT_GenStub_GetReturnValue(BPLib_AS_Init, int);
4742
}

v7/ut-coverage/test_v7_custody_tracking_block.c aa/as/unit-test/utilities/bplib_as_test_utils.c

+17-18
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,27 @@
1717
************************************************************************/
1818

1919
/*
20-
* Includes
21-
*/
22-
#include "test_bplib_v7.h"
20+
** Includes
21+
*/
2322

24-
void test_v7_decode_bp_custody_tracking_block(void)
25-
{
26-
/* Test function for:
27-
* void v7_decode_bp_custody_tracking_block(v7_decode_state_t *dec, bp_custody_tracking_block_t *v)
28-
*/
29-
v7_decode_state_t dec;
30-
bp_custody_tracking_block_t v;
31-
CborValue cval;
23+
#include "bplib_as_test_utils.h"
24+
25+
/*
26+
** Function Definitions
27+
*/
3228

33-
memset(&dec, 0, sizeof(v7_decode_state_t));
34-
memset(&v, 0, sizeof(bp_custody_tracking_block_t));
35-
memset(&cval, 0, sizeof(CborValue));
29+
void BPLib_AS_Test_Setup(void)
30+
{
31+
/* Initialize test environment to default state for every test */
32+
UT_ResetState(0);
33+
}
3634

37-
dec.cbor = &cval;
38-
UtAssert_VOIDCALL(v7_decode_bp_custody_tracking_block(&dec, &v));
35+
void BPLib_AS_Test_Teardown(void)
36+
{
37+
/* Clean up test environment */
3938
}
4039

41-
void TestV7CustodyTrackingRecord_Rgister(void)
40+
void UtTest_Setup(void)
4241
{
43-
UtTest_Add(test_v7_decode_bp_custody_tracking_block, NULL, NULL, "Test v7_decode_bp_custody_tracking_block");
42+
TestBplibAs_Register();
4443
}

0 commit comments

Comments
 (0)