-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Bluetooth: controller: Llcp update unittests #52894
Bluetooth: controller: Llcp update unittests #52894
Conversation
b1af50b
to
29eb3dc
Compare
a78b032
to
9f77d52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this improvement, some minor nits and question / proposals regarding some of the choices made.
Overall impression is that this is a nice improvement 👍
# some of the control procedures in the BT LL depend on | ||
# the following configs been set | ||
config SOC_COMPATIBLE_NRF | ||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to redefine the type here.
Actually not specifying the type not only minimize the file but also has the benefit of easily discover if the real symbol is renamed / removed.
Ref: https://docs.zephyrproject.org/latest/build/kconfig/tips.html#common-kconfig-shorthands
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know this, but makes sense. A cleanup of other Kconfig files may be required then, for example in tests/bluetooth/df/* (where this was copied from)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifying the type has been removed from all other places as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cleanup of other Kconfig files may be required then, for example in tests/bluetooth/df/* (where this was copied from)
Yes, there's a bit of whack-a-mole here, because developers naturally copies files / code snippes around and adjust.
Thanks for cleaning up.
default y | ||
|
||
config SOC_SERIES_NRFX | ||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool |
default y | ||
|
||
config BT_CTLR_PHY_UPDATE_SUPPORT | ||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool |
default y | ||
|
||
config ENTROPY_NRF_FORCE_ALT | ||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool |
default n | ||
|
||
config DT_HAS_NORDIC_NRF_RNG_ENABLED | ||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool |
# Common include directories and source files for bluetooth unit tests | ||
# | ||
|
||
include_directories( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exactly is include_directories()
used here ?
cause in this particular case then those include paths will only be applied to testbinary
afaict.
Generally target_include_directories()
is recommended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a uut library removes the need for this file
@@ -15,6 +15,14 @@ config BT_CTLR_PHY_UPDATE_SUPPORT | |||
bool | |||
default y | |||
|
|||
config BT_CTLR_PHY_CODED_SUPPORT | |||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool |
default y | ||
|
||
config BT_CTLR_PHY_2M_SUPPORT | ||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool |
${ZEPHYR_BASE}/subsys/bluetooth/controller/include | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/util | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller | ||
${ZEPHYR_BASE}/subsys/bluetooth | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw/nordic/lll | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw/nordic | ||
${ZEPHYR_BASE}/include/zephyr/bluetooth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those are also exported by the mocks
library.
are both really needed or could there be a single interface library that both the mock and the testbinary can link to ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer listing the required include directories explicitly for each library; however the list was too large, so the list will be reduced to only the absolutely minimum required include directories
Arguably the directory 'common' should be renamed 'helper', but that will have to be part of a separate PR, where we move the unittests for the controller to a more logical place
add_definitions(-include kconfig.h) | ||
if(KCONFIG_OVERRIDE_FILE) | ||
add_definitions(-include ${KCONFIG_OVERRIDE_FILE}) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have kconfig support in unittesting so I don't think we should be using this Kconfig override principle.
We should be able to handle this properly in Kconfig files directly, so that unittests are following same pattern as samples.
Please let me know if there are reasons when the common Kconfig approach cannot be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agreed, and the reason for this PR is so that we can get rid of this hack. It is left here because the other unittests rely on this. Once this PR is approved (meaning that we agree on how the framework for the unittests for the controller should be) we can create another PR updating all the other unittests and getting rid of this hack. See #35099
049e545
to
ff07730
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Definitely improved, making other things easier to spot.
# | ||
|
||
add_library(mocks STATIC | ||
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/src/kernel.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for full path, relative sources are picked up relative to CMAKE_CURRENT_SOURCE_DIR
, so this is sufficient here and below:
src/kernel.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
|
||
target_include_directories(mocks PUBLIC | ||
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line can be reduced to
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include | |
include |
as that include folder is below the CMAKE_CURRENT_SOURCE_DIR
.
This also makes it clearer to the reader which folders are local to the mock lib, and which folders are picked up externally (as they use abs path)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,35 @@ | |||
# | |||
# CMakeLists.txt file for creating of mocks library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
) | ||
|
||
target_include_directories(uut PUBLIC | ||
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line indicates that this library depends on the mock
library created.
Should there be a target_link_libraries(uut PUBLIC mocks)
here ?
That would ensure the include path gets inherited correctly, as well as generally making sense as I believe the sources in uut
actually links to functions provided my the mock lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed; that makes the CMakeLists.txt in the ctrl_feature_exchange cleaner as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so because you now link to the mocks
library, then this line can be removed because it is inherited.
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is still here.
The mock_ctrl/include
is an include native to the mock library, so it should be inherited.
The other includes, those with ${ZEPHYR_BASE}/subsys/bluetooth
are not native to the mock library (they are rightfully native to the bluetooth controller
library which we are not linking directly).
Therefor the ${ZEPHYR_BASE}/subsys/bluetooth
are acceptable not to inherit, but the mock include must be inherited. The uut
itself should not know about internals of the mock lib.
2dc3e63
to
802eabf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, also some minor nits.
) | ||
|
||
target_include_directories(uut PUBLIC | ||
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so because you now link to the mocks
library, then this line can be removed because it is inherited.
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include |
${ZEPHYR_BASE}/subsys/bluetooth/controller/include | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller | ||
${ZEPHYR_BASE}/subsys/bluetooth | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw/nordic | ||
${ZEPHYR_BASE}/include/zephyr/bluetooth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: Those include paths are also defined by the mocks
library, which in practice means you can remove them from here.
But as the uut
library refers to source files directly in the bluetooth controller library then it also make sense to keep those includes explicitly here, as well as in the mocks
lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer listing them here explicitly, due to the direct reference to bluetooth controller files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consequence is however that we also need to leave the ${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include in place to ensure that we include the mock include-files.
i.e. either we remove all include paths, or we leave all of them as is
${ZEPHYR_BASE}/include/zephyr/bluetooth | ||
) | ||
|
||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl mocks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment for future reference.
This is not ideal, as we should strive to have a straight forward CMake hierarchy.
But as this is an improvement on the overall test structure, then it is accepted in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #53741 for followup
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# CMakeLists.txt file for creating of mocks library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adjust, this file doesn't create the mocks
library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
802eabf
to
dc70d3c
Compare
@tejlmand please take another look |
) | ||
|
||
target_include_directories(uut PUBLIC | ||
${ZEPHYR_BASE}/tests/bluetooth/controller/mock_ctrl/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is still here.
The mock_ctrl/include
is an include native to the mock library, so it should be inherited.
The other includes, those with ${ZEPHYR_BASE}/subsys/bluetooth
are not native to the mock library (they are rightfully native to the bluetooth controller
library which we are not linking directly).
Therefor the ${ZEPHYR_BASE}/subsys/bluetooth
are acceptable not to inherit, but the mock include must be inherited. The uut
itself should not know about internals of the mock lib.
|
||
target_include_directories(mocks PUBLIC | ||
include | ||
${ZEPHYR_BASE}/subsys/bluetooth/controller/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you have decided that test lib themselves should not inherit includes under ${ZEPHYR_BASE}/subsys/bluetooth
, then those should be made PRIVATE
as to avoid mix of principles.
${ZEPHYR_BASE}/subsys/bluetooth/controller/include | |
PRIVATE | |
${ZEPHYR_BASE}/subsys/bluetooth/controller/include |
Update the unittests for feature exchange to use the new ZTEST API Here we only update the feature exchange procedure. The remaining unittests will be done in a next PR Mocks, helper routines and the Unit Under Test are splitted out as a library instead of adding them to the file list Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
dc70d3c
to
9767788
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for the effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good - thanks, Andries!
One nit-pick - the tittle of the PR could reflect this is feature exchange only.
Update to the feature exchange unit tests
Looking for feedback, in particular if we should have a file unit_sources.txt, and include that in each of the unit-tests (as per this PR), or copy the contents of this file to each CMakelists.txt in each unit-test.
fixes #52626