#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later """nanoboyadvance's smoke test: no ROM or BIOS from anywhere. python3 -I "$EMU_TOOLS_GPL/tools/nanoboyadvance/tests/smoke.py" Checks build.py's version line and its usage-error exit status (2); then, for each machine that is built, that its build-info.json names its pin and that the fetched tree carries the pin and NBA's licence; and that each program, given a file that is not its input, exits non-zero rather than hanging. Under a second. The identity runs of 2026-11-25 (CHANGELOG.md) need the SingleStepTests corpus and test ROMs, which the consumers fetch. """ from __future__ import annotations import json import subprocess import sys import tempfile from pathlib import Path HERE = Path(__file__).resolve().parents[1] sys.path.insert(0, str(HERE)) import build # noqa: E402 failures: list[str] = [] def check(ok: bool, what: str) -> None: print(("ok " if ok else "FAIL ") + what) if not ok: failures.append(what) def main() -> int: script = [sys.executable, "-I", str(HERE / "build.py")] done = subprocess.run([*script, "--version"], capture_output=True, text=True) check(done.returncode == 0 and done.stdout.startswith("nanoboyadvance-drivers 0.1.0 (NanoBoyAdvance: arm7tdmi-sst e8482c1, gba 8c3b159)"), "--version names the tool and both pins") # fmt: skip done = subprocess.run([*script, "--machine", "nds"], capture_output=True, text=True) check(done.returncode == 2, "an unknown machine: exit 2") with tempfile.TemporaryDirectory(prefix="nba-smoke-") as scratch: junk = Path(scratch) / "junk.bin" junk.write_bytes(b"\x00" * 16) for machine, spec in build.MACHINES.items(): record = build.BUILD / machine / "build-info.json" if not build.program(machine).exists() or not record.exists(): print(f"skip {machine}: not built (build.py --machine {machine})") continue info = json.loads(record.read_text()) tree = build.UPSTREAM_DIR / f"NanoBoyAdvance-{spec['pin'][:12]}" check(info["upstream"]["commit"] == spec["pin"] and (tree / ".complete").read_text().strip() == spec["pin"] and "GNU GENERAL PUBLIC LICENSE" in (tree / "LICENSE").read_text(), f"{machine}: built from NBA at its pin, the tree with its licence") # fmt: skip done = subprocess.run([str(build.program(machine)), str(junk)], capture_output=True, timeout=30, check=False) # fmt: skip check(done.returncode != 0, f"{machine}: a file that is not its input is refused") print(f"{len(failures)} failed" if failures else "smoke passed") return 1 if failures else 0 if __name__ == "__main__": raise SystemExit(main())