Skip to content

Commit

Permalink
device test updates (esp8266#5455)
Browse files Browse the repository at this point in the history
add test_ping
fix test_millis_mm
  • Loading branch information
liebman authored and devyte committed Dec 9, 2018
1 parent 4d15590 commit 0550ccd
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/device/test_millis_mm/test_millis_mm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
extern "C" { // SDK functions for Arduino IDE access
#include "osapi.h"
#include "user_interface.h"
#include "espconn.h"
} //end, 'extern C'

//---------------------------------------------------------------------------
Expand Down
60 changes: 60 additions & 0 deletions tests/device/test_ping/test_ping.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <Arduino.h>
#include <BSTest.h>
#include <ESP8266WiFi.h>

#include <ping.h>

BS_ENV_DECLARE();

void setup()
{
Serial.begin(115200);
Serial.setDebugOutput(true);
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS"));
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
BS_RUN(Serial);
}

static struct ping_option po;
static const uint32_t PING_COUNT = 5;
static volatile uint32_t recv_count;
static volatile uint32_t done_count;

static void ping_recv(void* options, void* resp)
{
(void)options;
(void)resp;
++recv_count;
}

static void ping_done(void* options, void* resp)
{
(void)options;
(void)resp;
done_count = ((struct ping_resp*)resp)->total_count;
}

TEST_CASE("pings sent/answered", "[lwip]")
{
IPAddress address;
if (WiFi.hostByName(getenv("SERVER_IP"), address))
{
po.ip = address;
po.count = PING_COUNT;
po.coarse_time = 1;
po.sent_function = &ping_done;
po.recv_function = &ping_recv;
ping_start(&po);
delay((PING_COUNT+2)*1000);
}
REQUIRE(recv_count == PING_COUNT);
REQUIRE(done_count == PING_COUNT);
}

void loop()
{
}

0 comments on commit 0550ccd

Please sign in to comment.