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/runtime/rx_operator_mutants_evidence_test.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 / runtime / rx_operator_mutants_evidence_test.sh` 68 lines ยท 3849 bytes Raw Blame History 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 self-test for the evidence rules of tests/runtime/rx_operator_mutants.sh (omega #313 item 2, #314). 18 # Runs the script inside a fake tree with a stub compiler and a stub operator test; no real build, no chip. 19 # 1. a failing run keeps its logs outside the work folder (RX_OP_MUT_KEEP); 20 # 2. mutant programs run in their own folder: their build/qual-runs is not the fake tree's; 21 # 3. a mutant program that does write under the real build/qual-runs makes the script FAIL. 22 set -u 23 HERE=$(cd "$(dirname "$0")/../.." && pwd) 24 T=$(mktemp -d "${TMPDIR:-/tmp}/rxopmut.XXXXXX"); trap 'rm -rf "$T"' EXIT 25 FAILS=0 26 check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi; } 27 F=$T/tree 28 mkdir -p "$F/tests/runtime" "$F/src" "$F/tests/fabric" "$F/tools" "$F/build/qual-runs/existing" 29 cp "$HERE/tests/runtime/rx_operator_mutants.sh" "$F/tests/runtime/" 30 # Stub of the operator test: runs the built program once (as the real test does) and reports one failed check. 31 printf '#!/bin/bash\n"$2" > /dev/null 2>&1 < /dev/null\necho "[-] stub check failed"\nexit 1\n' > "$F/tests/runtime/rx_operator_host.sh" 32 echo keep > "$F/build/qual-runs/existing/sentinel" 33 printf '#!/bin/sh\n:\n' > "$T/cli"; chmod +x "$T/cli" 34 # Stub compiler: the "program" it builds writes a receipt relative to its working folder, and, when 35 # STUB_REAL is set, also straight into the real build/qual-runs. 36 cat > "$T/cc" <<'STUB' 37 #!/bin/bash 38 while [ $# -gt 0 ]; do [ "$1" = -o ] && { out=$2; break; }; shift; done 39 cat > "$out" < build/qual-runs/stub/r.json 42 [ -n "${STUB_REAL:-}" ] && { mkdir -p "$STUB_REAL/build/qual-runs/leak"; echo x > "$STUB_REAL/build/qual-runs/leak/r.json"; } 43 exit 1 44 PROG 45 chmod +x "$out" 46 STUB 47 chmod +x "$T/cc" 48 run() { # keepdir, extra env... 49 local keep=$1; shift 50 env "$@" CC="$T/cc" CFLAGS= RX_PROD_ARGUS_FLAGS= RX_R13_SRCS=x RX_PROD_ARGUS_SRCS=y AIENOS_CAP_LIB= \ 51 RX_OP_MUT_KEEP="$keep" bash "$F/tests/runtime/rx_operator_mutants.sh" "$T/cli" 2>&1 52 } 53 before=$(find "$F/build/qual-runs" | LC_ALL=C sort) 54 out=$(run "$T/kept1" X=1); rc=$? 55 check "failing run exits non-zero" '[ $rc != 0 ]' 56 check "failing run keeps its logs" '[ -s "$T/kept1/base/run.log" ] && [ -s "$T/kept1/base/build.log" -o -e "$T/kept1/base/build.log" ]' 57 check "failing run says where the logs are" 'echo "$out" | grep -q "logs kept in $T/kept1"' 58 check "kept logs include the mutant receipt folder" '[ -s "$T/kept1/base/qual-runs/stub/r.json" ]' 59 check "mutant receipt did not land in the real build/qual-runs" '[ "$(find "$F/build/qual-runs" | LC_ALL=C sort)" = "$before" ]' 60 check "no leak reported when nothing leaked" '! echo "$out" | grep -q "wrote under the real"' 61 out=$(run "$T/kept2" STUB_REAL="$F"); rc=$? 62 check "a program writing under the real build/qual-runs is reported" 'echo "$out" | grep -q "FAIL mutant runs wrote under the real"' 63 check "that run exits non-zero" '[ $rc != 0 ]' 64 mkdir -p "$T/kept3" 65 out=$(run "$T/kept3" X=1) 66 check "an existing keep folder is not overwritten" 'echo "$out" | grep -q "not keeping logs" && [ -z "$(ls -A "$T/kept3")" ]' 67 echo "rx_operator_mutants_evidence_test: $FAILS failures" 68 [ "$FAILS" = 0 ]