From 2f58f679ee6f41c1cc8b0b07de33f2deff2a721f Mon Sep 17 00:00:00 2001 From: david gauchard Date: Mon, 3 Jan 2022 14:23:45 +0100 Subject: [PATCH] Emulation on host: updates (#8409) * mock: +Hash, +scheduled functions Co-authored-by: Max Prokhorov --- tests/host/Makefile | 1 + tests/host/common/Arduino.cpp | 13 +++++++++++-- tests/host/common/ArduinoMain.cpp | 1 + tests/host/common/mock.h | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/host/Makefile b/tests/host/Makefile index a2353a0841..3a5979c312 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -345,6 +345,7 @@ OPT_ARDUINO_LIBS ?= \ DNSServer/src/DNSServer.cpp \ ESP8266AVRISP/src/ESP8266AVRISP.cpp \ ESP8266HTTPClient/src/ESP8266HTTPClient.cpp \ + Hash/src/Hash.cpp \ ) MOCK_ARDUINO_LIBS := \ diff --git a/tests/host/common/Arduino.cpp b/tests/host/common/Arduino.cpp index c2c1fa10a2..1c651e7e1f 100644 --- a/tests/host/common/Arduino.cpp +++ b/tests/host/common/Arduino.cpp @@ -14,10 +14,12 @@ */ #include -#include "Arduino.h" +#include + #include -#include +#include +#include static struct timeval gtod0 = { 0, 0 }; @@ -42,6 +44,13 @@ extern "C" unsigned long micros() extern "C" void yield() { + run_scheduled_recurrent_functions(); +} + +extern "C" void loop_end() +{ + run_scheduled_functions(); + run_scheduled_recurrent_functions(); } extern "C" bool can_yield() diff --git a/tests/host/common/ArduinoMain.cpp b/tests/host/common/ArduinoMain.cpp index 051ca0dbc1..ddda929d46 100644 --- a/tests/host/common/ArduinoMain.cpp +++ b/tests/host/common/ArduinoMain.cpp @@ -308,6 +308,7 @@ int main (int argc, char* const argv []) if (!fast) usleep(1000); // not 100% cpu, ~1000 loops per second loop(); + loop_end(); check_incoming_udp(); if (run_once) diff --git a/tests/host/common/mock.h b/tests/host/common/mock.h index 0194271d9a..56919ee60a 100644 --- a/tests/host/common/mock.h +++ b/tests/host/common/mock.h @@ -116,6 +116,8 @@ extern uint32_t global_source_address; // 0 = INADDR_ANY by default #define NO_GLOBAL_BINDING 0xffffffff extern uint32_t global_ipv4_netfmt; // selected interface addresse to bind to +void loop_end(); + #ifdef __cplusplus } #endif