interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / test_gate_physics_pin.sh

64 lines · 2412 bytes Raw Blame History
1#!/usr/bin/env bash
2# tools/test_gate_physics_pin.sh -- host self-test (omega#523, omega#508).
3#
4# Every tests/gates/run.sh step that builds against physics must take the physics commit
5# from physics.lock, and every gate that runs such a step must list physics.lock as an input.
6# Why: the Makefile's check-physics-lock refuses any physics checkout other than the lock, so
7# a literal commit in run.sh turns every chip gate red on the next lock bump (it did for
8# e95e3ed -> 6d7cf0d4 in #508), and a gate that does not list physics.lock is never selected
9# by a lock-only bump, so the bump is judged without the gates it changes.
10#
11# Exit 0 when both hold, 1 with one line per violation otherwise. No GPU, no network.
12set -euo pipefail
13ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
14RUN="$ROOT/tests/gates/run.sh"
15fail=0
16
17# 1. No literal physics commit on a pin line.
18if grep -nE '^[^#]*pin[[:space:]]+physics-src[^[:space:]]*[[:space:]]+physics[[:space:]]+[0-9a-f]{7,40}' "$RUN"; then
19 echo "FAIL literal physics commit in tests/gates/run.sh (take it from physics.lock: physics_pin)"
20 fail=1
21fi
22
23# 2. The run.sh case labels whose block calls physics_pin (or pins physics by hand).
24labels="$(awk '
25 /^ [^ #][^)]*\)/ && $0 !~ /^ *\(/ { lab=$0; sub(/^ /,"",lab); sub(/\).*/,"",lab) }
26 /physics_pin|pin[ \t]+physics-src/ && lab != "" { print lab; lab="" }
27' "$RUN")"
28if [ -z "$labels" ]; then
29 echo "FAIL found no run.sh step that pins physics (parser out of date?)"
30 exit 1
31fi
32
33step_pins_physics() {
34 local step="$1" lab pat
35 while IFS= read -r lab; do
36 IFS='|' read -r -a pats <<<"$lab"
37 for pat in "${pats[@]}"; do
38 # shellcheck disable=SC2254
39 case "$step" in $pat) return 0 ;; esac
40 done
41 done <<<"$labels"
42 return 1
43}
44
45checked=0
46for g in "$ROOT"/tests/gates/*.gate; do
47 step="$(sed -n 's/^[[:space:]]*args:[[:space:]]*\["\([^"]*\)".*/\1/p' "$g" | head -n 1)"
48 [ -n "$step" ] || continue
49 step_pins_physics "$step" || continue
50 checked=$((checked + 1))
51 if ! grep -qx ' - physics.lock' "$g"; then
52 echo "FAIL $(basename "$g") runs step '$step', which builds against physics, but does not list physics.lock in inputs"
53 fail=1
54 fi
55done
56
57if [ "$checked" -eq 0 ]; then
58 echo "FAIL no gate runs a physics-pinning step (parser out of date?)"
59 exit 1
60fi
61if [ "$fail" -eq 0 ]; then
62 echo "OMEGA_GATE_PHYSICS_PIN_PASS gates_checked=$checked"
63fi
64exit "$fail"