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 mock improvement and reusability. #53741

Open
tejlmand opened this issue Jan 12, 2023 · 1 comment
Open

unittest mock improvement and reusability. #53741

tejlmand opened this issue Jan 12, 2023 · 1 comment
Assignees
Labels
area: Build System area: Test Framework Issues related not to a particular test, but to the framework instead Enhancement Changes/Updates/Additions to existing features

Comments

@tejlmand
Copy link
Collaborator

tejlmand commented Jan 12, 2023

Is your enhancement proposal related to a problem? Please describe.
The #52894 PR cleaned up the Bluetooth controller unit test significantly by introducing uut and mocks library.

However, it still has sub-optimal code like this:
https://github.com/zephyrproject-rtos/zephyr/blob/802eabf43f01b72aef615d48b0f08c05a0f32392/tests/bluetooth/controller/ctrl_feature_exchange/CMakeLists.txt#L11-L12
https://github.com/zephyrproject-rtos/zephyr/blob/802eabf43f01b72aef615d48b0f08c05a0f32392/tests/bluetooth/controller/uut/CMakeLists.txt#L38

See also: #52894 (comment)

Preferable CMake code which creates libraries should be included in the most straight forward way possible, following the folder structure of the repo.

As mocks may be reusable between test suites, then it should be considered how such sharing can be obtained, and the need for add_subdirectory() from the toplevel CMakeLists.txt test file is not needed.

Describe the solution you'd like
Idea: create common location where CMakeLists.txt are sourced in an heriachy and shared CMake libraries can be created.
Two options:

  • Always source the tree and define the libraries. The actual library to use will depend on link library calls in top-level CMakeLists.txt file. This cleans up the top-level CMakeLists.txt file, but might have reduced build performance.
  • Add extra arguments to COMPONENTS unittest, so that the extra CMake tree is sourced based on knowledge provided by top-level CMakeLists file, for example a call like:
    find_package(Zephyr COMPONENTS unittest bluetooth-uut bluetooth-mock HINTS $ENV{ZEPHYR_BASE})
    
    This approach allows to only source required components.
    It requires more knowledge by the user writing the test, but no build time penalty.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context

@tejlmand tejlmand added the Enhancement Changes/Updates/Additions to existing features label Jan 12, 2023
@tejlmand tejlmand added area: Test Framework Issues related not to a particular test, but to the framework instead area: Build System labels Jan 12, 2023
@tejlmand tejlmand self-assigned this Jan 12, 2023
@zephyrbot
Copy link
Collaborator

Hi @tejlmand,

This issue, marked as an Enhancement, was opened a while ago and did not get any traction. Please confirm the issue is correctly assigned and re-assign it otherwise.

Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System area: Test Framework Issues related not to a particular test, but to the framework instead Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

2 participants