From 33afdc2723461bbc0c68a4464daf72e501062374 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sun, 15 May 2022 22:06:20 +0200 Subject: [PATCH] emulation on host: fix internal udp management (#8561) * emulation on host: fix internal udp management help dtors: clear map before exit, check with valgrind * fix style --- tests/ci/host_test.sh | 3 ++- tests/host/common/ArduinoMain.cpp | 1 + tests/host/common/ArduinoMainUdp.cpp | 7 ++++++- tests/host/common/mock.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/ci/host_test.sh b/tests/ci/host_test.sh index ef143f90e..44d7517be 100755 --- a/tests/ci/host_test.sh +++ b/tests/ci/host_test.sh @@ -13,7 +13,8 @@ for i in ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient \ ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer \ ../../libraries/SD/examples/Files/Files \ ../../libraries/LittleFS/examples/LittleFS_Timestamp/LittleFS_Timestamp \ - ../../libraries/LittleFS/examples/SpeedTest/SpeedTest ; do + ../../libraries/LittleFS/examples/SpeedTest/SpeedTest \ + ../../libraries/DNSServer/examples/DNSServer/DNSServer ; do make -j2 D=1 FORCE32=0 $i valgrind --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999 bin/$(basename $i)/$(basename $i) -1 done diff --git a/tests/host/common/ArduinoMain.cpp b/tests/host/common/ArduinoMain.cpp index 80e0a0c85..ca03af9dd 100644 --- a/tests/host/common/ArduinoMain.cpp +++ b/tests/host/common/ArduinoMain.cpp @@ -163,6 +163,7 @@ static struct option options[] = { void cleanup() { + mock_stop_udp(); mock_stop_spiffs(); mock_stop_littlefs(); mock_stop_uart(); diff --git a/tests/host/common/ArduinoMainUdp.cpp b/tests/host/common/ArduinoMainUdp.cpp index cfcaacef2..49d7c091d 100644 --- a/tests/host/common/ArduinoMainUdp.cpp +++ b/tests/host/common/ArduinoMainUdp.cpp @@ -33,7 +33,7 @@ #include #include -std::map udps; +static std::map udps; void register_udp(int sock, UdpContext* udp) { @@ -58,3 +58,8 @@ void check_incoming_udp() } } } + +void mock_stop_udp() +{ + udps.clear(); +} diff --git a/tests/host/common/mock.h b/tests/host/common/mock.h index a8dc3e2bd..dbcb1dbf3 100644 --- a/tests/host/common/mock.h +++ b/tests/host/common/mock.h @@ -170,6 +170,7 @@ void mockUDPSwallow(size_t copied, char* ccinbuf, size_t& ccinbufsize); class UdpContext; void register_udp(int sock, UdpContext* udp = nullptr); +void mock_stop_udp(); //