Skip to content

tests: accept %p printing in uppercase and without leading 0x#21677

Merged
maribu merged 2 commits intoRIOT-OS:masterfrom
mguetschow:tests-printf-p
Aug 25, 2025
Merged

tests: accept %p printing in uppercase and without leading 0x#21677
maribu merged 2 commits intoRIOT-OS:masterfrom
mguetschow:tests-printf-p

Conversation

@mguetschow
Copy link
Copy Markdown
Contributor

Contribution description

The output of the specifier %p is implementation defined, and mpaland-printf gives something different than newlib. Be less strict in what the tests expect.

Testing procedure

Build and run any of the changed tests on a board now pulling mpaland-printf. Notice that they fail on master and not with these changes.

Issues/PRs references

Should fix the failing nightlies after #21438

@mguetschow mguetschow requested review from maribu and removed request for MichelRottleuthner, aabadie, leandrolanzieri and miri64 August 22, 2025 09:22
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Aug 22, 2025
@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Aug 22, 2025
child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)')
else:
child.expect_exact(f'type: 0x{counter:04x}, content: {counter} (0x{counter:x})')
child.expect(f'type: 0x{counter:04x}, content: {counter} \((0x)?0*{counter:x}\)')
Copy link
Copy Markdown
Member

@maribu maribu Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still not pass with mpaland-printf, as it also uses "(nil)" like glibc does on NULL.

The following would pass:

diff --git a/tests/core/msg_queue_print/tests/01-run.py b/tests/core/msg_queue_print/tests/01-run.py
index a03118d268..f78b50870e 100755
--- a/tests/core/msg_queue_print/tests/01-run.py
+++ b/tests/core/msg_queue_print/tests/01-run.py
@@ -41,12 +41,12 @@ def expect_some(child, size, avail, range_start):
 
 def expect_content(child, counter):
     if counter == 0:
-        if os.environ.get('BOARD') in ['native', 'native32', 'native64']:
-            child.expect_exact('type: 0x0000, content: 0 ((nil))')
-        else:
-            child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)')
+        child.expect(r'type: 0x0000, content: 0 \((\(nil\)|0x0+\))')
     else:
-        child.expect_exact(f'type: 0x{counter:04x}, content: {counter} (0x{counter:x})')
+        child.expect(r'type: ((0x)?[a-fA-F0-9]+), content: (\d+) \(((0x)?[a-fA-Z0-9]+)\)')
+        assert int(child.match.group(1), 16) == counter, f"Expected {counter:x} as type, got child.match.group(1)"
+        assert int(child.match.group(2)) == counter, f"Expected {counter} as content, got child.match.group(2)"
+        assert int(child.match.group(3), 16) == counter, f"Expected {counter:x} as ptr, got child.match.group(3)"
 
 
 def testfunc(child):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's only true after applying the patch in #21678

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I updated the patch above, I think would now work for all ways to do %p.

@riot-ci
Copy link
Copy Markdown

riot-ci commented Aug 22, 2025

Murdock results

✔️ PASSED

4767b98 tests/core/msg_queue_print: accept (nil) instead of 0x0+ for all boards

Success Failures Total Runtime
189 0 189 03m:11s

Artifacts

the output of the specifier %p is implementation defined, and mpaland-printf gives something different than newlib
@crasbe crasbe added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Aug 25, 2025
@mguetschow
Copy link
Copy Markdown
Contributor Author

Ready from my side, should still fix the remaining failing nightly.

@maribu maribu added this pull request to the merge queue Aug 25, 2025
Merged via the queue into RIOT-OS:master with commit 34c9084 Aug 25, 2025
26 checks passed
@mguetschow mguetschow deleted the tests-printf-p branch August 25, 2025 10:55
@benpicco benpicco added this to the Release 2025.10 milestone Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants