Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest: add COMPILER_WARNINGS_AS_ERRORS handling #82928

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

fabiobaltieri
Copy link
Member

Add a check to set the warnings_as_errors flags in unit tests if CONFIG_COMPILER_WARNINGS_AS_ERRORS is specified, this should catch warnings in unit test twister runs.

kartben
kartben previously approved these changes Dec 12, 2024
Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

Very nice, thanks for this!

subsys/bluetooth/host/conn.c Outdated Show resolved Hide resolved
tests/bluetooth/audio/codec/src/main.c Outdated Show resolved Hide resolved
tests/unit/pot/nhpot.cpp Outdated Show resolved Hide resolved
Comment on lines 11 to 13
#ifndef ZTEST_UNITTEST
#include <zephyr/devicetree.h>
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make more sense to have this #ifndef inside the devicetree.h file itself, so that not everybody who wants to include it needs to know of this exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah not liking that either, but hey seems like that override was only needed on the linker file itself, I added a couple of undef for those at the end of the file and that seems to work, so that crappy hack is self contained at least.

Undefine the DT_NODE_HAS_STATUS and DT_NODE_HAS_STATUS_OKAY no nop at
the end of the file so other uses can include devicetree.h without
generating a compiler warning.

Signed-off-by: Fabio Baltieri <[email protected]>
Fix various unit test build warnings, unused variables, set but unused
variables, wrong types etc...

Signed-off-by: Fabio Baltieri <[email protected]>
This flag is set on other compiler as well for normal builds, and
suppresses a warning for empty print, which is apparently quite common.

The unit test build uses its own flags so set it there as well to get
the same behavior as with the rest of the code base.

Signed-off-by: Fabio Baltieri <[email protected]>
Add a check to set the warnings_as_errors flags in unit tests if
CONFIG_COMPILER_WARNINGS_AS_ERRORS is specified, this should catch
warnings in unit test twister runs.

Signed-off-by: Fabio Baltieri <[email protected]>
@kartben kartben merged commit e9b8689 into zephyrproject-rtos:main Dec 16, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants