Commit graph zephyr/tests/bluetooth/host_direct_adv_recv/dts
Author SHA1 Message Date
Aric Radzin
05f23c5abb tests: bluetooth: host: Add LE Directed Advertising Report tests
Add tests for the LE Directed Advertising Report handling, driving the
host through a fake HCI driver on native_sim so that the LE event mask,
the meta event dispatch and the scanner state are exercised, and the
reports are observed where an application sees them, in the scan recv
callback.

The tests cover the event mask bit, the reported advertising type,
properties and target address for an unresolved target, events carrying
several reports, events that are truncated or empty, discarding reports
while no scanner is running, and that an ordinary LE Advertising Report
reports no target address. The fake Controller lets a test choose the LE
features it reports, so the case where the Extended Scanner Filter
Policies are unsupported is covered as well: the event stays masked off
and bt_le_scan_start() returns -ENOTSUP.

The suite is built three times. Whether a directed report for the local
identity is delivered depends on CONFIG_BT_SCAN_WITH_IDENTITY, so the
default configuration checks that such a report is still dropped and the
CONFIG_BT_SCAN_WITH_IDENTITY=y configuration checks that the identity
address type is converted. The CONFIG_BT_EXT_ADV=y configuration covers
the same advertisement arriving in an LE Extended Advertising Report,
whose target address must keep the BT_ADDR_LE_UNRESOLVED type.

This replaces a unit test that stubbed the HCI transport, the mutexes and
the own address setup and called the event handler directly, so it never
exercised the event mask, the meta event entry or the feature check.

The fake Controller also records the scanning filter policy the host asks
for, so the suite asserts that each combination of
BT_LE_SCAN_OPT_EXT_FILTER_POLICY and BT_LE_SCAN_OPT_FILTER_ACCEPT_LIST
maps to the expected one of the four policies. The configurations cover
the legacy and the extended scan parameter commands between them.

34 test cases pass with west twister -p native_sim. Removing the
BT_ADDR_LE_UNRESOLVED handling from either report path makes them fail,
as does swapping the two extended filter policy constants.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-09-17 16:41:20 -07:00