Skip to content

Commit 0550ccd

Browse files
liebmandevyte
authored andcommitted
device test updates (#5455)
add test_ping fix test_millis_mm
1 parent 4d15590 commit 0550ccd

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

tests/device/test_millis_mm/test_millis_mm.ino

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
extern "C" { // SDK functions for Arduino IDE access
1515
#include "osapi.h"
1616
#include "user_interface.h"
17-
#include "espconn.h"
1817
} //end, 'extern C'
1918

2019
//---------------------------------------------------------------------------

tests/device/test_ping/test_ping.ino

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <Arduino.h>
2+
#include <BSTest.h>
3+
#include <ESP8266WiFi.h>
4+
5+
#include <ping.h>
6+
7+
BS_ENV_DECLARE();
8+
9+
void setup()
10+
{
11+
Serial.begin(115200);
12+
Serial.setDebugOutput(true);
13+
WiFi.persistent(false);
14+
WiFi.mode(WIFI_STA);
15+
WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS"));
16+
while (WiFi.status() != WL_CONNECTED) {
17+
delay(500);
18+
}
19+
BS_RUN(Serial);
20+
}
21+
22+
static struct ping_option po;
23+
static const uint32_t PING_COUNT = 5;
24+
static volatile uint32_t recv_count;
25+
static volatile uint32_t done_count;
26+
27+
static void ping_recv(void* options, void* resp)
28+
{
29+
(void)options;
30+
(void)resp;
31+
++recv_count;
32+
}
33+
34+
static void ping_done(void* options, void* resp)
35+
{
36+
(void)options;
37+
(void)resp;
38+
done_count = ((struct ping_resp*)resp)->total_count;
39+
}
40+
41+
TEST_CASE("pings sent/answered", "[lwip]")
42+
{
43+
IPAddress address;
44+
if (WiFi.hostByName(getenv("SERVER_IP"), address))
45+
{
46+
po.ip = address;
47+
po.count = PING_COUNT;
48+
po.coarse_time = 1;
49+
po.sent_function = &ping_done;
50+
po.recv_function = &ping_recv;
51+
ping_start(&po);
52+
delay((PING_COUNT+2)*1000);
53+
}
54+
REQUIRE(recv_count == PING_COUNT);
55+
REQUIRE(done_count == PING_COUNT);
56+
}
57+
58+
void loop()
59+
{
60+
}

0 commit comments

Comments
 (0)