Commit graph

14 commits

Author SHA1 Message Date
Théo Battrel 9400823dcd Bluetooth: Tests: Remove usage of auto name in AD
The advertiser options to automatically add the name in the scan
response and the advertising data will be deprecated.

Update the tests that were relying on those options. A lot of test were
actually not using the name, for those the name have simply been
removed. For the others that were using the name, add it in the
advertising data or the scan response data.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-04-23 12:42:24 +02:00
Aleksander Wasaznik ebd176905a Bluetooth: testlib: add bt_testlib_disconnect
This is a convenience function.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-03-22 10:25:07 +01:00
Aleksander Wasaznik 89c9491804 Bluetooth: testlib: add bt_testlib_conn_wait_free
This function waits for a free connection slot. It should be used to
slow down a busy loop trying to obtains a connection slot.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-03-22 10:25:07 +01:00
Aleksander Wasaznik c84c9beece Bluetooth: testlib: Add bt_testlib_conn_unindex
This function obtains a reference to a connection object by its index.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-03-22 10:25:07 +01:00
Aleksander Wasaznik dd038b4405 Bluetooth: testlib: Support BT_SMP=n
This is the minimal change to make compilation with `BT_SMP=n` work.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-03-22 10:25:07 +01:00
Aleksander Wasaznik f82a86c21b Bluetooth: testlib: bt_testlib_connect: better error logs
Changes to logging:
 - Don't log "Connected" if there was an error.
 - Identify the relevant bt_conn object in log messages by its index.
 - Special case non-fatal errors:
  - Failure due to out of free conn object is INF.
 - Improve transparancy of error messages:
  - For errno, include the name of the API.
  - For HCI errors, include the common prefix of the symbols
    'BT_HCI_ERR_' so they are easier to look up.

This change includes some light refactoring to make the code more
understandable, but does not change any behavior.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-03-19 21:15:44 -05:00
Jonathan Rico 20057b6564 tests: Bluetooth: add missing param to testlib
The lib was refactored, but CI didn't run the tests that used it for
some reason.
A parameter was forgotten.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-12-05 15:09:18 +01:00
Aleksander Wasaznik f6fced8ecc Bluetooth: Testlib: Add comments
This patch just adds some comments and asserts to clarify the testlibs
att read code.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-05 10:12:13 +00:00
Aleksander Wasaznik b52d59dd57 Bluetooth: testlib: Clang format fix
This reformats some code on main branch that was not clang formated. The
syntax is changed from initializer list to multiple statements because
there is a conflict in formating requirements between clang format and
checkpatch.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-05 10:12:13 +00:00
Aleksander Wasaznik bbdcf4be7a Bluetooth: testlib: att_read: Fix assert on zero-sized read
`read_data` can be NULL even on success if `read_size` is `0`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-05 10:12:13 +00:00
Aleksander Wasaznik a29473c38e Bluetooth: Testlib: att_read allow ignoring result_size
Allow passing in NULL as `result_size` to ignore it.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-05 10:12:13 +00:00
Aleksander Wasaznik 589f3ad904 Bluetooth: testlib: Create testlib/conn.h
This header file declares the functions that rely on `bluetooth/conn.h`.

This collects `testlib/connect.h`, `conn_ref.h` and `conn_wait.h` into one.

Initial documentation for the functions in this file is also added.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-22 14:55:43 +00:00
Mariusz Skamra f0715fcbb3 tests: bsim: testlib: Fix compilation error
Fixes compilation error seen if CONFIG_BT_EATT is unset

testlib/src/att_read.c:179:73: error: expected expression before ‘,’ token
179 |               IF_ENABLED(CONFIG_BT_EATT, (.chan_opt = bearer)),
    |                                                               ^

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-13 09:45:20 +01:00
Aleksander Wasaznik bfff0f9f4c Bluetooth: Host: Tests: Move testlib to common
This is the first patch with the goal of establishing a common library
for Bluetooth utilities that are commonly used for setup in Bluetooth
Host tests. The ultimate goal is to remove redundant (near) copies of
these utilities and other more ad-hoc solutions.

This patch moves one instance of testlib (from
tests/bsim/bluetooth/host/att/long_read) to
tests/bluetooth/common/testlib and makes it a proper CMake library.

The long_read test is updated to link to the new CMake library.

Further changes and de-duplication will come in later patches.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-07 10:09:33 +01:00