Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mcp/blob/main/gates/pincheck-cases.sh # omega-mcp aien-dev/omega-mcp Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mcp / gates / pincheck-cases.sh` 77 lines ยท 4417 bytes Raw Blame History 1 #!/bin/sh 2 # gates/pincheck-cases.sh : cases for build/pincheck (gates/pincheck.om). Run in the repository root 3 # after build.sh (it uses build/pincheck and build/omc). Two scratch directories: the first has a 4 # copy of PIN, and a file restating the first 8 characters of the revision and one restating the omc 5 # sha256 are each refused (exit 1). The second has a fixture PIN whose revision and sha256 both 6 # start with 8 digits, so these hold at any real pin: the all-digit 8-character prefixes, 12- and 7 # 16-character prefixes, an upper-case prefix and both full values are each refused (exit 1), as is 8 # another hash-like word (the general rule); dates, counts, 8-digit near misses of the prefixes and the 9 # hex alphabet pass (exit 0). Five mutants of gates/pincheck.om (a restating word must hold a letter 10 # again, prefixes shorter than 9 ignored, only the first character compared, the sha256 compared at 11 # the revision's offset, no A-F folding) are compiled with build/omc and each must get at least one 12 # fixture case wrong. Prints PASS/FAIL per case and `pincheck-cases: pass=N fail=M`; exit 0 only when 13 # every case gives its expected result. 14 set -u 15 R=$(cd "$(dirname "$0")/.." && pwd) 16 P=$R/build/pincheck 17 O=$R/build/omc 18 [ -x "$P" ] && [ -x "$O" ] || { echo "pincheck-cases: run sh build.sh first" >&2; exit 2; } 19 W=$(mktemp -d "${TMPDIR:-/tmp}/pincheck-cases.XXXXXX") || exit 2 20 trap 'rm -rf "$W"' EXIT 21 pass=0 fail=0 22 ok() { echo "PASS $*"; pass=$((pass + 1)); } 23 bad() { echo "FAIL $*"; fail=$((fail + 1)); } 24 want() { # want NAME RC DIR FILE 25 out=$(cd "$3" && echo "$4" | "$P" 2>&1); rc=$? 26 if [ $rc -eq "$2" ]; then ok "$1 (exit $rc)"; else bad "$1: exit $rc, want $2: $out"; fi 27 } 28 rev=$(sed -n 's/^omega-mv //p' "$R/PIN") 29 sha=$(sed -n 's/^omc-sha256 //p' "$R/PIN") 30 mkdir -p "$W/c" 31 cp "$R/PIN" "$W/c/PIN" 32 printf 'built with omega-mv %s\n' "$(echo "$rev" | cut -c1-8)" > "$W/c/rev.md" 33 printf 'omc sha256 %s\n' "$sha" > "$W/c/sha.md" 34 want control-rev 1 "$W/c" rev.md 35 want control-sha 1 "$W/c" sha.md 36 # fixture values built from short pieces, so this file names no 7-character word of them 37 d8=$((2718 * 10000 + 2818)) 38 s8=$((3141 * 10000 + 5926)) 39 drev=$d8$(printf %s 0a1b 2c3d 4e5f 6a7b 8c9d 0e1f 2a3b 4c5d) 40 dsha=$s8$(printf %s 5e6f 7a8b 9c0d 1e2f 3a4b 5c6d 7e8f 9a0b 1c2d 3e4f 5a6b 7c8d 9e0f 1a2b) 41 mkdir -p "$W/d" 42 printf 'omega-mv %s\nomc-sha256 %s\n' "$drev" "$dsha" > "$W/d/PIN" 43 printf 'built with omega-mv %s\n' "$d8" > "$W/d/r8.md" 44 printf 'omc %s (sha256 prefix)\n' "$s8" > "$W/d/s8.md" 45 printf 'rev %s\n' "$(echo "$drev" | cut -c1-12)" > "$W/d/r12.md" 46 printf 'omc %s\n' "$(echo "$dsha" | cut -c1-16)" > "$W/d/s16.md" 47 printf 'omega-mv %s\n' "$drev" > "$W/d/rfull.md" 48 printf 'omc-sha256 %s\n' "$dsha" > "$W/d/sfull.md" 49 printf 'REV %s\n' "$(echo "$drev" | cut -c1-12 | tr a-f A-F)" > "$W/d/upper.md" 50 printf 'an older compiler %s\n' "$(printf %s c0ff ee12)" > "$W/d/other.md" 51 printf 'landed %s, %s rows; %s and %s are not the pin; %s\n' $((2026 * 10000 + 1111)) $((1000 * 10000)) \ 52 $((d8 + 1)) $((s8 + 1)) "$(printf %s 0123 4567 89ab cdef)" > "$W/d/numbers.md" 53 cases="r8:1 s8:1 r12:1 s16:1 rfull:1 sfull:1 upper:1 other:1 numbers:0" 54 for c in $cases; do want "fixture-${c%:*}" "${c#*:}" "$W/d" "${c%:*}.md"; done 55 wrong() { # wrong BIN: the fixture cases BIN gets wrong 56 for c in $cases; do 57 (cd "$W/d" && echo "${c%:*}.md" | "$1" > /dev/null 2>&1); rc=$? 58 [ $rc -eq "${c#*:}" ] || printf '%s ' "${c%:*}" 59 done 60 } 61 mutant() { # mutant NAME SED-ARGS...: compile gates/pincheck.om edited by sed; it must be caught 62 n=$1; shift 63 sed "$@" "$R/gates/pincheck.om" > "$W/$n.om" 64 if cmp -s "$R/gates/pincheck.om" "$W/$n.om"; then bad "mutant $n: the edit did not apply"; return; fi 65 "$O" < "$W/$n.om" > "$W/$n" 2> "$W/$n.err" 66 if [ $? -ne 0 ] || [ -s "$W/$n.err" ]; then bad "mutant $n does not compile: $(cat "$W/$n.err")"; return; fi 67 chmod +x "$W/$n" 68 got=$(wrong "$W/$n") 69 if [ -n "$got" ]; then ok "mutant $n caught by: $got"; else bad "mutant $n passes every fixture case"; fi 70 } 71 mutant m-letter -e 's/^if eq get st q_hexf 0$/if or eq get st q_hexf 0 or eq get st q_dig 0 eq get st q_let 0/' 72 mutant m-floor -e 's/^if lt n 7$/if lt n 9/' 73 mutant m-first -e 's/^if ne get tok i get pin add o i$/if ne get tok 0 get pin o/' 74 mutant m-shaoff -e 's/^r = tokat 61 n$/r = tokat 9 n/' 75 mutant m-nofold -e 's/^d = add c 32$/d = c/' 76 echo "pincheck-cases: pass=$pass fail=$fail" 77 [ $fail -eq 0 ] && [ $pass -eq 16 ]