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/discovery-capsule/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 / discovery-capsule / tools / check-vectors.sh` 47 lines ยท 1908 bytes Raw Blame History 1 #!/bin/bash 2 # check-vectors.sh: build the DCP1 reference checker and check the vectors. 3 # 4 # Usage: check-vectors.sh [CC] (default CC: cc) 5 # 6 # 1. Builds tools/dcp_verify.c with warnings as errors (C99, libc only). 7 # 2. Regenerates the vectors into a scratch directory (dcp_verify 8 # --make-vectors) and requires them byte-identical to vectors/, so a stale 9 # or hand-edited vector fails here. 10 # 3. Runs every vectors/expected.txt line (and re-encodes every accepted 11 # message, which must give the same bytes), plus an ASan/UBSan build when 12 # the compiler supports it. 13 # 4. Runs tools/mutate-verifier.sh: every check must be caught by a vector. 14 # Host-only check: no hardware. Shell and C only. Found by the PROTO-C-VECTORS 15 # gate (tests/gates/run.sh c-vectors) because its name matches check-*.sh. 16 set -eu 17 export LC_ALL=C 18 here=$(cd "$(dirname "$0")" && pwd) 19 vec="$here/../vectors" 20 CC=${1:-cc} 21 tmp=$(mktemp -d) 22 trap 'rm -rf "$tmp"' EXIT 23 24 "$CC" -std=c99 -O2 -Wall -Wextra -Werror -pedantic -o "$tmp/dcp_verify" "$here/dcp_verify.c" 25 26 mkdir -p "$tmp/regen" 27 "$tmp/dcp_verify" --make-vectors "$tmp/regen" 28 ignore="-x .crumb -x .crumb.local -x .gitattributes" 29 if ! diff -r $ignore "$vec" "$tmp/regen" >/dev/null; then 30 echo "DCP1_VECTORS_STALE: vectors/ differs from dcp_verify --make-vectors output" >&2 31 diff -rq $ignore "$vec" "$tmp/regen" >&2 || true 32 exit 1 33 fi 34 echo "DCP1_VECTORS_REGEN identical" 35 36 "$tmp/dcp_verify" --corpus "$vec" 37 38 if "$CC" -std=c99 -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all \ 39 -o "$tmp/dcp_verify_san" "$here/dcp_verify.c" 2>/dev/null; then 40 "$tmp/dcp_verify_san" --corpus "$vec" | sed 's/^DCP1_CONFORMANCE impl=c/DCP1_CONFORMANCE impl=c-asan-ubsan/' 41 test "${PIPESTATUS[0]}" -eq 0 42 else 43 echo "DCP1_SANITIZER NOT_RUN (compiler lacks -fsanitize=address,undefined)" 44 fi 45 46 bash "$here/mutate-verifier.sh" "$CC" 47 echo "DCP1_VECTORS_PASS"