hci_dump: enable packet logger in tests

This commit is contained in:
Matthias Ringwald 2021-03-10 14:50:44 +01:00
parent 22dc82503e
commit 31437b5204
16 changed files with 81 additions and 24 deletions

View File

@ -208,8 +208,6 @@ int main(int argc, const char * argv[]){
hci_transport_usb_set_path(usb_path_len, usb_path);
}
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
char pklg_path[100];
strcpy(pklg_path, "/tmp/hci_dump");
if (usb_path_len){
@ -218,7 +216,7 @@ int main(int argc, const char * argv[]){
}
strcat(pklg_path, ".pklg");
printf("Packet Log: %s\n", pklg_path);
// hci_dump_open(pklg_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(pklg_path, hci_dump_posix);
// init HCI
hci_init(hci_transport_usb_instance(), NULL);

View File

@ -8,12 +8,14 @@ COMMON = \
btstack_util.c \
hal_flash_bank_memory.c \
hci_dump.c \
hci_dump_posix_fs.c \
VPATH = \
${BTSTACK_ROOT}/src \
${BTSTACK_ROOT}/src/classic \
${BTSTACK_ROOT}/src/ble \
${BTSTACK_ROOT}/platform/embedded \
${BTSTACK_ROOT}/platform/posix \
CFLAGS = \
-DBTSTACK_TEST \
@ -25,6 +27,7 @@ CFLAGS = \
-I.. \
-I${BTSTACK_ROOT}/src \
-I${BTSTACK_ROOT}/platform/embedded \
-I${BTSTACK_ROOT}/platform/posix \
CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
CFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT

View File

@ -7,6 +7,7 @@
#include "btstack_tlv.h"
#include "btstack_tlv_flash_bank.h"
#include "hci_dump.h"
#include "hci_dump_posix_fs.h"
#include "classic/btstack_link_key_db.h"
#include "classic/btstack_link_key_db_tlv.h"
#include "btstack_util.h"
@ -327,6 +328,11 @@ TEST(LINK_KEY_DB, KeyReplacement){
}
int main (int argc, const char * argv[]){
// hci_dump_open("tlv_test.pklg", HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * pklg_path = "hci_dump.pklg";
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", pklg_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -4,7 +4,7 @@ CC = g++
BTSTACK_ROOT = ../..
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null -I. -I${BTSTACK_ROOT}/src
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/platform/posix
CFLAGS += -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
VPATH += ${BTSTACK_ROOT}/src
@ -21,6 +21,7 @@ COMMON = \
hci.c \
hci_cmd.c \
hci_dump.c \
hci_dump_posix_fs.c \
le_device_db_memory.c \
CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage

View File

@ -14,6 +14,7 @@
#include "ble/gatt_client.h"
#include "btstack_event.h"
#include "hci_dump.h"
#include "hci_dump_posix_fs.h"
#include "btstack_debug.h"
typedef struct {
@ -132,8 +133,11 @@ TEST(GAP_LE, ScanStartParam){
}
int main (int argc, const char * argv[]){
const char * log_path = "/tmp/test_scan.pklg";
printf("Log: %s\n", log_path);
// hci_dump_open(log_path, HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * pklg_path = "hci_dump.pklg";
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", pklg_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -7,13 +7,14 @@ BTSTACK_ROOT = ../..
CPPFLAGS = -x c++ -Wall -Wno-unused
CFLAGS = -DUNIT_TEST -g
CFLAGS += -I. -I${BTSTACK_ROOT}/src
VPATH += ${BTSTACK_ROOT}/src
CFLAGS += -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/src ${BTSTACK_ROOT}/platform/posix
COMMON = \
btstack_util.c \
btstack_hid_parser.c \
hci_dump.c
hci_dump.c \
hci_dump_posix_fs.c \
CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
CFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT

View File

@ -15,6 +15,7 @@
#include "CppUTest/CommandLineTestRunner.h"
#include "btstack_hid_parser.h"
#include "hci_dump_posix_fs.h"
const uint8_t mouse_descriptor_without_report_id[] = {
0x05, 0x01, /* Usage Page (Desktop), */
@ -345,6 +346,11 @@ TEST(HID, GetReportSize){
int main (int argc, const char * argv[]){
// hci_dump_open("hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * pklg_path = "hci_dump.pklg";
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", pklg_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -24,7 +24,7 @@ CORE += \
l2cap.c \
uECC.c \
rijndael.c \
hci_dump_posix_fs.c \
# examples
@ -112,13 +112,13 @@ build-asan/sniffer: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${SM_OBJ
${CC} $^ ${LDFLAGS_ASAN} -o $@
build-asan/mesh_message_test: $(addprefix build-asan/, mesh_message_test.o mesh_foundation.o mesh_node.o mesh_iv_index_seq_number.o mesh_network.o mesh_peer.o mesh_lower_transport.o mesh_upper_transport.o mesh_virtual_addresses.o mesh_keys.o mesh_crypto.o btstack_memory.o btstack_memory_pool.o btstack_util.o btstack_crypto.o btstack_linked_list.o hci_dump.o uECC.o mock.o rijndael.o hci_cmd.o) | build-asan
build-asan/mesh_message_test: $(addprefix build-asan/, mesh_message_test.o mesh_foundation.o mesh_node.o mesh_iv_index_seq_number.o mesh_network.o mesh_peer.o mesh_lower_transport.o mesh_upper_transport.o mesh_virtual_addresses.o mesh_keys.o mesh_crypto.o btstack_memory.o btstack_memory_pool.o btstack_util.o btstack_crypto.o btstack_linked_list.o hci_dump.o uECC.o mock.o rijndael.o hci_cmd.o hci_dump_posix_fs.o) | build-asan
g++ $^ ${CFLAGS} ${LDFLAGS_ASAN} -o $@
build-asan/provisioning_device_test: $(addprefix build-asan/, provisioning_device_test.o uECC.o mesh_crypto.o provisioning_device.o btstack_crypto.o btstack_util.o btstack_linked_list.o mesh_node.o mock.o rijndael.o hci_cmd.o hci_dump.o) | build-asan
build-asan/provisioning_device_test: $(addprefix build-asan/, provisioning_device_test.o uECC.o mesh_crypto.o provisioning_device.o btstack_crypto.o btstack_util.o btstack_linked_list.o mesh_node.o mock.o rijndael.o hci_cmd.o hci_dump.o hci_dump_posix_fs.o) | build-asan
${CC_UNIT} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@
build-asan/provisioning_provisioner_test: $(addprefix build-asan/, provisioning_provisioner_test.o uECC.o mesh_crypto.o provisioning_provisioner.o btstack_crypto.o btstack_util.o btstack_linked_list.o mock.o rijndael.o hci_cmd.o hci_dump.o) | build-asan
build-asan/provisioning_provisioner_test: $(addprefix build-asan/, provisioning_provisioner_test.o uECC.o mesh_crypto.o provisioning_provisioner.o btstack_crypto.o btstack_util.o btstack_linked_list.o mock.o rijndael.o hci_cmd.o hci_dump.o hci_dump_posix_fs.o) | build-asan
${CC_UNIT} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@
build-asan/mesh_configuration_composition_data_message_test: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${MESH_OBJ_ASAN} build-asan/mesh_configuration_composition_data_message_test.o | build-asan

View File

@ -60,6 +60,7 @@
#include "bluetooth_company_id.h"
#include "hci.h"
#include "hci_dump.h"
#include "hci_dump_posix_fs.h"
#include "btstack_stdin.h"
#include "btstack_tlv.h"
#include "btstack_tlv_posix.h"
@ -205,8 +206,10 @@ int main(int argc, const char * argv[]){
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
strcat(log_path, ".pklg");
// log into file using HCI_DUMP_PACKETLOGGER format
hci_dump_posix_fs_open(log_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", log_path);
// hci_dump_open(log_path, HCI_DUMP_PACKETLOGGER);
// init HCI
const hci_transport_t * transport;

View File

@ -40,6 +40,7 @@
#include "btstack_memory.h"
#include "ble/gatt-service/mesh_provisioning_service_server.h"
#include "hci_dump.h"
#include "hci_dump_posix_fs.h"
#include "mesh/mesh_node.h"
#include "mesh/pb_adv.h"
#include "mesh/pb_gatt.h"
@ -246,6 +247,11 @@ TEST(Provisioning, Prov1){
}
int main (int argc, const char * argv[]){
hci_dump_open("hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * log_path = "hci_dump.pklg";
hci_dump_posix_fs_open(log_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", log_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -45,6 +45,7 @@
#include "mesh/provisioning.h"
#include "mesh/provisioning_provisioner.h"
#include "hci_dump.h"
#include "hci_dump_posix_fs.h"
#include "mock.h"
#include "CppUTest/TestHarness.h"
@ -255,6 +256,11 @@ TEST(Provisioning, Prov1){
}
int main (int argc, const char * argv[]){
hci_dump_open("hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * log_path = "hci_dump.pklg";
hci_dump_posix_fs_open(log_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", log_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -21,6 +21,7 @@ COMMON += \
ad_parser.c \
hci_cmd.c \
hci_dump.c \
hci_dump_posix_fs.c \
l2cap.c \
l2cap_signaling.c \
rfcomm.c \

View File

@ -8,6 +8,7 @@ CFLAGS = -DUNIT_TEST -g
CFLAGS += -Wall -Wno-unused
CFLAGS += -I. -I.. -I${BTSTACK_ROOT}/src
CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
CFLAGS += -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
@ -16,7 +17,7 @@ LDFLAGS += -lCppUTest -lCppUTestExt
VPATH += ${BTSTACK_ROOT}/src
VPATH += ${BTSTACK_ROOT}/src/ble
VPATH += ${BTSTACK_ROOT}/platform/embedded
# VPATH += ${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
@ -29,6 +30,7 @@ COMMON = \
btstack_run_loop_embedded.c \
hci_cmd.c \
hci_dump.c \
hci_dump_posix_fs.c \
le_device_db_memory.c \
mock.c \
rijndael.c \

View File

@ -22,6 +22,7 @@
#include "btstack_memory.h"
#include "hci.h"
#include "hci_dump.h"
#include "hci_dump_posix_fs.h"
#include "l2cap.h"
#include "ble/sm.h"
@ -223,7 +224,13 @@ TEST_GROUP(SecurityManager){
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
sm_event_callback_registration.callback = &app_packet_handler;
sm_add_event_handler(&sm_event_callback_registration);
// hci_dump_open("security_manager.pklg", HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * log_path = "hci_dump.pklg";
hci_dump_posix_fs_open(log_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", log_path);
}
};
@ -404,6 +411,11 @@ TEST(SecurityManager, MainTest){
}
int main (int argc, const char * argv[]){
// hci_dump_open("hci_dump.pklg", HCI_DUMP_STDOUT); // HCI_DUMP_PACKETLOGGER
// log into file using HCI_DUMP_PACKETLOGGER format
const char * log_path = "hci_dump.pklg";
hci_dump_posix_fs_open(log_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", log_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}

View File

@ -217,8 +217,11 @@ int main(int argc, const char * argv[]){
strcat(pklg_path, usb_path_string);
}
strcat(pklg_path, ".pklg");
// log into file using HCI_DUMP_PACKETLOGGER format
hci_dump_posix_fs_open(pklg_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", pklg_path);
// hci_dump_open(pklg_path, HCI_DUMP_PACKETLOGGER);
// init HCI
hci_init(hci_transport_usb_instance(), NULL);

View File

@ -185,6 +185,11 @@ TEST(BSTACK_TLV, TestWriteDeleteResetReadDeleteRead){
int main (int argc, const char * argv[]){
// hci_dump_open("tlv_test.pklg", HCI_DUMP_PACKETLOGGER);
// log into file using HCI_DUMP_PACKETLOGGER format
const char * log_path = "hci_dump.pklg";
hci_dump_posix_fs_open(log_path, HCI_DUMP_PACKETLOGGER);
hci_dump_init(hci_dump_posix_fs_get_instance());
printf("Packet Log: %s\n", log_path);
return CommandLineTestRunner::RunAllTests(argc, argv);
}