Fixes findings from Greentea netsocket UDP test cases

pull/6665/head
Veijo Pesonen 2018-05-17 12:48:18 +03:00 committed by Seppo Takalo
parent 53eb36e729
commit 3e11a3e666
5 changed files with 16 additions and 8 deletions

View File

@ -67,6 +67,7 @@ void UDPSOCKET_ECHOTEST()
fill_tx_buffer_ascii(tx_buffer, BUFF_SIZE);
for (int retry_cnt = 0; retry_cnt <= 2; retry_cnt++) {
memset(rx_buffer, 0, BUFF_SIZE);
sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
if (sent != pkt_s) {
printf("[Round#%02d - Sender] error, returned %d\n", s_idx, sent);

View File

@ -23,20 +23,23 @@
#include "utest.h"
#include "udp_tests.h"
#define SIGNAL_SIGIO 0x1
#define SIGIO_TIMEOUT 5000 //[ms]
#define RECV_TIMEOUT 1 //[s]
using namespace utest::v1;
namespace
{
typedef struct pkg {
int len;
char *payload;
} pkg_t;
static const int SIGNAL_SIGIO = 0x1;
static const int SIGIO_TIMEOUT = 5000; //[ms]
static const int RECV_TIMEOUT = 1; //[s]
static const int BURST_CNT = 100;
static const int BURST_PKTS = 5;
static const int PKG_SIZES[BURST_PKTS] = {100, 200, 300, 120, 500};
static const int RECV_TOTAL = 1220;
typedef struct pkg {
int len;
char *payload;
} pkg_t;
pkg_t tx_buffers[BURST_PKTS];
char rx_buffer[500] = {0};
}

View File

@ -23,6 +23,8 @@
#include "unity/unity.h"
#include "utest.h"
using namespace utest::v1;
void UDPSOCKET_OPEN_CLOSE_REPEAT()
{
UDPSocket *sock = new UDPSocket;

View File

@ -63,7 +63,7 @@ void UDPSOCKET_RECV_TIMEOUT()
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT);
printf("MBED: recvfrom() took: %dms\n", timer.read_ms());
TEST_ASSERT_INT_WITHIN(50, (100+200)/2, timer.read_ms());
TEST_ASSERT_INT_WITHIN(50, 150, timer.read_ms());
continue;
} else if (recvd < 0) {
printf("[bt#%02d] network error %d\n", i, recvd);

View File

@ -23,6 +23,8 @@
#include "utest.h"
#include "udp_tests.h"
using namespace utest::v1;
void UDPSOCKET_SENDTO_TIMEOUT()
{
char tx_buffer[100];