mirror of
https://github.com/ratspeak/C6-Reticulum-ASM
synced 2026-08-12 18:07:18 -04:00
Single `ret` on qemu-virt — the CPU is already at qemu's configured rate. Body is target-conditional via .ifdef TARGET_QEMU_VIRT; the C6 arm contains a .error so it fails loudly the first time someone builds for the C6 without writing the PLL sequence. Per @verify: kat-only, the test asserts shape only — function exists, body is exactly one instruction (ret), no callee-saved writes.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Tests for src/clock/clock_init.S.
|
|
|
|
On qemu-virt the body is `ret` — the CPU is already running at qemu's
|
|
configured rate. The test asserts the function exists, contains exactly
|
|
one return, and preserves callee-saved registers (trivially, since the
|
|
body is empty).
|
|
|
|
The C6-target test will assert the post-condition that the CPU is at
|
|
160 MHz; that lands when the C6 register sequence does.
|
|
"""
|
|
|
|
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:
|
|
addr = build.symbol_address(artifacts.elf, "clock_init")
|
|
assert addr > 0
|
|
|
|
|
|
def test_qemu_virt_body_is_just_return(artifacts: build.BuildArtifacts) -> None:
|
|
body = build.objdump_disassemble(artifacts.elf, symbol="clock_init")
|
|
instrs = [line for line in body.splitlines() if re.match(r"^\s*[0-9a-f]{8}:", line)]
|
|
assert len(instrs) == 1, body
|
|
assert "ret" in instrs[0] or "jalr\tzero" in instrs[0], instrs[0]
|
|
|
|
|
|
def test_no_callee_saved_writes(artifacts: build.BuildArtifacts) -> None:
|
|
body = build.objdump_disassemble(artifacts.elf, symbol="clock_init")
|
|
for match in re.findall(r"\b(s\d+)\b,", body):
|
|
pytest.fail(f"clock_init writes callee-saved {match}: {body}")
|