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/seed/trace/gate.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 / seed / trace / gate.sh` 60 lines ยท 3005 bytes Raw Blame History 1 #!/bin/sh 2 # seed/trace/gate.sh -- host gate for the local trace segment (omega-mv #608). 3 # Run from anywhere: sh seed/trace/gate.sh 4 # Compiles segment.om + segment-test.om with seed/out/omc (sha checked against seed/out/omc.sha256), runs 5 # the test in a fresh scratch directory and requires exit 0 and stdout equal to expected.txt byte for byte. 6 # The expected values (sizes, offsets, CRC check value, flags) were computed in Wolfram Language; see 7 # README.md. Then each source mutant (a literal swap of a line that must occur exactly once in segment.om) 8 # must compile, exit 1, and fail on its own check label: 9 # crc record CRC no longer compared -> crc-reason FAIL 10 # torn partial tail not reported as torn -> torn-reason FAIL 11 # align append ignores a misaligned tail -> torn-append-refused FAIL 12 # excl create opens with O_TRUNC, not O_EXCL -> create-again-refused FAIL 13 # Prints PASS trace and exits 0, or FAIL and exits 1. 14 set -eu 15 R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 16 cd "$R" 17 D=seed/trace 18 B=build/seed/trace 19 rm -rf "$B" 20 mkdir -p "$B" 21 bad() { printf 'FAIL trace: %s\n' "$*" >&2; exit 1; } 22 23 want=$(cut -c1-64 seed/out/omc.sha256) 24 have=$(sha256sum < seed/out/omc | cut -c1-64) 25 [ "$want" = "$have" ] || bad "seed/out/omc is $have, omc.sha256 says $want" 26 OMC="$R/seed/out/omc" 27 28 # run NAME SRC: compile SRC to $B/NAME/t, run it inside $B/NAME, stdout to $B/NAME/out.txt, sets rc 29 run() { 30 mkdir -p "$B/$1" 31 "$OMC" < "$2" > "$B/$1/t" || bad "omc refused $2" 32 chmod 700 "$B/$1/t" 33 rc=0 34 (cd "$B/$1" && ./t > out.txt) || rc=$? 35 } 36 37 cat "$D/segment.om" "$D/segment-test.om" > "$B/test.om" 38 run main "$B/test.om" 39 printf 'omc %s\nsegment-test %s\n' "$have" "$(sha256sum < "$B/main/t" | cut -c1-64)" 40 [ "$rc" -eq 0 ] || { cat "$B/main/out.txt" >&2; bad "segment-test exited $rc"; } 41 cmp -s "$B/main/out.txt" "$D/expected.txt" || { diff "$D/expected.txt" "$B/main/out.txt" >&2 || true; bad "output differs from expected.txt"; } 42 43 n=0 44 mutant() { # NAME SITE REPLACEMENT LABEL 45 c=$(grep -c -x -F "$2" "$D/segment.om" || true) 46 [ "$c" = 1 ] || bad "mutant $1: site found $c times" 47 awk -v s="$2" -v r="$3" '$0 == s { print r; next } { print }' "$D/segment.om" > "$B/$1.om" 48 cmp -s "$B/$1.om" "$D/segment.om" && bad "mutant $1: source unchanged" 49 cat "$B/$1.om" "$D/segment-test.om" > "$B/$1-test.om" 50 run "$1" "$B/$1-test.om" 51 [ "$rc" -eq 1 ] || bad "mutant $1 exited $rc, need 1" 52 grep -q "^$4 [0-9]* FAIL want=" "$B/$1/out.txt" || bad "mutant $1 did not fail $4" 53 echo "mutant $1: exit 1, $4 FAIL" 54 n=$((n + 1)) 55 } 56 mutant crc 'if ne want segcrc 60' 'if ne want want' crc-reason 57 mutant torn 'put sreason 0 1' 'put sreason 0 0' torn-reason 58 mutant align 'if ne rem r 64 0' 'if ne rem r 1 0' torn-append-refused 59 mutant excl 'fd = fopen tpath 0 get tlen 0 32961 384' 'fd = fopen tpath 0 get tlen 0 33345 384' create-again-refused 60 printf 'PASS trace %s checks, %s/4 mutants caught\n' "$(sed -n 's/^segment-test checks=\([0-9]*\) fails=0$/\1/p' "$B/main/out.txt")" "$n"