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 / tools / sm121dis / corpus_selftest.sh
| 1 | #!/bin/sh |
| 2 | # A missing or failing producer, or one that exits 0 after a kernel could not be dumped whole, must invalidate the |
| 3 | # disassembler corpus. |
| 4 | set -eu |
| 5 | HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) |
| 6 | WORK=$(mktemp -d "${TMPDIR:-/tmp}/sm121dis-corpus-control.XXXXXX") |
| 7 | trap 'rm -rf "$WORK"' EXIT HUP INT TERM |
| 8 | mkdir "$WORK/bin" "$WORK/missing" "$WORK/failing" "$WORK/partial" |
| 9 | rc=0 |
| 10 | sh "$HERE/corpus.sh" "$WORK/bin" "$WORK/missing" > "$WORK/missing.log" 2>&1 || rc=$? |
| 11 | [ "$rc" -eq 127 ] && grep -q 'VERDICT FAIL: corpus producer failed:' "$WORK/missing.log" || { |
| 12 | echo 'FAIL: a missing producer did not invalidate the corpus'; exit 1; |
| 13 | } |
| 14 | printf '#!/bin/sh\necho deliberate-producer-failure\nexit 42\n' > "$WORK/bin/gpu_matmul_api_test" |
| 15 | chmod +x "$WORK/bin/gpu_matmul_api_test" |
| 16 | rc=0 |
| 17 | sh "$HERE/corpus.sh" "$WORK/bin" "$WORK/failing" > "$WORK/failing.log" 2>&1 || rc=$? |
| 18 | [ "$rc" -eq 42 ] && grep -q 'deliberate-producer-failure' "$WORK/failing.log" && |
| 19 | grep -q 'VERDICT FAIL: corpus producer failed:' "$WORK/failing.log" || { |
| 20 | echo 'FAIL: a failing producer did not invalidate the corpus'; exit 1; |
| 21 | } |
| 22 | # exit 0, but omega_kernel_dump reported a kernel it could not write whole (src/omega_blackwell_codegen.c) |
| 23 | printf '#!/bin/sh\necho "omega_kernel_dump: write failed, removed /x/k.bin" >&2\nexit 0\n' > "$WORK/bin/gpu_matmul_api_test" |
| 24 | rc=0 |
| 25 | sh "$HERE/corpus.sh" "$WORK/bin" "$WORK/partial" > "$WORK/partial.log" 2>&1 || rc=$? |
| 26 | [ "$rc" -eq 1 ] && grep -q 'VERDICT FAIL: kernels not captured whole:' "$WORK/partial.log" || { |
| 27 | echo 'FAIL: a kernel not captured whole did not invalidate the corpus'; exit 1; |
| 28 | } |
| 29 | echo 'PASS: missing and failing corpus producers are refused' |