Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/runtime/rx_deadline_cancel_mutants.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / runtime / rx_deadline_cancel_mutants.sh` 112 lines ยท 4641 bytes Raw Blame History 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 # HD-09 mutant proof for tests/runtime/rx_deadline_cancel.c. 18 # 19 # Copies the tracked tree to a temp dir (the real tree is never modified), 20 # builds and runs the unmutated test there first (it must PASS, otherwise no 21 # kill means anything), then applies each mutant M1-M4 to the copy's 22 # src/runtime/rx_world.c, rebuilds only the test binary, and requires the 23 # test to FAIL. A mutant that does not apply or does not build is reported 24 # as NOT_APPLIED / BUILD_FAIL and counts as a survivor. 25 # 26 # M1 `>` -> `>=` in the run_one deadline check 27 # M2 the run_one deadline check removed (condition forced false) 28 # M3 cancel recorded, but the activation falls through to publishing 29 # (writes staged and committed) 30 # M4 cancel without refund (charge marked released before end_activation, 31 # so uncharge skips it) 32 # 33 # Prints MUTANTS_KILLED k/4; exit 0 only when k == 4. 34 set -u 35 36 root=$(cd "$(dirname "$0")/../.." && pwd) 37 tmp=$(mktemp -d "${TMPDIR:-/tmp}/rx_deadline_mut.XXXXXX") || exit 1 38 trap 'rm -rf "$tmp"' EXIT INT TERM 39 40 base="$tmp/base" 41 mkdir -p "$base" 42 (cd "$root" && git ls-files) > "$tmp/files" || { echo "MUTANTS: cannot list tree"; exit 1; } 43 (cd "$root" && tar -cf - -T "$tmp/files") | (cd "$base" && tar -xf -) || 44 { echo "MUTANTS: copy failed"; exit 1; } 45 46 src=src/runtime/rx_world.c 47 check='if (d->need.deadline .. w->budget.logical_tick > d->need.deadline) {' # BRE; '..' matches the && 48 grep -q 'if (d->need.deadline && w->budget.logical_tick > d->need.deadline) {' "$base/$src" || 49 { echo "MUTANTS: deadline check not found in $src"; exit 1; } 50 51 build_run() { # dir -> 0 pass, 1 fail, 2 build error 52 # PHYSICS_DIR / PHYSICS_LOCK_CHECK are passed through explicitly when set 53 # (host-only runs use PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0). 54 set -- "$1" 55 [ -n "${PHYSICS_DIR+x}" ] && set -- "$@" "PHYSICS_DIR=$PHYSICS_DIR" 56 [ -n "${PHYSICS_LOCK_CHECK+x}" ] && set -- "$@" "PHYSICS_LOCK_CHECK=$PHYSICS_LOCK_CHECK" 57 dir=$1; shift 58 make -C "$dir" --no-print-directory "$@" build/rx_deadline_cancel > "$dir/.mut_build.log" 2>&1 || return 2 59 set -- "$dir" 60 (cd "$1" && ./build/rx_deadline_cancel) > "$1/.mut_run.log" 2>&1 && return 0 61 return 1 62 } 63 64 build_run "$base"; rc=$? 65 if [ $rc -ne 0 ]; then 66 echo "BASELINE: FAIL (rc $rc); mutants not judged" 67 tail -n 20 "$base/.mut_build.log" "$base/.mut_run.log" 2>/dev/null 68 echo "MUTANTS_KILLED 0/4" 69 exit 1 70 fi 71 echo "BASELINE: PASS" 72 73 # Apply mutant $1 to the copy in $2. Edits only inside the HD-09 block 74 # (from the deadline check line to the first line that is exactly " }"). 75 mutate() { 76 f="$2/$src" 77 case "$1" in 78 M1) sed "s/$check/if (d->need.deadline \&\& w->budget.logical_tick >= d->need.deadline) {/" "$f" > "$f.new" ;; 79 M2) sed "s/$check/if (0) {/" "$f" > "$f.new" ;; 80 M3) awk -v pat='if (d->need.deadline && w->budget.logical_tick > d->need.deadline) {' ' 81 index($0, pat) { inb = 1; print; next } 82 inb && $0 == " }" { inb = 0; print; next } 83 inb && ($0 ~ /set_state\(w, r, RX_CANCELLED\);/ || $0 ~ /end_activation\(w, rid\);/ || 84 $0 ~ /^[ ]*return;[ ]*$/) { next } 85 { print }' "$f" > "$f.new" ;; 86 M4) awk -v pat='if (d->need.deadline && w->budget.logical_tick > d->need.deadline) {' ' 87 index($0, pat) { inb = 1; print; next } 88 inb && $0 == " }" { inb = 0; print; next } 89 inb && $0 ~ /end_activation\(w, rid\);/ { print " r->holding = false;" } 90 { print }' "$f" > "$f.new" ;; 91 esac 92 if cmp -s "$f" "$f.new"; then rm -f "$f.new"; return 1; fi 93 mv "$f.new" "$f" 94 } 95 96 killed=0 97 for m in M1 M2 M3 M4; do 98 d="$tmp/$m" 99 mkdir -p "$d" 100 (cd "$base" && tar -cf - -T "$tmp/files") | (cd "$d" && tar -xf -) 101 if ! mutate "$m" "$d"; then echo "$m: NOT_APPLIED (survivor)"; continue; fi 102 build_run "$d"; rc=$? 103 case $rc in 104 1) killed=$((killed + 1)); echo "$m: KILLED ($(grep -c ' FAIL ' "$d/.mut_run.log") failed checks)" ;; 105 0) echo "$m: SURVIVED" ;; 106 *) echo "$m: BUILD_FAIL (survivor)"; tail -n 5 "$d/.mut_build.log" ;; 107 esac 108 rm -rf "$d" 109 done 110 111 echo "MUTANTS_KILLED $killed/4" 112 [ "$killed" -eq 4 ]