Record the finite dependency search, Wi-Fi maintenance blocker, and pinned icon provenance. Add bounded host orchestration and fixture coverage, and update release documentation with current evidence.
67 lines
3.5 KiB
Python
67 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Compile actual console implementation with deterministic host RTOS/IO fakes.
|
|
|
|
No target scheduler, socket library, or hardware execution is claimed.
|
|
"""
|
|
from pathlib import Path
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
IDF = Path(os.environ.get("IDF_PATH", str(Path.home() / ".platformio/packages/framework-espidf")))
|
|
parser = str(IDF / "components/console/split_argv.c")
|
|
source = (ROOT / "src/admin_ssh_console.c").read_text()
|
|
header = (ROOT / "src/admin_ssh_console.h").read_text()
|
|
def strip_includes(text):
|
|
return "\n".join(line for line in text.splitlines()
|
|
if not line.startswith(("#include", "#pragma once")))
|
|
|
|
with tempfile.TemporaryDirectory(prefix="admin-console-boundary-") as directory:
|
|
path = Path(directory)
|
|
unit = ((ROOT / "tests/admin_console_boundary/fakes.h").read_text()
|
|
+ strip_includes(header) + "\n" + strip_includes(source)
|
|
+ (ROOT / "tests/admin_console_boundary/test.c").read_text())
|
|
(path / "test.c").write_text(unit)
|
|
subprocess.run(["cc", "-std=c11", "-Wall", "-Wextra", "-Werror",
|
|
"-g", str(path / "test.c"), parser,
|
|
"-o", str(path / "test")], check=True, timeout=30)
|
|
subprocess.run([str(path / "test")], check=True, timeout=10)
|
|
unit = ((ROOT / "tests/admin_console_boundary/fakes.h").read_text()
|
|
+ strip_includes(header) + "\n" + strip_includes(source)
|
|
+ (ROOT / "tests/admin_console_boundary/certificate.c").read_text())
|
|
(path / "certificate.c").write_text(unit)
|
|
subprocess.run(["cc", "-std=c11", "-Wall", "-Wextra", "-Werror",
|
|
"-g", str(path / "certificate.c"), parser,
|
|
"-o", str(path / "certificate")], check=True, timeout=30)
|
|
subprocess.run([str(path / "certificate")], check=True, timeout=10)
|
|
ssh = (ROOT / "src/ssh_transport.c").read_text()
|
|
# Bound the adapter by its own functions, not the allocator helpers now
|
|
# owned by ssh_memory.c. Fail closed if the reviewed source layout changes.
|
|
adapter_markers = (
|
|
"static admin_ssh_console_token_t admin_console_token(",
|
|
"static void publish_slot(",
|
|
"static size_t admin_console_snapshot_index_locked(",
|
|
"static bool admin_console_is_current(",
|
|
"static bool admin_console_drained(",
|
|
"static esp_err_t admin_console_perform(",
|
|
"static const admin_console_owner_t s_admin_console_owner = {",
|
|
"static bool consume_external_close(",
|
|
)
|
|
positions = []
|
|
for marker in adapter_markers:
|
|
assert ssh.count(marker) == 1, f"SSH adapter marker missing/ambiguous: {marker}"
|
|
positions.append(ssh.index(marker))
|
|
assert positions == sorted(positions), "SSH adapter source order changed"
|
|
adapter_end = ssh.index("\n}", positions[-1]) + len("\n}")
|
|
adapter = ssh[positions[0]:adapter_end]
|
|
unit = ((ROOT / "tests/admin_console_boundary/fakes.h").read_text()
|
|
+ strip_includes(header) + "\n" + strip_includes(source)
|
|
+ (ROOT / "tests/admin_console_boundary/adapter.c").read_text()
|
|
+ adapter + "\nint main(void) { test_adapter(); }\n")
|
|
(path / "adapter.c").write_text(unit)
|
|
subprocess.run(["cc", "-std=c11", "-Wall", "-Wextra", "-Werror",
|
|
"-Wno-unused-variable", str(path / "adapter.c"), parser,
|
|
"-o", str(path / "adapter")], check=True, timeout=30)
|
|
subprocess.run([str(path / "adapter")], check=True, timeout=10)
|