From f400efd4c34c2c3d094122d9c99ddcc5357e2a2e Mon Sep 17 00:00:00 2001 From: Matthias Ringwald <matthias@ringwald.ch> Date: Mon, 31 Aug 2020 13:56:51 +0200 Subject: [PATCH] test/coverage: avoid compiling classic parts for LE-only coverage --- test/Makefile | 62 ++++++++++++++++++++++---------- test/att_db/btstack_config.h | 7 ---- test/ble_client/Makefile | 2 +- test/ble_client/btstack_config.h | 30 ++++++++++++++++ test/coverage_subset_bat.py | 1 + test/crypto/Makefile | 2 +- test/crypto/btstack_config.h | 30 ++++++++++++++++ test/gap/Makefile | 2 +- test/gap/btstack_config.h | 30 ++++++++++++++++ test/hid_parser/Makefile | 2 +- test/hid_parser/btstack_config.h | 30 ++++++++++++++++ 11 files changed, 169 insertions(+), 29 deletions(-) create mode 100644 test/ble_client/btstack_config.h create mode 100644 test/crypto/btstack_config.h create mode 100644 test/gap/btstack_config.h create mode 100644 test/hid_parser/btstack_config.h diff --git a/test/Makefile b/test/Makefile index ff2269cb5..a9d6782e8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -26,10 +26,24 @@ SUBDIRS = \ sdp_client \ security_manager \ tlv_posix \ - # not testing anything in source tree # maths \ +# flash_tlv also contains btstack_linked_key_db tests + +SUBDIRS_BLE = \ + att_db \ + ble_client \ + crypto \ + gatt_client \ + gatt_server \ + gap \ + hid_parser \ + linked_list \ + ring_buffer \ + security_manager \ +# tlv_posix \ + # test fails # not unit-tests @@ -59,31 +73,43 @@ test: $(MAKE) -C $$dir test; \ done -test-coverage: +test-ble: + echo Run all BLE tests + @set -e; \ + for dir in $(SUBDIRS_BLE); do \ + $(MAKE) -C $$dir test; \ + done + +test-coverage-ble: subdirs # delete trace data - rm -f coverage.info find . -name "*.gcda" -type f -delete - # collect all files - # lcov --capture --initial --directory . --output-file coverage.info # run tests - make test + $(MAKE) test-ble + # collect traces + lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-unit-ble.info + +test-coverage: subdirs + # delete trace data + find . -name "*.gcda" -type f -delete + # run tests + $(MAKE) test # collect traces lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-unit.info -coverage: test-coverage +coverage: test-coverage test-coverage-ble # download pts coverage and fix paths - curl https://bluekitchen-gmbh.com/btstack/develop/coverage-pts.info | sed -e 's|/Users/mringwal/buildbot-worker/auto-pts/btstack|/root/buildbot-worker/test-develop/build|' > coverage-pts.info + curl https://bluekitchen-gmbh.com/btstack/develop/coverage-pts.info | sed -e 's|/Users/mringwal/buildbot-worker/auto-pts/btstack|/root/buildbot-worker/test-develop/build|' > coverage-pts.info - # combine unit and pts - lcov --rc lcov_branch_coverage=1 -a coverage-pts.info -a coverage-unit.info --output-file coverage.info + # combine unit[-ble] and pts + lcov --rc lcov_branch_coverage=1 -a coverage-pts.info -a coverage-unit.info --output-file coverage.info + lcov --rc lcov_branch_coverage=1 -a coverage-pts.info -a coverage-unit-ble.info --output-file coverage-ble.info - # create bat subset - ./coverage_subset_bat.py coverage.info coverage-bat.info + # create bat subset from ble subset + ./coverage_subset_bat.py coverage-ble.info coverage-bat.info + ./coverage_subset_bat.py coverage-unit-ble.info coverage-unit-bat.info # generate html output - genhtml coverage-unit.info --branch-coverage --output-directory coverage-unit - genhtml coverage-bat.info --branch-coverage --output-directory coverage-bat - genhtml coverage.info --branch-coverage --output-directory coverage - -coverage-freertos-ble: - ./coverage_filter.py src/mesh src/classic + genhtml coverage-unit.info --branch-coverage --output-directory coverage-unit + genhtml coverage-unit-bat.info --branch-coverage --output-directory coverage-unit-bat + genhtml coverage-bat.info --branch-coverage --output-directory coverage-bat + genhtml coverage.info --branch-coverage --output-directory coverage diff --git a/test/att_db/btstack_config.h b/test/att_db/btstack_config.h index 7e25fee2f..e881e8ca5 100644 --- a/test/att_db/btstack_config.h +++ b/test/att_db/btstack_config.h @@ -14,18 +14,11 @@ // BTstack features that can be enabled #define ENABLE_BLE -#define ENABLE_CLASSIC -// #define ENABLE_LOG_DEBUG #define ENABLE_LOG_ERROR #define ENABLE_LOG_INFO -#define ENABLE_SDP_DES_DUMP -#define ENABLE_SDP_EXTRA_QUERIES -// #define ENABLE_LE_SECURE_CONNECTIONS #define ENABLE_LE_SIGNED_WRITE #define ENABLE_LE_PERIPHERAL #define ENABLE_LE_CENTRAL -#define ENABLE_SDP_EXTRA_QUERIES -#define ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE #define ENABLE_SOFTWARE_AES128 // BTstack configuration. buffers, sizes, ... diff --git a/test/ble_client/Makefile b/test/ble_client/Makefile index 0c6a80cac..a3e5bb5d1 100644 --- a/test/ble_client/Makefile +++ b/test/ble_client/Makefile @@ -4,7 +4,7 @@ CC = g++ BTSTACK_ROOT = ../.. -CFLAGS = -g -Wall -I.. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include +CFLAGS = -g -Wall -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include CFLAGS += -fprofile-arcs -ftest-coverage LDFLAGS += -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt diff --git a/test/ble_client/btstack_config.h b/test/ble_client/btstack_config.h new file mode 100644 index 000000000..e881e8ca5 --- /dev/null +++ b/test/ble_client/btstack_config.h @@ -0,0 +1,30 @@ +// +// btstack_config.h for most tests +// + +#ifndef __BTSTACK_CONFIG +#define __BTSTACK_CONFIG + +// Port related features +#define HAVE_MALLOC +#define HAVE_ASSERT +#define HAVE_POSIX_TIME +#define HAVE_POSIX_FILE_IO +#define HAVE_BTSTACK_STDIN + +// BTstack features that can be enabled +#define ENABLE_BLE +#define ENABLE_LOG_ERROR +#define ENABLE_LOG_INFO +#define ENABLE_LE_SIGNED_WRITE +#define ENABLE_LE_PERIPHERAL +#define ENABLE_LE_CENTRAL +#define ENABLE_SOFTWARE_AES128 + +// BTstack configuration. buffers, sizes, ... +#define HCI_ACL_PAYLOAD_SIZE 1024 +#define HCI_INCOMING_PRE_BUFFER_SIZE 6 +#define NVM_NUM_LINK_KEYS 2 +#define NVM_NUM_DEVICE_DB_ENTRIES 4 + +#endif diff --git a/test/coverage_subset_bat.py b/test/coverage_subset_bat.py index eaa632a8d..4258fb518 100755 --- a/test/coverage_subset_bat.py +++ b/test/coverage_subset_bat.py @@ -15,6 +15,7 @@ blacklist = [ 'platform/embedded/btstack_em9304_spi_embedded.c', 'platform/libusb', 'platform/posix', + 'port/libusb', 'src/ble/ancs_client.c', 'src/ble/le_device_db_memory.c', 'src/ble/gatt-service/cycling_power_service_server.c', diff --git a/test/crypto/Makefile b/test/crypto/Makefile index 3130fd33a..80346942f 100644 --- a/test/crypto/Makefile +++ b/test/crypto/Makefile @@ -6,7 +6,7 @@ BTSTACK_ROOT = ../.. CFLAGS = -DUNIT_TEST -g CPPFLAGS = -x c++ -Wall -Wno-unused -fno-exceptions -CFLAGS += -I. -I.. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/platform/posix +CFLAGS += -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/platform/posix CFLAGS += -I${BTSTACK_ROOT}/3rd-party/mbedtls/include CFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc CFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael diff --git a/test/crypto/btstack_config.h b/test/crypto/btstack_config.h new file mode 100644 index 000000000..e881e8ca5 --- /dev/null +++ b/test/crypto/btstack_config.h @@ -0,0 +1,30 @@ +// +// btstack_config.h for most tests +// + +#ifndef __BTSTACK_CONFIG +#define __BTSTACK_CONFIG + +// Port related features +#define HAVE_MALLOC +#define HAVE_ASSERT +#define HAVE_POSIX_TIME +#define HAVE_POSIX_FILE_IO +#define HAVE_BTSTACK_STDIN + +// BTstack features that can be enabled +#define ENABLE_BLE +#define ENABLE_LOG_ERROR +#define ENABLE_LOG_INFO +#define ENABLE_LE_SIGNED_WRITE +#define ENABLE_LE_PERIPHERAL +#define ENABLE_LE_CENTRAL +#define ENABLE_SOFTWARE_AES128 + +// BTstack configuration. buffers, sizes, ... +#define HCI_ACL_PAYLOAD_SIZE 1024 +#define HCI_INCOMING_PRE_BUFFER_SIZE 6 +#define NVM_NUM_LINK_KEYS 2 +#define NVM_NUM_DEVICE_DB_ENTRIES 4 + +#endif diff --git a/test/gap/Makefile b/test/gap/Makefile index 6c0cb4dba..ee0e3417d 100644 --- a/test/gap/Makefile +++ b/test/gap/Makefile @@ -4,7 +4,7 @@ CC = g++ BTSTACK_ROOT = ../.. -CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null -I. -I../ -I${BTSTACK_ROOT}/src +CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null -I. -I${BTSTACK_ROOT}/src CFLAGS += -fsanitize=address CFLAGS += -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION CFLAGS += -fprofile-arcs -ftest-coverage diff --git a/test/gap/btstack_config.h b/test/gap/btstack_config.h new file mode 100644 index 000000000..e881e8ca5 --- /dev/null +++ b/test/gap/btstack_config.h @@ -0,0 +1,30 @@ +// +// btstack_config.h for most tests +// + +#ifndef __BTSTACK_CONFIG +#define __BTSTACK_CONFIG + +// Port related features +#define HAVE_MALLOC +#define HAVE_ASSERT +#define HAVE_POSIX_TIME +#define HAVE_POSIX_FILE_IO +#define HAVE_BTSTACK_STDIN + +// BTstack features that can be enabled +#define ENABLE_BLE +#define ENABLE_LOG_ERROR +#define ENABLE_LOG_INFO +#define ENABLE_LE_SIGNED_WRITE +#define ENABLE_LE_PERIPHERAL +#define ENABLE_LE_CENTRAL +#define ENABLE_SOFTWARE_AES128 + +// BTstack configuration. buffers, sizes, ... +#define HCI_ACL_PAYLOAD_SIZE 1024 +#define HCI_INCOMING_PRE_BUFFER_SIZE 6 +#define NVM_NUM_LINK_KEYS 2 +#define NVM_NUM_DEVICE_DB_ENTRIES 4 + +#endif diff --git a/test/hid_parser/Makefile b/test/hid_parser/Makefile index 7da8f3dfa..b5b5aeac8 100644 --- a/test/hid_parser/Makefile +++ b/test/hid_parser/Makefile @@ -7,7 +7,7 @@ BTSTACK_ROOT = ../.. CPPFLAGS = -x c++ -Wall -Wno-unused CFLAGS = -DUNIT_TEST -g -CFLAGS += -I. -I.. -I${BTSTACK_ROOT}/src +CFLAGS += -I. -I${BTSTACK_ROOT}/src CFLAGS += -fprofile-arcs -ftest-coverage -fsanitize=address,undefined LDFLAGS += -lCppUTest -lCppUTestExt VPATH += ${BTSTACK_ROOT}/src diff --git a/test/hid_parser/btstack_config.h b/test/hid_parser/btstack_config.h new file mode 100644 index 000000000..e881e8ca5 --- /dev/null +++ b/test/hid_parser/btstack_config.h @@ -0,0 +1,30 @@ +// +// btstack_config.h for most tests +// + +#ifndef __BTSTACK_CONFIG +#define __BTSTACK_CONFIG + +// Port related features +#define HAVE_MALLOC +#define HAVE_ASSERT +#define HAVE_POSIX_TIME +#define HAVE_POSIX_FILE_IO +#define HAVE_BTSTACK_STDIN + +// BTstack features that can be enabled +#define ENABLE_BLE +#define ENABLE_LOG_ERROR +#define ENABLE_LOG_INFO +#define ENABLE_LE_SIGNED_WRITE +#define ENABLE_LE_PERIPHERAL +#define ENABLE_LE_CENTRAL +#define ENABLE_SOFTWARE_AES128 + +// BTstack configuration. buffers, sizes, ... +#define HCI_ACL_PAYLOAD_SIZE 1024 +#define HCI_INCOMING_PRE_BUFFER_SIZE 6 +#define NVM_NUM_LINK_KEYS 2 +#define NVM_NUM_DEVICE_DB_ENTRIES 4 + +#endif