interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / tools / ops / test-quiet-lock-order.sh

53 lines · 3400 bytes Raw Blame History
1#!/bin/bash
2# L217 replay: quiet-measure lock order. Scratch locks only: never touches /tmp/aien-quiet.lock,
3# /tmp/aien-gb10.lock, the gate, the want flags or ~/.local/state/quiet (HOME is redirected per case).
4# Runs quiet-lock-order/suite.sh on several copies of quiet-measure, each beside this directory's quiet-build:
5# new ./quiet-measure: must pass every check
6# orig quiet-lock-order/quiet-measure.pre-L217, the installed copy before L217 (sha256 c838569e...):
7# must FAIL A1-A3, the reproduction (queued for the chip it holds the quiet lock and stops builds)
8# mutants ./quiet-measure with one part of the fix undone: each must FAIL its own check
9# Exit 0 only when all of that holds. The suite pins commands to cores 16-18; run it under that pool lock:
10# flock -o ~/handoffs/hive/queen/pool-16-18.lock taskset -c 16-18 nice -n 10 bash tools/ops/test-quiet-lock-order.sh
11# About 80 s per copy, 8 copies.
12set -u
13here=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
14root=$(mktemp -d "${TMPDIR:-/tmp}/l217-replay.XXXXXX")
15trap 'rm -rf "$root"' EXIT
16variant() { # variant NAME QUIET-MEASURE: a directory with that quiet-measure and the current quiet-build
17 mkdir -p "$root/$1"; cp "$2" "$root/$1/quiet-measure"; cp "$here/quiet-build" "$root/$1/quiet-build"
18}
19mut() { # mut NAME SED-EXPR: the new quiet-measure with one change; refuses if the sed changed nothing
20 variant "$1" "$here/quiet-measure"; sed -i "$2" "$root/$1/quiet-measure"
21 if cmp -s "$here/quiet-measure" "$root/$1/quiet-measure"; then echo "MUTANT $1 did not change the script"; exit 98; fi
22}
23variant new "$here/quiet-measure"
24variant orig "$here/quiet-lock-order/quiet-measure.pre-L217"
25mut flagfirst 's|^ exec 9<"$RL"$| exec 9<"$RL"; echo "$(date -u +%FT%TZ) $all" > "$f"|' # want flag up while queued
26mut noguard 's|^chip_waiter_holds_quiet() {$|chip_waiter_holds_quiet() { return 1;|' # no deadlock guard
27mut chipdrop 's|^ tsf="$W/.$$.held"; date -u| flock -u 9; tsf="$W/.$$.held"; date -u|' # chip let go before CMD
28mut noquiet 's|flock -x -w 5 8 \&\& { got=1; break; }|got=1; break|' # quiet lock never taken
29mut gatewait 's|flock -s -w "$DRAIN" "$GATE" true|flock -s -w 1500 "$GATE" true|' # 25 min gate wait with the chip
30mut oldtrap "s|; trap 'exit 130' INT; trap 'exit 143' TERM| INT TERM|" # TERM only removes the flag
31bad=0
32run() { # run NAME [CHECK-ID...]: no ids = every check must pass; else each id must FAIL
33 v=$1; shift
34 out=$(L217_ROOT=$root/run-$v bash "$here/quiet-lock-order/suite.sh" "$root/$v")
35 printf '=== %s (quiet-measure sha256 %s)\n%s\n' "$v" "$(sha256sum < "$root/$v/quiet-measure" | cut -c1-16)" "$out"
36 if [ $# -eq 0 ]; then
37 if printf '%s\n' "$out" | grep -q '^FAIL '; then echo "VERDICT $v: WRONG, a check failed"; bad=$((bad + 1)); else echo "VERDICT $v: ok, every check passed"; fi
38 return
39 fi
40 miss=
41 for id; do printf '%s\n' "$out" | grep -q "^FAIL $id " || miss="$miss $id"; done
42 if [ -n "$miss" ]; then echo "VERDICT $v: WRONG, expected to FAIL but passed:$miss"; bad=$((bad + 1)); else echo "VERDICT $v: ok, failed as expected: $*"; fi
43}
44run new
45run orig A1 A2 A3
46run flagfirst A2
47run noguard F1
48run chipdrop C2
49run noquiet C3
50run gatewait I1
51run oldtrap H1
52echo "RESULT $([ $bad = 0 ] && echo PASS || echo "FAIL ($bad wrong verdicts)")"
53exit $bad