Commit graph

101 commits

Author SHA1 Message Date
Ahmed Moheb e6356c2770 tests: bluetooth: host: Add UT for bt_id_del()
Unit test project for bt_id_del().
This part of subsys/bluetooth/host/id.c unit testing.

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

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>

# Conflicts:
#	tests/bluetooth/host/id/CMakeLists.txt
2023-01-17 13:13:28 +01:00
Ahmed Moheb 10001af2b9 tests: bluetooth: host: Add UT for bt_id_adv_random_addr_check()
Unit test project for bt_id_adv_random_addr_check().
This part of subsys/bluetooth/host/id.c unit testing.

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

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>

# Conflicts:
#	tests/bluetooth/host/id/CMakeLists.txt
2023-01-17 13:13:28 +01:00
Ahmed Moheb 053a7fdd37 tests: bluetooth: host: Add UT for bt_id_set_adv_random_addr()
Unit test project for bt_id_set_adv_random_addr().
This part of subsys/bluetooth/host/id.c unit testing.

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

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>

# Conflicts:
#	tests/bluetooth/host/id/mocks/adv.c
#	tests/bluetooth/host/id/mocks/adv.h
2023-01-17 13:13:28 +01:00
Ahmed Moheb 4e6a92408e tests: bluetooth: host: Add UT for bt_id_set_private_addr()
Unit test project for bt_id_set_private_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>

# Conflicts:
#	tests/bluetooth/host/id/CMakeLists.txt
2023-01-17 13:13:28 +01:00
Ahmed Moheb 9a0f610652 tests: bluetooth: host: Add UT for bt_lookup_id_addr()
Unit test project for bt_lookup_id_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>

# Conflicts:
#	tests/bluetooth/host/id/CMakeLists.txt
2023-01-17 13:13:28 +01:00
Ahmed Moheb abb7e8bfc2 tests: bluetooth: host: Add UT for bt_id_init()
Unit test project for bt_id_init().
This part of subsys/bluetooth/host/id.c unit testing.

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

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

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

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01: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
Fabio Baltieri f5b4acac57 yamllint: indentation: fix files in tests/
Fix the YAML files indentation for files in tests/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Ahmed Moheb 4f3d5a10c4 tests: bluetooth: host: Add UT for bt_id_read_public_addr()
Unit test project for bt_id_read_public_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-12-27 15:34:34 +01:00
Ahmed Moheb ea6076116b tests: bluetooth: host: Add mocks for id.c
Add required mocks to be able to compile and test /bluetooth/host/id.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-12-27 15:34:34 +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
Ahmed Moheb 71aa52d79d tests: bluetooth: host: Add UT for bt_keys_find_addr()
Unit test project for bt_keys_find_addr().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-30 12:31:46 +01:00
Théo Battrel 53ee728227 Bluetooth: Bluetooth: tests: host: Replace host_mocks/print_utils.h
Replace `host_mocks/print_utils.h` which does not exist anymore with
`common/bt_str.h`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-24 15:21:39 +01:00
Jonathan Rico 77f7acace0 Bluetooth: tests: host: Update CMakeLists files
Update CMakeLists files to include new required files and new paths.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-11-24 15:21:39 +01:00
Jonathan Rico c12709b1ef Bluetooth: tests: host: disable logging in UT
A PR got in after some changes were done to the BT logging system. This
nulls the error by not including the logging framework in this unit test.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-11-24 15:21:39 +01:00
Ahmed Moheb 37de395fc5 tests: bluetooth: host: Add UT for prng_init()
Unit test project for prng_init().
This is part of subsys/bluetooth/host/crypto.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:06:05 +01:00
Ahmed Moheb b86150ff0c tests: bluetooth: host: Add mocks for crypto.c
Add required mocks to be able to compile/test /bluetooth/host/crypto.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:06:05 +01:00
Ahmed Moheb cba3ed9ad1 tests: bluetooth: host: Add UT for bt_keys_add_type()
Unit test project for bt_keys_add_type().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:05:54 +01:00
Ahmed Moheb f674a56a13 tests: bluetooth: host: Add UT for bt_keys_find_irk()
Unit test project for bt_keys_find_irk().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:05:40 +01:00
Ahmed Moheb 932e49e020 tests: bluetooth: host: Add UT for bt_keys_get_type()
Unit test project for bt_keys_get_type().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 10:05:32 +01:00
Ahmed Moheb 5b1c6566b8 tests: bluetooth: host: Add UT for bt_keys_find()
Unit test project for bt_keys_find().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-11-24 09:35:04 +01:00
Théo Battrel effb76c61e Bluetooth: Move re-implementation of snprintk
Move the function in the `subsys/testsuite/ztest/src/ztest_mock.c` files.

This is motivated by the fact that there is others re-implementation of
`*printk` functions using libc counterparts in the `ztest_mock.c` file.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-11-02 13:28:57 +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
Yuval Peress f460c21578 test: update how unit tests set sources
Replaces cases of setting SOURCES before calling find_package with
proper target_sources.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-31 17:01:59 +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 7ef05751a3 tests: bluetooth: host: Fix CI failures with bt_keys_get_addr() UT
CI tests were failing due to a recent change to zassume_true()
implementation.
While the test case is still skipped when assumption fails, but it is
now causing the final execution result to fail.

zassume_true() was replaced by ztest_test_skip() combined with
a conditional 'if' statement to get the required effect.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-14 12:40:46 +02:00
Ahmed Moheb 385527bdd6 tests: bluetooth: Remove deprecated definitions
Remove ZTest deprecated definitions that aren't used anymore.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:29:42 +02:00
Ahmed Moheb b8d5aaccd2 tests: bluetooth: Use ZTest new APIs with bt_buf_get_cmd_complete() UT
Migrate bt_buf_get_cmd_complete() UT to use the new APIs of ZTest
framework.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:29:42 +02:00
Ahmed Moheb c7c0e2d654 tests: bluetooth: Use ZTest new APIs with bt_buf_get_evt() UT
Migrate bt_buf_get_evt() UT to use the new APIs of ZTest framework.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:29:42 +02:00
Ahmed Moheb 8c9235c2b0 tests: bluetooth: Use ZTest new APIs with bt_buf_get_rx() UT
Migrate bt_buf_get_rx() UT to use the new APIs of ZTest framework.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:29:42 +02:00
Ahmed Moheb ea67890fdc tests: bluetooth: Use ZTest new APIs with bt_buf_get_type() UT
Migrate bt_buf_get_type() UT to use the new APIs of ZTest framework.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:29:42 +02:00
Ahmed Moheb 2254fab332 tests: bluetooth: host: Add UT for bt_foreach_bond()
Unit test project for bt_foreach_bond().
This part of subsys/bluetooth/host/keys.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-10-11 11:29:29 +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
Ahmed Moheb db5ef779c4 tests: bluetooth: host: Add UT for bt_buf_get_type()
Unit test project for bt_buf_get_type().
This part of subsys/bluetooth/host/buf.c unit testing

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

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-09 10:06:19 +02:00
Ahmed Moheb 13203cc801 tests: bluetooth: host: Add UT for bt_buf_get_cmd_complete()
Unit test project for bt_buf_get_cmd_complete().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-09 10:06:19 +02:00
Ahmed Moheb 4abff8a625 tests: bluetooth: host: Add UT for bt_buf_get_rx()
Unit test project for bt_buf_get_rx().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-09 10:06:19 +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