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
pull/477/head
Przemek Wirkus 2014-09-04 10:10:55 +01:00
parent 2df3125ca4
commit c12b5de37b
6 changed files with 48 additions and 6 deletions

View File

@ -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++) {

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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",