Files
leleka/engine/strata/tests/desktop/test_tester_readme.py
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree
(570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base =
the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main).

Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR
experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details,
conflict table and left-out files are in docs/upstream.md.

Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61),
docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out.

scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run").
Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR
macros on. No GPU run, no quality gate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:49:15 +01:00

75 lines
3.4 KiB
Python

"""The tester READMEs get their checksums from the files themselves (apps/desktop/scripts/make-tester-readme.sh)."""
import hashlib
import shutil
import subprocess
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SCRIPT = ROOT / "apps" / "desktop" / "scripts" / "make-tester-readme.sh"
TEMPLATES = ROOT / "apps" / "desktop" / "tester"
NOTICE = "Strata opened in your browser because the app window couldn't start on this computer."
def sha(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def run(*args, check=True):
return subprocess.run(["bash", str(SCRIPT), *map(str, args)], capture_output=True, text=True, check=check)
@unittest.skipIf(shutil.which("bash") is None or shutil.which("sha256sum") is None, "needs bash and sha256sum")
class TesterReadmeTests(unittest.TestCase):
def setUp(self):
self.tmp = Path(tempfile.mkdtemp(prefix="strata-readme-"))
self.addCleanup(shutil.rmtree, self.tmp, True)
self.files = self.tmp / "files"
self.files.mkdir()
self.out = self.tmp / "README.txt"
def put(self, name, data):
(self.files / name).write_bytes(data)
return self.files / name
def test_every_hash_and_size_in_the_readme_comes_from_the_file(self):
app = self.put("Strata-tester-linux.AppImage", b"app image bytes " * 1000)
run(TEMPLATES / "README-linux.txt.in", self.out, "--appimage", app.name, "--files-dir", self.files)
text = self.out.read_text()
self.assertIn(sha(app), text)
self.assertNotIn("@APPIMAGE@", text)
for needle in ("libfuse2t64", "Ubuntu 26.04", "--browser", "--quit", "--save-logs", "Strata 0.2.3", NOTICE):
self.assertIn(needle, text)
run("--verify", self.out, "--files-dir", self.files)
def test_amd_readmes_hash_both_files(self):
for variant in ("rx9070", "rx7900"):
app, zipname = f"Strata-tester-linux-amd-{variant}.AppImage", f"Strata-Terminal-Linux-tester-amd-{variant}.zip"
a, z = self.put(app, b"a" * 5000), self.put(zipname, b"z" * 3000)
run(TEMPLATES / f"README-amd-{variant}.txt.in", self.out, "--appimage", app, "--files-dir", self.files)
text = self.out.read_text()
self.assertIn(sha(a), text)
self.assertIn(sha(z), text)
self.assertIn(f"./{app} --browser", text)
run("--verify", self.out, "--files-dir", self.files)
def test_a_missing_file_stops_the_readme_instead_of_leaving_a_stale_hash(self):
app = self.put("Strata-tester-linux-amd-rx9070.AppImage", b"a" * 5000) # the zip is not there
result = run(TEMPLATES / "README-amd-rx9070.txt.in", self.out, "--appimage", app.name, "--files-dir", self.files, check=False)
self.assertNotEqual(result.returncode, 0)
self.assertIn("must not carry a hash it did not compute", result.stderr)
self.assertFalse(self.out.exists())
def test_verify_catches_a_stale_hash(self):
app = self.put("Strata-tester-linux.AppImage", b"first build")
run(TEMPLATES / "README-linux.txt.in", self.out, "--appimage", app.name, "--files-dir", self.files)
app.write_bytes(b"rebuilt") # the file changed after the README was written
result = run("--verify", self.out, "--files-dir", self.files, check=False)
self.assertNotEqual(result.returncode, 0)
self.assertIn("STALE", result.stderr)
if __name__ == "__main__":
unittest.main()