diff --git a/test/Makefile b/test/Makefile index 23f2a51ac..2fe9d3060 100644 --- a/test/Makefile +++ b/test/Makefile @@ -29,6 +29,7 @@ SUBDIRS = \ sdp_client \ security_manager \ tlv_posix \ + embedded \ # not testing anything in source tree # maths \ @@ -55,7 +56,7 @@ SUBDIRS_BLE = \ ring_buffer \ gatt_server \ security_manager \ - + embedded \ # test fails # not unit-tests diff --git a/test/embedded/Makefile b/test/embedded/Makefile index 9e924c845..7e9f2895c 100644 --- a/test/embedded/Makefile +++ b/test/embedded/Makefile @@ -6,7 +6,6 @@ BTSTACK_ROOT = ../.. CFLAGS = -g -Wall \ -I. \ - -I.. \ -I${BTSTACK_ROOT}/src \ -I${BTSTACK_ROOT}/platform/embedded @@ -23,6 +22,7 @@ VPATH += ${BTSTACK_ROOT}/platform/freertos COMMON = \ btstack_em9304_spi_embedded.c \ + btstack_memory.c \ btstack_run_loop.c \ btstack_run_loop_embedded.c \ btstack_stdin_embedded.c \ diff --git a/test/embedded/btstack_config.h b/test/embedded/btstack_config.h new file mode 100644 index 000000000..82222fcc3 --- /dev/null +++ b/test/embedded/btstack_config.h @@ -0,0 +1,30 @@ +// +// btstack_config.h for most tests +// + +#ifndef BTSTACK_CONFIG_H +#define BTSTACK_CONFIG_H + +// 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/embedded/embedded_test.c b/test/embedded/embedded_test.c index cf32fb931..dd0b2b1c7 100644 --- a/test/embedded/embedded_test.c +++ b/test/embedded/embedded_test.c @@ -23,6 +23,9 @@ #include "hal_time_ms.h" #include "hal_uart_dma.h" +#include "btstack_run_loop.h" +#include "btstack_run_loop_embedded.h" +#include "btstack_memory.h" // quick mock // hal_cpu @@ -73,11 +76,37 @@ void hal_audio_source_start(void){} void hal_audio_source_stop(void){} void hal_audio_source_close(void){} + +#define HEARTBEAT_PERIOD_MS 1000 + +static btstack_timer_source_t heartbeat; + +static void heartbeat_timeout_handler(btstack_timer_source_t * timer){ + UNUSED(timer); +} + TEST_GROUP(Embedded){ + void setup(void){ + // start with BTstack init - especially configure HCI Transport + btstack_memory_init(); + btstack_run_loop_init(btstack_run_loop_embedded_get_instance()); + btstack_run_loop_set_timer_handler(&heartbeat, heartbeat_timeout_handler); } }; +TEST(Embedded, Init){ + btstack_run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS); + btstack_run_loop_add_timer(&heartbeat); + + btstack_run_loop_embedded_execute_once(); + btstack_run_loop_embedded_trigger(); + btstack_run_loop_embedded_execute_once(); + btstack_run_loop_get_time_ms(); + + btstack_run_loop_remove_timer(&heartbeat); +} + int main (int argc, const char * argv[]){ return CommandLineTestRunner::RunAllTests(argc, argv); }