mirror of
https://github.com/esphome/esphome.git
synced 2026-10-10 13:33:06 +00:00
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
22 lines
767 B
Python
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
|