C6-Reticulum-ASM/tests/log/test_log_init.py
DeFiDude 7c80281244 log_init + log_str: verified
log_init is a single ret today; the ts source lands when clock_get_freq
is wired and log_event needs a real ms-since-boot value. The function
exists now so log_event can call it without forward dependency.

log_str tail-calls uart_tx_bytes — no frame, ra threads through. The
indirection exists so log_event and downstream primitives don't couple
to the underlying TX implementation; a future IRQ-driven uart_tx_bytes
swap stays local to one file.
2026-05-01 22:46:56 -06:00

31 lines
994 B
Python

"""Tests for src/log/log_init.S — placeholder body, single ret today."""
from __future__ import annotations
import re
import pytest
from harness import build
@pytest.fixture(scope="module")
def artifacts() -> build.BuildArtifacts:
return build.build("qemu-virt")
def test_function_exists(artifacts: build.BuildArtifacts) -> None:
assert build.symbol_address(artifacts.elf, "log_init") > 0
def test_body_is_just_return(artifacts: build.BuildArtifacts) -> None:
body = build.objdump_disassemble(artifacts.elf, symbol="log_init")
instrs = [line for line in body.splitlines() if re.match(r"^\s*[0-9a-f]{8}:", line)]
assert len(instrs) == 1
assert "ret" in instrs[0] or "jalr\tzero" in instrs[0]
def test_no_callee_saved_writes(artifacts: build.BuildArtifacts) -> None:
body = build.objdump_disassemble(artifacts.elf, symbol="log_init")
for match in re.findall(r"\b(s\d+)\b,", body):
pytest.fail(f"log_init writes callee-saved {match}: {body}")