interplane.Get Omega
Read in your language

aien-protocols-mv

Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem

Brought by drakestapleton

branch main Branches Tags History

aien-protocols-mv / specs / execution-transcript / tools / mutate-verifier.sh

30 lines · 1221 bytes Raw Blame History
1#!/bin/bash
2# mutate-verifier.sh: show that every check in trn1_verify.c is exercised by
3# the corpus. Builds one verifier per check with that check disabled
4# (-DTRN1_MUTANT=K) and requires the corpus to report at least one miss.
5# A mutant the corpus does not notice is a SURVIVOR and fails this script.
6#
7# Usage: mutate-verifier.sh [CC]
8set -eu
9export LC_ALL=C
10here=$(cd "$(dirname "$0")" && pwd)
11vec="$here/../vectors"
12CC=${1:-cc}
13tmp=$(mktemp -d)
14trap 'rm -rf "$tmp"' EXIT
15names=$(sed -n '/CHK_MAGIC = 1/,/CHK_LAST/p' "$here/trn1_verify.c" | tr -d ' \n' | sed 's/CHK_MAGIC=1/CHK_MAGIC/; s/,CHK_LAST.*//' | tr ',' ' ')
16test -n "$names" || { echo "cannot read the check list" >&2; exit 2; }
17k=0 killed=0 survived=0
18for name in $names; do
19 k=$((k + 1))
20 "$CC" -std=c99 -O1 -w -DTRN1_MUTANT=$k -o "$tmp/m$k" "$here/trn1_verify.c"
21 if "$tmp/m$k" --corpus "$vec" >"$tmp/out$k" 2>&1; then
22 echo "SURVIVOR $k $name"
23 survived=$((survived + 1))
24 else
25 echo "killed $k $name: $(grep -c '^MISMATCH' "$tmp/out$k") corpus line(s) differ"
26 killed=$((killed + 1))
27 fi
28done
29echo "TRN1_VERIFIER_MUTANTS total=$k killed=$killed survived=$survived"
30test "$survived" -eq 0 && test "$k" -gt 0