Commit graph zephyr/tests/bluetooth
Author SHA1 Message Date
Lyle Zhu
ce0d82aa46 tests: bluetooth: tester: add BTP command to send RFCOMM RLS
Add a new BTP command `BTP_RFCOMM_SEND_RLS` to send RFCOMM RLS
command.

The command accepts a Bluetooth address, channel number, and line
status value, allowing test automation to send RLS commands on
established RFCOMM DLC connections.

And using the function `tester_supported_commands()` to generate the
response to the request `supported_commands()`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-10-30 12:48:37 -04:00
Johan Hedberg
55e35e4410 tests: Bluetooth: Classic: Test ACL packets with trailing bytes
Append one to three bytes after the last L2CAP PDU of an HCI ACL
packet: the PDU must still be delivered and the ACL buffer freed.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-30 10:12:10 -04:00
Johan Hedberg
0e1d61d83a tests: Bluetooth: Classic: Test bt_br_acl_recv() with kept buffers
Cover receivers that keep L2CAP PDU buffers after bt_l2cap_recv()
returns: a single PDU, several PDUs in one HCI ACL packet, and all views
in use, where the remaining PDUs must still be delivered. Each kept
buffer must still show its own PDU, and the ACL buffer must be freed
exactly once, after the last reference is gone.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-30 10:12:10 -04:00
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
Aric Radzin
01f814fec5 Bluetooth: Expose bt_addr_matches_irk() as public API
A scanner that sets BT_LE_SCAN_OPT_EXT_FILTER_POLICY receives directed
advertisements whose target is a resolvable private address that the
Controller could not resolve, reported as BT_ADDR_LE_UNRESOLVED. To act
on one, the application has to check whether the address was generated
from an IRK it holds, such as its own IRK after a peer lost the bond or
an old IRK after bt_id_reset_irk(). The Host and the Controller already
share this check as bt_rpa_irk_matches() in the private common/rpa.h.

Declare it in addr.h as bt_addr_matches_irk(), next to
bt_addr_le_rpa_resolve(), taking the address first like the other
bt_addr_ functions, and update the Host, Controller and test callers.
BT_IRK_SIZE moves from bluetooth.h to addr.h for the prototype;
bluetooth.h includes addr.h, so its users still see it. The bt_addr API
version goes to 1.1.0. The direct_addr documentation of struct
bt_le_scan_recv_info points to the new function.

It now returns false for an address that is not an RPA, without running
AES. The Host callers already check for an RPA, so they behave as
before. The Controller's resolving list lookup keeps its address type
check and leaves the RPA bit check to the function. The Controller's
PAST receiver with CONFIG_BT_CTLR_SW_DEFERRED_PRIVACY does not check: it
passes any random AdvA to the deferred resolution, static and
non-resolvable ones included. Such an address used to match on a 24-bit
hash collision and no longer does.

Fixes #120887

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-29 19:45:30 -04:00
Alex Ciascai
79217eb502 tests: Bluetooth: tester: Audio: report OTS Object Changed handle
BTP_MCP_DISCOVERED_EV already has the Object First-Created and Object
Last-Modified handles, but the MCC never discovered them, so they were
always reported as 0. They are now filled in.
PTS expects the handle of every supported OTS characteristic to be
returned to the upper tester during discovery, so add the Object
Changed handle. It is appended as the last field of the event, so
parsers that ignore trailing bytes keep working.

Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
2026-10-29 15:45:18 -04:00
Alex Ciascai
9b2c55e89d tests: Bluetooth: tester: Audio: fix OTS handle order in MCP event
This is a bug fix where Zephyr implemented the BTP incorrectly
(i.e. did not follow
https://github.com/auto-pts/auto-pts/blob/master/doc/btp_mcp.txt).
It's also worth noting that BTP fails to list some of these fields,
which is being fixed by auto-pts/auto-pts#1866.

Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
2026-10-28 22:51:17 -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
5eced97d07 tests: Bluetooth: hci: Give two test cases the test_ prefix
Twister's source scan rejects a test case not named test_*, an error
since commit 44f7ba0781 ("sanitycheck: detect wrongly named tests and
fail"): the test suite is not loaded and twister exits with an error.
Two cases in test_hci_driver_ext_adv_report_process.c lack the prefix
that doc/develop/test/ztest.rst asks for. The scan has not seen them so
far because it skips test cases declared static, which the next commit
changes.

Twister strips the prefix, so the reported test names stay the same.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-28 22:46:01 -04:00
Johan Hedberg
e27287dec6 tests: Bluetooth: host_long_adv_recv: Test failed PAwR subevents
Check that the recv() callback gets a NULL buffer for a subevent that
the Controller failed to receive, without a periodic advertising
reassembly buffer. The new scenario enables PAwR sync support, with
which the Host takes only the v2 sync established and report events, so
the test sends those there.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-28 22:45:07 -04:00
Aric Radzin
2462447d6f tests: bluetooth: host_id: Add an observer-only privacy variant
Run the identity tests with privacy in an observer-only build, without
SMP or connections. The privacy.no_smp variant covers the
broadcaster-only case.

In the new variant, also check that the RPA timer stops while only a
passive scanner runs, and keeps running for an active scanner. The
variant enables CONFIG_BT_RPA_TIMEOUT_DYNAMIC to shorten the timeout.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-28 22:44:00 -04:00
Alex Ciascai
c6e60753c0 tests: Bluetooth: tester: BAP: Defer BIS sync until broadcast code
btp_bap_broadcast_sink_bis_sync() started a BIG sync once BIGInfo was
received, regardless of whether the broadcast code had arrived yet.
On an encrypted BIG, if the BTP bis_sync command won the race against
the Set Broadcast Code write, it synced with an all-zero placeholder
code instead of the real one.

Cache whether the BIG is encrypted when BIGInfo is received, and
defer the BIS sync request until the code has been received;
broadcast_code_cb() then starts the sync once it has the real code.

Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
2026-10-28 22:43:50 -04:00
Alex Ciascai
62dcea73b7 tests: Bluetooth: tester: BAP: Serialize broadcast sink BIG sync
BIGInfo reception, Set Broadcast Code, a BIS sync request from a
connected Broadcast Assistant, and the BTP bis_sync/sink_sync/
sink_stop commands can each read or write the shared per-broadcaster
sync state, and some of them attempt to start or stop a BIG sync for
the same broadcast sink from different threads. When two of these
raced, both paths could call bt_bap_broadcast_sink_sync() for the
same sink; the second call tore down the stream the first was still
using, and the first then dereferenced a NULL endpoint.

Add a mutex and guard every access to remote_broadcast_sources with
it, so only one caller ever invokes bt_bap_broadcast_sink_sync() or
bt_bap_broadcast_sink_stop() for a given broadcaster, and no field is
read or written outside the critical section.

Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
2026-10-28 22:43:50 -04:00
Emil Gydesen
67b33c626b tests: Bluetooth: Tester: Send event per discovered CSIS
When bt_csip_set_coordinator_discover is called, it will discover
all CSIS instances on the remote device.
btp_csip.c:csip_discover_cb only considered the callback as a
single service discovery. Additionally it had a bug that it used the
conn_index, instead of the service index, when calling
bt_csip_set_coordinator_lookup_instance_by_index, which would
in cases for multiple lower tester report the incorrect handles,
and worse also possibly attempt to access invalid data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-10-28 22:43:13 -04:00
Kai Cheng
c797d0292a Bluetooth: Classic: L2CAP: Make echo API a testing API
The echo API is used for qualification testing, through the tester and
the shell, and has no other known user. Make it available only with
CONFIG_BT_TESTING, like the other APIs needed only for testing. Echo
Requests are still answered in other builds, by the stack.

Update the shell, whose echo commands now need CONFIG_BT_TESTING and are
built by a new scenario, the tests and the documentation, and describe
the change in the migration guide.

Assisted-by: Kiro:claude-opus-5.5
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-10-28 22:42:58 -04:00
Kai Cheng
3f834cfa02 tests: Bluetooth: Classic: Test L2CAP Echo Request answered by stack
Check that the stack answers an Echo Request with an Echo Response
without data when no req callback is registered, and that an Echo
Request received while no buffer is available for the response is kept
to be processed again, instead of being dropped.

Assisted-by: Kiro:claude-opus-5.5
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-10-28 22:42:58 -04:00
Kai Cheng
fe52d01f94 tests: Bluetooth: Classic: Test L2CAP echo with other signaling
Send Echo Requests while the Information Request sent on connection is
outstanding, and check that the Information Response, an Echo Response
with another identifier and a Command Reject are handled apart from
the Echo Request. The echo suite no longer clears the identifier of
the Information Request before each test.

Assisted-by: Kiro:claude-opus-5.5
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-10-28 22:42:58 -04:00
Kai Cheng
b93c1009e6 Bluetooth: Classic: L2CAP: Track Echo Request apart from signaling ident
The Echo Request used the signaling channel identifier and RTX timer,
which also track the Information Request. This had several effects:

- bt_l2cap_br_echo_req() returned -EBUSY while an Information Request
  was outstanding, such as right after the ACL connection is made.
- An Information Response arriving after its request timed out, while
  an Echo Request was outstanding, cleared the Echo Request identifier,
  so the Echo Response was dropped.
- An Echo Response with a mismatching identifier ended the outstanding
  Echo Request, so the matching response was dropped.
- A Command Reject for the Echo Request was taken as one for a dynamic
  channel and disconnected the signaling channel.
- The echo RTX timer was not canceled on disconnection.

Keep the Echo Request identifier and RTX timer in the signaling context.
Ignore Echo Responses that do not match the outstanding request, end
the request on a matching Command Reject, and cancel the timer when the
signaling channel is disconnected. The identifier is cleared before the
response callbacks run, so they can send the next request, and the RTX
timer is started before the request is sent, so that a response that
comes before the send returns cancels it.

Update the test that set the signaling channel identifier to stand for
an outstanding Echo Request, so that it sends an Echo Request instead.

Assisted-by: Kiro:claude-opus-5.5
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-10-28 22:42:58 -04:00
Arkadiusz Grzelka
05909e5dce bluetooth: nus: add Kconfig for security requirements
The NUS TX CCC and RX characteristic accept writes on an unencrypted
link, and a bonded peer's stored subscription lets notifications go out
before encryption.

Add the BT_ZEPHYR_NUS_SECURITY choice to require encryption, or
encryption and authentication, for those writes and for notifications.
Encryption alone still admits a peer paired with Just Works. The
default is no requirements, and the secured options depend on BT_SMP.

Add tests/bluetooth/nus to check the attribute permissions.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-28 22:38:56 -04:00
Johan Hedberg
3d09163f59 tests: bluetooth: classic: bumble: add a minimal ACL connection test
Add a reference user for the bumble twister sidecar, small enough to
show what a test has to declare: its controllers and devices in
tests.yaml, the normal ztest harness, and no scripts.

Two instances of the same native_sim executable run against two
linked Bumble virtual controllers: the central pages the peripheral,
and both verify that the ACL connection comes up and goes down again.

Tested on native_sim with Bumble 0.0.220; only built when Bumble is
missing.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-28 22:28:03 -04:00
Johan Hedberg
239cc53473 twister: add a Bumble Bluetooth sidecar
Bluetooth Classic tests on native_sim need linked virtual controllers
and one Zephyr instance per device. Without host-side support every
test carries shell scripts that allocate TCP ports, start and stop the
controllers and launch the peers, and that depend on the layout of the
twister output directory.

The "bumble" sidecar provisions this from sidecar_config, so a test
keeps its normal harness and ships no scripts. The controllers bind
kernel-chosen ports and report them to the sidecar, since a port
picked up front can be taken by a parallel worker before it is bound.
The handler watches the guest only, so the sidecar reads the Ztest
results the peers printed and reports the cases they ran, and the
peers share the scenario's timeout with the guest. On a host without
Bumble the test is built but not run.

Based on Anas Nashif's proof of concept for the pre-merge sidecar
framework (nashif/zephyr commit 099427868f7).

Tested on native_sim with Bumble 0.0.220: the acl_conn test passes
with both of its cases reported, also as three instances run in
parallel, and is only built when Bumble is missing.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-28 22:28:03 -04:00
Lyle Zhu
f720617346 tests: bluetooth: classic: bumble: add the simulation backend
Add the Python modules for Bluetooth Classic simulation testing:
virtual controllers built on Bumble, with a BR/EDR link and link-layer
simulation (inquiry, paging, ACL) that Bumble's stock virtual
controller does not provide, exposed as TCP HCI servers that native_sim
reaches through the HCI user-channel driver (--bt-dev=<ip:port>).

controllers.py starts one or more of these controllers, linked, from a
"<bumble-transport>@<bd_address>" specification per controller.

[johan: taken from the Bluetooth Classic simulation framework
proposal (PR #100491), trimmed to the Python simulation backend; the
shell-script test orchestration from that PR is superseded by the
bumble twister sidecar added on top of this.]

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-28 22:28:03 -04:00
Kyle Bonnici
47255ff899 style: Sorting properties in tests
Order of Properties in Device Node
The following order of properties in device nodes is preferred:

“compatible”
“reg”
“ranges”
Standard/common properties (defined by common bindings,
e.g. without vendor-prefixes)
Vendor-specific properties
“status” (if applicable)
Child nodes, where each node is preceded with a blank line

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2026-10-28 20:10:28 -04:00
Fin Maaß
7a476d0079 tests: bluetooth: tester: rename the panb511evb board files
The PAN B511 evaluation board is named panb611evb now, so the panb511evb
files are never picked up. Rename them to the current board name.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-10-22 18:43:56 +02:00
Fin Maaß
860f26188f samples, tests: remove the bl54l15u_dvk board files
bl54l15u_dvk is a deprecated alias of bl54l15_dvk, so board overlays and
configuration fragments named after it are never picked up. bl54l15_dvk
already has identical copies; the spi_controller_peripheral copy only
adds a zephyr,user sck-gpios property the test does not use.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-10-22 18:43:56 +02:00
Aric Radzin
e3f1e6099f tests: bluetooth: host_id: Test a legacy NRPA advertiser
The test HCI driver now rejects LE Set Random Address with Command
Disallowed while legacy advertising or scanning is enabled, as a
controller does (Core v6.3, Vol 4, Part E, 7.8.4), and records the
addresses it accepts.

With an advertiser started with BT_LE_ADV_OPT_USE_NRPA, check that:
- after a 1 s RPA timeout its address is a new NRPA;
- passive and active scanning start and keep its NRPA, and the scanner
  is enabled again with the next one;
- bt_conn_le_create() and bt_le_oob_get_local() fail with -EINVAL,
  bt_conn_le_create() also when it would resolve the peer's address in
  the Host.

The privacy variant enables CONFIG_BT_RPA_TIMEOUT_DYNAMIC to shorten
the timeout.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-22 18:34:07 +02:00
Johan Hedberg
2e6087244a tests: Bluetooth: host_long_adv_recv: Test Incomplete periodic reports
Check that the Host delivers the periodic advertising report that
follows one with the Incomplete data status: after a report that the
Controller failed to receive in full, after one with the Incomplete
data status only and after one that the Host already drops.

Run the suite without a periodic advertising reassembly buffer too, the
default configuration, where the fragment length checks do not apply.

Each test synchronizes on its own and deletes the sync afterwards, also
when it fails, so that a failure does not carry over into the next test.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:33:05 +02:00
Johan Hedberg
81f280bed3 Bluetooth: Host: Fix completed packets for ACL data dropped early
With Controller to Host flow control, an ACL buffer that is freed before
hci_acl() has looked up its connection, as when the driver drops the
packet or it is too short for its header, keeps the zeroed user data of
its allocation. Its completion is then reported for handle 0x0000 while
the first connection is up: to a handle the Controller may not have, or
to another connection. Mark the buffer as having no connection from its
allocation on.

The host_disable test added here fails without the fix.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:17:35 +02:00
Johan Hedberg
8d7d406897 tests: Bluetooth: Host: Test ISO TX when a CIS goes down
A fake controller with two small ISO data buffers lets the Host get an
SDU of two fragments half sent while the controller holds an earlier
SDU. When the peer disconnects the CIS, or bt_disable() takes it down,
every SDU given to the Host must be reported to send_failed, and once
the central has connected the CIS again, its first SDU must be sent
whole and not as a continuation.

Without the previous commits the cases fail: one SDU of three is
reported on a disconnection, bt_disable() reports none or asserts, and
the SDU after reconnecting is flagged as the end of one.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-22 18:16:52 +02:00
Johan Hedberg
c5d1983274 tests: bluetooth: init: Build the Controller without its crypto
Nothing in CI builds BT_CTLR_CRYPTO=n, so its build failures went
unnoticed since v3.7. Add a variant of test_ctlr_central_priv with
BT_CTLR_CRYPTO=n on nrf52840dk/nrf52840.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 13:46:41 +02:00
Johan Hedberg
1c19f89bb2 tests: Bluetooth: Host: Fix helper thread stacks on arm64
On qemu_cortex_a53 the helper threads of host_disable are too small:
the thread that calls bt_enable() in the ctlr_stops and send_blocks
scenarios, sized CONFIG_ZTEST_STACK_SIZE (1024 bytes), overflows when
the Host asserts, and the workqueue that disconnects in the conn
scenario uses 964 of its 1024. Add CONFIG_TEST_EXTRA_STACK_SIZE to both,
as ztest does for its own thread. It is 0 on native_sim.

Tested on qemu_cortex_a53 with the stack sentinel, and on native_sim and
native_sim/native/64.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:59:59 +02:00
Johan Hedberg
8cab85f0d4 Bluetooth: Fix the copyright holder of files from Silicon Labs
These files were written for Silicon Laboratories, which holds their
copyright, but were added with the line for The Zephyr Project
Contributors. They came with #119615, #120846, #121257 and #122021, and
nobody has changed them since. The build and test scaffolding that came
with them, and a file mostly copied from another test, keep that line.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:56:53 +02:00
Johan Hedberg
2b787bc8ab tests: Bluetooth: Host: Test L2CAP TX behind a channel without credits
Through a test controller with a single ACL buffer, queue an SDU on a
credit-based channel that has no credits and, behind it, a response on
the LE signalling channel. Once the controller frees its buffer, the
response must be sent, and the SDU once the peer gives a credit.

Tested on native_sim and native_sim/native/64: without the fix the
response is not sent.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-21 11:52:48 +02:00
Mark Tamas
72f89844f2 Bluetooth: Host: tests: Cover OVERWRITE_OLDEST pool paths in host_keys
Cover the key-pool eviction paths in keys.c that only the removed
internal-mock unit tests reached: eviction of the least recently used
entry, aging updates via bt_keys_update_usage(), protection of in-use
entries (fake incoming connections through the test HCI driver), and
rejection when every entry is in use.

The pool edge tests that assume rejection on a full pool skip under
this configuration, where eviction replaces rejection. The suite and
its helpers are guarded by
#if defined(CONFIG_BT_KEYS_OVERWRITE_OLDEST), since
bt_keys_update_usage() only exists under that config.

Part of #117836

Signed-off-by: Mark Tamas <marktamas28@gmail.com>
Assisted-by: Kimi:kimi-k2.7
2026-10-20 17:42:24 +02:00
Johan Hedberg
43f8dcd0b2 tests: Bluetooth: Host: Test the directed advertising timeout
Let a test Controller report the timeout of high duty cycle directed
advertising with a connection complete event followed by LE Advertising
Set Terminated and, in two scenarios that set
BT_HCI_QUIRK_NO_ADV_TERM_ON_DIR_TIMEOUT, with the connection complete
alone, the second of them with two advertising sets.

In all scenarios bt_le_ext_adv_start() and bt_le_adv_start() have to
deliver the connected callback and accept a second start, and a
connection complete that arrives after the application stopped the set
must have no effect. With two sets, a low duty cycle directed set has to
stay enabled and a second high duty cycle set has to be refused.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-20 17:29:34 +02:00
Johan Hedberg
dc5d1d07ad tests: Bluetooth: Classic: Test L2CAP echo send failures
Make Echo Request and Echo Response sends fail with a buffer that lacks
the user data L2CAP needs. The buffer must come back unchanged, and a
failed request must not be left waiting for a response.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-19 10:18:42 +02:00
Johan Hedberg
5eaa0f3264 tests: Bluetooth: Classic: Test L2CAP echo and connless callbacks
Register two Echo and two connectionless callbacks that consume their
data, and deliver Echo Requests and an Echo Response followed by other
commands in the same signaling packet. Each callback must see exactly
the data of its own command or frame.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-19 10:18:27 +02:00
Johan Hedberg
229470f661 tests: Bluetooth: Classic: Test L2CAP receivers keeping buffers
Cover recv() callbacks that return -EINPROGRESS on basic and streaming
mode channels: the buffer must stay valid until
bt_l2cap_chan_recv_complete() is called and be freed exactly once.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-19 10:18:11 +02:00
Johan Hedberg
ec7a37c558 tests: Bluetooth: Classic: Fix IUT address parsing in pytest fixtures
Commit 2b9422c426 ("Bluetooth: addr: Change LE address string format
to prefix-based") changed the identity address that `bt init` and
`bt id-show` print from "C0:00:00:00:00:01 (public)" to
"P:C0:00:00:00:00:01". The fixtures of the Classic pytest suites still
expected the old form, so every case failed at setup with "Fail to get
IUT BD address". Match the new form; the suites use only the address.

The A2DP fixtures get the duplicate-code pylint pragma that the other
Classic fixtures already carry, since pylint compares all changed
conftests with each other.

Tested on native_sim against Bumble and a simulated BR/EDR controller,
first case of each suite: all 13 non-A2DP suites get past setup.
l2cap_c, l2cap_s, rfcomm_c, rfcomm_s, sdp_c and sdp_s pass; the gap and
smp cases fail at the same assertion as before the address format
change. The A2DP suites need a newer Bumble and were not run.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-19 10:17:49 +02:00
Mark Tamas
aec90cd5c2 Bluetooth: Host: tests: Cover settings load branches in host_keys
Extend the native_sim host_keys suite with keys_set() migration and
edge branches. These branches had no test coverage: the internal-mock
unit tests removed in #93086 never called keys_set(), and the bsim
configurations do not reach them. Entries are written through the
real settings backend and reloaded per entry with
settings_load_subtree():

- restore of a well-formed bond (current format)
- zero-length delete marker (delivered through the runtime backend)
- old storage format (BT_KEYS_STORAGE_LEN_COMPAT)
- invalid length rejection
- cfg version and cfg flags mismatch rejection
- unprovable-authentication downgrade (AUTHENTICATED without SC/OOB)

The suite initializes the settings subsystem in its setup, so it
passes standalone and in any suite order, and a teardown deletes what
the tests stored. Blob cfg_flags mirror the host's STORAGE_CFG_FLAGS
derivation, so the tests adapt to the scenario configuration.

Part of #117836

Signed-off-by: Mark Tamas <marktamas28@gmail.com>
Assisted-by: Kimi:kimi-k2.7
2026-10-16 13:16:20 +02:00
Mark Tamas
b95dd1e5dc Bluetooth: Host: tests: Cover key pool edge branches in host_keys
Extend the native_sim host_keys suite with pool edge cases: fresh-slot
allocation, full-pool rejection for bt_keys_get_addr() and
bt_keys_get_type(), ref stability, and find/find_addr hit and miss
paths with the public bt_foreach_bond().

The full-pool return paths were only exercised by the internal-mock
unit tests removed in #93086; other key pool paths are covered by the
bsim test configurations. The key pool is reset before each test, as
ZTest does not guarantee test execution order within a suite.

Part of #117836

Signed-off-by: Mark Tamas <marktamas28@gmail.com>
Assisted-by: Kimi:kimi-k2.7
2026-10-16 13:16:20 +02:00
Johan Hedberg
6ec2b2670b tests: Bluetooth: Host: Test a command response that is too long
Give the fake driver a vendor command with a 200-byte response and
check that the command fails and the next one works. Without the length
check in hci_cmd_done() the test stops in the net_buf assertion.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-15 14:17:50 +02:00
Yuheng Li
b865a2fc8e Bluetooth: tester: Fix misleading GAP connection callback names
The connected, disconnected and security_changed callbacks of the GAP
tester are registered on the transport-agnostic bt_conn_cb, and all three
handle BR/EDR connections in addition to LE ones. The le_ prefix suggests
they are LE-only, which they are not.

Rename them to btp_gap_connected, btp_gap_disconnected and
btp_gap_security_changed. le_identity_resolved, le_param_updated and
le_param_req only ever see LE connections, so they keep their names.

No functional change.

Signed-off-by: Yuheng Li <liyuheng@xiaomi.com>
2026-10-14 13:49:19 +02:00
Arkadiusz Grzelka
3ae8217cf7 Bluetooth: PACS: Fix notify property of Sink and Source PAC
The Sink and Source PAC characteristics set the notify property under
CONFIG_BT_PAC_SNK_LOC_NOTIFIABLE and CONFIG_BT_PAC_SRC_LOC_NOTIFIABLE,
but their CCCD follows CONFIG_BT_PAC_SNK_NOTIFIABLE and
CONFIG_BT_PAC_SRC_NOTIFIABLE.

With only the PAC option set, a client's CCCD write is rejected with
CCC Improper Configuration. With only the location option set, the
property has no CCCD behind it.

Gate the property on the PAC option.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-14 08:40:58 +02:00
Johan Hedberg
00d62b6b74 tests: Bluetooth: Host: Test a command in flight during bt_disable()
Disconnect from a thread of its own while bt_disable() waits for the
controller to be reset. The controller gets the command before the
transport is closed and does not get to respond to it.
bt_conn_disconnect() has to return an error when the transport has
been closed, and Bluetooth has to come up again afterwards.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-12 23:26:05 +02:00
Johan Hedberg
4b29eb3a0f tests: Bluetooth: Host: Test a driver that fails to send data
Add two tests in which the HCI driver fails to send a data packet. In
the first the Host disconnects the connection, and sends nothing more
on it while the controller takes its time to respond to the command.
In the second the controller rejects the command, and the connection
goes on sending what was queued meanwhile.

The test driver now answers a disconnect command the way a controller
does, with a Command Status and a Disconnection Complete event, after
a delay and with a status that the test sets.

Without the fix in the previous commit the TX processor thread waits
for its own HCI_Disconnect command until the command times out and the
Host asserts.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-12 23:26:05 +02:00
Johan Hedberg
a7da8b000a tests: Bluetooth: Host: Test sending data during bt_disable()
Add a scenario to the bt_disable() test in which an application sends
data on a connection while bt_disable() waits for the controller to be
reset. The test driver gains what that takes: a connection, a
controller that takes its time to respond to the reset, as one at the
other end of a UART or USB link does, and counters for the disconnect
commands and the data packets it is given.

Without the fix in the previous commit the TX processor thread waits
for its own HCI_Disconnect command until the command times out and the
Host asserts.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-12 23:26:05 +02:00
Johan Hedberg
d1ab0b2089 tests: Bluetooth: Classic: Test L2CAP send failures
Make a send and a connectionless send fail with a buffer that lacks the
user data L2CAP needs. The caller must get the buffer back unchanged.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-10 06:52:47 +02:00
Ludvig Jordet
3f878df514 Bluetooth: Mesh: Decouple RPL store timeout from storage mode
Solve two issues:

  * Other storage modes than CONFIG_BT_MESH_RPL_STORAGE_MODE_SETTINGS
    could not reuse the pending store scheduler used by the settings
    backend.
  * The store timing of SRPL, which is always stored through the
    Settings subsystem, would use CONFIG_BT_MESH_RPL_STORE_TIMEOUT if
    RPL was also stored in settings via
    CONFIG_BT_MESH_RPL_STORAGE_MODE_SETTINGS, but not if another storage
    mode was used for RPL.

Decouple the store scheduler from the Settings subsystem and the
chosen RPL storage mode, so the scheduler code and the separate
CONFIG_BT_MESH_RPL_STORE_TIMEOUT option are

a) Available regardless of storage mode, and always used for SRPL when
set and
b) Available without CONFIG_BT_SETTINGS, in case an RPL storage mode
does not need Settings but would like the scheduling.

Also change the BT_MESH_SETTINGS_RPL_RESET_PENDING to always store
immediately. This was in practice already the case whenever settings was
used, since this was only ever scheduled right before a second NO_WAIT
configuration was scheduled (like net key, IV, etc.). Now this behavior
is consistent both with and without BT_SETTINGS enabled.

Assisted-by: Copilot:claude-sonnet-5.5
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2026-10-09 16:58:06 +02:00
Vandra-Meyer Akos
53dbcfce64 tests: Bluetooth: Host: Test bt_enable() with a silent Controller
The test driver can now drop every command, drop every command after the
first one, or stay in send() for longer than the command timeout.

When the driver drops every command, bt_enable() must fail with
-ETIMEDOUT and close the transport, and a later bt_enable() must succeed
when the driver responds again. One case calls bt_enable() without a
callback. The other case uses the ready callback, so the initialization
and the close run on the system work queue.

When the driver answers HCI Reset and then drops every command, or when
it is still in send() at the timeout, the Host must assert and must not
close the transport. The ztest fatal error hook catches the assert in a
separate thread. The assert leaves the Host in the middle of bt_enable(),
so each of these cases runs alone, in the bluetooth.host_disable.ctlr_stops
and bluetooth.host_disable.send_blocks scenarios.

Without the previous commit, the cases with a silent controller assert on
the timeout of HCI Reset.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Vandra-Meyer Akos <akos@lvgl.io>
2026-10-09 16:55:07 +02:00