mirror of https://github.com/ARMmbed/mbed-os.git
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 optionpull/477/head
parent
2df3125ca4
commit
c12b5de37b
|
@ -1,4 +1,5 @@
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
|
#include "test_env.h"
|
||||||
#include "EthernetInterface.h"
|
#include "EthernetInterface.h"
|
||||||
|
|
||||||
struct s_ip_address
|
struct s_ip_address
|
||||||
|
@ -11,6 +12,7 @@ struct s_ip_address
|
||||||
|
|
||||||
#define MAX_ECHO_LOOPS 100
|
#define MAX_ECHO_LOOPS 100
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char buffer[256] = {0};
|
char buffer[256] = {0};
|
||||||
char out_buffer[] = "Hello World\n";
|
char out_buffer[] = "Hello World\n";
|
||||||
|
@ -36,7 +38,7 @@ int main() {
|
||||||
wait(1);
|
wait(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test loop for multiple client conenctions
|
// Test loop for multiple client connections
|
||||||
bool result = true;
|
bool result = true;
|
||||||
int count_error = 0;
|
int count_error = 0;
|
||||||
for (int i = 0; i < MAX_ECHO_LOOPS; i++) {
|
for (int i = 0; i < MAX_ECHO_LOOPS; i++) {
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
namespace {
|
namespace {
|
||||||
const char *HTTP_SERVER_NAME = "utcnist.colorado.edu";
|
const char *HTTP_SERVER_NAME = "utcnist.colorado.edu";
|
||||||
const int HTTP_SERVER_PORT = 37;
|
const int HTTP_SERVER_PORT = 37;
|
||||||
|
const float YEARS_TO_PASS = 114.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
EthernetInterface eth;
|
EthernetInterface eth;
|
||||||
|
@ -30,14 +32,14 @@ int main() {
|
||||||
|
|
||||||
const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab));
|
const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab));
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
|
result = true;
|
||||||
const unsigned int timeRes = ntohl(in_buffer_uint);
|
const unsigned int timeRes = ntohl(in_buffer_uint);
|
||||||
const float years = timeRes / 60.0 / 60.0 / 24.0 / 365;
|
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: 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: %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]");
|
printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]");
|
||||||
result = true;
|
|
||||||
|
|
||||||
if (years < 114.0) {
|
if (years < YEARS_TO_PASS) {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ from SocketServer import BaseRequestHandler, TCPServer
|
||||||
import socket
|
import socket
|
||||||
from host_test import Test
|
from host_test import Test
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
|
SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
|
||||||
SERVER_PORT = 7
|
SERVER_PORT = 7
|
||||||
|
@ -31,7 +32,25 @@ class TCPEchoClientTest(Test):
|
||||||
def send_server_ip_port(self, ip_address, port_no):
|
def send_server_ip_port(self, ip_address, port_no):
|
||||||
print "Resetting target..."
|
print "Resetting target..."
|
||||||
self.mbed.reset()
|
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..."
|
print "Sending server IP Address to target..."
|
||||||
|
stdout.flush()
|
||||||
connection_str = ip_address + ":" + str(port_no) + "\n"
|
connection_str = ip_address + ":" + str(port_no) + "\n"
|
||||||
self.mbed.serial_write(connection_str)
|
self.mbed.serial_write(connection_str)
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,23 @@ class UDPEchoClientTest(Test):
|
||||||
def send_server_ip_port(self, ip_address, port_no):
|
def send_server_ip_port(self, ip_address, port_no):
|
||||||
print "Resetting target..."
|
print "Resetting target..."
|
||||||
self.mbed.reset()
|
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..."
|
print "Sending server IP Address to target..."
|
||||||
connection_str = ip_address + ":" + str(port_no) + "\n"
|
connection_str = ip_address + ":" + str(port_no) + "\n"
|
||||||
self.mbed.serial_write(connection_str)
|
self.mbed.serial_write(connection_str)
|
||||||
|
|
|
@ -833,7 +833,9 @@ class SingleTestRunner(object):
|
||||||
output.append(c)
|
output.append(c)
|
||||||
if verbose:
|
if verbose:
|
||||||
sys.stdout.write(c)
|
sys.stdout.write(c)
|
||||||
print "Test::Output::Finish"
|
|
||||||
|
if verbose:
|
||||||
|
print "Test::Output::Finish"
|
||||||
# Stop test process
|
# Stop test process
|
||||||
obs.stop()
|
obs.stop()
|
||||||
|
|
||||||
|
|
|
@ -727,7 +727,7 @@ TESTS = [
|
||||||
{
|
{
|
||||||
"id": "NET_13", "description": "TCP client echo loop",
|
"id": "NET_13", "description": "TCP client echo loop",
|
||||||
"source_dir": join(TEST_DIR, "net", "echo", "tcp_client_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,
|
"automated": True,
|
||||||
"duration": 15,
|
"duration": 15,
|
||||||
"host_test": "tcpecho_client_auto",
|
"host_test": "tcpecho_client_auto",
|
||||||
|
|
Loading…
Reference in New Issue