c74a8cf3a9
* Add <zephyr/fff.h> from zephyr v3.1.0 Zephyr is deprecating the zmock library in favor of using the FFF faking library for defining and controlling fake implementations of depended-upon APIs called by the code-under-test. Signed-off-by: Gregory Shue <gregory.shue@legrand.com> * Fix bacerror_decode_service_request return value; add unit tests bacerror_decode_service_request() return value now includes the apdu bytes parsed for invoke_id and service. Also added a unit test for functions in bacerror.c, using `fff` for faking the depended-upon functions. Verified by: 1. (Pass) cd $bacnet-stack/test && make test 2. (Pass) west build -p always -b unit_testing \ bacnet-stack/zephyr/tests/unit/bacnet/bacerror/ && \ ./build/testbinary 3. (Pass) ./zephyr/scripts/twister -p unit_testing \ -T bacnet-stack/zephyr/tests/unit/bacnet/bacerror/ Signed-off-by: Gregory Shue <gregory.shue@legrand.com> --------- Signed-off-by: Gregory Shue <gregory.shue@legrand.com> Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
44 lines
872 B
CMake
44 lines
872 B
CMake
# SPDX-License-Identifier: MIT
|
|
|
|
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
|
|
|
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|
project(unittest_${basename}
|
|
VERSION 1.0.0
|
|
LANGUAGES C)
|
|
|
|
|
|
string(REGEX REPLACE
|
|
"/test/unit/bacnet/[a-zA-Z_/-]*$"
|
|
"/src"
|
|
SRC_DIR
|
|
${CMAKE_CURRENT_SOURCE_DIR})
|
|
string(REGEX REPLACE
|
|
"/test/unit/bacnet/[a-zA-Z_/-]*$"
|
|
"/test"
|
|
TST_DIR
|
|
${CMAKE_CURRENT_SOURCE_DIR})
|
|
set(ZTST_DIR "${TST_DIR}/ztest/src")
|
|
|
|
add_compile_definitions(
|
|
BIG_ENDIAN=0
|
|
CONFIG_ZTEST=1
|
|
)
|
|
|
|
include_directories(
|
|
./src
|
|
${SRC_DIR}
|
|
${TST_DIR}/ztest/include
|
|
)
|
|
|
|
add_executable(${PROJECT_NAME}
|
|
# File(s) under test
|
|
${SRC_DIR}/bacnet/bacerror.c
|
|
# Support files and stubs (pathname alphabetical)
|
|
# Test and test library files
|
|
./src/main.c
|
|
./src/fakes/bacdcode.c
|
|
${ZTST_DIR}/ztest_mock.c
|
|
${ZTST_DIR}/ztest.c
|
|
)
|