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: Fix issue with modules #64401

Merged
merged 2 commits into from
Oct 27, 2023
Merged

Conversation

ceolin
Copy link
Member

@ceolin ceolin commented Oct 25, 2023

Unit tests may use zephyr modules, so we need to run zephyr_module.py

jeremybettis
jeremybettis previously approved these changes Oct 25, 2023
@aescolar aescolar requested a review from Thalley October 26, 2023 07:08
Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

Thanks for providing a fix, but please include the west CMake module in addition to the zephyr_module CMake module.

Loading those two module should give you the desired behavior.

Comment on lines 55 to 57
# Unittest may use modules too, we need to execute zephyr_module to
# generate ZEPHYR_*_MODULE for existent modules.
if(WEST OR ZEPHYR_MODULES OR UNITTEST)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert.

Modules can either be provided through west (if installed) or the CMake variable ZEPHYR_MODULES.
Simply testing for UNITTEST doesn't ensure that code below is only executed when west is installed or ZEPHYR_MODULES is defined.

Instead you must ensure WEST and thus Zephyr modules are picked up through west (if not defined directly).
That is, the following line must be added here instead:

include(west)
Suggested change
# Unittest may use modules too, we need to execute zephyr_module to
# generate ZEPHYR_*_MODULE for existent modules.
if(WEST OR ZEPHYR_MODULES OR UNITTEST)
if(WEST OR ZEPHYR_MODULES)

Copy link
Member Author

Choose a reason for hiding this comment

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

Including west will just be used to define WEST variable and consequently having this block executed ...
Anyway, I have may missed something else. will change it since the change will become simpler.

Comment on lines 9 to 10

set(UNITTEST ON CACHE INTERNAL BOOL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
set(UNITTEST ON CACHE INTERNAL BOOL)

Flavio Ceolin added 2 commits October 26, 2023 13:01
Generate ZEPHYR_{MODULE_NAME}_MODULE for existent modules
for unittests as well since they may be using Zephyr modules.

Fixes: 64348

Signed-off-by: Flavio Ceolin <[email protected]>
…able""

This reverts commit 572491a.

Signed-off-by: Flavio Ceolin <[email protected]>
Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Approving on behalf of @tejlmand

@nordicjm nordicjm dismissed tejlmand’s stale review October 27, 2023 07:58

Changes addressed

@MaureenHelm MaureenHelm merged commit e57e7f2 into zephyrproject-rtos:main Oct 27, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZEPHYR_{MODULE_NAME}_MODULE not defined for unit tests
7 participants