Files
pyxis/tests/build_scripts/test_release_build_contract.py
T
Torlando 3c6275d9e6 chore(diag): gate [SENDT] and [PG] instrumentation behind build flags
[SENDT] send-pipeline timing and the microReticulum [PG] path-store
call-site counters now compile to no-ops unless explicitly enabled:
  - DPYXIS_SEND_DIAG / -DRNS_PATHGET_DIAG added to env:tdeck base flags
  - both removed by env:tdeck-release build_unflags (no-op in release)

So production tdeck/tdeck-release builds are merge-clean, while the
instrumented build stays one env/flag away for the path-request
spammer hunt. Bumps microReticulum pin to 921b3aa (same endpoint
hot-path read gate, counters gated behind RNS_PATHGET_DIAG).

Contract suite: 176/176.
2026-09-06 22:42:16 +00:00

81 lines
3.3 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
MICROSTORE_PIN = "https://github.com/torlando-tech/microStore.git#2762f7606800ffb23f4a593947d4f58e259cda7a"
MICRORETICULUM_PIN = "https://github.com/torlando-tech/microReticulum.git#921b3aa030525f819671d99eff1d1f28350c9b69"
MAX_RNS_PSRAM_POOL_BYTES = 1024 * 1024
def test_microstore_pin_resolves_before_transitive_registry_requirement():
config = (ROOT / "platformio.ini").read_text()
dependencies = config.split("lib_deps =", 1)[1].split("; Build configuration", 1)[0]
assert dependencies.count(MICROSTORE_PIN) == 1
assert dependencies.index(MICROSTORE_PIN) < dependencies.index(MICRORETICULUM_PIN)
def test_release_auditor_expects_the_configured_microreticulum_pin():
audit = (ROOT / "tools/audit_release_build.py").read_text()
expected_revision = MICRORETICULUM_PIN.rsplit("#", 1)[1]
assert f'"microReticulum": "{expected_revision}"' in audit
def test_rns_psram_pool_leaves_workspace_for_python_level9_bz2_responses():
config = (ROOT / "platformio.ini").read_text()
prefix = "-DRNS_PSRAM_POOL_BUFFER_SIZE="
configured = next(
int(line.strip()[len(prefix) :])
for line in config.splitlines()
if line.strip().startswith(prefix)
)
# Python bz2.compress() defaults to level 9. libbz2's small decoder needs
# 2.25 MB for its two block arrays before output/state allocations. Keep the
# long-lived RNS container pool bounded so that workspace remains available.
assert configured == MAX_RNS_PSRAM_POOL_BYTES
def test_tdeck_release_removes_diagnostic_flags():
config = (ROOT / "platformio.ini").read_text()
release = config.split("[env:tdeck-release]", 1)[1].split("[env:", 1)[0]
assert "extends = env:tdeck" in release
for flag in (
"-DPYXIS_TEST_HOOKS",
"-DPYXIS_TEST_TCP_HOST",
"-DPYXIS_TEST_TCP_PORT",
"-DMEMORY_INSTRUMENTATION_ENABLED",
"-DBOOT_PROFILING_ENABLED",
):
assert flag in release
def test_disabled_instrumentation_macros_remain_defined():
main = (ROOT / "src/main.cpp").read_text()
memory = (ROOT / "lib/microreticulum-shim/Instrumentation/MemoryMonitor.h").read_text()
boot = (ROOT / "lib/microreticulum-shim/Instrumentation/BootProfiler.h").read_text()
assert "#include <Instrumentation/MemoryMonitor.h>" in main
assert "#include <Instrumentation/BootProfiler.h>" in main
assert "#define MEMORY_MONITOR_POLL() ((void)0)" in memory
assert "#define BOOT_PROFILE_COMPLETE() ((void)0)" in boot
def test_ci_and_deployment_build_the_release_environment():
build_check = (ROOT / ".github/workflows/build-check.yml").read_text()
release = (ROOT / ".github/workflows/release-firmware.yml").read_text()
assert "environment: [tdeck, tdeck-release]" in build_check
assert "matrix.environment == 'tdeck-release'" in build_check
assert ".pio/build/tdeck-release/firmware.bin" in build_check
assert "python tools/audit_release_build.py" in build_check
assert "pio run -e tdeck-release" in release
assert "python tools/audit_release_build.py" in release
assert ".pio/build/tdeck-release/bootloader.bin" in release
assert ".pio/build/tdeck-release/partitions.bin" in release
assert ".pio/build/tdeck-release/firmware.bin" in release
assert ".pio/build/tdeck/firmware.bin" not in release