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 / tests / dagsim / mutant_predict.sh
| 1 | #!/bin/sh |
| 2 | # Drop the unsupported-return and refused checks. Leave the p.known test in |
| 3 | # place. The named assertions must fail: a prediction can be marked known and |
| 4 | # still be a refusal. |
| 5 | set -eu |
| 6 | ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 7 | cd "$ROOT" |
| 8 | src=tools/dagsim/dagsim.om |
| 9 | unit=tests/dagsim/dagsim_unit.om |
| 10 | OMC=${OMC:-seed/out/omc} |
| 11 | grep -q 'PREDICT_REFUSAL_CHECK_START' "$src" |
| 12 | grep -q 'PREDICT_REFUSAL_CHECK_END' "$src" |
| 13 | tmp=$(mktemp -d) |
| 14 | trap 'rm -rf "$tmp"' EXIT |
| 15 | sed '/PREDICT_REFUSAL_CHECK_START/,/PREDICT_REFUSAL_CHECK_END/d' "$src" > "$tmp/dagsim.om" |
| 16 | if cmp -s "$src" "$tmp/dagsim.om"; then |
| 17 | echo "mutant: failed to drop PREDICT_REFUSAL_CHECK block" |
| 18 | exit 1 |
| 19 | fi |
| 20 | grep -q 'fn dr_bad' "$tmp/dagsim.om" || { echo "mutant: deleted dr_bad"; exit 1; } |
| 21 | |
| 22 | cat "$tmp/dagsim.om" "$unit" | "$OMC" > "$tmp/unit" |
| 23 | chmod +x "$tmp/unit" |
| 24 | set +e |
| 25 | "$tmp/unit" > "$tmp/out" 2>&1 |
| 26 | rc=$? |
| 27 | set -e |
| 28 | if [ "$rc" -eq 0 ]; then |
| 29 | echo "mutant survived: unit suite passed after dropping the predict refusal check" |
| 30 | exit 1 |
| 31 | fi |
| 32 | if ! grep -q 'predict_unsupported_despite_known' "$tmp/out"; then |
| 33 | echo "mutant did not fail named assertion predict_unsupported_despite_known" |
| 34 | cat "$tmp/out" |
| 35 | exit 1 |
| 36 | fi |
| 37 | if ! grep -q 'predict_refused_despite_known' "$tmp/out"; then |
| 38 | echo "mutant did not fail named assertion predict_refused_despite_known" |
| 39 | cat "$tmp/out" |
| 40 | exit 1 |
| 41 | fi |
| 42 | echo "mutant killed: predict_unsupported_despite_known predict_refused_despite_known" |