Commit graph

5 commits

Author SHA1 Message Date
Théo Battrel a57dbb15db Bluetooth: Consolidate duplicated code
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>
2022-11-02 13:28:57 +01:00
Jonathan Rico d870df0054 Bluetooth: tests: use a single definition of the fff global
Linking fails on ubuntu 22.04 because of multiple definitions of the `fff`
global, which is defined by `DEFINE_FFF_GLOBALS`.

Only define it in the tests' `main.c` instead of the mocks.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-10-26 13:29:19 +02:00
Ahmed Moheb d354179a68 include: Add missed 'zephyr' prefix while including header files
Add missed 'zephyr' prefix to files paths while including.
Also, remove that paths from libraries include paths to generate
compilation error if shortened path is used.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-18 14:12:45 +02:00
Ahmed Moheb fd888df41d tests: bluetooth: host: Add mocks for keys.c
Add required mocks to be able to compile and test /bluetooth/host/keys.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-26 13:05:47 +02:00
Ahmed Moheb cb5ba5bea8 tests: bluetooth: host: Add mocks for buf.c
Add required mocks to be able to compile and test /bluetooth/host/buf.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-09 10:06:19 +02:00