The file `tests/bluetooth/host/keys/bt_keys_get_addr/src/main.c` was using functions from `tests/bluetooth/host/host_mocks/print_utils.c` which were exactly the same as the one in `common/log.h`. The code was duplicated because the test author wanted to include `common/log.h` to get the stringifying functions, but could not due to unwanted side-effects. See the comment from the unit test author here: https://github.com/zephyrproject-rtos/zephyr/pull/48676#discussion_r973672151 The new `common/bt_str.h` does not have side-effects, so it is suitable for unit tests. The `snprintk` function has been redefined inside the `main.c` to use the libc because of the kernel being not compiled entirely. Also, the `CONFIG_LOG`, `CONFIG_BT_DEBUG_LOG` and `CONFIG_TEST_LOGGING_DEFAULTS` have been disabled in the Kconfig files of each `keys` tests. That so logs are not compiled and so, there is no need to link the `printk` functions that are used by the logs. Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no> Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
17 lines
410 B
CMake
17 lines
410 B
CMake
#
|
|
# CMakeLists.txt file for creating of host mocks library.
|
|
#
|
|
|
|
add_library(host_mocks STATIC
|
|
host_mocks/assert.c
|
|
)
|
|
|
|
target_include_directories(host_mocks PUBLIC
|
|
${ZEPHYR_BASE}/subsys/bluetooth
|
|
${ZEPHYR_BASE}/subsys/bluetooth/host
|
|
${ZEPHYR_BASE}/tests/bluetooth/host
|
|
)
|
|
|
|
target_link_libraries(host_mocks PRIVATE test_interface)
|
|
target_compile_options(test_interface INTERFACE -include ztest.h)
|