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/test_autodiff_conversion_equiv.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 / test_autodiff_conversion_equiv.sh` 64 lines ยท 3487 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 # Proof that tools/autodiff_mutations.sh (now an adapter over 18 # tools/mutation_runner.sh) behaves like the pinned legacy script. Host, CPU 19 # only. Runs the OLD script (git show `2dc9dd8`:tools/autodiff_mutations.sh, 20 # placed under tools/ because it cds to dirname/..; removed by the trap) and 21 # the NEW script on the same tree, then compares stdout and exit code, and the 22 # per-mutant verdict list (name + KILLED/SURVIVED/ERROR, derived from the 23 # legacy "MUTATION : ..." lines). Nothing is normalised: both scripts' 24 # stdout carries no paths or timings (scratch dirs are never printed on the 25 # pass path). A negative check proves the comparison can fail. 26 set -u 27 root=$(cd "$(dirname "$0")/.." && pwd) 28 cd "$root" || exit 2 29 PIN=`2dc9dd8` 30 old=tools/.autodiff_mutations_old.$$.sh 31 tmp=$(mktemp -d "${TMPDIR:-/tmp}/autodiff-equiv.XXXXXX") || exit 2 32 trap 'rm -rf "$tmp" "$root/$old"' EXIT INT TERM 33 git show "$PIN:tools/autodiff_mutations.sh" > "$old" || { echo "FAIL cannot extract $PIN"; exit 1; } 34 chmod +x "$old" 35 sh "$old" > "$tmp/old.out" 2>/dev/null; echo $? > "$tmp/old.rc" 36 sh tools/autodiff_mutations.sh > "$tmp/new.out" 2>/dev/null; echo $? > "$tmp/new.rc" 37 38 verdicts() { # stdout file -> "name VERDICT" lines 39 sed -n 's/^MUTATION \([A-Z_0-9]*\): caught.*/\1 KILLED/p; 40 s/^MUTATION \([A-Z_0-9]*\): NOT CAUGHT.*/\1 SURVIVED/p; 41 s/^MUTATION \([A-Z_0-9]*\): \(NOT APPLIED\|does not build\).*/\1 ERROR/p' "$1" 42 } 43 verdicts "$tmp/old.out" > "$tmp/old.v" 44 verdicts "$tmp/new.out" > "$tmp/new.v" 45 count=$(wc -l < "$tmp/old.v") 46 47 fails=0 48 chk() { if [ "$2" = 0 ]; then echo "ok $1"; else echo "FAIL $1"; fails=$((fails + 1)); fi; } 49 [ "$count" -ge 5 ]; chk "old script produced at least 5 mutant verdicts ($count)" $? 50 cmp -s "$tmp/old.rc" "$tmp/new.rc"; chk "exit code identical (old $(cat "$tmp/old.rc"), new $(cat "$tmp/new.rc"))" $? 51 cmp -s "$tmp/old.out" "$tmp/new.out"; chk "stdout byte-identical" $? 52 cmp -s "$tmp/old.v" "$tmp/new.v"; chk "per-mutant verdict list identical" $? 53 54 # Negative check: an altered verdict line must be reported as different. 55 sed '1s/KILLED/SURVIVED/' "$tmp/new.v" > "$tmp/alt.v" 56 if cmp -s "$tmp/old.v" "$tmp/alt.v"; then chk "negative: altered verdict is detected" 1; else chk "negative: altered verdict is detected" 0; fi 57 sed '1s/^MUTATION/MUTATIONX/' "$tmp/new.out" > "$tmp/alt.out" 58 if cmp -s "$tmp/old.out" "$tmp/alt.out"; then chk "negative: altered stdout is detected" 1; else chk "negative: altered stdout is detected" 0; fi 59 echo $(( $(cat "$tmp/old.rc") + 1 )) > "$tmp/alt.rc" 60 if cmp -s "$tmp/old.rc" "$tmp/alt.rc"; then chk "negative: altered exit code is detected" 1; else chk "negative: altered exit code is detected" 0; fi 61 62 echo "compared $count mutants" 63 if [ "$fails" -ne 0 ]; then echo "autodiff conversion equivalence: FAIL"; exit 1; fi 64 echo "autodiff conversion equivalence: PASS"