Skip to content

Commit 2f58f67

Browse files
authored
Emulation on host: updates (#8409)
* mock: +Hash, +scheduled functions Co-authored-by: Max Prokhorov <[email protected]>
1 parent d0cc3a8 commit 2f58f67

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

tests/host/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ OPT_ARDUINO_LIBS ?= \
345345
DNSServer/src/DNSServer.cpp \
346346
ESP8266AVRISP/src/ESP8266AVRISP.cpp \
347347
ESP8266HTTPClient/src/ESP8266HTTPClient.cpp \
348+
Hash/src/Hash.cpp \
348349
)
349350

350351
MOCK_ARDUINO_LIBS := \

tests/host/common/Arduino.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
*/
1515

1616
#include <sys/time.h>
17-
#include "Arduino.h"
17+
#include <unistd.h>
18+
1819
#include <functional>
1920

20-
#include <unistd.h>
21+
#include <Arduino.h>
22+
#include <Schedule.h>
2123

2224
static struct timeval gtod0 = { 0, 0 };
2325

@@ -42,6 +44,13 @@ extern "C" unsigned long micros()
4244

4345
extern "C" void yield()
4446
{
47+
run_scheduled_recurrent_functions();
48+
}
49+
50+
extern "C" void loop_end()
51+
{
52+
run_scheduled_functions();
53+
run_scheduled_recurrent_functions();
4554
}
4655

4756
extern "C" bool can_yield()

tests/host/common/ArduinoMain.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ int main (int argc, char* const argv [])
308308
if (!fast)
309309
usleep(1000); // not 100% cpu, ~1000 loops per second
310310
loop();
311+
loop_end();
311312
check_incoming_udp();
312313

313314
if (run_once)

tests/host/common/mock.h

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ extern uint32_t global_source_address; // 0 = INADDR_ANY by default
116116
#define NO_GLOBAL_BINDING 0xffffffff
117117
extern uint32_t global_ipv4_netfmt; // selected interface addresse to bind to
118118

119+
void loop_end();
120+
119121
#ifdef __cplusplus
120122
}
121123
#endif

0 commit comments

Comments
 (0)