Skip to content

Commit c12b5de

Browse files
committed
Fixed NET_(4,6,13) client tests so after reset we wait for device to send print it's ready
Fixed small print issue with -V option
1 parent 2df3125 commit c12b5de

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

libraries/tests/net/echo/tcp_client_loop/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "mbed.h"
2+
#include "test_env.h"
23
#include "EthernetInterface.h"
34

45
struct s_ip_address
@@ -11,6 +12,7 @@ struct s_ip_address
1112

1213
#define MAX_ECHO_LOOPS 100
1314

15+
1416
int main() {
1517
char buffer[256] = {0};
1618
char out_buffer[] = "Hello World\n";
@@ -36,7 +38,7 @@ int main() {
3638
wait(1);
3739
}
3840

39-
// Test loop for multiple client conenctions
41+
// Test loop for multiple client connections
4042
bool result = true;
4143
int count_error = 0;
4244
for (int i = 0; i < MAX_ECHO_LOOPS; i++) {

libraries/tests/net/helloworld/udpclient/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
namespace {
66
const char *HTTP_SERVER_NAME = "utcnist.colorado.edu";
77
const int HTTP_SERVER_PORT = 37;
8+
const float YEARS_TO_PASS = 114.0;
89
}
910

11+
1012
int main() {
1113
bool result = false;
1214
EthernetInterface eth;
@@ -30,14 +32,14 @@ int main() {
3032

3133
const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab));
3234
if (n > 0) {
35+
result = true;
3336
const unsigned int timeRes = ntohl(in_buffer_uint);
3437
const float years = timeRes / 60.0 / 60.0 / 24.0 / 365;
3538
printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port());
3639
printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]");
37-
printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > 114.0 ? "[OK]" : "[FAIL]");
38-
result = true;
40+
printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]");
3941

40-
if (years < 114.0) {
42+
if (years < YEARS_TO_PASS) {
4143
result = false;
4244
}
4345
}

workspace_tools/host_tests/tcpecho_client_auto.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import socket
2020
from host_test import Test
2121
from sys import stdout
22+
from time import sleep
2223

2324
SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
2425
SERVER_PORT = 7
@@ -31,7 +32,25 @@ def __init__(self):
3132
def send_server_ip_port(self, ip_address, port_no):
3233
print "Resetting target..."
3334
self.mbed.reset()
35+
36+
# Let's wait for Mbed to print its readiness, usually "{{start}}"
37+
if self.mbed.serial_timeout(None) is None:
38+
self.print_result("ioerr_serial")
39+
return
40+
41+
c = self.mbed.serial_read(len('TCPCllient waiting for server IP and port...'))
42+
if c is None:
43+
self.print_result("ioerr_serial")
44+
return
45+
print c
46+
stdout.flush()
47+
48+
if self.mbed.serial_timeout(1) is None:
49+
self.print_result("ioerr_serial")
50+
return
51+
3452
print "Sending server IP Address to target..."
53+
stdout.flush()
3554
connection_str = ip_address + ":" + str(port_no) + "\n"
3655
self.mbed.serial_write(connection_str)
3756

workspace_tools/host_tests/udpecho_client_auto.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ def __init__(self):
3030
def send_server_ip_port(self, ip_address, port_no):
3131
print "Resetting target..."
3232
self.mbed.reset()
33+
34+
# Let's wait for Mbed to print its readiness, usually "{{start}}"
35+
if self.mbed.serial_timeout(None) is None:
36+
self.print_result("ioerr_serial")
37+
return
38+
39+
c = self.mbed.serial_read(len('UDPCllient waiting for server IP and port...'))
40+
if c is None:
41+
self.print_result("ioerr_serial")
42+
return
43+
print c
44+
stdout.flush()
45+
46+
if self.mbed.serial_timeout(1) is None:
47+
self.print_result("ioerr_serial")
48+
return
49+
3350
print "Sending server IP Address to target..."
3451
connection_str = ip_address + ":" + str(port_no) + "\n"
3552
self.mbed.serial_write(connection_str)

workspace_tools/test_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,9 @@ def run_host_test(self, name, disk, port, duration, reset=None, reset_tout=None,
833833
output.append(c)
834834
if verbose:
835835
sys.stdout.write(c)
836-
print "Test::Output::Finish"
836+
837+
if verbose:
838+
print "Test::Output::Finish"
837839
# Stop test process
838840
obs.stop()
839841

workspace_tools/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@
727727
{
728728
"id": "NET_13", "description": "TCP client echo loop",
729729
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"),
730-
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY],
730+
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB],
731731
"automated": True,
732732
"duration": 15,
733733
"host_test": "tcpecho_client_auto",

0 commit comments

Comments
 (0)