omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tools / codebook / test-mutate.sh
| 1 | #!/bin/sh |
| 2 | # External driver regression: failure of the test runner is never a mutation kill. |
| 3 | set -eu |
| 4 | R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 5 | W=$(mktemp -d "${TMPDIR:-/tmp}/codebook-driver-check.XXXXXX") |
| 6 | OMC=${OMC:-$R/seed/out/omc}; export OMC |
| 7 | case $OMC in /*) ;; *) OMC=$(pwd)/$OMC; export OMC ;; esac |
| 8 | for mode in baseline crash no-assertion survivor; do |
| 9 | d="$W/$mode"; mkdir -p "$d/tools" "$d/seed/trace" |
| 10 | cp -r "$R/tools/codebook" "$d/tools/" |
| 11 | cp "$R/seed/trace/sha256.om" "$d/seed/trace/" |
| 12 | cat > "$d/tools/codebook/test.sh" <<'STUB' |
| 13 | #!/bin/sh |
| 14 | if [ "$MODE" = baseline ]; then echo 'runner unavailable' >&2; exit 2; fi |
| 15 | case $BIN in */base/codebook) echo 'TOTAL pass=1 fail=0 skip=0'; exit 0 ;; esac |
| 16 | case $MODE in |
| 17 | crash) echo 'runner unavailable' >&2; exit 2 ;; |
| 18 | no-assertion) echo 'TOTAL pass=0 fail=1 skip=0'; exit 1 ;; |
| 19 | survivor) echo 'TOTAL pass=1 fail=0 skip=0'; exit 0 ;; |
| 20 | esac |
| 21 | exit 2 |
| 22 | STUB |
| 23 | rc=0 |
| 24 | (cd "$d" && MODE=$mode M="$d/results" sh tools/codebook/mutate.sh) > "$d/output.log" 2>&1 || rc=$? |
| 25 | case $mode in baseline) want=5 ;; crash|no-assertion) want=4 ;; survivor) want=1 ;; esac |
| 26 | if [ "$rc" != "$want" ]; then echo "FAIL $mode: exit $rc expected $want logs=$W"; exit 1; fi |
| 27 | if grep -q ': caught' "$d/output.log"; then echo "FAIL $mode: false kill logs=$W"; exit 1; fi |
| 28 | echo "PASS $mode exit=$rc" |
| 29 | done |
| 30 | # A supplied work directory and symlink must preserve existing evidence. |
| 31 | mkdir "$W/keep"; printf 'evidence\n' > "$W/keep/sentinel"; ln -s "$W/keep" "$W/link" |
| 32 | for target in "$W/keep" "$W/link"; do |
| 33 | rc=0 |
| 34 | M="$target" sh "$R/tools/codebook/mutate.sh" > "$W/directory.log" 2>&1 || rc=$? |
| 35 | [ "$rc" = 2 ] && [ "$(cat "$W/keep/sentinel")" = evidence ] && [ -L "$W/link" ] || { echo 'FAIL preserve work directory'; exit 1; } |
| 36 | done |
| 37 | echo "CODEBOOK-DRIVER PASS logs=$W" |