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_lifetime.sh

35 lines · 1165 bytes Raw Blame History
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.
4set -eu
5ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
6cd "$ROOT"
7src=tools/dagsim/dagsim.om
8unit=tests/dagsim/dagsim_unit.om
9OMC=${OMC:-seed/out/omc}
10grep -q 'LIFETIME_ORDER_CHECK' "$src"
11tmp=$(mktemp -d)
12trap 'rm -rf "$tmp"' EXIT
13sed '/LIFETIME_ORDER_CHECK/{n;s/dag_life m s/ulong 0/;}' "$src" > "$tmp/dagsim.om"
14if cmp -s "$src" "$tmp/dagsim.om"; then
15 echo "mutant: failed to drop LIFETIME_ORDER_CHECK call"
16 exit 1
17fi
18grep -q 'fn dag_life' "$tmp/dagsim.om" || { echo "mutant: deleted more than the call"; exit 1; }
19
20cat "$tmp/dagsim.om" "$unit" | "$OMC" > "$tmp/unit"
21chmod +x "$tmp/unit"
22set +e
23"$tmp/unit" > "$tmp/out" 2>&1
24rc=$?
25set -e
26if [ "$rc" -eq 0 ]; then
27 echo "mutant survived: unit suite passed after dropping LIFETIME_ORDER_CHECK"
28 exit 1
29fi
30if ! 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
34fi
35echo "mutant killed: inverted_lifetime_masks_overflow"