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 / tests / dagsim / mutant_predict.sh

42 lines · 1432 bytes Raw Blame History
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.
5set -eu
6ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
7cd "$ROOT"
8src=tools/dagsim/dagsim.om
9unit=tests/dagsim/dagsim_unit.om
10OMC=${OMC:-seed/out/omc}
11grep -q 'PREDICT_REFUSAL_CHECK_START' "$src"
12grep -q 'PREDICT_REFUSAL_CHECK_END' "$src"
13tmp=$(mktemp -d)
14trap 'rm -rf "$tmp"' EXIT
15sed '/PREDICT_REFUSAL_CHECK_START/,/PREDICT_REFUSAL_CHECK_END/d' "$src" > "$tmp/dagsim.om"
16if cmp -s "$src" "$tmp/dagsim.om"; then
17 echo "mutant: failed to drop PREDICT_REFUSAL_CHECK block"
18 exit 1
19fi
20grep -q 'fn dr_bad' "$tmp/dagsim.om" || { echo "mutant: deleted dr_bad"; exit 1; }
21
22cat "$tmp/dagsim.om" "$unit" | "$OMC" > "$tmp/unit"
23chmod +x "$tmp/unit"
24set +e
25"$tmp/unit" > "$tmp/out" 2>&1
26rc=$?
27set -e
28if [ "$rc" -eq 0 ]; then
29 echo "mutant survived: unit suite passed after dropping the predict refusal check"
30 exit 1
31fi
32if ! 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
36fi
37if ! 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
41fi
42echo "mutant killed: predict_unsupported_despite_known predict_refused_despite_known"