mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""The rp2 BTstack pool overrides: multi-slot builds emit the --wrap flags
|
|
that swap the prebuilt single-client pools for the codegen-sized ones;
|
|
single-slot builds emit none and stay byte-identical to previous releases."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Callable
|
|
from pathlib import Path
|
|
|
|
from esphome.components import rp2040_ble
|
|
from esphome.core import CORE
|
|
|
|
from ..helpers import get_define_value
|
|
|
|
WRAP_FLAGS = tuple(
|
|
f"-Wl,--wrap={symbol}" for symbol in rp2040_ble._BTSTACK_POOL_SYMBOLS
|
|
)
|
|
|
|
|
|
def test_default_slots_emit_the_pool_wrap(
|
|
generate_main: Callable[[str | Path], str],
|
|
component_config_path: Callable[[str], Path],
|
|
) -> None:
|
|
generate_main(component_config_path("rp2_proxy_default.yaml"))
|
|
assert all(flag in CORE.build_flags for flag in WRAP_FLAGS)
|
|
assert get_define_value("ESPHOME_BLE_GATT_CLIENT_COUNT") == "3"
|
|
assert get_define_value("BLUETOOTH_PROXY_MAX_CONNECTIONS") == "3"
|
|
|
|
|
|
def test_two_slots_emit_the_pool_wrap(
|
|
generate_main: Callable[[str | Path], str],
|
|
component_config_path: Callable[[str], Path],
|
|
) -> None:
|
|
# Two slots: the wrap pools are smaller than the cap, sized from the count.
|
|
generate_main(component_config_path("rp2_proxy_two_slots.yaml"))
|
|
assert all(flag in CORE.build_flags for flag in WRAP_FLAGS)
|
|
assert get_define_value("ESPHOME_BLE_GATT_CLIENT_COUNT") == "2"
|
|
assert get_define_value("BLUETOOTH_PROXY_MAX_CONNECTIONS") == "2"
|
|
|
|
|
|
def test_single_slot_keeps_the_prebuilt_pools(
|
|
generate_main: Callable[[str | Path], str],
|
|
component_config_path: Callable[[str], Path],
|
|
) -> None:
|
|
generate_main(component_config_path("rp2_proxy_single_slot.yaml"))
|
|
assert not any(flag in CORE.build_flags for flag in WRAP_FLAGS)
|
|
assert get_define_value("ESPHOME_BLE_GATT_CLIENT_COUNT") == "1"
|
|
assert get_define_value("BLUETOOTH_PROXY_MAX_CONNECTIONS") == "1"
|