Skip to content

tests/periph/selftest_shield: Improve error output#20101

Merged
maribu merged 3 commits intoRIOT-OS:masterfrom
maribu:tests/periph/selftest_shield
Nov 22, 2023
Merged

tests/periph/selftest_shield: Improve error output#20101
maribu merged 3 commits intoRIOT-OS:masterfrom
maribu:tests/periph/selftest_shield

Conversation

@maribu
Copy link
Copy Markdown
Member

@maribu maribu commented Nov 22, 2023

Contribution description

While debugging the I2C bug on STM32F1, I found the output of the test application lacking. This addresses this by using tiny_strerror() to print the error codes indicating what went wrong (not only for pcf857x, but for every other initialization call as well).

In order to make use of this, the pcf857x driver was updated to return negative errno codes. This also as the advantage to provide more details on what specifically went wrong when the I2C communication fails, rather than just a single I2C error code.

Testing procedure

Run the test on a board without the peripheral selftest shield attach. Upon initialization of the PCF587x chip the test should fail with a meaningful error message.

 ~/Repos/software/RIOT/master/tests/periph/selftest_shield % make BOARD=nucleo-l152re flash test-with-config -j
[...]
/home/maribu/Repos/software/RIOT/master/dist/tools/pyterm/pyterm -p "/dev/ttyACM1" -b "115200" --no-reconnect --noprefix --no-repeat-command-on-empty-line 
Connect to serial port /dev/ttyACM1
Welcome to pyterm!
Type '/exit' to exit.
READY
s
START
main(): This is RIOT! (Version: 2023.10-devel-560-g68a4f-tests/periph/selftest_shield)
self-testing peripheral drivers
===============================
ERROR in tests/periph/selftest_shield/main.c:1064 with code -ENXIO
Timeout in expect script at "child.expect("ALL TESTS SUCCEEDED")" (tests/periph/selftest_shield/tests-with-config/01-run.py:17)

make: *** [/home/maribu/Repos/software/RIOT/master/makefiles/tests/tests.inc.mk:70: test-with-config] Error 1

Issues/PRs references

None

This makes it easier to use common error reporting such as `strerror()`
or `tiny_strerror()` to give more insight on why something failed.

The custom error codes via `enum` have been updated to be synonymous
with the `errno` codes for backward compatibility.

In addition, `pcf857x_init()` has been updated to no longer or
together the return code, but rather abort on the first fail transaction
and return the error code as is. Otherwise (when both fail due to
different error codes) the returned error code may be garbage.
Use `tiny_strerror()` to report back errors when calling initialization
functions.
@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: tests Area: tests and testing framework Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 22, 2023
@maribu maribu force-pushed the tests/periph/selftest_shield branch from 6349ac1 to fb9abe3 Compare November 22, 2023 09:31
@riot-ci
Copy link
Copy Markdown

riot-ci commented Nov 22, 2023

Murdock results

✔️ PASSED

fb9abe3 tests/periph/selftest_shield: fix a misplaced comment

Success Failures Total Runtime
7957 0 7957 10m:42s

Artifacts

@maribu maribu added this pull request to the merge queue Nov 22, 2023
Merged via the queue into RIOT-OS:master with commit 8d8bd82 Nov 22, 2023
@maribu maribu deleted the tests/periph/selftest_shield branch November 22, 2023 16:26
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Nov 22, 2023

Thx :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers 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 Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants