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 / divsqrt_check_sweep.sh
| 1 | #!/bin/bash |
| 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 | # divsqrt_check_sweep.sh -- proves each pre-submission check in |
| 18 | # src/omega_numeric_divsqrt_gb10.c is load-bearing. Every check is one line |
| 19 | # ending in a /* CHECK:<name> */ marker. For each marker this script deletes |
| 20 | # that line in a scratch copy, rebuilds the CPU-only test and runs the host |
| 21 | # tier. The sweep passes only if every copy builds and every run FAILS with |
| 22 | # exit status 1 and a [FAIL] line (a crash or signal counts as BROKEN). |
| 23 | # Unused-variable and unused-parameter warnings are allowed in the scratch |
| 24 | # copies only: deleting a check can leave the value it tested unused. |
| 25 | # Host only: opens no device, writes only under a temporary directory. |
| 26 | # Run: make test-divsqrt-sweep (or run this file). |
| 27 | set -u |
| 28 | HERE=$(cd -P "$(dirname "$0")/.." && pwd) |
| 29 | SRC=$HERE/src/omega_numeric_divsqrt_gb10.c |
| 30 | TMP=$(mktemp -d) |
| 31 | trap 'rm -rf "$TMP"' EXIT |
| 32 | OTHER="tests/test_omega_divsqrt_gb10.c src/omega_numeric.c src/omega_numeric_provenance.c src/omega_blackwell_encoder.c |
| 33 | src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_om_units.c" |
| 34 | names=$(grep -o '/\* CHECK:[a-z0-9_]* \*/' "$SRC" | sed 's|/\* CHECK:\([a-z0-9_]*\) \*/|\1|') |
| 35 | total=0 killed=0 survived=0 broken=0 |
| 36 | for name in $names; do |
| 37 | total=$((total + 1)) |
| 38 | mut=$TMP/omega_numeric_divsqrt_gb10.c |
| 39 | grep -v "/\* CHECK:$name \*/" "$SRC" > "$mut" |
| 40 | if [ "$(wc -l < "$SRC")" -ne $(( $(wc -l < "$mut") + 1 )) ]; then |
| 41 | echo " [BROKEN] $name: marker is not on exactly one line"; broken=$((broken + 1)); continue |
| 42 | fi |
| 43 | # shellcheck disable=SC2086 |
| 44 | if ! (cd "$HERE" && gcc -std=gnu11 -O2 -Wall -Wextra -Werror -ffp-contract=off -Isrc -pthread \ |
| 45 | -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter \ |
| 46 | -DOMEGA_NUMERIC_CPU_ONLY -o "$TMP/t" "$mut" $OTHER) > "$TMP/build.log" 2>&1; then |
| 47 | echo " [BROKEN] $name: scratch copy does not build"; broken=$((broken + 1)); continue |
| 48 | fi |
| 49 | "$TMP/t" > "$TMP/run.log" 2>&1; rc=$? |
| 50 | if [ "$rc" = 0 ]; then |
| 51 | echo " [SURVIVED] $name: removing this check fails no test"; survived=$((survived + 1)) |
| 52 | elif [ "$rc" != 1 ] || ! grep -q "^\[FAIL\]" "$TMP/run.log"; then |
| 53 | # a crash, signal or other exit is not a test catching the mutation |
| 54 | echo " [BROKEN] $name: run ended with status $rc and no [FAIL] line (crash, not a caught mutation)"; broken=$((broken + 1)) |
| 55 | else |
| 56 | echo " [KILLED] $name: $(grep -m2 '^\[FAIL\]' "$TMP/run.log" | sed 's/^\[FAIL\] //' | tr '\n' ' ')" |
| 57 | killed=$((killed + 1)) |
| 58 | fi |
| 59 | done |
| 60 | echo "SWEEP total=$total killed=$killed survived=$survived broken=$broken" |
| 61 | [ "$total" -gt 0 ] && [ "$killed" = "$total" ] && echo "VERDICT PASS" && exit 0 |
| 62 | echo "VERDICT FAIL"; exit 1 |