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 / numeric_native / mutants.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Compile real wrappers with one safety check removed. Compilation failure is |
| 18 | # not a kill: each mutated binary must run and reject a named test scenario. |
| 19 | set -eu |
| 20 | ulimit -c 0 |
| 21 | out=${1:?output directory required} |
| 22 | cc=${CC:-cc} |
| 23 | mkdir -p "$out" |
| 24 | for mutant in poison retain exact; do |
| 25 | dir="$out/$mutant" |
| 26 | mkdir -p "$dir" |
| 27 | cp src/omega_numeric_lifecycle.h "$dir/" |
| 28 | case "$mutant" in |
| 29 | poison) sed 's/omega_numeric_native_poison();/(void)0;/g' src/omega_numeric_native.h > "$dir/omega_numeric_native.h" ;; |
| 30 | retain) sed 's/if (omega_numeric_native_uncertain()) return -1;/(void)0;/' src/omega_numeric_native.h > "$dir/omega_numeric_native.h" ;; |
| 31 | exact) sed 's/if (rc == 0 \&\& (!word || \*word != want)) rc = -1;/(void)0;/' src/omega_numeric_native.h > "$dir/omega_numeric_native.h" ;; |
| 32 | esac |
| 33 | if cmp -s src/omega_numeric_native.h "$dir/omega_numeric_native.h"; then |
| 34 | echo "FAIL: mutation $mutant changed nothing"; exit 1 |
| 35 | fi |
| 36 | $cc -std=c11 -O2 -Wall -Wextra -Werror -I"$dir" -Isrc -Itests/numeric_native tests/test_numeric_lifecycle.c tests/numeric_native/other_launcher.c -o "$dir/test" |
| 37 | rc=0 |
| 38 | "$dir/test" > "$dir/output" 2>&1 || rc=$? |
| 39 | if [ "$rc" -ne 1 ] || ! grep -q '^FAIL numeric lifecycle scenario ' "$dir/output"; then |
| 40 | echo "FAIL: mutation $mutant survived or did not run"; cat "$dir/output"; exit 1 |
| 41 | fi |
| 42 | echo "numeric lifecycle mutant $mutant: killed" |
| 43 | done |