Преглед на файлове

socket examples: fix random ci failure on reading ipv6 address

dut.expect() returns groups of a matching regex, but could be truncated upon reading/buffering. fixed by forcing expect to acquire exactly 8 octets of IPv6 address, i.e. not supporting short-handed entries such as fe80::0000..
David Cermak преди 5 години
родител
ревизия
5f4e2cf391
променени са 2 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 2 1
      examples/protocols/sockets/tcp_server/example_test.py
  2. 2 1
      examples/protocols/sockets/udp_server/example_test.py

+ 2 - 1
examples/protocols/sockets/tcp_server/example_test.py

@@ -65,7 +65,8 @@ def test_examples_protocol_socket(env, extra_data):
     dut1.start_app()
 
     ipv4 = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30)[0]
-    ipv6 = dut1.expect(re.compile(r" IPv6 address: ([0-9A-Fa-f\:]+)"), timeout=30)[0]
+    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))
 
     # test IPv4

+ 2 - 1
examples/protocols/sockets/udp_server/example_test.py

@@ -63,7 +63,8 @@ def test_examples_protocol_socket(env, extra_data):
     dut1.start_app()
 
     ipv4 = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30)[0]
-    ipv6 = dut1.expect(re.compile(r" IPv6 address: ([0-9A-Fa-f\:]+)"), timeout=30)[0]
+    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))
 
     # test IPv4