mirror of
https://github.com/esphome/esphome.git
synced 2026-05-22 09:56:15 +08:00
839139df36
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Stale / stale (push) Has been cancelled
Lock closed issues and PRs / lock (push) Has been cancelled
Publish Release / Initialize build (push) Has been cancelled
Publish Release / Build and publish to PyPi (push) Has been cancelled
Publish Release / Build ESPHome amd64 (push) Has been cancelled
Publish Release / Build ESPHome arm64 (push) Has been cancelled
Publish Release / Publish ESPHome docker to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome docker to ghcr (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to ghcr (push) Has been cancelled
Publish Release / deploy-ha-addon-repo (push) Has been cancelled
Publish Release / deploy-esphome-schema (push) Has been cancelled
Publish Release / version-notifier (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04-arm) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04-arm) (push) Has been cancelled
70 lines
2.5 KiB
Python
70 lines
2.5 KiB
Python
"""Integration test for FNV-1a hash functions."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import re
|
|
|
|
import pytest
|
|
|
|
from .types import APIClientConnectedFactory, RunCompiledFunction
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fnv1a_hash(
|
|
yaml_config: str,
|
|
run_compiled: RunCompiledFunction,
|
|
api_client_connected: APIClientConnectedFactory,
|
|
) -> None:
|
|
"""Test that FNV-1a hash functions work correctly."""
|
|
|
|
test_results = {}
|
|
all_tests_complete = asyncio.Event()
|
|
expected_tests = {"empty", "known_hello", "known_helloworld", "extend", "string"}
|
|
|
|
def on_log_line(line: str) -> None:
|
|
"""Capture log lines with test results."""
|
|
# Strip ANSI escape codes
|
|
clean_line = re.sub(r"\x1b\[[0-9;]*m", "", line)
|
|
# Look for our test result messages
|
|
# Format: "[timestamp][level][FNV1A:line]: test_name PASSED"
|
|
match = re.search(r"\[FNV1A:\d+\]:\s+(\w+)\s+(PASSED|FAILED)", clean_line)
|
|
if match:
|
|
test_name = match.group(1)
|
|
result = match.group(2)
|
|
test_results[test_name] = result
|
|
if set(test_results.keys()) >= expected_tests:
|
|
all_tests_complete.set()
|
|
|
|
async with (
|
|
run_compiled(yaml_config, line_callback=on_log_line),
|
|
api_client_connected() as client,
|
|
):
|
|
device_info = await client.device_info()
|
|
assert device_info is not None
|
|
assert device_info.name == "fnv1a-hash-test"
|
|
|
|
# Wait for all tests to complete or timeout
|
|
try:
|
|
await asyncio.wait_for(all_tests_complete.wait(), timeout=2.0)
|
|
except TimeoutError:
|
|
pytest.fail(f"Tests timed out. Got results for: {set(test_results.keys())}")
|
|
|
|
# Verify all tests passed
|
|
assert "empty" in test_results, "empty string test not found"
|
|
assert test_results["empty"] == "PASSED", "empty string test failed"
|
|
|
|
assert "known_hello" in test_results, "known_hello test not found"
|
|
assert test_results["known_hello"] == "PASSED", "known_hello test failed"
|
|
|
|
assert "known_helloworld" in test_results, "known_helloworld test not found"
|
|
assert test_results["known_helloworld"] == "PASSED", (
|
|
"known_helloworld test failed"
|
|
)
|
|
|
|
assert "extend" in test_results, "fnv1a_hash_extend test not found"
|
|
assert test_results["extend"] == "PASSED", "fnv1a_hash_extend test failed"
|
|
|
|
assert "string" in test_results, "std::string test not found"
|
|
assert test_results["string"] == "PASSED", "std::string test failed"
|