Refactored TCP and UPD client tests (with default host test instrumentation)

pull/900/head
Przemek Wirkus 2015-01-28 16:08:54 +00:00
parent ab472195ce
commit 9fc02738ac
2 changed files with 15 additions and 5 deletions

View File

@ -24,6 +24,11 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
} }
int main() { int main() {
TEST_TIMEOUT(20);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(TCP client hello world);
TEST_START("NET_1");
bool result = false; bool result = false;
EthernetInterface eth; EthernetInterface eth;
eth.init(); //Use DHCP eth.init(); //Use DHCP
@ -76,6 +81,5 @@ int main() {
sock.close(); sock.close();
eth.disconnect(); eth.disconnect();
notify_completion(result); TEST_RESULT(result);
return 0;
} }

View File

@ -10,6 +10,11 @@ namespace {
int main() { int main() {
TEST_TIMEOUT(20);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(NIST Internet Time Service);
TEST_START("NET_2");
bool result = false; bool result = false;
EthernetInterface eth; EthernetInterface eth;
eth.init(); //Use DHCP eth.init(); //Use DHCP
@ -34,9 +39,11 @@ int main() {
if (n > 0) { if (n > 0) {
result = true; 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.0;
const float days = timeRes / 24.0 / 60.0 / 60.0;
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 days since 01/01/1900 00:00 GMT ... %s\r\n", days, timeRes > 0 ? "[OK]" : "[FAIL]");
printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]"); printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]");
if (years < YEARS_TO_PASS) { if (years < YEARS_TO_PASS) {
@ -45,6 +52,5 @@ int main() {
} }
sock.close(); sock.close();
eth.disconnect(); eth.disconnect();
notify_completion(result); TEST_RESULT(result);
return 0;
} }