test/security_manager: adapt test for queued sm_run callbacks

This commit is contained in:
Matthias Ringwald 2020-09-16 10:24:43 +02:00
parent 54eca18e6f
commit 90fe6d5fb1
4 changed files with 25 additions and 7 deletions

View File

@ -6,16 +6,19 @@ BTSTACK_ROOT = ../..
CFLAGS = -DUNIT_TEST -g
CPPFLAGS = -x c++ -Wall -Wno-unused
CFLAGS += -I. -I.. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/platform/posix
CFLAGS += -I. -I.. -I${BTSTACK_ROOT}/src
#CFLAGS += -I${BTSTACK_ROOT}/platform/posix
CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
CFLAGS += -I${BTSTACK_ROOT}/3rd-party/mbedtls/include
CFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
CFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
CFLAGS += -fprofile-arcs -ftest-coverage -fsanitize=address,undefined
# CFLAGS += -fprofile-arcs -ftest-coverage -fsanitize=address,undefined
LDFLAGS += -lCppUTest -lCppUTestExt
VPATH += ${BTSTACK_ROOT}/src
VPATH += ${BTSTACK_ROOT}/src/ble
VPATH += ${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/platform/embedded
# VPATH += ${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
@ -25,7 +28,7 @@ COMMON = \
btstack_memory.c \
btstack_memory_pool.c \
btstack_run_loop.c \
btstack_run_loop_posix.c \
btstack_run_loop_embedded.c \
hci_cmd.c \
hci_dump.c \
le_device_db_memory.c \

View File

@ -7,7 +7,7 @@
// Port related features
#define HAVE_MALLOC
#define HAVE_POSIX_TIME
#define HAVE_EMBEDDED_TIME_MS
#define HAVE_POSIX_FILE_IO
#define HAVE_BTSTACK_STDIN

View File

@ -9,6 +9,7 @@
#include "l2cap.h"
#include "rijndael.h"
#include "btstack_linked_list.h"
#include "btstack_run_loop_embedded.h"
static btstack_packet_handler_t le_data_handler;
@ -97,6 +98,9 @@ void mock_simulate_sm_data_packet(uint8_t * packet, uint16_t len){
hci_dump_packet(HCI_ACL_DATA_PACKET, 1, &acl_buffer[0], len + 8);
le_data_handler(SM_DATA_PACKET, handle, packet, len);
// process queued callbacks, might become obsolete after queued callback integration in run loop
btstack_run_loop_embedded_execute_once();
}
void mock_simulate_command_complete(const hci_cmd_t *cmd){
@ -264,3 +268,14 @@ void l2cap_run(void){
HCI_STATE hci_get_state(void){
return HCI_STATE_WORKING;
}
#include "hal_cpu.h"
void hal_cpu_disable_irqs(void){}
void hal_cpu_enable_irqs(void){}
void hal_cpu_enable_irqs_and_sleep(void){}
#include "hal_time_ms.h"
static uint32_t time_ms;
uint32_t hal_time_ms(void){
return time_ms++;
}

View File

@ -14,7 +14,7 @@
#include "CppUTest/TestHarness.h"
#include "CppUTest/CommandLineTestRunner.h"
#include "btstack_run_loop_posix.h"
#include "btstack_run_loop_embedded.h"
#include "hci_cmd.h"
#include "btstack_util.h"
@ -244,7 +244,7 @@ TEST_GROUP(SecurityManager){
if (first){
first = 0;
btstack_memory_init();
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
}
sm_init();
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);