Skip to content

Commit 516e2db

Browse files
committed
test/embedded: draft test
1 parent defbf20 commit 516e2db

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

test/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ SUBDIRS = \
2929
sdp_client \
3030
security_manager \
3131
tlv_posix \
32+
embedded \
3233

3334
# not testing anything in source tree
3435
# maths \
@@ -55,7 +56,7 @@ SUBDIRS_BLE = \
5556
ring_buffer \
5657
gatt_server \
5758
security_manager \
58-
59+
embedded \
5960
# test fails
6061

6162
# not unit-tests

test/embedded/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ BTSTACK_ROOT = ../..
66

77
CFLAGS = -g -Wall \
88
-I. \
9-
-I.. \
109
-I${BTSTACK_ROOT}/src \
1110
-I${BTSTACK_ROOT}/platform/embedded
1211

@@ -23,6 +22,7 @@ VPATH += ${BTSTACK_ROOT}/platform/freertos
2322

2423
COMMON = \
2524
btstack_em9304_spi_embedded.c \
25+
btstack_memory.c \
2626
btstack_run_loop.c \
2727
btstack_run_loop_embedded.c \
2828
btstack_stdin_embedded.c \

test/embedded/btstack_config.h

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// btstack_config.h for most tests
3+
//
4+
5+
#ifndef BTSTACK_CONFIG_H
6+
#define BTSTACK_CONFIG_H
7+
8+
// Port related features
9+
#define HAVE_MALLOC
10+
#define HAVE_ASSERT
11+
#define HAVE_POSIX_TIME
12+
#define HAVE_POSIX_FILE_IO
13+
#define HAVE_BTSTACK_STDIN
14+
15+
// BTstack features that can be enabled
16+
#define ENABLE_BLE
17+
#define ENABLE_LOG_ERROR
18+
#define ENABLE_LOG_INFO
19+
#define ENABLE_LE_SIGNED_WRITE
20+
#define ENABLE_LE_PERIPHERAL
21+
#define ENABLE_LE_CENTRAL
22+
#define ENABLE_SOFTWARE_AES128
23+
24+
// BTstack configuration. buffers, sizes, ...
25+
#define HCI_ACL_PAYLOAD_SIZE 1024
26+
#define HCI_INCOMING_PRE_BUFFER_SIZE 6
27+
#define NVM_NUM_LINK_KEYS 2
28+
#define NVM_NUM_DEVICE_DB_ENTRIES 4
29+
30+
#endif

test/embedded/embedded_test.c

+29
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "hal_time_ms.h"
2424
#include "hal_uart_dma.h"
2525

26+
#include "btstack_run_loop.h"
27+
#include "btstack_run_loop_embedded.h"
28+
#include "btstack_memory.h"
2629
// quick mock
2730

2831
// hal_cpu
@@ -73,11 +76,37 @@ void hal_audio_source_start(void){}
7376
void hal_audio_source_stop(void){}
7477
void hal_audio_source_close(void){}
7578

79+
80+
#define HEARTBEAT_PERIOD_MS 1000
81+
82+
static btstack_timer_source_t heartbeat;
83+
84+
static void heartbeat_timeout_handler(btstack_timer_source_t * timer){
85+
UNUSED(timer);
86+
}
87+
7688
TEST_GROUP(Embedded){
89+
7790
void setup(void){
91+
// start with BTstack init - especially configure HCI Transport
92+
btstack_memory_init();
93+
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
94+
btstack_run_loop_set_timer_handler(&heartbeat, heartbeat_timeout_handler);
7895
}
7996
};
8097

98+
TEST(Embedded, Init){
99+
btstack_run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
100+
btstack_run_loop_add_timer(&heartbeat);
101+
102+
btstack_run_loop_embedded_execute_once();
103+
btstack_run_loop_embedded_trigger();
104+
btstack_run_loop_embedded_execute_once();
105+
btstack_run_loop_get_time_ms();
106+
107+
btstack_run_loop_remove_timer(&heartbeat);
108+
}
109+
81110
int main (int argc, const char * argv[]){
82111
return CommandLineTestRunner::RunAllTests(argc, argv);
83112
}

0 commit comments

Comments
 (0)