"""Run a Linux invalid-descriptor API check; not a cache or performance test.""" import datetime import hashlib import json import os import pathlib import platform import subprocess import tempfile root = pathlib.Path(__file__).resolve().parent source = root / "probe.c" if platform.system() != "Linux": raise SystemExit("This probe requires Linux and libc preadv2/readahead wrappers.") compiler = os.environ.get("CC", "cc") command = [compiler, "-std=c11", "-Wall", "-Wextra", "-Werror", "-O2"] with tempfile.TemporaryDirectory(prefix="hesela-prefetch-") as directory: executable = pathlib.Path(directory) / "probe" subprocess.run([*command, str(source), "-o", str(executable)], check=True) execution = subprocess.run([str(executable)], capture_output=True, text=True, timeout=10) observations = json.loads(execution.stdout) result = { "schemaVersion": 1, "generatedAt": datetime.datetime.now(datetime.timezone.utc).isoformat(), "method": "Three libc calls using fd=-1 and a nonempty one-byte range; errno reset before each call.", "population": "One Linux host, one invocation per API; deterministic invalid-descriptor checks.", "limits": "No valid file was read. This does not measure cache residency, NOWAIT support on a filesystem, latency, durability or prefetch effectiveness.", "environment": { "kernel": platform.release(), "machine": platform.machine(), "libc": list(platform.libc_ver()), "compiler": subprocess.check_output([compiler, "--version"], text=True).splitlines()[0], "python": platform.python_version(), }, "compileFlags": command[1:], "sourceSha256": hashlib.sha256(source.read_bytes()).hexdigest(), "runnerSha256": hashlib.sha256(pathlib.Path(__file__).read_bytes()).hexdigest(), "passed": execution.returncode == 0, **observations, } if execution.returncode != 0: raise SystemExit(json.dumps(result, indent=2)) (root / "result.json").write_text(json.dumps(result, indent=2) + "\n") print(json.dumps(result, indent=2))