2019-09-23 11:12:35 +00:00
|
|
|
# Requirements: cpputest.github.io
|
|
|
|
|
|
|
|
BTSTACK_ROOT = ../..
|
|
|
|
|
2023-08-20 14:13:49 +00:00
|
|
|
# CppuTest from pkg-config
|
|
|
|
CFLAGS += ${shell pkg-config --cflags CppuTest}
|
|
|
|
LDFLAGS += ${shell pkg-config --libs CppuTest}
|
|
|
|
|
|
|
|
CFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null
|
2021-06-12 10:03:02 +00:00
|
|
|
CFLAGS += -I${BTSTACK_ROOT}/src
|
|
|
|
CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
|
|
|
|
CFLAGS += -I.
|
2019-09-23 11:12:35 +00:00
|
|
|
|
2019-09-23 11:52:33 +00:00
|
|
|
CFLAGS += -DHAVE_HAL_AUDIO
|
|
|
|
|
2020-12-01 21:13:09 +00:00
|
|
|
CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
|
2021-01-29 20:47:15 +00:00
|
|
|
CFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
|
2020-12-01 21:13:09 +00:00
|
|
|
|
|
|
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
|
|
|
LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
|
|
|
|
LDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address
|
2019-09-23 11:12:35 +00:00
|
|
|
|
|
|
|
VPATH += ${BTSTACK_ROOT}/src
|
|
|
|
VPATH += ${BTSTACK_ROOT}/src/ble
|
|
|
|
VPATH += ${BTSTACK_ROOT}/platform/embedded
|
2019-09-23 11:52:33 +00:00
|
|
|
VPATH += ${BTSTACK_ROOT}/platform/freertos
|
2019-09-23 11:12:35 +00:00
|
|
|
|
|
|
|
COMMON = \
|
2021-01-28 18:21:15 +00:00
|
|
|
btstack_linked_list.c \
|
2021-06-18 17:34:32 +00:00
|
|
|
btstack_memory.c \
|
|
|
|
btstack_run_loop.c \
|
|
|
|
btstack_util.c \
|
|
|
|
hci_dump.c \
|
|
|
|
l2cap_signaling.c \
|
|
|
|
hci_cmd.c \
|
2023-03-24 17:08:41 +00:00
|
|
|
hci_event.c \
|
2021-06-18 17:34:32 +00:00
|
|
|
|
2020-12-01 21:13:09 +00:00
|
|
|
FREERTOS = \
|
|
|
|
btstack_run_loop_freertos.c \
|
|
|
|
|
|
|
|
COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
|
|
|
|
COMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o))
|
|
|
|
|
|
|
|
FREERTOS_OBJ_COVERAGE = $(addprefix build-coverage/,$(FREERTOS:.c=.o))
|
|
|
|
FREERTOS_OBJ_ASAN = $(addprefix build-asan/, $(FREERTOS:.c=.o))
|
|
|
|
|
2021-06-17 08:21:45 +00:00
|
|
|
all: build-coverage/embedded_test build-asan/embedded_test \
|
|
|
|
build-coverage/run_loop_base_test build-asan/run_loop_base_test \
|
|
|
|
build-coverage/btstack_util_test build-asan/btstack_util_test \
|
|
|
|
build-coverage/l2cap_le_signaling_test build-asan/l2cap_le_signaling_test \
|
|
|
|
build-coverage/hci_cmd_test build-asan/hci_cmd_test \
|
2021-12-05 19:46:44 +00:00
|
|
|
build-coverage/hci_dump_test build-asan/hci_dump_test \
|
2023-03-24 17:08:41 +00:00
|
|
|
build-coverage/hci_event_test build-asan/hci_event_test \
|
2021-06-17 08:21:45 +00:00
|
|
|
build-coverage/freertos_test build-asan/freertos_test \
|
2020-12-01 21:13:09 +00:00
|
|
|
|
|
|
|
build-%:
|
|
|
|
mkdir -p $@
|
2019-09-23 11:12:35 +00:00
|
|
|
|
2020-12-01 21:13:09 +00:00
|
|
|
build-coverage/%.o: %.c | build-coverage
|
|
|
|
${CC} -c $(CFLAGS_COVERAGE) $< -o $@
|
2019-09-23 11:52:33 +00:00
|
|
|
|
2022-03-11 21:15:38 +00:00
|
|
|
build-coverage/%.o: %.cpp | build-coverage
|
|
|
|
${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
|
|
|
|
|
2020-12-01 21:13:09 +00:00
|
|
|
build-asan/%.o: %.c | build-asan
|
|
|
|
${CC} -c $(CFLAGS_ASAN) $< -o $@
|
2019-09-23 11:12:35 +00:00
|
|
|
|
2022-03-11 21:15:38 +00:00
|
|
|
build-asan/%.o: %.cpp | build-asan
|
|
|
|
${CXX} -c $(CFLAGS_ASAN) $< -o $@
|
|
|
|
|
2020-11-30 20:35:42 +00:00
|
|
|
|
2021-06-17 08:21:45 +00:00
|
|
|
build-coverage/embedded_test: ${COMMON_OBJ_COVERAGE} build-coverage/btstack_run_loop_embedded.o build-coverage/embedded_test.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2019-09-23 11:12:35 +00:00
|
|
|
|
2021-06-17 08:21:45 +00:00
|
|
|
build-asan/embedded_test: ${COMMON_OBJ_ASAN} build-asan/embedded_test.o build-asan/btstack_run_loop_embedded.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
|
2020-12-10 14:13:13 +00:00
|
|
|
build-coverage/freertos_test: ${COMMON_OBJ_COVERAGE} ${FREERTOS_OBJS} build-coverage/freertos_test.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2020-12-01 21:13:09 +00:00
|
|
|
|
2021-06-17 08:21:45 +00:00
|
|
|
build-asan/freertos_test: ${COMMON_OBJ_ASAN} ${FREERTOS_OBJS} build-asan/freertos_test.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2020-12-01 21:13:09 +00:00
|
|
|
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
build-coverage/run_loop_base_test: ${COMMON_OBJ_COVERAGE} build-coverage/run_loop_base_test.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
build-asan/run_loop_base_test: ${COMMON_OBJ_ASAN} build-asan/run_loop_base_test.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
build-coverage/btstack_util_test: ${COMMON_OBJ_COVERAGE} build-coverage/btstack_util_test.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
build-asan/btstack_util_test: ${COMMON_OBJ_ASAN} build-asan/btstack_util_test.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
build-coverage/l2cap_le_signaling_test: ${COMMON_OBJ_COVERAGE} build-coverage/l2cap_le_signaling_test.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
build-asan/l2cap_le_signaling_test: ${COMMON_OBJ_ASAN} build-asan/l2cap_le_signaling_test.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2019-09-23 11:52:33 +00:00
|
|
|
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
build-coverage/hci_cmd_test: ${COMMON_OBJ_COVERAGE} build-coverage/hci_cmd_test.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
|
|
|
build-asan/hci_cmd_test: ${COMMON_OBJ_ASAN} build-asan/hci_cmd_test.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
2021-12-05 19:46:44 +00:00
|
|
|
build-coverage/hci_dump_test: ${COMMON_OBJ_COVERAGE} build-coverage/hci_dump_test.o build-coverage/hci_dump.o | build-coverage
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-12-05 19:46:44 +00:00
|
|
|
|
|
|
|
build-asan/hci_dump_test: ${COMMON_OBJ_ASAN} build-asan/hci_dump_test.o build-asan/hci_dump.o | build-asan
|
2022-03-11 21:15:38 +00:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2021-06-17 08:21:45 +00:00
|
|
|
|
2023-03-24 17:08:41 +00:00
|
|
|
build-coverage/hci_event_test: ${COMMON_OBJ_COVERAGE} build-coverage/hci_event_test.o | build-coverage
|
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
|
|
|
|
|
|
|
build-asan/hci_event_test: ${COMMON_OBJ_ASAN} build-asan/hci_event_test.o | build-asan
|
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
|
|
|
|
2019-09-23 11:12:35 +00:00
|
|
|
test: all
|
2020-12-01 21:13:09 +00:00
|
|
|
build-asan/embedded_test
|
|
|
|
build-asan/freertos_test
|
2021-06-17 08:21:45 +00:00
|
|
|
build-asan/run_loop_base_test
|
|
|
|
build-asan/btstack_util_test
|
|
|
|
build-asan/l2cap_le_signaling_test
|
|
|
|
build-asan/hci_cmd_test
|
2021-12-05 19:46:44 +00:00
|
|
|
build-asan/hci_dump_test
|
2023-03-24 17:08:41 +00:00
|
|
|
build-asan/hci_event_test
|
2020-11-30 20:35:42 +00:00
|
|
|
|
|
|
|
coverage: all
|
2020-12-01 21:13:09 +00:00
|
|
|
rm -f build-coverage/*.gcda
|
2020-11-30 20:35:42 +00:00
|
|
|
build-coverage/embedded_test
|
|
|
|
build-coverage/freertos_test
|
2021-06-17 08:21:45 +00:00
|
|
|
build-coverage/run_loop_base_test
|
|
|
|
build-coverage/btstack_util_test
|
|
|
|
build-coverage/l2cap_le_signaling_test
|
|
|
|
build-coverage/hci_cmd_test
|
2021-12-05 19:46:44 +00:00
|
|
|
build-coverage/hci_dump_test
|
2023-03-24 17:08:41 +00:00
|
|
|
build-coverage/hci_event_test
|
2019-09-23 11:12:35 +00:00
|
|
|
|
|
|
|
clean:
|
2021-06-17 08:21:45 +00:00
|
|
|
rm -rf build-coverage build-asan *.dSYM
|