mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-28 16:11:24 +00:00
test: split l2cap-channel into l2cap-cbm and l2cap-ecbm
This commit is contained in:
parent
1382159caa
commit
af7c3ae6cd
@ -22,7 +22,8 @@ SUBDIRS = \
|
|||||||
gatt_service \
|
gatt_service \
|
||||||
hfp \
|
hfp \
|
||||||
hid_parser \
|
hid_parser \
|
||||||
l2cap-channel \
|
l2cap-cbm \
|
||||||
|
l2cap-ecbm \
|
||||||
le_device_db_tlv \
|
le_device_db_tlv \
|
||||||
linked_list \
|
linked_list \
|
||||||
map_test \
|
map_test \
|
||||||
@ -59,7 +60,7 @@ SUBDIRS_BLE = \
|
|||||||
gatt_server \
|
gatt_server \
|
||||||
gatt_service \
|
gatt_service \
|
||||||
hid_parser \
|
hid_parser \
|
||||||
l2cap-channel \
|
l2cap-cbm \
|
||||||
le_device_db_tlv \
|
le_device_db_tlv \
|
||||||
linked_list \
|
linked_list \
|
||||||
ring_buffer \
|
ring_buffer \
|
||||||
|
78
test/l2cap-cbm/Makefile
Normal file
78
test/l2cap-cbm/Makefile
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
|
||||||
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
|
BTSTACK_ROOT = ../..
|
||||||
|
|
||||||
|
CFLAGS = -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null -Ibuild-coverage -I./
|
||||||
|
CFLAGS += -I${BTSTACK_ROOT}/src
|
||||||
|
CFLAGS += -I${BTSTACK_ROOT}/src/ble
|
||||||
|
CFLAGS += -I${BTSTACK_ROOT}/platform/posix
|
||||||
|
CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
|
||||||
|
# CFLAGS += -D ENABLE_TESTING_SUPPORT
|
||||||
|
|
||||||
|
VPATH += ${BTSTACK_ROOT}/src
|
||||||
|
VPATH += ${BTSTACK_ROOT}/src/ble
|
||||||
|
VPATH += ${BTSTACK_ROOT}/platform/embedded
|
||||||
|
VPATH += ${BTSTACK_ROOT}/platform/posix
|
||||||
|
|
||||||
|
COMMON = \
|
||||||
|
btstack_linked_list.c \
|
||||||
|
btstack_util.c \
|
||||||
|
hci.c \
|
||||||
|
hci_cmd.c \
|
||||||
|
ad_parser.c \
|
||||||
|
l2cap.c \
|
||||||
|
l2cap_signaling.c \
|
||||||
|
btstack_memory.c \
|
||||||
|
btstack_run_loop.c \
|
||||||
|
btstack_run_loop_embedded.c \
|
||||||
|
hci_dump.c \
|
||||||
|
hci_dump_posix_stdout.c \
|
||||||
|
|
||||||
|
CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
|
||||||
|
CFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
|
||||||
|
|
||||||
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
|
LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
|
||||||
|
LDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address
|
||||||
|
|
||||||
|
COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
|
||||||
|
COMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o))
|
||||||
|
|
||||||
|
|
||||||
|
all: \
|
||||||
|
build-coverage/l2cap_cbm_test build-asan/l2cap_cbm_test \
|
||||||
|
|
||||||
|
build-%:
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
build-coverage/%.o: %.c | build-coverage
|
||||||
|
${CC} -c $(CFLAGS_COVERAGE) $< -o $@
|
||||||
|
|
||||||
|
build-coverage/%.o: %.cpp | build-coverage
|
||||||
|
${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
|
||||||
|
|
||||||
|
build-asan/%.o: %.c | build-asan
|
||||||
|
${CC} -c $(CFLAGS_ASAN) $< -o $@
|
||||||
|
|
||||||
|
build-asan/%.o: %.cpp | build-asan
|
||||||
|
${CXX} -c $(CFLAGS_ASAN) $< -o $@
|
||||||
|
|
||||||
|
build-coverage/l2cap_cbm_test: ${COMMON_OBJ_COVERAGE} build-coverage/l2cap_cbm_test.o | build-coverage
|
||||||
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
||||||
|
|
||||||
|
build-asan/l2cap_cbm_test: ${COMMON_OBJ_ASAN} build-asan/l2cap_cbm_test.o | build-asan
|
||||||
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
||||||
|
|
||||||
|
test: all
|
||||||
|
build-asan/l2cap_cbm_test
|
||||||
|
|
||||||
|
coverage: all
|
||||||
|
rm -f build-coverage/*.gcda
|
||||||
|
build-coverage/l2cap_cbm_test
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build-coverage build-asan
|
||||||
|
|
32
test/l2cap-cbm/btstack_config.h
Normal file
32
test/l2cap-cbm/btstack_config.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// btstack_config.h for most tests
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BTSTACK_CONFIG_H
|
||||||
|
#define BTSTACK_CONFIG_H
|
||||||
|
|
||||||
|
// Port related features
|
||||||
|
#define HAVE_BTSTACK_STDIN
|
||||||
|
#define HAVE_MALLOC
|
||||||
|
#define HAVE_POSIX_FILE_IO
|
||||||
|
#define HAVE_POSIX_TIME
|
||||||
|
|
||||||
|
|
||||||
|
// BTstack features that can be enabled
|
||||||
|
#define ENABLE_BLE
|
||||||
|
#define ENABLE_LOG_ERROR
|
||||||
|
#define ENABLE_LOG_INFO
|
||||||
|
#define ENABLE_PRINTF_HEXDUMP
|
||||||
|
|
||||||
|
#define ENABLE_LE_CENTRAL
|
||||||
|
#define ENABLE_LE_PERIPHERAL
|
||||||
|
#define ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
|
||||||
|
|
||||||
|
// for ready-to-use hci channels
|
||||||
|
#define FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
|
|
||||||
|
// BTstack configuration. buffers, sizes, ...
|
||||||
|
#define HCI_ACL_PAYLOAD_SIZE 52
|
||||||
|
#define HCI_INCOMING_PRE_BUFFER_SIZE 4
|
||||||
|
|
||||||
|
#endif
|
51
test/l2cap-ecbm/CMakeLists.txt
Normal file
51
test/l2cap-ecbm/CMakeLists.txt
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
cmake_minimum_required (VERSION 3.5)
|
||||||
|
project(gatt-client-test)
|
||||||
|
|
||||||
|
# add CppUTest
|
||||||
|
include_directories("/usr/local/include")
|
||||||
|
link_directories("/usr/local/lib")
|
||||||
|
link_libraries( CppUTest )
|
||||||
|
link_libraries( CppUTestExt )
|
||||||
|
|
||||||
|
# set include paths
|
||||||
|
include_directories(.)
|
||||||
|
include_directories(../../src)
|
||||||
|
include_directories(../mock)
|
||||||
|
include_directories(../../platform/embedded)
|
||||||
|
include_directories(../../platform/posix)
|
||||||
|
include_directories( ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
# common files
|
||||||
|
set(SOURCES
|
||||||
|
../../src/btstack_linked_list.c
|
||||||
|
../../src/btstack_util.c
|
||||||
|
../../src/hci.c
|
||||||
|
../../src/hci_cmd.c
|
||||||
|
../../src/ad_parser.c
|
||||||
|
../../src/l2cap.c
|
||||||
|
../../src/l2cap_signaling.c
|
||||||
|
../../src/btstack_memory.c
|
||||||
|
../../src/btstack_run_loop.c
|
||||||
|
../../src/hci_dump.c
|
||||||
|
../../platform/posix/hci_dump_posix_stdout.c
|
||||||
|
../../platform/embedded/btstack_run_loop_embedded.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Enable ASAN
|
||||||
|
add_compile_options( -g -fsanitize=address)
|
||||||
|
add_link_options( -fsanitize=address)
|
||||||
|
|
||||||
|
# create static lib
|
||||||
|
add_library(btstack STATIC ${SOURCES})
|
||||||
|
|
||||||
|
# create targets
|
||||||
|
file(GLOB TEST_FILES_CPP "*_test.cpp")
|
||||||
|
foreach(TEST_FILE ${TEST_FILES_CPP})
|
||||||
|
# Use C++ Compiler
|
||||||
|
# set_source_files_properties(${TEST_FILE} PROPERTIES LANGUAGE CXX )
|
||||||
|
set (SOURCE_FILES ${TEST_FILE})
|
||||||
|
get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
|
||||||
|
message("- " ${TEST_NAME})
|
||||||
|
add_executable(${TEST_NAME} ${SOURCE_FILES} )
|
||||||
|
target_link_libraries(${TEST_NAME} btstack)
|
||||||
|
endforeach(TEST_FILE)
|
@ -43,7 +43,6 @@ COMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o))
|
|||||||
|
|
||||||
|
|
||||||
all: \
|
all: \
|
||||||
build-coverage/l2cap_cbm_test build-asan/l2cap_cbm_test \
|
|
||||||
build-coverage/l2cap_ecbm_test build-asan/l2cap_ecbm_test \
|
build-coverage/l2cap_ecbm_test build-asan/l2cap_ecbm_test \
|
||||||
|
|
||||||
build-%:
|
build-%:
|
||||||
@ -61,12 +60,6 @@ build-asan/%.o: %.c | build-asan
|
|||||||
build-asan/%.o: %.cpp | build-asan
|
build-asan/%.o: %.cpp | build-asan
|
||||||
${CXX} -c $(CFLAGS_ASAN) $< -o $@
|
${CXX} -c $(CFLAGS_ASAN) $< -o $@
|
||||||
|
|
||||||
build-coverage/l2cap_cbm_test: ${COMMON_OBJ_COVERAGE} build-coverage/l2cap_cbm_test.o | build-coverage
|
|
||||||
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
|
||||||
|
|
||||||
build-asan/l2cap_cbm_test: ${COMMON_OBJ_ASAN} build-asan/l2cap_cbm_test.o | build-asan
|
|
||||||
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
|
||||||
|
|
||||||
build-coverage/l2cap_ecbm_test: ${COMMON_OBJ_COVERAGE} build-coverage/l2cap_ecbm_test.o | build-coverage
|
build-coverage/l2cap_ecbm_test: ${COMMON_OBJ_COVERAGE} build-coverage/l2cap_ecbm_test.o | build-coverage
|
||||||
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
||||||
|
|
||||||
@ -74,12 +67,10 @@ build-asan/l2cap_ecbm_test: ${COMMON_OBJ_ASAN} build-asan/l2cap_ecbm_test.o | bu
|
|||||||
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
||||||
|
|
||||||
test: all
|
test: all
|
||||||
build-asan/l2cap_cbm_test
|
|
||||||
build-asan/l2cap_ecbm_test
|
build-asan/l2cap_ecbm_test
|
||||||
|
|
||||||
coverage: all
|
coverage: all
|
||||||
rm -f build-coverage/*.gcda
|
rm -f build-coverage/*.gcda
|
||||||
build-coverage/l2cap_cbm_test
|
|
||||||
build-coverage/l2cap_ecbm_test
|
build-coverage/l2cap_ecbm_test
|
||||||
|
|
||||||
clean:
|
clean:
|
Loading…
x
Reference in New Issue
Block a user