2020-09-28 11:59:13 +02:00
|
|
|
# Requirements: cpputest.github.io
|
|
|
|
|
|
|
|
BTSTACK_ROOT = ../..
|
|
|
|
|
2023-08-20 16:13:49 +02:00
|
|
|
# CppuTest from pkg-config
|
|
|
|
CFLAGS += ${shell pkg-config --cflags CppuTest}
|
|
|
|
LDFLAGS += ${shell pkg-config --libs CppuTest}
|
2021-06-12 12:03:02 +02:00
|
|
|
|
2023-08-20 16:13:49 +02:00
|
|
|
CFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null
|
2021-06-12 12:03:02 +02:00
|
|
|
CFLAGS += -I${BTSTACK_ROOT}/src
|
2020-12-01 22:13:09 +01:00
|
|
|
|
|
|
|
CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
|
2021-01-29 21:47:15 +01:00
|
|
|
CFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
|
2020-12-01 22:13:09 +01:00
|
|
|
|
2020-09-28 11:59:13 +02:00
|
|
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
2020-12-01 22:13:09 +01:00
|
|
|
LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
|
|
|
|
LDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address
|
2020-09-28 11:59:13 +02:00
|
|
|
|
|
|
|
VPATH += ${BTSTACK_ROOT}/src
|
|
|
|
VPATH += ${BTSTACK_ROOT}/src/classic
|
|
|
|
VPATH += ${BTSTACK_ROOT}/platform/posix
|
|
|
|
|
|
|
|
COMMON = \
|
|
|
|
btstack_util.c \
|
|
|
|
hci_dump.c \
|
|
|
|
btstack_memory_pool.c \
|
|
|
|
|
2020-12-01 22:13:09 +01:00
|
|
|
COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
|
|
|
|
COMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o))
|
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
all: build-coverage/btstack_memory_pool_test \
|
|
|
|
build-coverage-none/btstack_memory_test \
|
|
|
|
build-coverage-single/btstack_memory_test \
|
|
|
|
build-coverage-malloc/btstack_memory_test \
|
|
|
|
build-asan/btstack_memory_pool_test \
|
|
|
|
build-asan/btstack_memory_test
|
2020-12-01 22:13:09 +01:00
|
|
|
|
|
|
|
build-%:
|
|
|
|
mkdir -p $@
|
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
|
2020-12-01 22:13:09 +01:00
|
|
|
build-coverage/%.o: %.c | build-coverage
|
2021-01-28 15:20:28 +01:00
|
|
|
${CC} -c $(CFLAGS_COVERAGE) -I config_single $< -o $@
|
|
|
|
|
2022-03-11 22:15:38 +01:00
|
|
|
build-coverage/%.o: %.cpp | build-coverage
|
|
|
|
${CXX} -c $(CFLAGS_COVERAGE) -I config_single $< -o $@
|
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage-none/%.o: %.c | build-coverage-none
|
|
|
|
${CC} -c $(CFLAGS_COVERAGE) -I config_none $< -o $@
|
|
|
|
|
2022-03-11 22:15:38 +01:00
|
|
|
build-coverage-none/%.o: %.cpp | build-coverage-none
|
|
|
|
${CXX} -c $(CFLAGS_COVERAGE) -I config_none $< -o $@
|
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage-single/%.o: %.c | build-coverage-single
|
|
|
|
${CC} -c $(CFLAGS_COVERAGE) -I config_single $< -o $@
|
|
|
|
|
2022-03-11 22:15:38 +01:00
|
|
|
build-coverage-single/%.o: %.cpp | build-coverage-single
|
|
|
|
${CXX} -c $(CFLAGS_COVERAGE) -I config_single $< -o $@
|
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage-malloc/%.o: %.c | build-coverage-malloc
|
|
|
|
${CC} -c $(CFLAGS_COVERAGE) -I config_malloc $< -o $@
|
2020-09-28 11:59:13 +02:00
|
|
|
|
2022-03-11 22:15:38 +01:00
|
|
|
build-coverage-malloc/%.o: %.cpp | build-coverage-malloc
|
|
|
|
${CXX} -c $(CFLAGS_COVERAGE) -I config_malloc $< -o $@
|
|
|
|
|
2020-12-01 22:13:09 +01:00
|
|
|
build-asan/%.o: %.c | build-asan
|
2021-01-28 15:20:28 +01:00
|
|
|
${CC} -c $(CFLAGS_ASAN) $< -I config_single -o $@
|
2020-09-28 11:59:13 +02:00
|
|
|
|
2022-03-11 22:15:38 +01:00
|
|
|
build-asan/%.o: %.cpp | build-asan
|
|
|
|
${CXX} -c $(CFLAGS_ASAN) $< -I config_single -o $@
|
2020-11-30 21:35:42 +01:00
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage/btstack_memory_pool_test: ${COMMON_OBJ_COVERAGE} build-coverage/btstack_memory.o build-coverage/btstack_memory_pool_test.o | build-coverage
|
2022-03-11 22:15:38 +01:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2020-09-28 11:59:13 +02:00
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage-none/btstack_memory_test: ${COMMON_OBJ_COVERAGE} build-coverage-none/btstack_memory.o build-coverage-none/btstack_memory_test.o | build-coverage-none
|
2022-03-11 22:15:38 +01:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2020-12-01 22:13:09 +01:00
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage-single/btstack_memory_test: ${COMMON_OBJ_COVERAGE} build-coverage-single/btstack_memory.o build-coverage-single/btstack_memory_test.o | build-coverage-single
|
2022-03-11 22:15:38 +01:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-01-28 15:20:28 +01:00
|
|
|
|
|
|
|
build-coverage-malloc/btstack_memory_test: ${COMMON_OBJ_COVERAGE} build-coverage-malloc/btstack_memory.o build-coverage-malloc/btstack_memory_test.o | build-coverage-malloc
|
2022-03-11 22:15:38 +01:00
|
|
|
${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
|
2021-01-28 15:20:28 +01:00
|
|
|
|
|
|
|
build-asan/btstack_memory_pool_test: ${COMMON_OBJ_ASAN} build-asan/btstack_memory.o build-asan/btstack_memory_pool_test.o | build-asan
|
2022-03-11 22:15:38 +01:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2020-12-01 22:13:09 +01:00
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
build-asan/btstack_memory_test: ${COMMON_OBJ_ASAN} build-asan/btstack_memory.o build-asan/btstack_memory_test.o | build-asan
|
2022-03-11 22:15:38 +01:00
|
|
|
${CXX} $^ ${LDFLAGS_ASAN} -o $@
|
2020-09-28 11:59:13 +02:00
|
|
|
|
2021-01-28 15:20:28 +01:00
|
|
|
|
2020-09-28 11:59:13 +02:00
|
|
|
test: all
|
2020-12-01 22:13:09 +01:00
|
|
|
build-asan/btstack_memory_pool_test
|
|
|
|
build-asan/btstack_memory_test
|
2020-11-30 21:35:42 +01:00
|
|
|
|
|
|
|
coverage: all
|
2020-12-01 22:13:09 +01:00
|
|
|
rm -f build-coverage/*.gcda
|
2020-11-30 21:35:42 +01:00
|
|
|
build-coverage/btstack_memory_pool_test
|
2021-01-28 15:20:28 +01:00
|
|
|
build-coverage-none/btstack_memory_test
|
|
|
|
build-coverage-single/btstack_memory_test
|
|
|
|
build-coverage-malloc/btstack_memory_test
|
2020-09-28 11:59:13 +02:00
|
|
|
|
|
|
|
clean:
|
2021-01-28 15:20:28 +01:00
|
|
|
rm -rf build-*
|