mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
Merge branch 'bugfix/optimize_protocol_socket_cases_4.4' into 'release/v4.4'
CI: optimize example protocol test cases (4.4) See merge request espressif/esp-idf!22311
This commit is contained in:
@ -51,7 +51,7 @@ def test_examples_protocol_http_server_advanced(env, extra_data):
|
|||||||
|
|
||||||
# Parse IP address of STA
|
# Parse IP address of STA
|
||||||
Utility.console_log('Waiting to connect with AP')
|
Utility.console_log('Waiting to connect with AP')
|
||||||
got_ip = dut1.expect(re.compile(r'(?:[\s\S]*)IPv4 address: (\d+.\d+.\d+.\d+)'), timeout=30)[0]
|
got_ip = dut1.expect(re.compile(r'(?:[\s\S]*)IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]'), timeout=30)[0]
|
||||||
|
|
||||||
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Started HTTP server on port: '(\d+)'"), timeout=15)[0]
|
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Started HTTP server on port: '(\d+)'"), timeout=15)[0]
|
||||||
result = dut1.expect(re.compile(r"(?:[\s\S]*)Max URI handlers: '(\d+)'(?:[\s\S]*)Max Open Sessions: " # noqa: W605
|
result = dut1.expect(re.compile(r"(?:[\s\S]*)Max URI handlers: '(\d+)'(?:[\s\S]*)Max Open Sessions: " # noqa: W605
|
||||||
|
@ -47,7 +47,7 @@ def test_examples_protocol_http_server_persistence(env, extra_data):
|
|||||||
|
|
||||||
# Parse IP address of STA
|
# Parse IP address of STA
|
||||||
Utility.console_log('Waiting to connect with AP')
|
Utility.console_log('Waiting to connect with AP')
|
||||||
got_ip = dut1.expect(re.compile(r'(?:[\s\S]*)IPv4 address: (\d+.\d+.\d+.\d+)'), timeout=30)[0]
|
got_ip = dut1.expect(re.compile(r'(?:[\s\S]*)IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]'), timeout=30)[0]
|
||||||
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Starting server on port: '(\d+)'"), timeout=30)[0]
|
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Starting server on port: '(\d+)'"), timeout=30)[0]
|
||||||
|
|
||||||
Utility.console_log('Got IP : ' + got_ip)
|
Utility.console_log('Got IP : ' + got_ip)
|
||||||
|
@ -78,7 +78,7 @@ def test_examples_protocol_http_server_simple(env, extra_data):
|
|||||||
|
|
||||||
# Parse IP address of STA
|
# Parse IP address of STA
|
||||||
Utility.console_log('Waiting to connect with AP')
|
Utility.console_log('Waiting to connect with AP')
|
||||||
got_ip = dut1.expect(re.compile(r'(?:[\s\S]*)IPv4 address: (\d+.\d+.\d+.\d+)'), timeout=30)[0]
|
got_ip = dut1.expect(re.compile(r'(?:[\s\S]*)IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]'), timeout=30)[0]
|
||||||
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Starting server on port: '(\d+)'"), timeout=30)[0]
|
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Starting server on port: '(\d+)'"), timeout=30)[0]
|
||||||
|
|
||||||
Utility.console_log('Got IP : ' + got_ip)
|
Utility.console_log('Got IP : ' + got_ip)
|
||||||
|
@ -63,7 +63,7 @@ def test_examples_protocol_http_ws_echo_server(env, extra_data):
|
|||||||
|
|
||||||
# Parse IP address of STA
|
# Parse IP address of STA
|
||||||
Utility.console_log('Waiting to connect with AP')
|
Utility.console_log('Waiting to connect with AP')
|
||||||
got_ip = dut1.expect(re.compile(r'IPv4 address: (\d+.\d+.\d+.\d+)'), timeout=60)[0]
|
got_ip = dut1.expect(re.compile(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]'), timeout=60)[0]
|
||||||
got_port = dut1.expect(re.compile(r"Starting server on port: '(\d+)'"), timeout=60)[0]
|
got_port = dut1.expect(re.compile(r"Starting server on port: '(\d+)'"), timeout=60)[0]
|
||||||
|
|
||||||
Utility.console_log('Got IP : ' + got_ip)
|
Utility.console_log('Got IP : ' + got_ip)
|
||||||
|
@ -106,11 +106,11 @@ def test_examples_protocol_https_server_simple(env, extra_data): # type: (tiny_
|
|||||||
# start test
|
# start test
|
||||||
dut1.start_app()
|
dut1.start_app()
|
||||||
# Parse IP address and port of the server
|
# Parse IP address and port of the server
|
||||||
dut1.expect(re.compile(r'Starting server'))
|
dut1.expect(re.compile(r'Starting server'), timeout=60)
|
||||||
got_port = dut1.expect(re.compile(r'Server listening on port (\d+)'), timeout=30)[0]
|
got_port = dut1.expect(re.compile(r'Server listening on port (\d+)[^\d]'), timeout=30)[0]
|
||||||
Utility.console_log('Waiting to connect with AP')
|
Utility.console_log('Waiting to connect with AP')
|
||||||
|
|
||||||
got_ip = dut1.expect(re.compile(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)'), timeout=30)[0]
|
got_ip = dut1.expect(re.compile(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]'), timeout=30)[0]
|
||||||
# Expected logs
|
# Expected logs
|
||||||
|
|
||||||
Utility.console_log('Got IP : ' + got_ip)
|
Utility.console_log('Got IP : ' + got_ip)
|
||||||
|
@ -133,9 +133,9 @@ def test_examples_protocol_https_wss_server(env, extra_data): # type: (tiny_tes
|
|||||||
dut1.start_app()
|
dut1.start_app()
|
||||||
|
|
||||||
# Parse IP address of STA
|
# Parse IP address of STA
|
||||||
got_port = dut1.expect(re.compile(r'Server listening on port (\d+)'), timeout=60)[0]
|
got_port = dut1.expect(re.compile(r'Server listening on port (\d+)[^\d]'), timeout=60)[0]
|
||||||
Utility.console_log('Waiting to connect with AP')
|
Utility.console_log('Waiting to connect with AP')
|
||||||
got_ip = dut1.expect(re.compile(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)'), timeout=60)[0]
|
got_ip = dut1.expect(re.compile(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]'), timeout=60)[0]
|
||||||
|
|
||||||
Utility.console_log('Got IP : ' + got_ip)
|
Utility.console_log('Got IP : ' + got_ip)
|
||||||
Utility.console_log('Got Port : ' + got_port)
|
Utility.console_log('Got Port : ' + got_port)
|
||||||
|
@ -12,7 +12,7 @@ def test_examples_icmp_echo(env, extra_data):
|
|||||||
dut = env.get_dut('icmp_echo', 'examples/protocols/icmp_echo')
|
dut = env.get_dut('icmp_echo', 'examples/protocols/icmp_echo')
|
||||||
dut.start_app()
|
dut.start_app()
|
||||||
|
|
||||||
dut.expect('example_connect: Connected to')
|
dut.expect('example_connect: Connected to', timeout=60)
|
||||||
dut.expect('esp>')
|
dut.expect('esp>')
|
||||||
|
|
||||||
ping_dest = os.getenv('EXAMPLE_ICMP_SERVER', 'www.espressif.com')
|
ping_dest = os.getenv('EXAMPLE_ICMP_SERVER', 'www.espressif.com')
|
||||||
|
@ -68,6 +68,7 @@ def test_examples_protocol_socket_tcpserver(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('Socket listening')
|
||||||
|
|
||||||
# test IPv4
|
# test IPv4
|
||||||
received = tcp_client(ipv4, MESSAGE)
|
received = tcp_client(ipv4, MESSAGE)
|
||||||
|
@ -17,6 +17,7 @@ from threading import Event, Thread
|
|||||||
|
|
||||||
import netifaces
|
import netifaces
|
||||||
import ttfw_idf
|
import ttfw_idf
|
||||||
|
from tiny_test_fw.DUT import ExpectTimeout
|
||||||
|
|
||||||
# ----------- Config ----------
|
# ----------- Config ----------
|
||||||
PORT = 3333
|
PORT = 3333
|
||||||
@ -104,14 +105,28 @@ def test_examples_protocol_socket_udpclient(env, extra_data):
|
|||||||
with UdpServer(PORT, socket.AF_INET):
|
with UdpServer(PORT, socket.AF_INET):
|
||||||
server_ip = get_my_ip(netifaces.AF_INET)
|
server_ip = get_my_ip(netifaces.AF_INET)
|
||||||
print('Connect udp client to server IP={}'.format(server_ip))
|
print('Connect udp client to server IP={}'.format(server_ip))
|
||||||
dut1.write(server_ip)
|
for _ in range(3):
|
||||||
dut1.expect(re.compile(r'OK: Message from ESP32'))
|
try:
|
||||||
|
dut1.write(server_ip)
|
||||||
|
dut1.expect(re.compile(r'OK: Message from ESP32'))
|
||||||
|
break
|
||||||
|
except ExpectTimeout:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise ValueError('Failed to send/recv udp packets.')
|
||||||
# test IPv6
|
# test IPv6
|
||||||
with UdpServer(PORT, socket.AF_INET6):
|
with UdpServer(PORT, socket.AF_INET6):
|
||||||
server_ip = get_my_ip(netifaces.AF_INET6)
|
server_ip = get_my_ip(netifaces.AF_INET6)
|
||||||
print('Connect udp client to server IP={}'.format(server_ip))
|
print('Connect udp client to server IP={}'.format(server_ip))
|
||||||
dut1.write(server_ip)
|
for _ in range(3):
|
||||||
dut1.expect(re.compile(r'OK: Message from ESP32'))
|
try:
|
||||||
|
dut1.write(server_ip)
|
||||||
|
dut1.expect(re.compile(r'OK: Message from ESP32'))
|
||||||
|
break
|
||||||
|
except ExpectTimeout:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise ValueError('Failed to send/recv udp packets.')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user