Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test_millis_mm & add test_ping #5455

Merged
merged 3 commits into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

Copy link
Contributor Author

@liebman liebman Dec 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igrr - good catch! I'll make a new PR to fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitted pr #5459

REQUIRE(done_count == PING_COUNT);
}

void loop()
{
}