diff --git a/libraries/tests/net/echo/tcp_client_loop/main.cpp b/libraries/tests/net/echo/tcp_client_loop/main.cpp index 46f613237f..39ea62ee4c 100644 --- a/libraries/tests/net/echo/tcp_client_loop/main.cpp +++ b/libraries/tests/net/echo/tcp_client_loop/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" #include "EthernetInterface.h" struct s_ip_address @@ -11,6 +12,7 @@ struct s_ip_address #define MAX_ECHO_LOOPS 100 + int main() { char buffer[256] = {0}; char out_buffer[] = "Hello World\n"; @@ -36,7 +38,7 @@ int main() { wait(1); } - // Test loop for multiple client conenctions + // Test loop for multiple client connections bool result = true; int count_error = 0; for (int i = 0; i < MAX_ECHO_LOOPS; i++) { diff --git a/libraries/tests/net/helloworld/udpclient/main.cpp b/libraries/tests/net/helloworld/udpclient/main.cpp index 0cc446d31e..843d906ca2 100644 --- a/libraries/tests/net/helloworld/udpclient/main.cpp +++ b/libraries/tests/net/helloworld/udpclient/main.cpp @@ -5,8 +5,10 @@ namespace { const char *HTTP_SERVER_NAME = "utcnist.colorado.edu"; const int HTTP_SERVER_PORT = 37; + const float YEARS_TO_PASS = 114.0; } + int main() { bool result = false; EthernetInterface eth; @@ -30,14 +32,14 @@ int main() { const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab)); if (n > 0) { + result = true; const unsigned int timeRes = ntohl(in_buffer_uint); const float years = timeRes / 60.0 / 60.0 / 24.0 / 365; printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port()); printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]"); - printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > 114.0 ? "[OK]" : "[FAIL]"); - result = true; + printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]"); - if (years < 114.0) { + if (years < YEARS_TO_PASS) { result = false; } } diff --git a/workspace_tools/host_tests/tcpecho_client_auto.py b/workspace_tools/host_tests/tcpecho_client_auto.py index 1d8b6b0f82..7dd89b5bde 100644 --- a/workspace_tools/host_tests/tcpecho_client_auto.py +++ b/workspace_tools/host_tests/tcpecho_client_auto.py @@ -19,6 +19,7 @@ from SocketServer import BaseRequestHandler, TCPServer import socket from host_test import Test from sys import stdout +from time import sleep SERVER_IP = str(socket.gethostbyname(socket.getfqdn())) SERVER_PORT = 7 @@ -31,7 +32,25 @@ class TCPEchoClientTest(Test): def send_server_ip_port(self, ip_address, port_no): print "Resetting target..." self.mbed.reset() + + # Let's wait for Mbed to print its readiness, usually "{{start}}" + if self.mbed.serial_timeout(None) is None: + self.print_result("ioerr_serial") + return + + c = self.mbed.serial_read(len('TCPCllient waiting for server IP and port...')) + if c is None: + self.print_result("ioerr_serial") + return + print c + stdout.flush() + + if self.mbed.serial_timeout(1) is None: + self.print_result("ioerr_serial") + return + print "Sending server IP Address to target..." + stdout.flush() connection_str = ip_address + ":" + str(port_no) + "\n" self.mbed.serial_write(connection_str) diff --git a/workspace_tools/host_tests/udpecho_client_auto.py b/workspace_tools/host_tests/udpecho_client_auto.py index 9d65bac3a8..906537d6a3 100644 --- a/workspace_tools/host_tests/udpecho_client_auto.py +++ b/workspace_tools/host_tests/udpecho_client_auto.py @@ -30,6 +30,23 @@ class UDPEchoClientTest(Test): def send_server_ip_port(self, ip_address, port_no): print "Resetting target..." self.mbed.reset() + + # Let's wait for Mbed to print its readiness, usually "{{start}}" + if self.mbed.serial_timeout(None) is None: + self.print_result("ioerr_serial") + return + + c = self.mbed.serial_read(len('UDPCllient waiting for server IP and port...')) + if c is None: + self.print_result("ioerr_serial") + return + print c + stdout.flush() + + if self.mbed.serial_timeout(1) is None: + self.print_result("ioerr_serial") + return + print "Sending server IP Address to target..." connection_str = ip_address + ":" + str(port_no) + "\n" self.mbed.serial_write(connection_str) diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 6f46d00fa8..054c1bea23 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -833,7 +833,9 @@ class SingleTestRunner(object): output.append(c) if verbose: sys.stdout.write(c) - print "Test::Output::Finish" + + if verbose: + print "Test::Output::Finish" # Stop test process obs.stop() diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 7a7f18f112..53e2976619 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -727,7 +727,7 @@ TESTS = [ { "id": "NET_13", "description": "TCP client echo loop", "source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, "duration": 15, "host_test": "tcpecho_client_auto",