mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: expect match \r\n or \s
- Since `printf()` is buffered it might not arrive in a single read to pexpect. Regex which terminate in a group match might match only some elements, this might break tests that depend on exact group matching.
This commit is contained in:
parent
bf676d4728
commit
3db9eab6d9
@ -119,7 +119,7 @@ def testfunc(child):
|
||||
|
||||
# get version of currently running image
|
||||
# "Image Version: 0x00000000"
|
||||
child.expect(r"Image Version: (?P<app_ver>0x[0-9a-fA-F:]+)")
|
||||
child.expect(r"Image Version: (?P<app_ver>0x[0-9a-fA-F:]+)\r\n")
|
||||
current_app_ver = int(child.match.group("app_ver"), 16)
|
||||
|
||||
for version in [current_app_ver + 1, current_app_ver + 2]:
|
||||
@ -139,7 +139,7 @@ def testfunc(child):
|
||||
child.expect_exact("suit_coap: trigger received")
|
||||
child.expect_exact("suit: verifying manifest signature...")
|
||||
child.expect(
|
||||
r"riotboot_flashwrite: initializing update to target slot (\d+)",
|
||||
r"riotboot_flashwrite: initializing update to target slot (\d+)\r\n",
|
||||
timeout=MANIFEST_TIMEOUT,
|
||||
)
|
||||
target_slot = int(child.match.group(1))
|
||||
@ -148,7 +148,7 @@ def testfunc(child):
|
||||
pass
|
||||
|
||||
# Verify running slot
|
||||
child.expect(r"running from slot (\d+)")
|
||||
child.expect(r"running from slot (\d+)\r\n")
|
||||
assert target_slot == int(child.match.group(1)), "BOOTED FROM SAME SLOT"
|
||||
|
||||
print("TEST PASSED")
|
||||
|
@ -595,9 +595,9 @@ def testfunc(child):
|
||||
|
||||
lladdr_src = get_host_lladdr(tap)
|
||||
child.sendline("ifconfig")
|
||||
child.expect("HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)")
|
||||
child.expect(r"HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)\s")
|
||||
hwaddr_dst = child.match.group("hwaddr").lower()
|
||||
child.expect("(?P<lladdr>fe80::[A-Fa-f:0-9]+)")
|
||||
child.expect(r"(?P<lladdr>fe80::[A-Fa-f:0-9]+)\s")
|
||||
lladdr_dst = child.match.group("lladdr").lower()
|
||||
|
||||
def run(func):
|
||||
|
@ -260,7 +260,7 @@ def _fwd_setup(child, ll_dst, g_src, g_dst):
|
||||
child.expect(r"fe80::1 dev #7 lladdr\s+-")
|
||||
# get TAP MAC address
|
||||
child.sendline("ifconfig 6")
|
||||
child.expect("HWaddr: ([0-9A-F:]+)")
|
||||
child.expect(r"HWaddr: ([0-9A-F:]+)\s")
|
||||
hwaddr = child.match.group(1)
|
||||
# consume MTU for later calls of `ifconfig 7`
|
||||
child.expect(r"MTU:(\d+)")
|
||||
@ -337,7 +337,7 @@ def testfunc(child):
|
||||
print("FAILED")
|
||||
raise e
|
||||
|
||||
child.expect(r"Sending UDP test packets to port (\d+)")
|
||||
child.expect(r"Sending UDP test packets to port (\d+)\r\n")
|
||||
|
||||
port = int(child.match.group(1))
|
||||
with socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) as s:
|
||||
@ -368,7 +368,7 @@ def testfunc(child):
|
||||
# link-local address becomes valid
|
||||
time.sleep(1)
|
||||
child.sendline("ifconfig")
|
||||
child.expect("HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)")
|
||||
child.expect(r"HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)\s")
|
||||
hwaddr_dst = child.match.group("hwaddr").lower()
|
||||
res = child.expect([
|
||||
r"(?P<lladdr>fe80::[A-Fa-f:0-9]+)\s+scope:\s+link\s+VAL",
|
||||
|
@ -19,7 +19,7 @@ ZEP_V2_TYPE_DATA = 1
|
||||
def testfunc(child):
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
s.bind(("", 17754))
|
||||
child.expect("l2_addr: ([0-9A-F:]+)")
|
||||
child.expect(r"l2_addr: ([0-9A-F:]+)\r\n")
|
||||
dst = int(child.match.group(1).replace(':', ''), base=16)
|
||||
|
||||
# first send valid packet to check if communication is set up correctly
|
||||
|
@ -143,7 +143,7 @@ def unregister(child):
|
||||
|
||||
def get_first_interface(child):
|
||||
child.sendline("ifconfig")
|
||||
child.expect(r"Iface\s+(\d+)")
|
||||
child.expect(r"Iface\s+(\d+)\s")
|
||||
return int(child.match.group(1))
|
||||
|
||||
|
||||
@ -342,9 +342,9 @@ def testfunc(child):
|
||||
print("." * int(child.match.group(1)), end="", flush=True)
|
||||
lladdr_src = get_host_lladdr(tap)
|
||||
child.sendline("ifconfig")
|
||||
child.expect("HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)")
|
||||
child.expect(r"HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)\s")
|
||||
hwaddr_dst = child.match.group("hwaddr").lower()
|
||||
child.expect("(?P<lladdr>fe80::[A-Fa-f:0-9]+)")
|
||||
child.expect(r"(?P<lladdr>fe80::[A-Fa-f:0-9]+)\s")
|
||||
lladdr_dst = child.match.group("lladdr").lower()
|
||||
sniffer = Sniffer(tap)
|
||||
sniffer.start()
|
||||
|
@ -35,7 +35,7 @@ def testfunc(func):
|
||||
child.sendline('gnrc_tcp_open_passive AF_INET6 {}'.format(port))
|
||||
child.expect(r'gnrc_tcp_open_passive: argc=3, '
|
||||
r'argv\[0\] = gnrc_tcp_open_passive, '
|
||||
r'argv\[1\] = AF_INET6, argv\[2\] = (\d+)')
|
||||
r'argv\[1\] = AF_INET6, argv\[2\] = (\d+)\r\n')
|
||||
assert int(child.match.group(1)) == port
|
||||
|
||||
try:
|
||||
|
@ -58,26 +58,26 @@ def get_host_ll_addr(interface):
|
||||
|
||||
def get_riot_l2_addr(child):
|
||||
child.sendline('ifconfig')
|
||||
child.expect('HWaddr: ([A-F-a-f0-9:]+)')
|
||||
child.expect(r'HWaddr: ([A-F-a-f0-9:]+)\s')
|
||||
return child.match.group(1)
|
||||
|
||||
|
||||
def get_riot_ll_addr(child):
|
||||
child.sendline('ifconfig')
|
||||
child.expect('(fe80:[0-9a-f:]+)')
|
||||
child.expect(r'(fe80:[0-9a-f:]+)\s')
|
||||
return child.match.group(1).strip()
|
||||
|
||||
|
||||
def get_riot_if_id(child):
|
||||
child.sendline('ifconfig')
|
||||
child.expect(r'Iface\s+(\d+)')
|
||||
child.expect(r'Iface\s+(\d+)\s')
|
||||
return child.match.group(1).strip()
|
||||
|
||||
|
||||
def setup_internal_buffer(child):
|
||||
child.sendline('buffer_init')
|
||||
child.sendline('buffer_get_max_size')
|
||||
child.expect(r'returns (\d+)')
|
||||
child.expect(r'returns (\d+)\s')
|
||||
return int(child.match.group(1).strip())
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@ class TestStrategy(ApplicationStrategy):
|
||||
|
||||
def get_ipv6_address(spawn):
|
||||
spawn.sendline(u"ifconfig")
|
||||
spawn.expect(u"[A-Za-z0-9]{2}_[0-9]+: inet6 (fe80::[0-9a-f:]+)")
|
||||
spawn.expect(r"[A-Za-z0-9]{2}_[0-9]+: inet6 (fe80::[0-9a-f:]+)\s")
|
||||
return spawn.match.group(1)
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ def _ipv4_tests(code):
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect(u"code (0x[0-9a-f]{2})")
|
||||
child.expect(r"code (0x[0-9a-f]{2}\s)")
|
||||
code = int(child.match.group(1), base=16)
|
||||
if _ipv4_tests(code):
|
||||
child.expect_exact(u"Calling test_sock_ip_create4__EAFNOSUPPORT()")
|
||||
|
@ -23,7 +23,7 @@ def _ipv4_tests(code):
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect(u"code (0x[0-9a-f]{2})")
|
||||
child.expect(r"code (0x[0-9a-f]{2}\s)")
|
||||
code = int(child.match.group(1), base=16)
|
||||
if _ipv4_tests(code):
|
||||
if _reuse_tests(code):
|
||||
|
@ -23,7 +23,7 @@ def _ipv4_tests(code):
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect(u"code (0x[0-9a-f]{2})")
|
||||
child.expect(r"code (0x[0-9a-f]{2})\s")
|
||||
code = int(child.match.group(1), base=16)
|
||||
if _ipv4_tests(code):
|
||||
if _reuse_tests(code):
|
||||
|
@ -13,7 +13,7 @@ from testrunner import run
|
||||
def testfunc(child):
|
||||
child.expect_exact('Test for the CPUID driver')
|
||||
child.expect_exact('This test is reading out the CPUID of the platforms CPU')
|
||||
child.expect(r'CPUID_LEN: (\d+)')
|
||||
child.expect(r'CPUID_LEN: (\d+)\r\n')
|
||||
cpuid_len = int(child.match.group(1))
|
||||
child.expect(r'CPUID:( 0x[0-9a-fA-F]{2})+\s*\r\n')
|
||||
assert child.match.group(0).count(' 0x') == cpuid_len
|
||||
|
@ -11,7 +11,7 @@ from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect(r'Available timers: (\d+)')
|
||||
child.expect(r'Available timers: (\d+)\r\n')
|
||||
timers_num = int(child.match.group(1))
|
||||
for timer in range(timers_num):
|
||||
child.expect_exact('Testing TIMER_{}'.format(timer))
|
||||
|
@ -38,7 +38,7 @@ def get_reset_time(child):
|
||||
|
||||
def testfunc(child):
|
||||
child.sendline("range")
|
||||
child.expect(r"lower_bound: (\d+) upper_bound: (\d+)",
|
||||
child.expect(r"lower_bound: (\d+) upper_bound: (\d+)\s*\r\n",
|
||||
timeout=1)
|
||||
wdt_lower_bound = int(child.match.group(1))
|
||||
wdt_upper_bound = int(child.match.group(2))
|
||||
|
@ -5,28 +5,28 @@ from testrunner import run, test_utils_interactive_sync
|
||||
|
||||
|
||||
def expect_unary(child):
|
||||
child.expect(r'COUNT: (\d+)')
|
||||
child.expect(r'COUNT: (\d+)\r\n')
|
||||
count = int(child.match.group(1))
|
||||
assert count > 0
|
||||
for _ in range(count):
|
||||
for op_name in ('abs', 'sq', 'atan', 'exp'):
|
||||
child.expect(r'{}\(-?\d+\.\d+\) = -?\d+\.\d+'.format(op_name))
|
||||
|
||||
child.expect(r'COUNT: (\d+)')
|
||||
child.expect(r'COUNT: (\d+)\r\n')
|
||||
count = int(child.match.group(1))
|
||||
assert count > 0
|
||||
for _ in range(count):
|
||||
for op_name in ('sin', 'cos', 'tan'):
|
||||
child.expect(r'{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name))
|
||||
|
||||
child.expect(r'COUNT: (\d+)')
|
||||
child.expect(r'COUNT: (\d+)\r\n')
|
||||
count = int(child.match.group(1))
|
||||
assert count > 0
|
||||
for _ in range(count):
|
||||
for op_name in ('asin', 'acos'):
|
||||
child.expect(r'{}\(-?\d+.\d+\) = -?\d+.\d+'.format(op_name))
|
||||
|
||||
child.expect(r'COUNT: (\d+)')
|
||||
child.expect(r'COUNT: (\d+)\r\n')
|
||||
count = int(child.match.group(1))
|
||||
assert count > 0
|
||||
for _ in range(count):
|
||||
@ -35,7 +35,7 @@ def expect_unary(child):
|
||||
|
||||
|
||||
def expect_binary(child):
|
||||
child.expect(r'COUNT: (\d+)')
|
||||
child.expect(r'COUNT: (\d+)\r\n')
|
||||
count = int(child.match.group(1))
|
||||
assert count > 0
|
||||
for _ in range(count):
|
||||
|
@ -5,7 +5,7 @@ from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)')
|
||||
child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)\r\n')
|
||||
children = int(child.match.group(1))
|
||||
iterations = int(child.match.group(2))
|
||||
for i in range(children):
|
||||
|
@ -11,10 +11,10 @@ from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect(r"TRACE_SIZE: (\d+)")
|
||||
child.expect(r"TRACE_SIZE: (\d+)\r\n")
|
||||
trace_size = int(child.match.group(1))
|
||||
for i in range(trace_size):
|
||||
child.expect("0x[0-9a-f]{7,8}")
|
||||
child.expect(r"0x[0-9a-f]{7,8}")
|
||||
|
||||
print("All tests successful")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user