049e3d8bb3
Move benches/ -> src/kernbench/benches/ and src/kernbench/cli/probe.py -> src/kernbench/probes/probe.py. Each bench self-registers via @bench(name=..., description=...); kernbench list enumerates benches with auto-assigned indices, --bench accepts kebab-case name or numeric index. Audit at package-import time fails if any non-underscore module forgets the decorator. ADR-0010 (EN + KO) updated to reflect the new resolver path, list subcommand, and probes package separation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
"""Tests for `kernbench list` subcommand and `--bench <index>` resolution."""
|
|
from __future__ import annotations
|
|
|
|
import kernbench.cli.main as cli_main
|
|
from kernbench.benches import registry
|
|
|
|
|
|
def test_cli_list_outputs_all_benches(capsys):
|
|
rc = cli_main.main(["list"])
|
|
assert rc == 0
|
|
out = capsys.readouterr().out
|
|
for spec in registry.list_all():
|
|
assert spec.name in out
|
|
assert "DESCRIPTION" in out
|
|
|
|
|
|
def test_cli_run_by_index(monkeypatch):
|
|
"""CLI accepts numeric index for --bench; same callable as the name."""
|
|
qkv_spec = registry.resolve("qkv-gemm")
|
|
|
|
captured = {}
|
|
|
|
def fake_run_bench(*, topology, bench_fn, device, engine_factory):
|
|
captured["bench_fn"] = bench_fn
|
|
|
|
class _R:
|
|
traces = []
|
|
engine = None
|
|
|
|
class completion:
|
|
ok = True
|
|
|
|
def summary_text(self):
|
|
return ""
|
|
return _R()
|
|
|
|
monkeypatch.setattr(cli_main, "run_bench", fake_run_bench)
|
|
rc = cli_main.main([
|
|
"run", "--topology", "topology.yaml",
|
|
"--bench", str(qkv_spec.index),
|
|
"--device", "sip:0",
|
|
])
|
|
assert rc == 0
|
|
assert captured["bench_fn"] is qkv_spec.run
|