Commit graph zephyr/tests/bluetooth/addr
Author SHA1 Message Date
Aric Radzin
65df0c1576 tests: bluetooth: addr: Add bt_addr_matches_irk() tests
Check bt_addr_matches_irk() against the sample data for the random
address hash function ah in the Core Specification, Vol 3, Part H,
Appendix D.7, which fixes the byte order of both arguments. Check that a
different IRK, the IRK in reverse byte order, a modified hash or prand,
and addresses with a valid hash but the non-resolvable, reserved or
static address bits do not match.

Add a bluetooth.addr.no_smp scenario, an observer without SMP or
privacy, to cover the function's availability without them. The RPA
resolution tests need both, so they are built only with
CONFIG_BT_PRIVACY and CONFIG_BT_SMP.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-29 19:45:30 -04:00
Johan Hedberg
f0b21c4e07 tests: Bluetooth: Fix main stack overflow from PSA init
On qemu_cortex_m3 the addr, bluetooth, hci_prop_evt, l2cap, smp and
uuid suites pass and then fault in the idle thread, which twister
reports as a failure. BT_HOST_CRYPTO pulls in psa_crypto_init() through
the Mbed TLS SYS_INIT hook, and without an entropy driver it seeds the
software HMAC_DRBG on the main thread, peaking at 1344 bytes. The
default 1024-byte main stack overflows into the idle thread's stack,
which is first used once the suite is done.

Use the 2048 bytes that the gatt and bt_crypto tests already set.
Tested with twister -T tests/bluetooth -p qemu_cortex_m3.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-28 22:49:23 -04:00
Johan Hedberg
5f3ee983d4 tests: bluetooth: addr: Cover bt_addr_le_to_str and bt_addr_le_from_str
Add ZTEST suites for the two conversion APIs that use the prefix-based
LE address string format:

bt_addr_le_to_str
  - PUBLIC produces the 'P:' prefix, RANDOM produces 'R:'
  - PUBLIC_ID and RANDOM_ID are formatted by their base type
  - HCI-level extended types (resolved-RPA bit) are formatted by their
    base type
  - Byte order is preserved (display is most-significant first while
    a.val is stored on-air, little-endian)
  - BT_ADDR_LE_STR_LEN is large enough for the longest output
  - The UNRESOLVED and ANONYMOUS sentinels are formatted as random

bt_addr_le_from_str
  - 'P:..' / 'R:..' parse to the expected type, with the prefix and
    the hexadecimal digits accepted in either case
  - An unknown prefix, a missing prefix, a missing ':' separator,
    malformed addresses and truncated strings are rejected with -EINVAL
  - Roundtrip to_str -> from_str preserves the address

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-09-22 17:53:33 +02:00
Johan Hedberg
2428d3c33f tests: bluetooth: addr: Cover bt_addr_le_is_resolved() and copy_resolved()
Add a ZTEST suite for the two internal helpers that translate the
address types found in HCI LE events:

  - bt_addr_le_is_resolved() is true for the two identity types only,
    and false for public, random and the anonymous and unresolved
    sentinels
  - bt_addr_le_copy_resolved() maps an identity type to its base type
    and keeps the address bytes

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-09-17 16:47:23 -07:00
Benjamin Cabé
a119dbf957 build: bump minimum CMake version to 3.28.0
Raise the minimum required CMake version from 3.20.0 (documented as
3.20.5) to 3.28.0, which is satisfied by the CMake 3.28.3 package
shipped in the Ubuntu 24.04 LTS repositories. Ubuntu 24.04 is the
current Ubuntu LTS release targeted by the Zephyr getting started
guide, and by the time of the next Zephyr release, Ubuntu 22.04 will be
within months of its end of standard support. Users of distributions
shipping an older CMake can use the Kitware APT repository or a
pip-installed CMake, as the documentation already suggests.

Raising the floor to 3.28 unlocks a range of modern CMake features for
the build system, among which the cmake_file_api() command (3.27),
file(COPY_FILE) (3.21), block()/endblock() (3.25), and allows removal
of several version-conditional workarounds.

The tree-wide cmake_minimum_required() occurrences in samples, tests
and boards are updated accordingly, together with the documentation
and the sysbuild CMake presets. The IAR C-STAT integration keeps its
own higher requirement (4.1.0).

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-03 15:03:35 -04:00
Anas Nashif
032e50fb91 tests: bluetooth: rename testcase.yaml to tests.yaml
Rename the test metadata file(s) in this area from testcase.yaml to
tests.yaml so sample and test metadata share one consistent filename
across the tree. Pure rename, no content change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-03 19:24:17 -04:00
Yago Fontoura do Rosario
32e0ab566c tests: add Bluetooth LE address resolution tests
* Test newly added bt_addr_le_rpa_resolve api

Assisted-by: Copilot:GPT-5.3-Codex
Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2026-06-19 22:48:04 +02:00
Josuah Demangeon
e6e7fc549e style: tests: apply coding style on CMakeLists.txt files
Apply the CMake style guidelines to CMakeList.txt files in tests/.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Johan Hedberg
8b02141ca7 Bluetooth: Controller: Replace BT_CTLR with HAS_BT_CTLR
Deprecate BT_CTLR, and add a new HAS_BT_CTLR as a virtual option which
specific users (like BT_LL_SW_SPLIT) select. This also means that we can
remove all places that were forcefully enabling the BT_CTLR option, and
instead we now depend on devicetree to get some local LL HCI driver
enabled which in turn also enables the HAS_BT_CTLR option.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-12-03 10:16:44 +01:00
Alberto Escolar Piedras
66a70a2ffd tests/bluetooth: Don't test on native_posix
native_posix is now deprecated.
Building these tests in both native_sim and native_posix does not
improve coverage for the tests or subsystem but doubles CI time.
As anyhow native_posix will be removed all together in
2 releases, let's remove it already for these.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-25 04:04:36 -04:00
Johan Hedberg
1824dcda7c Bluetooth: tests: Convert to new HCI driver API
Convert all Bluetooth tests that define dummy HCI driver instances to use
the new HCI driver API. This requires both a custom DTS binding as well
as an app-specific overlay file.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Alberto Escolar Piedras
68975aa837 tests/bluetooth: Use hwmv2 native targets identifiers
For the 64 bit targets, change identifiers to the new hwmv2 ones.
And remove redundant overlays (which were equal for the 32
and 64 bit versions)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-03-15 16:13:12 +01:00
Alberto Escolar Piedras
6c9dfe1b2c tests/bluetooth/*: Enable for native_sim
Enable all remaining bluetooth tests for native_sim
and switch from native_posix to native_sim as default
test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-22 09:53:10 +01:00
Anas Nashif
345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Aleksander Wasaznik
75bb62ad24 Bluetooth: Host: Test: bt_addr_from_str
Some basic tests for `bt_addr_from_str`. This proves a bug.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-05 08:31:06 -04:00
Gerard Marull-Paretas
93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Anas Nashif
ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Aleksander Wasaznik
e2e326dded Bluetooth: Add unit tests for bt_addr_le_eq
Add some basic unit tests for bt_addr_le_eq.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-10-19 15:40:18 +03:00