Skip to content

Commit 3e11a3e

Browse files
Veijo PesonenSeppo Takalo
authored andcommitted
Fixes findings from Greentea netsocket UDP test cases
1 parent 53eb36e commit 3e11a3e

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

TESTS/netsocket/udp/udpsocket_echotest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void UDPSOCKET_ECHOTEST()
6767
fill_tx_buffer_ascii(tx_buffer, BUFF_SIZE);
6868

6969
for (int retry_cnt = 0; retry_cnt <= 2; retry_cnt++) {
70+
memset(rx_buffer, 0, BUFF_SIZE);
7071
sent = sock.sendto(udp_addr, tx_buffer, pkt_s);
7172
if (sent != pkt_s) {
7273
printf("[Round#%02d - Sender] error, returned %d\n", s_idx, sent);

TESTS/netsocket/udp/udpsocket_echotest_burst.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,23 @@
2323
#include "utest.h"
2424
#include "udp_tests.h"
2525

26-
#define SIGNAL_SIGIO 0x1
27-
#define SIGIO_TIMEOUT 5000 //[ms]
28-
#define RECV_TIMEOUT 1 //[s]
26+
using namespace utest::v1;
2927

3028
namespace
3129
{
32-
typedef struct pkg {
33-
int len;
34-
char *payload;
35-
} pkg_t;
30+
static const int SIGNAL_SIGIO = 0x1;
31+
static const int SIGIO_TIMEOUT = 5000; //[ms]
32+
static const int RECV_TIMEOUT = 1; //[s]
33+
3634
static const int BURST_CNT = 100;
3735
static const int BURST_PKTS = 5;
3836
static const int PKG_SIZES[BURST_PKTS] = {100, 200, 300, 120, 500};
3937
static const int RECV_TOTAL = 1220;
38+
39+
typedef struct pkg {
40+
int len;
41+
char *payload;
42+
} pkg_t;
4043
pkg_t tx_buffers[BURST_PKTS];
4144
char rx_buffer[500] = {0};
4245
}

TESTS/netsocket/udp/udpsocket_open_close_repeat.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "unity/unity.h"
2424
#include "utest.h"
2525

26+
using namespace utest::v1;
27+
2628
void UDPSOCKET_OPEN_CLOSE_REPEAT()
2729
{
2830
UDPSocket *sock = new UDPSocket;

TESTS/netsocket/udp/udpsocket_recv_timeout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void UDPSOCKET_RECV_TIMEOUT()
6363
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
6464
osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT);
6565
printf("MBED: recvfrom() took: %dms\n", timer.read_ms());
66-
TEST_ASSERT_INT_WITHIN(50, (100+200)/2, timer.read_ms());
66+
TEST_ASSERT_INT_WITHIN(50, 150, timer.read_ms());
6767
continue;
6868
} else if (recvd < 0) {
6969
printf("[bt#%02d] network error %d\n", i, recvd);

TESTS/netsocket/udp/udpsocket_sendto_timeout.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "utest.h"
2424
#include "udp_tests.h"
2525

26+
using namespace utest::v1;
27+
2628
void UDPSOCKET_SENDTO_TIMEOUT()
2729
{
2830
char tx_buffer[100];

0 commit comments

Comments
 (0)