interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / codebook / test-mutate.sh

37 lines · 1797 bytes Raw Blame History
1#!/bin/sh
2# External driver regression: failure of the test runner is never a mutation kill.
3set -eu
4R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
5W=$(mktemp -d "${TMPDIR:-/tmp}/codebook-driver-check.XXXXXX")
6OMC=${OMC:-$R/seed/out/omc}; export OMC
7case $OMC in /*) ;; *) OMC=$(pwd)/$OMC; export OMC ;; esac
8for 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
14if [ "$MODE" = baseline ]; then echo 'runner unavailable' >&2; exit 2; fi
15case $BIN in */base/codebook) echo 'TOTAL pass=1 fail=0 skip=0'; exit 0 ;; esac
16case $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 ;;
20esac
21exit 2
22STUB
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"
29done
30# A supplied work directory and symlink must preserve existing evidence.
31mkdir "$W/keep"; printf 'evidence\n' > "$W/keep/sentinel"; ln -s "$W/keep" "$W/link"
32for 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; }
36done
37echo "CODEBOOK-DRIVER PASS logs=$W"