Files
esphome/tests/component_tests/wireguard/test_allowed_ips.py
T
J. Nick Kostonandpre-commit-ci-lite[bot] 5cd7bf5993 [wireguard] Keep allowed IPs in a shared flash table (#20087)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-10-09 09:20:46 -10:00

22 lines
767 B
Python

"""Tests for the wireguard allowed IPs codegen."""
from collections.abc import Callable
from pathlib import Path
def test_allowed_ips_are_a_progmem_table(
generate_main: Callable[[str | Path], str],
component_config_path: Callable[[str], Path],
) -> None:
"""Allowed IPs live in a flash table ended by an empty entry instead of a heap vector."""
main_cpp = generate_main(component_config_path("allowed_ips.yaml"))
table = main_cpp.split(
"wireguard::AllowedIP wireguard_allowed_ips[] PROGMEM = ", 1
)[1]
table = table.split(";", 1)[0]
assert '.ip = "172.16.34.0"' in table
assert '.netmask = "255.255.0.0"' in table
assert ".ip = nullptr" in table
assert "->set_allowed_ips(wireguard_allowed_ips);" in main_cpp