mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-24 22:43:35 +00:00
test/embedded: add more tests for embedded run loop
This commit is contained in:
parent
ee02574111
commit
1fba6313b3
@ -9,7 +9,7 @@
|
||||
#define HAVE_BTSTACK_STDIN
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
#define HAVE_POSIX_TIME
|
||||
#define HAVE_EMBEDDED_TIME_MS
|
||||
|
||||
// BTstack features that can be enabled
|
||||
#define ENABLE_BLE
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
#include "hal_cpu.h"
|
||||
#include "hal_time_ms.h"
|
||||
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_run_loop_embedded.h"
|
||||
@ -14,6 +15,10 @@ void hal_cpu_disable_irqs(void){}
|
||||
void hal_cpu_enable_irqs(void){}
|
||||
void hal_cpu_enable_irqs_and_sleep(void){}
|
||||
|
||||
// hal_time_ms_h
|
||||
uint32_t hal_time_ms(void){
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define HEARTBEAT_PERIOD_MS 1000
|
||||
|
||||
@ -32,6 +37,12 @@ static void data_source_handler(btstack_data_source_t * ds, btstack_data_source_
|
||||
data_source_called = true;
|
||||
}
|
||||
|
||||
static void data_source_handler_trigger_exit(btstack_data_source_t * ds, btstack_data_source_callback_type_t callback_type){
|
||||
UNUSED(ds);
|
||||
UNUSED(callback_type);
|
||||
btstack_run_loop_trigger_exit();
|
||||
}
|
||||
|
||||
TEST_GROUP(Embedded){
|
||||
|
||||
void setup(void){
|
||||
@ -57,6 +68,8 @@ TEST(Embedded, Init){
|
||||
btstack_run_loop_timer_dump();
|
||||
btstack_run_loop_remove_timer(&timer_1);
|
||||
(void) btstack_run_loop_get_timer_context(&timer_1);
|
||||
static btstack_context_callback_registration_t callback_registration;
|
||||
btstack_run_loop_execute_on_main_thread(&callback_registration);
|
||||
}
|
||||
|
||||
TEST(Embedded, DataSource){
|
||||
@ -69,6 +82,16 @@ TEST(Embedded, DataSource){
|
||||
btstack_run_loop_remove_data_source(&data_source);
|
||||
}
|
||||
|
||||
TEST(Embedded, ExitRunLoop){
|
||||
btstack_run_loop_set_data_source_handler(&data_source, &data_source_handler_trigger_exit);
|
||||
btstack_run_loop_set_data_source_fd(&data_source, 0);
|
||||
btstack_run_loop_set_data_source_handle(&data_source, NULL);
|
||||
btstack_run_loop_enable_data_source_callbacks(&data_source, DATA_SOURCE_CALLBACK_POLL);
|
||||
btstack_run_loop_add_data_source(&data_source);
|
||||
btstack_run_loop_execute();
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
return CommandLineTestRunner::RunAllTests(argc, argv);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user