Skip to content

Commit

Permalink
In response to: IOTSFW-325
Browse files Browse the repository at this point in the history
1. Removed globaly initialized data inside class test() function
2. Removed global variables initialization dependency. Any cause some Python
   implementations and configurations to fail in runtime
3. Added info about Echo port #7 rationale.
4. Testsed with K64F and network tests:

Test summary:
+--------+--------+---------+----------------------------+--------------------+
| Result | Target | Test ID | Test Description           | Elapsed Time (sec) |
+--------+--------+---------+----------------------------+--------------------+
| OK     | K64F   | NET_1   | TCP client hello world     |        3.26        |
| OK     | K64F   | NET_13  | TCP client echo loop       |        2.05        |
| OK     | K64F   | NET_2   | NIST Internet Time Service |        3.43        |
| OK     | K64F   | NET_3   | TCP echo server            |        1.54        |
| OK     | K64F   | NET_4   | TCP echo client            |        1.54        |
| OK     | K64F   | NET_5   | UDP echo server            |        1.46        |
| OK     | K64F   | NET_6   | UDP echo client            |        1.6         |
| OK     | K64F   | NET_7   | HTTP client hello world    |        3.4         |
| OK     | K64F   | NET_8   | NTP client                 |        2.39        |
+--------+--------+---------+----------------------------+--------------------+
Result: 9 OK

Completed in 122.18 sec
  • Loading branch information
PrzemekWirkus committed Feb 19, 2015
1 parent 4d5b877 commit 78cc959
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
19 changes: 16 additions & 3 deletions workspace_tools/host_tests/tcpecho_client_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
from sys import stdout
from SocketServer import BaseRequestHandler, TCPServer

SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
SERVER_PORT = 7

class TCPEchoClient_Handler(BaseRequestHandler):
def handle(self):
""" One handle per connection
Expand Down Expand Up @@ -67,6 +64,22 @@ def send_server_ip_port(self, selftest, ip_address, port_no):
selftest.notify(c.strip())

def test(self, selftest):
# We need to discover SERVEP_IP and set up SERVER_PORT
# Note: Port 7 is Echo Protocol:
#
# Port number rationale:
#
# The Echo Protocol is a service in the Internet Protocol Suite defined
# in RFC 862. It was originally proposed for testing and measurement
# of round-trip times[citation needed] in IP networks.
#
# A host may connect to a server that supports the Echo Protocol using
# the Transmission Control Protocol (TCP) or the User Datagram Protocol
# (UDP) on the well-known port number 7. The server sends back an
# identical copy of the data it received.
SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
SERVER_PORT = 7

# Returning none will suppress host test from printing success code
server = TCPServer((SERVER_IP, SERVER_PORT), TCPEchoClient_Handler)
print "HOST: Listening for TCP connections: " + SERVER_IP + ":" + str(SERVER_PORT)
Expand Down
19 changes: 16 additions & 3 deletions workspace_tools/host_tests/udpecho_client_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
from sys import stdout
from SocketServer import BaseRequestHandler, UDPServer

SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
SERVER_PORT = 7

class UDPEchoClient_Handler(BaseRequestHandler):
def handle(self):
""" One handle per connection
Expand Down Expand Up @@ -57,6 +54,22 @@ def send_server_ip_port(self, selftest, ip_address, port_no):
return selftest.RESULT_PASSIVE

def test(self, selftest):
# We need to discover SERVEP_IP and set up SERVER_PORT
# Note: Port 7 is Echo Protocol:
#
# Port number rationale:
#
# The Echo Protocol is a service in the Internet Protocol Suite defined
# in RFC 862. It was originally proposed for testing and measurement
# of round-trip times[citation needed] in IP networks.
#
# A host may connect to a server that supports the Echo Protocol using
# the Transmission Control Protocol (TCP) or the User Datagram Protocol
# (UDP) on the well-known port number 7. The server sends back an
# identical copy of the data it received.
SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
SERVER_PORT = 7

# Returning none will suppress host test from printing success code
server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler)
print "HOST: Listening for UDP connections..."
Expand Down

0 comments on commit 78cc959

Please sign in to comment.