asio: added socket timeout for example tests

This commit is contained in:
David Cermak 2018-08-04 22:09:34 +02:00
parent b674fa0b99
commit c0186858ad
4 changed files with 6 additions and 1 deletions

View File

@ -34,10 +34,12 @@ def chat_server_sketch(my_ip):
print("Starting the server on {}".format(my_ip))
port=2222
s=socket(AF_INET, SOCK_STREAM)
s.settimeout(600)
s.bind((my_ip, port))
s.listen(1)
q,addr=s.accept()
print("connection accepted")
q.settimeout(30)
q.send(g_msg_to_client)
data = q.recv(1024)
# check if received initial empty message
@ -86,7 +88,7 @@ def test_examples_protocol_asio_chat_client(env, extra_data):
time.sleep(1)
print(g_client_response)
# 6. evaluate host_server received this message
if (g_client_response[4:] == test_msg):
if (g_client_response[4:7] == test_msg):
print("PASS: Received correct message")
pass
else:

View File

@ -40,6 +40,7 @@ def test_examples_protocol_asio_chat_server(env, extra_data):
data = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30)
# 3. create tcp client and connect to server
cli = socket(AF_INET,SOCK_STREAM)
cli.settimeout(30)
cli.connect((data[0],80))
cli.send(test_msg)
data = cli.recv(1024)

View File

@ -41,6 +41,7 @@ def test_examples_protocol_asio_tcp_server(env, extra_data):
data = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30)
# 3. create tcp client and connect to server
cli = socket(AF_INET,SOCK_STREAM)
cli.settimeout(30)
cli.connect((data[0],80))
cli.send(test_msg)
data = cli.recv(1024)

View File

@ -41,6 +41,7 @@ def test_examples_protocol_asio_udp_server(env, extra_data):
data = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30)
# 3. create tcp client and connect to server
cli = socket(AF_INET, SOCK_DGRAM)
cli.settimeout(30)
cli.connect((data[0], 80))
cli.send(test_msg)
data = cli.recv(1024)