diff --git a/CHANGELOG.md b/CHANGELOG.md index c2efe1e..b071364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ remains unsupported. ### Fixed - Made the native semantic-review timeout in `scripts/test-gpu.sh` configurable with `XENORA_SEMANTIC_TIMEOUT` and raised its default from 120 to 300 seconds, so cold Apple Silicon runs do not fail while the expanded Metal known-answer suite is still progressing. +- Added a Python 3 fallback for `timeout` in `scripts/test-gpu.sh`, so the native Metal suite runs on stock macOS without GNU coreutils while preserving bounded execution and the usual timeout exit status. ### Added - Added a documented independent acceptance rule for promoting AMD RDNA2 desktop GPU (gfx1030) forms from local CPU and Metal results to `fixture verified`, including clean-commit evidence, reviewer independence, raw-log location, review-log summary, failure handling and status regeneration (#302). diff --git a/README.md b/README.md index 82da167..5f5d38b 100644 --- a/README.md +++ b/README.md @@ -309,7 +309,7 @@ These require a Metal-capable Apple Silicon Mac. scripts/test-gpu.sh ``` -The native test suite enables Metal API and shader validation and tests the supported compute, rendering and texture paths. The full semantic-review batch defaults to a 300-second timeout; set `XENORA_SEMANTIC_TIMEOUT` to raise or lower it for a slower or faster host. +The native test suite enables Metal API and shader validation and tests the supported compute, rendering and texture paths. The full semantic-review batch defaults to a 300-second timeout; set `XENORA_SEMANTIC_TIMEOUT` to raise or lower it for a slower or faster host. On macOS, the script uses a Python 3 fallback when GNU `timeout` is unavailable. ### Verify guest execution diff --git a/scripts/test-gpu.sh b/scripts/test-gpu.sh index 27a4f27..a9502cc 100755 --- a/scripts/test-gpu.sh +++ b/scripts/test-gpu.sh @@ -13,6 +13,43 @@ export CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-4} # allow slower hosts to raise it without editing the script. export XENORA_SEMANTIC_TIMEOUT=${XENORA_SEMANTIC_TIMEOUT:-300s} +# macOS does not ship GNU timeout. Python 3 is already a project requirement, +# so use a small POSIX-compatible fallback rather than making coreutils a +# prerequisite for the native suite. +if ! command -v timeout >/dev/null 2>&1; then + timeout() { + duration=$1 + shift + python3 - "$duration" "$@" <<'PY' +import os +import re +import signal +import subprocess +import sys + +text = sys.argv[1] +match = re.fullmatch(r"(\d+(?:\.\d+)?)([smh]?)", text) +if match is None: + print(f"timeout: invalid duration {text!r}", file=sys.stderr) + raise SystemExit(2) +seconds = float(match.group(1)) * {"": 1, "s": 1, "m": 60, "h": 3600}[match.group(2)] +try: + process = subprocess.Popen(sys.argv[2:], start_new_session=True) +except FileNotFoundError as error: + print(f"timeout: {error}", file=sys.stderr) + raise SystemExit(127) +try: + code = process.wait(timeout=seconds) +except subprocess.TimeoutExpired: + os.killpg(process.pid, signal.SIGKILL) + process.wait() + print(f"timeout: command exceeded {seconds:g} seconds", file=sys.stderr) + raise SystemExit(124) +raise SystemExit(code) +PY + } +fi + cargo test --locked -p xenora-metal --features gpu-tests --test native_compute --no-run timeout 30s cargo test --locked -p xenora-metal --features gpu-tests --test native_compute -- \ --nocapture --test-threads=1