zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.8k stars 6.59k forks source link

unittest mock improvement and reusability. #53741

Open tejlmand opened 1 year ago

tejlmand commented 1 year ago

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: https://github.com/zephyrproject-rtos/zephyr/pull/52894#discussion_r1067902057

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:

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

Additional context

zephyrbot commented 8 months ago

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!