Skip to content

Commit

Permalink
Emulation on host: updates (#8409)
Browse files Browse the repository at this point in the history
* mock: +Hash, +scheduled functions
Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
  • Loading branch information
d-a-v committed Jan 3, 2022
1 parent d0cc3a8 commit 2f58f67
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 := \
Expand Down
13 changes: 11 additions & 2 deletions tests/host/common/Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
*/

#include <sys/time.h>
#include "Arduino.h"
#include <unistd.h>

#include <functional>

#include <unistd.h>
#include <Arduino.h>
#include <Schedule.h>

static struct timeval gtod0 = { 0, 0 };

Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions tests/host/common/ArduinoMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/host/common/mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2f58f67

Please sign in to comment.