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 / tests / runtime / rx_r13_first_failure_test.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 | # Host test: the R13 receipt carries the FIRST failure message (omega #313 item 3). |
| 18 | # Builds the R13 host test build twice into its own scratch OUT_DIR (never build/): the normal program |
| 19 | # (receipt first_failure is null) and one compiled with an unreachable goal (-DTARGET_PCT=1u, so the goal |
| 20 | # check fails). The failing run must exit 1, write a FAIL receipt, and record the goal message in |
| 21 | # first_failure; the stderr line and the receipt agree. No GPU. Runs from a scratch folder so no receipt |
| 22 | # is written under the real build/qual-runs. |
| 23 | # Usage: tests/runtime/rx_r13_first_failure_test.sh (environment as for `make test-r13-testbuild-host`) |
| 24 | set -u |
| 25 | HERE=$(cd "$(dirname "$0")/../.." && pwd) |
| 26 | T=$(mktemp -d "${TMPDIR:-/tmp}/rxr13ff.XXXXXX"); trap 'rm -rf "$T"' EXIT |
| 27 | FAILS=0 |
| 28 | check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi; } |
| 29 | BASE_CFLAGS=$(make -C "$HERE" -pn 2>/dev/null | sed -n 's/^CFLAGS = //p' | head -1) |
| 30 | mk() { make -C "$HERE" OUT_DIR="$T/out" CFLAGS="$BASE_CFLAGS $1" "$T/out/rx_r13_living_testbuild_host" > "$T/make.log" 2>&1; } |
| 31 | runit() { # name; runs the built program in its own folder |
| 32 | mkdir -p "$T/$1" && chmod 700 "$T/$1" && mkdir -m 700 "$T/$1/state" |
| 33 | (cd "$T/$1" && "$T/out/rx_r13_living_testbuild_host" --state-dir "$T/$1/state" > stdout.log 2> stderr.log; echo $? > rc) |
| 34 | receipt=$(find "$T/$1" -name rx_living_test_build_receipt.json | head -1) |
| 35 | } |
| 36 | mk "" || { echo "NOT_RUN: normal build failed (see environment: PHYSICS_DIR, ARGUS_REPO, AIENOS_LOCK_REPO)"; tail -3 "$T/make.log"; exit 3; } |
| 37 | runit pass |
| 38 | check "normal run: receipt written" '[ -s "$receipt" ]' |
| 39 | check "normal run: first_failure is null" '[ "$(jq -c .first_failure "$receipt")" = null ]' |
| 40 | rm -f "$T/out/rx_r13_living_testbuild_host" |
| 41 | mk "-DTARGET_PCT=1u" || { echo "FAIL variant build"; tail -3 "$T/make.log"; exit 1; } |
| 42 | runit fail |
| 43 | check "unreachable goal: exit 1" '[ "$(cat "$T/fail/rc")" = 1 ]' |
| 44 | check "unreachable goal: receipt written" '[ -s "$receipt" ]' |
| 45 | check "unreachable goal: gate is FAIL" '[ "$(jq -r ".gate | to_entries[0].value" "$receipt")" = FAIL ]' |
| 46 | check "first_failure names the goal check" 'jq -r .first_failure "$receipt" | grep -q "AIEN.s belief does not show the goal met"' |
| 47 | check "first_failure is the first stderr R13 failure line" '[ "$(jq -r .first_failure "$receipt")" = "$(grep -m1 "^R13 mode" "$T/fail/stderr.log")" ]' |
| 48 | # omega #527: the judge keeps stdout in its receipt; the reason must be there, not only on stderr. |
| 49 | check "stdout carries the first failure" '[ "$(sed -n "s/^R13 first failure: //p" "$T/fail/stdout.log")" = "$(jq -r .first_failure "$receipt")" ]' |
| 50 | check "stdout carries the FAILED counts line" 'grep -q "^R13 positive FAILED: plan " "$T/fail/stdout.log"' |
| 51 | check "stdout carries the AIEN, Omega and GPU state" 'grep -q "^R13 positive AIEN: prediction " "$T/fail/stdout.log" && grep -q "^R13 positive Omega: search epoch " "$T/fail/stdout.log" && grep -q "^R13 positive GPU: claims .*why no GPU result: " "$T/fail/stdout.log"' |
| 52 | check "normal run: no failure lines on stdout" '! grep -qE "^R13 (first failure|.* FAILED:)" "$T/pass/stdout.log"' |
| 53 | check "nothing written under the real build/qual-runs by this test" '[ -z "$(find "$HERE/build/qual-runs" -newer "$T/make.log" 2>/dev/null | head -1)" ]' |
| 54 | echo "rx_r13_first_failure_test: $FAILS failures" |
| 55 | [ "$FAILS" = 0 ] |