From ec4690afd10fec8b375d4122b81902e9c9a379a0 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 5 Dec 2023 17:47:34 +0100 Subject: [PATCH] test: fix build --- test/avdtp_util/Makefile | 2 ++ test/gatt-service-client/CMakeLists.txt | 13 ++++++++----- test/gatt_client/CMakeLists.txt | 13 ++++++------- test/gatt_client/mock.c | 23 ++++++----------------- test/gatt_server/CMakeLists.txt | 12 ++++++------ test/gatt_server/Makefile | 3 ++- test/gatt_server/gatt_server_test.cpp | 3 ++- test/gatt_service_server/Makefile | 1 + 8 files changed, 33 insertions(+), 37 deletions(-) diff --git a/test/avdtp_util/Makefile b/test/avdtp_util/Makefile index b7463c32c..65474d68e 100644 --- a/test/avdtp_util/Makefile +++ b/test/avdtp_util/Makefile @@ -8,6 +8,8 @@ LDFLAGS += ${shell pkg-config --libs CppuTest} CFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null CFLAGS += -I${BTSTACK_ROOT}/src +CFLAGS += -I${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include +CFLAGS += -I${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include CFLAGS += -I.. VPATH += ${BTSTACK_ROOT}/src diff --git a/test/gatt-service-client/CMakeLists.txt b/test/gatt-service-client/CMakeLists.txt index a744b6cff..18a89496f 100644 --- a/test/gatt-service-client/CMakeLists.txt +++ b/test/gatt-service-client/CMakeLists.txt @@ -1,11 +1,14 @@ 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 ) +# pkgconfig +find_package(PkgConfig REQUIRED) + +# CppuTest +pkg_check_modules(CPPUTEST REQUIRED CppuTest) +include_directories(${CPPUTEST_INCLUDE_DIRS}) +link_directories(${CPPUTEST_LIBRARY_DIRS}) +link_libraries(${CPPUTEST_LIBRARIES}) # set include paths include_directories(..) diff --git a/test/gatt_client/CMakeLists.txt b/test/gatt_client/CMakeLists.txt index 1794d6b7a..d59e40df6 100644 --- a/test/gatt_client/CMakeLists.txt +++ b/test/gatt_client/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required (VERSION 3.5) project(gatt-client-test) -# fink pkgconfig +# pkgconfig find_package(PkgConfig REQUIRED) -# add CppUTest -include_directories("/usr/local/include") -link_directories("/usr/local/lib") -link_libraries( CppUTest ) -link_libraries( CppUTestExt ) +# CppuTest +pkg_check_modules(CPPUTEST REQUIRED CppuTest) +include_directories(${CPPUTEST_INCLUDE_DIRS}) +link_directories(${CPPUTEST_LIBRARY_DIRS}) +link_libraries(${CPPUTEST_LIBRARIES}) include_directories(.) include_directories(../../src) @@ -27,7 +27,6 @@ set(SOURCES ../../src/btstack_util.c ../../src/hci_cmd.c ../../src/hci_dump.c - ../../src/le-audio/gatt-service/coordinated_set_identification_service_client.c ../../src/btstack_crypto.c ../../3rd-party/rijndael/rijndael.c ) diff --git a/test/gatt_client/mock.c b/test/gatt_client/mock.c index 92f2d0b25..b75626661 100644 --- a/test/gatt_client/mock.c +++ b/test/gatt_client/mock.c @@ -74,6 +74,7 @@ void mock_simulate_scan_response(void){ uint8_t packet[] = {GAP_EVENT_ADVERTISING_REPORT, 0x13, 0xE2, 0x01, 0x34, 0xB1, 0xF7, 0xD1, 0x77, 0x9B, 0xCC, 0x09, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; registered_hci_event_handler(HCI_EVENT_PACKET, 0, (uint8_t *)&packet, sizeof(packet)); } + bool gap_authenticated(hci_con_handle_t con_handle){ UNUSED(con_handle); return false; @@ -266,22 +267,10 @@ void hci_setup_le_connection(uint16_t con_handle){ hci_setup_connection(con_handle, BD_ADDR_TYPE_LE_PUBLIC); } -// int hci_send_cmd(const hci_cmd_t *cmd, ...){ -// // printf("hci_send_cmd opcode 0x%02x\n", cmd->opcode); -// return 0; -// } - -// int hci_can_send_packet_now_using_packet_buffer(uint8_t packet_type){ -// return 1; -// } - -// void hci_disconnect_security_block(hci_con_handle_t con_handle){ -// printf("hci_disconnect_security_block \n"); -// } - -// void hci_dump_log(const char * format, ...){ -// printf("hci_disconnect_security_block \n"); -// } - void l2cap_run(void){ } +#include "btstack_run_loop.h" + +void btstack_run_loop_execute_on_main_thread(btstack_context_callback_registration_t * callback_registration){ + callback_registration->callback(callback_registration->context); +} diff --git a/test/gatt_server/CMakeLists.txt b/test/gatt_server/CMakeLists.txt index 3bcbae66d..44cf1f1b6 100644 --- a/test/gatt_server/CMakeLists.txt +++ b/test/gatt_server/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required (VERSION 3.5) project(gatt_server) -# fink pkgconfig +# pkgconfig find_package(PkgConfig REQUIRED) -# add CppUTest -include_directories("/usr/local/include") -link_directories("/usr/local/lib") -link_libraries( CppUTest ) -link_libraries( CppUTestExt ) +# CppuTest +pkg_check_modules(CPPUTEST REQUIRED CppuTest) +include_directories(${CPPUTEST_INCLUDE_DIRS}) +link_directories(${CPPUTEST_LIBRARY_DIRS}) +link_libraries(${CPPUTEST_LIBRARIES}) include_directories(.) include_directories(../mock/) diff --git a/test/gatt_server/Makefile b/test/gatt_server/Makefile index f4f397fc2..343afabc8 100644 --- a/test/gatt_server/Makefile +++ b/test/gatt_server/Makefile @@ -28,7 +28,8 @@ COMMON = \ att_db.c \ att_db_util.c \ att_server.c \ - battery_service_server.c \ + btstack_hid_parser.c \ + battery_service_server.c \ btstack_crypto.c \ btstack_linked_list.c \ btstack_memory.c \ diff --git a/test/gatt_server/gatt_server_test.cpp b/test/gatt_server/gatt_server_test.cpp index 6984c8eb5..cc6ea59e3 100644 --- a/test/gatt_server/gatt_server_test.cpp +++ b/test/gatt_server/gatt_server_test.cpp @@ -359,6 +359,7 @@ TEST(ATT_SERVER, att_packet_handler_ATT_WRITE_COMMAND_signed_write_confirmation) buffer[0] = SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED; buffer[1] = 18; // H1B1B2 + little_endian_store_16(buffer, 18, 0); mock_call_att_packet_handler(HCI_EVENT_PACKET, 0, &buffer[0], 11); } @@ -542,7 +543,7 @@ TEST(ATT_SERVER, sm_event_identity_resolving_succeeded_event) { uint8_t buffer[20]; buffer[0] = SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED; buffer[1] = 18; // H1B1B2 - + little_endian_store_16(buffer, 18, 0); test_hci_event_encryption_events(att_con_handle, 2, buffer, sizeof(buffer)); } diff --git a/test/gatt_service_server/Makefile b/test/gatt_service_server/Makefile index 37d0b4153..e59d9aeb3 100644 --- a/test/gatt_service_server/Makefile +++ b/test/gatt_service_server/Makefile @@ -24,6 +24,7 @@ VPATH += ${BTSTACK_ROOT}/test/mock COMMON = \ ad_parser.c \ att_db.c \ + btstack_hid_parser.c \ battery_service_server.c \ btstack_linked_list.c \ btstack_memory.c \