Commit graph

13 commits

Author SHA1 Message Date
Arkadiusz Kozdra 82d8f09de1 bluetooth: host: track connection type enum
The enum used for connection types gets named bt_conn_type to guard
against accidental usage of generic integers with relation to it.

The added default case in several switch statements avoids warnings
against unhandled enum values.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Théo Battrel 0f079a1ab8 Bluetooth: Unit: Fix unit tests that rely on settings
Following the previous commit that introduce the settings API for the
Bluetooth subsystem, some unit tests needed to be updated to use it.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-17 07:58:07 -04:00
Ahmed Moheb 60345c1ddc tests: bluetooth: host: Add UT for bt_keys_update_usage()
Unit test project for bt_keys_update_usage().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:02 +01:00
Ahmed Moheb 5768c45a9d tests: bluetooth: host: Add UT for bt_keys_store()
Unit test project for bt_keys_store().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:02 +01:00
Ahmed Moheb eceb8341e0 tests: bluetooth: host: Add UT for bt_keys_clear()
Unit test project for bt_keys_clear().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-12-27 15:33:40 +01:00
Erwan Gouriou 66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
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 0d5a49e815 tests: bluetooth: host: Add UT for bt_keys_foreach_type()
Unit test project for bt_keys_foreach_type().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:14:10 +02:00
Gerard Marull-Paretas 97ef197d05 include: add missing zephyr/ prefix
Some files still manage to get into the tree without the zephyr/ include
prefix (likely because they lack CI coverage).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-06 10:41:02 +02:00
Ahmed Moheb a341792ca0 tests: bluetooth: host: Remove unused definitions and inclusions
Clean up sources by removing unused definitions and inclusions.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-29 10:17:38 +00:00
Ahmed Moheb fab9c5a140 tests: bluetooth: host: Add UT for bt_keys_get_addr()
Unit test project for bt_keys_get_addr().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-26 13:05:47 +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