Skip to content

Commit 34c9084

Browse files
authored
Merge pull request #21677 from mguetschow/tests-printf-p
tests: accept %p printing in uppercase and without leading 0x
2 parents 480ed83 + 4767b98 commit 34c9084

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

tests/core/msg_queue_print/tests/01-run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def expect_some(child, size, avail, range_start):
4141

4242
def expect_content(child, counter):
4343
if counter == 0:
44-
if os.environ.get('BOARD') in ['native', 'native32', 'native64']:
45-
child.expect_exact('type: 0x0000, content: 0 ((nil))')
46-
else:
47-
child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)')
44+
child.expect(r'type: 0x0000, content: 0 \(\(nil\)|(0x)?0+\)')
4845
else:
49-
child.expect_exact(f'type: 0x{counter:04x}, content: {counter} (0x{counter:x})')
46+
child.expect(r'type: (0x[a-fA-F0-9]+), content: (\d+) \(((0x)?[a-fA-Z0-9]+)\)')
47+
assert int(child.match.group(1), 16) == counter, f"Expected {counter:x} as type, got child.match.group(1)"
48+
assert int(child.match.group(2)) == counter, f"Expected {counter} as content, got child.match.group(2)"
49+
assert int(child.match.group(3), 16) == counter, f"Expected {counter:x} as ptr, got child.match.group(3)"
5050

5151

5252
def testfunc(child):

tests/net/gnrc_ipv6_fwd_w_sub/tests/01-run.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ def testfunc(child):
3131
child.expect(r"00000020 55 44 33 FF FE 22 11 00 54 B8 59 AF 3A B4 5C 85")
3232
child.expect(r"00000030 1E CE E2 EB 05 4E A3 85")
3333
child.sendline("pktbuf")
34-
child.expect(r"packet buffer: first byte: (0x[0-9a-fA-F]+), "
35-
r"last byte: 0x[0-9a-fA-F]+ \(size: (\d+)\)")
34+
child.expect(r"packet buffer: first byte: ((0x)?[0-9a-fA-F]+), "
35+
r"last byte: (0x)?[0-9a-fA-F]+ \(size: (\d+)\)")
3636
start_addr = child.match.group(1)
37-
size = child.match.group(2)
37+
size = child.match.group(4)
38+
print(start_addr, size)
3839
child.expect(r" position of last byte used: \d+")
3940
child.expect(r"~ unused: {} \(next: (\(nil\)|0(x0+)?), size: +{}\) ~"
4041
.format(start_addr, size))

tests/riotboot/tests/01-run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def check_current_slot_and_app_ver(self, child):
6666
# Ask for data of all slots
6767
child.expect_exact('>')
6868
child.sendline("dumpaddrs")
69-
child.expect(r"slot 0: metadata: 0x[0-9a-fA-F]{1,8} "
69+
child.expect(r"slot 0: metadata: (0x)?[0-9a-fA-F]{1,8} "
7070
r"image: 0x[0-9a-fA-F]{8}\r\n")
71-
child.expect(r"slot 1: metadata: 0x[0-9a-fA-F]{1,8} "
71+
child.expect(r"slot 1: metadata: (0x)?[0-9a-fA-F]{1,8} "
7272
r"image: 0x[0-9a-fA-F]{8}\r\n")
7373
child.expect_exact('>')
7474

tests/sys/heap_cmd/tests/01-run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ def testfunc(child):
1717
if ret == 1:
1818
return
1919
child.sendline('malloc 100')
20-
child.expect('allocated 0x')
20+
child.expect('allocated (0x)?')
2121
addr = child.readline()
2222
addr = addr[:-2]
2323
child.expect_exact('> ')
2424
child.sendline('heap')
2525
child.expect(r'heap: \d+ \(used \d+, free \d+\) \[bytes\]')
2626
child.sendline('free 0x' + addr)
27-
child.expect('freeing 0x' + addr)
27+
child.expect('freeing (0x)?' + addr)
2828
child.expect_exact('>')
2929
child.sendline('heap')
3030
child.expect(r'heap: \d+ \(used \d+, free \d+\) \[bytes\]')

tests/sys/malloc/tests/01-run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def testfunc(child):
2222
number_of_tests = int(child.match.group(1))
2323
initial_allocations = 0
2424
for _ in range(number_of_tests):
25-
child.expect(r"Allocated {} Bytes at 0x[a-z0-9]+, total [a-z0-9]+\r\n"
25+
child.expect(r"Allocated {} Bytes at (0x)?[a-z0-9]+, total [a-z0-9]+\r\n"
2626
.format(chunk_size))
2727
child.expect(r'Allocations count: (\d+)\r\n',
2828
timeout=ALLOCATION_TIMEOUT)
@@ -31,7 +31,7 @@ def testfunc(child):
3131
if initial_allocations == 0:
3232
initial_allocations = allocations
3333
assert initial_allocations == allocations
34-
child.expect(r"Free {} Bytes at 0x[a-z0-9]+, total [a-z0-9]+\r\n"
34+
child.expect(r"Free {} Bytes at (0x)?[a-z0-9]+, total [a-z0-9]+\r\n"
3535
.format(chunk_size))
3636
child.expect(r'Free count: (\d+)\r\n', timeout=FREE_TIMEOUT)
3737
freed = int(child.match.group(1))

tests/sys/memarray/tests/01-run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def testfunc(child):
2222
for test in range(number_of_tests):
2323
child.expect_exact("TEST #{}:".format(test + 1))
2424
for i in range(max_number_blocks):
25-
child.expect(r'\({}, @@@@@@@\) Allocated \d+ Bytes at 0x[a-z0-9]+,'
25+
child.expect(r'\({}, @@@@@@@\) Allocated \d+ Bytes at (0x)?[a-zA-Z0-9]+,'
2626
r' total [0-9]+\r\n'.format(i))
2727
for i in range(max_number_blocks):
28-
child.expect(r'Free \({}\) \d+ Bytes at 0x[a-z0-9]+,'
28+
child.expect(r'Free \({}\) \d+ Bytes at (0x)?[a-zA-Z0-9]+,'
2929
' total [0-9]+\r\n'.format(i))
3030

3131
child.expect_exact("Extend and reduce tests")

0 commit comments

Comments
 (0)