mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 19:54:32 +02:00
Merge branch 'bugfix/ci_move_udp_socket_tests_to_eth_runners_v4.2' into 'release/v4.2'
CI: Adjust UDP socket tests to be more reliable (v4.2) See merge request espressif/esp-idf!14421
This commit is contained in:
@@ -27,9 +27,10 @@ def udp_client(address, payload):
|
|||||||
family_addr, socktype, proto, canonname, addr = res
|
family_addr, socktype, proto, canonname, addr = res
|
||||||
try:
|
try:
|
||||||
sock = socket.socket(family_addr, socket.SOCK_DGRAM)
|
sock = socket.socket(family_addr, socket.SOCK_DGRAM)
|
||||||
sock.settimeout(60.0)
|
sock.settimeout(20.0)
|
||||||
except socket.error as msg:
|
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
|
raise
|
||||||
try:
|
try:
|
||||||
sock.sendto(payload.encode(), addr)
|
sock.sendto(payload.encode(), addr)
|
||||||
@@ -37,8 +38,12 @@ def udp_client(address, payload):
|
|||||||
if not reply:
|
if not reply:
|
||||||
return
|
return
|
||||||
print('Reply[' + addr[0] + ':' + str(addr[1]) + '] - ' + str(reply))
|
print('Reply[' + addr[0] + ':' + str(addr[1]) + '] - ' + str(reply))
|
||||||
|
except socket.timeout:
|
||||||
|
print('Socket operation timeout')
|
||||||
|
return str(None)
|
||||||
except socket.error as msg:
|
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()
|
sock.close()
|
||||||
raise
|
raise
|
||||||
return reply.decode()
|
return reply.decode()
|
||||||
@@ -47,6 +52,7 @@ def udp_client(address, payload):
|
|||||||
@ttfw_idf.idf_example_test(env_tag="Example_WIFI")
|
@ttfw_idf.idf_example_test(env_tag="Example_WIFI")
|
||||||
def test_examples_protocol_socket_udpserver(env, extra_data):
|
def test_examples_protocol_socket_udpserver(env, extra_data):
|
||||||
MESSAGE = "Data to ESP"
|
MESSAGE = "Data to ESP"
|
||||||
|
MAX_RETRIES = 3
|
||||||
"""
|
"""
|
||||||
steps:
|
steps:
|
||||||
1. join AP
|
1. join AP
|
||||||
@@ -67,16 +73,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_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]
|
ipv6 = dut1.expect(re.compile(r' IPv6 address: ({})'.format(ipv6_r)), timeout=30)[0]
|
||||||
print("Connected with IPv4={} and IPv6={}".format(ipv4, ipv6))
|
print("Connected with IPv4={} and IPv6={}".format(ipv4, ipv6))
|
||||||
|
dut1.expect(re.compile(r'Waiting for data'), timeout=10)
|
||||||
|
|
||||||
# test IPv4
|
# test IPv4
|
||||||
received = udp_client(ipv4, MESSAGE)
|
for _ in range(MAX_RETRIES):
|
||||||
if not received == MESSAGE:
|
print('Testing UDP on IPv4...')
|
||||||
raise
|
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)
|
dut1.expect(MESSAGE)
|
||||||
|
|
||||||
# test IPv6
|
# test IPv6
|
||||||
received = udp_client("{}%{}".format(ipv6, INTERFACE), MESSAGE)
|
for _ in range(MAX_RETRIES):
|
||||||
if not received == MESSAGE:
|
print('Testing UDP on IPv6...')
|
||||||
raise
|
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)
|
dut1.expect(MESSAGE)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user