Small improvements to ETH test cases - handle not open socket on host test side

pull/509/head^2
Przemek Wirkus 2014-09-23 11:41:35 +01:00
parent b1260b55d4
commit e3e49cb67d
3 changed files with 17 additions and 5 deletions

View File

@ -53,6 +53,7 @@ class TCPEchoServerTest(DefaultTest):
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.connect((self.ECHO_SERVER_ADDRESS, self.ECHO_PORT))
except Exception, e:
self.s = None
print "HOST: Error: %s" % e
self.print_result('error')
exit(-1)
@ -74,7 +75,9 @@ class TCPEchoServerTest(DefaultTest):
print "'%s'"% received_str
result = False
break
self.s.close()
if self.s is not None:
self.s.close()
else:
print "HOST: TCP Server not found"
result = False

View File

@ -71,8 +71,11 @@ class UDPEchoServerTest(DefaultTest):
def get_control_data(self, command="stat\n"):
BUFFER_SIZE = 256
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.ECHO_SERVER_ADDRESS, self.CONTROL_PORT))
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.ECHO_SERVER_ADDRESS, self.CONTROL_PORT))
except Exception, e:
data = None
s.send(command)
data = s.recv(BUFFER_SIZE)
s.close()
@ -97,6 +100,7 @@ class UDPEchoServerTest(DefaultTest):
try:
self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
except Exception, e:
self.s = None
print "HOST: Error: %s" % e
self.print_result('error')
return
@ -114,7 +118,9 @@ class UDPEchoServerTest(DefaultTest):
self.s.sendto(payload, (self.ECHO_SERVER_ADDRESS, self.ECHO_PORT))
dict_udp_sent_datagrams[payload] = time()
sleep(self.TEST_STRESS_FACTOR)
self.s.close()
if self.s is not None:
self.s.close()
# Wait 5 seconds for packets to come
result = True

View File

@ -53,6 +53,7 @@ class UDPEchoServerTest(DefaultTest):
try:
self.s = socket(AF_INET, SOCK_DGRAM)
except Exception, e:
self.s = None
print "HOST: Error: %s" % e
self.print_result('error')
exit(-1)
@ -70,7 +71,9 @@ class UDPEchoServerTest(DefaultTest):
else:
result = False
self.s.close()
if self.s is not None:
self.s.close()
if result:
self.print_result('success')
else: