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_lifetime.sh
| 1 | #!/bin/sh |
| 2 | # Drop the inverted-lifetime check and require the named assertion to fail. |
| 3 | # A mutant that still prints a passing inverted_lifetime_masks_overflow is a miss. |
| 4 | set -eu |
| 5 | ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 6 | cd "$ROOT" |
| 7 | src=tools/dagsim/dagsim.om |
| 8 | unit=tests/dagsim/dagsim_unit.om |
| 9 | OMC=${OMC:-seed/out/omc} |
| 10 | grep -q 'LIFETIME_ORDER_CHECK' "$src" |
| 11 | tmp=$(mktemp -d) |
| 12 | trap 'rm -rf "$tmp"' EXIT |
| 13 | sed '/LIFETIME_ORDER_CHECK/{n;s/dag_life m s/ulong 0/;}' "$src" > "$tmp/dagsim.om" |
| 14 | if cmp -s "$src" "$tmp/dagsim.om"; then |
| 15 | echo "mutant: failed to drop LIFETIME_ORDER_CHECK call" |
| 16 | exit 1 |
| 17 | fi |
| 18 | grep -q 'fn dag_life' "$tmp/dagsim.om" || { echo "mutant: deleted more than the call"; exit 1; } |
| 19 | |
| 20 | cat "$tmp/dagsim.om" "$unit" | "$OMC" > "$tmp/unit" |
| 21 | chmod +x "$tmp/unit" |
| 22 | set +e |
| 23 | "$tmp/unit" > "$tmp/out" 2>&1 |
| 24 | rc=$? |
| 25 | set -e |
| 26 | if [ "$rc" -eq 0 ]; then |
| 27 | echo "mutant survived: unit suite passed after dropping LIFETIME_ORDER_CHECK" |
| 28 | exit 1 |
| 29 | fi |
| 30 | if ! grep -q 'inverted_lifetime_masks_overflow' "$tmp/out"; then |
| 31 | echo "mutant did not fail named assertion inverted_lifetime_masks_overflow" |
| 32 | cat "$tmp/out" |
| 33 | exit 1 |
| 34 | fi |
| 35 | echo "mutant killed: inverted_lifetime_masks_overflow" |