mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/ci_move_udp_socket_tests_to_eth_runners' into 'master'
CI: Adjust UDP socket tests to be more reliable Closes IDFCI-528 See merge request espressif/esp-idf!14080
This commit is contained in:
commit
8d476269d6
@ -27,9 +27,10 @@ def udp_client(address, payload):
|
||||
family_addr, socktype, proto, canonname, addr = res
|
||||
try:
|
||||
sock = socket.socket(family_addr, socket.SOCK_DGRAM)
|
||||
sock.settimeout(60.0)
|
||||
sock.settimeout(20.0)
|
||||
except socket.error as msg:
|
||||
print('Could not create socket: ' + str(msg[0]) + ': ' + msg[1])
|
||||
print('Could not create socket')
|
||||
print(os.strerror(msg.errno))
|
||||
raise
|
||||
try:
|
||||
sock.sendto(payload.encode(), addr)
|
||||
@ -37,8 +38,12 @@ def udp_client(address, payload):
|
||||
if not reply:
|
||||
return
|
||||
print('Reply[' + addr[0] + ':' + str(addr[1]) + '] - ' + str(reply))
|
||||
except socket.timeout:
|
||||
print('Socket operation timeout')
|
||||
return str(None)
|
||||
except socket.error as msg:
|
||||
print('Error Code : ' + str(msg[0]) + ' Message: ' + msg[1])
|
||||
print('Error while sending or receiving data from the socket')
|
||||
print(os.strerror(msg.errno))
|
||||
sock.close()
|
||||
raise
|
||||
return reply.decode()
|
||||
@ -47,6 +52,7 @@ def udp_client(address, payload):
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI_Protocols')
|
||||
def test_examples_protocol_socket_udpserver(env, extra_data):
|
||||
MESSAGE = 'Data to ESP'
|
||||
MAX_RETRIES = 3
|
||||
"""
|
||||
steps:
|
||||
1. join AP
|
||||
@ -66,16 +72,28 @@ def test_examples_protocol_socket_udpserver(env, extra_data):
|
||||
ipv6_r = r':'.join((r'[0-9a-fA-F]{4}',) * 8) # expect all 8 octets from IPv6 (assumes it's printed in the long form)
|
||||
ipv6 = dut1.expect(re.compile(r' IPv6 address: ({})'.format(ipv6_r)), timeout=30)[0]
|
||||
print('Connected with IPv4={} and IPv6={}'.format(ipv4, ipv6))
|
||||
dut1.expect(re.compile(r'Waiting for data'), timeout=10)
|
||||
|
||||
# test IPv4
|
||||
received = udp_client(ipv4, MESSAGE)
|
||||
if not received == MESSAGE:
|
||||
raise
|
||||
for _ in range(MAX_RETRIES):
|
||||
print('Testing UDP on IPv4...')
|
||||
received = udp_client(ipv4, MESSAGE)
|
||||
if received == MESSAGE:
|
||||
print('OK')
|
||||
break
|
||||
else:
|
||||
raise ValueError('IPv4: Did not receive UDP message after {} retries'.format(MAX_RETRIES))
|
||||
dut1.expect(MESSAGE)
|
||||
|
||||
# test IPv6
|
||||
received = udp_client('{}%{}'.format(ipv6, INTERFACE), MESSAGE)
|
||||
if not received == MESSAGE:
|
||||
raise
|
||||
for _ in range(MAX_RETRIES):
|
||||
print('Testing UDP on IPv6...')
|
||||
received = udp_client('{}%{}'.format(ipv6, INTERFACE), MESSAGE)
|
||||
if received == MESSAGE:
|
||||
print('OK')
|
||||
break
|
||||
else:
|
||||
raise ValueError('IPv6: Did not receive UDP message after {} retries'.format(MAX_RETRIES))
|
||||
dut1.expect(MESSAGE)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user