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/aien-protocols-mv/blob/main/specs/osc-unit-artifact/tools/check-vectors.sh # aien-protocols-mv Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem 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 `aien-protocols-mv / specs / osc-unit-artifact / tools / check-vectors.sh` 45 lines ยท 2482 bytes Raw Blame History 1 #!/bin/bash 2 # check-vectors.sh: regenerate the vectors into a scratch directory, require 3 # them byte-identical to the committed ones, then run the reference checker 4 # over every line of vectors/expected.txt. Exit 1 on any difference. 5 set -eu 6 export LC_ALL=C 7 here=$(cd "$(dirname "$0")" && pwd) 8 tmp=$(mktemp -d) 9 trap 'rm -rf "$tmp"' EXIT 10 bash "$here/make-vectors.sh" "$tmp/vectors" "$tmp/keys" 11 # the committed keys must also be the regenerated ones 12 diff -r "$tmp/keys" "$here/../keys" >/dev/null || { echo "OSC_UNIT_KEYS_STALE" >&2; exit 1; } 13 diff -r "$tmp/vectors" "$here/../vectors" -x README.md >/dev/null || { echo "OSC_UNIT_VECTORS_STALE" >&2; diff -rq "$tmp/vectors" "$here/../vectors" -x README.md >&2 || true; exit 1; } 14 echo "OSC_UNIT_REGEN identical" 15 fail=0; n=0 16 while read -r name mode domains anchors rest; do 17 case $name in '#'*|'') continue ;; esac 18 got=$(bash "$here/osc-unit-check.sh" "$here/../vectors/$name" "$mode" "$domains" "$anchors") 19 n=$((n + 1)) 20 if [ "$got" != "$rest" ]; then echo "MISMATCH $name: want '$rest' got '$got'" >&2; fail=1; fi 21 done <"$here/../vectors/expected.txt" 22 while read -r name mode domains anchors lname rest; do 23 case $name in '#'*|'') continue ;; esac 24 got=$(bash "$here/osc-unit-check.sh" "$here/../vectors/$name" "$mode" "$domains" "$anchors" "$lname") 25 n=$((n + 1)) 26 if [ "$got" != "$rest" ]; then echo "MISMATCH lookup $name $lname: want '$rest' got '$got'" >&2; fail=1; fi 27 done <"$here/../vectors/lookups.txt" 28 while read -r name mode domains anchors state rest; do 29 case $name in '#'*|'') continue ;; esac 30 case $state in 31 gens=*) got=$(OSC_STATE_GENS="${state#gens=}" bash "$here/osc-unit-check.sh" "$here/../vectors/$name" "$mode" "$domains" "$anchors") ;; 32 noreserve) got=$(OSC_STATE_NORESERVE=1 bash "$here/osc-unit-check.sh" "$here/../vectors/$name" "$mode" "$domains" "$anchors") ;; 33 esac 34 n=$((n + 1)) 35 if [ "$got" != "$rest" ]; then echo "MISMATCH state $name $state: want '$rest' got '$got'" >&2; fail=1; fi 36 done <"$here/../vectors/state.txt" 37 cc -std=c99 -O2 -Wall -Wextra -Werror -o "$tmp/launch" "$here/osc-launch-check.c" 38 while read -r kinds args rest; do 39 case $kinds in '#'*|'') continue ;; esac 40 got=$("$tmp/launch" "$kinds" "$args") 41 n=$((n + 1)) 42 if [ "$got" != "$rest" ]; then echo "MISMATCH launch $kinds $args: want '$rest' got '$got'" >&2; fail=1; fi 43 done <"$here/../vectors/launch.txt" 44 [ $fail -eq 0 ] || exit 1 45 echo "OSC_UNIT_VECTORS_PASS $n vectors"