omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / evidence / device-window / DRA-441 / gates.sh
| 1 | #!/bin/sh |
| 2 | # DRA-441 fresh-clone gates for omega-bridge head $1 (I3, 2026-11-16). CPU only, no GPU, |
| 3 | # no spark-window. Hold the queen pool-2-3 lock while it runs; it pins itself to CPUs 2,3. |
| 4 | # usage: sh gates.sh HEAD SRC_REPO WORKDIR |
| 5 | # Every gate names the exit status it expects; the last line is GATES PASS or GATES FAIL |
| 6 | # (exit 0 or 1). The mutants are negative controls and must make their gate fail (rc 1). |
| 7 | set -u |
| 8 | [ "${DRA441_GATES_PINNED:-}" = 1 ] || DRA441_GATES_PINNED=1 exec taskset -c 2,3 sh "$0" "$@" |
| 9 | head=$1 src=$2 wd=$3 |
| 10 | omc=$HOME/workspace/I3-omc/omc |
| 11 | want=34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3 |
| 12 | [ ! -e "$wd" ] || { echo "workdir exists: $wd"; exit 2; } |
| 13 | mkdir -p "$wd" |
| 14 | bad=0 |
| 15 | st() { |
| 16 | if [ "$2" = "$3" ]; then echo "GATE $1 rc=$2 expect=$3 ok" |
| 17 | else echo "GATE $1 rc=$2 expect=$3 WRONG"; bad=$((bad + 1)); fi |
| 18 | } |
| 19 | git clone -q --no-checkout "$src" "$wd/fc" && git -C "$wd/fc" checkout -q "$head" |
| 20 | st clone $? 0 |
| 21 | cd "$wd/fc" || exit 2 |
| 22 | echo "head $(git rev-parse HEAD)" |
| 23 | printf '%s %s\n' "$want" "$omc" | sha256sum --check --strict; st omc-pin $? 0 |
| 24 | mkdir -p build |
| 25 | "$omc" < tools/run-device-window.om > build/run-device-window; st compile-om $? 0 |
| 26 | chmod +x build/run-device-window |
| 27 | sha256sum build/run-device-window |
| 28 | "$omc" < tests/device-window/race.om > build/race; st compile-race $? 0 |
| 29 | chmod +x build/race |
| 30 | # mutant 1: evidence directory never created (makedir result forced to 0) |
| 31 | awk '{print} /^r = makedir sb 0 get sn 0 511$/{print "r = 0"}' tools/run-device-window.om > build/mutant.om |
| 32 | cmp -s tools/run-device-window.om build/mutant.om; st mutant-differs $? 1 |
| 33 | "$omc" < build/mutant.om > build/mutant; st compile-mutant $? 0 |
| 34 | chmod +x build/mutant |
| 35 | # mutant 2: rows do not hold the closer's hold pipe |
| 36 | grep -c '^c = dupfd int get g gClH 0 0$' tools/run-device-window.om | grep -qx 1; st hold-line-once $? 0 |
| 37 | grep -v '^c = dupfd int get g gClH 0 0$' tools/run-device-window.om > build/mutant-hold.om |
| 38 | "$omc" < build/mutant-hold.om > build/mutant-hold; st compile-mutant-hold $? 0 |
| 39 | chmod +x build/mutant-hold |
| 40 | # mutant 3: the closer takes a lost driver (no N, no X) as "nothing to close" |
| 41 | grep -c '^if eq v 88$' tools/run-device-window.om | grep -qx 1; st lost-line-once $? 0 |
| 42 | sed 's/^if eq v 88$/if lt v 89/' tools/run-device-window.om > build/mutant-lost.om |
| 43 | cmp -s tools/run-device-window.om build/mutant-lost.om; st mutant-lost-differs $? 1 |
| 44 | "$omc" < build/mutant-lost.om > build/mutant-lost; st compile-mutant-lost $? 0 |
| 45 | chmod +x build/mutant-lost |
| 46 | sh -n tools/run-device-window.sh; st sh-syntax $? 0 |
| 47 | python3 tests/device-window/compare.py tools/run-device-window.sh build/run-device-window "$wd/cmp" > "$wd/compare.log" 2>&1; st compare $? 0 |
| 48 | tail -1 "$wd/compare.log" |
| 49 | python3 tests/device-window/compare.py tools/run-device-window.sh build/mutant "$wd/cmpmut" > "$wd/compare-mutant.log" 2>&1; st compare-mutant $? 1 |
| 50 | tail -1 "$wd/compare-mutant.log" |
| 51 | python3 tests/device-window/compare.py tools/run-device-window.sh build/mutant-hold "$wd/cmphold" > "$wd/compare-mutant-hold.log" 2>&1; st compare-mutant-hold $? 1 |
| 52 | grep '^DIFF ' "$wd/compare-mutant-hold.log"; tail -1 "$wd/compare-mutant-hold.log" |
| 53 | python3 tests/device-window/compare.py tools/run-device-window.sh build/mutant-lost "$wd/cmplost" > "$wd/compare-mutant-lost.log" 2>&1; st compare-mutant-lost $? 1 |
| 54 | grep '^DIFF ' "$wd/compare-mutant-lost.log"; tail -1 "$wd/compare-mutant-lost.log" |
| 55 | build/race build/run-device-window "$wd/race-om" 100 > "$wd/race-om.log" 2>&1; st race-om $? 0 |
| 56 | tail -2 "$wd/race-om.log" |
| 57 | build/race tools/run-device-window.sh "$wd/race-sh" 100 > "$wd/race-sh.log" 2>&1; st race-sh $? 0 |
| 58 | tail -2 "$wd/race-sh.log" |
| 59 | build/race build/mutant "$wd/race-mut" 20 > "$wd/race-mut.log" 2>&1; st race-mutant $? 1 |
| 60 | tail -2 "$wd/race-mut.log" |
| 61 | OMEGA_SOURCE=$HOME/git/omega-mv.git sh tools/bootstrap.sh > "$wd/bootstrap.log" 2>&1; st bootstrap $? 0 |
| 62 | OMEGA_SEED=build/bootstrap/omc sh tools/test.sh > "$wd/test.log" 2>&1; st repo-test $? 0 |
| 63 | tail -1 "$wd/test.log" |
| 64 | rm -rf "$wd/cmp" "$wd/cmpmut" "$wd/cmphold" "$wd/cmplost" "$wd/race-om" "$wd/race-sh" "$wd/race-mut" |
| 65 | sha256sum "$wd"/*.log |
| 66 | if [ "$bad" = 0 ]; then echo "GATES PASS"; exit 0; fi |
| 67 | echo "GATES FAIL wrong=$bad" |
| 68 | exit 1 |