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 / window_lane_guard_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 self-test for tools/window_lane_guard.sh (omega #315). No chip, no make clean is run. |
| 18 | set -u |
| 19 | HERE=$(cd "$(dirname "$0")/.." && pwd) |
| 20 | T=$(mktemp -d "${TMPDIR:-/tmp}/wlg.XXXXXX"); trap 'rm -rf "$T"' EXIT |
| 21 | FAILS=0 |
| 22 | check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi; } |
| 23 | . "$HERE/tools/window_lane_guard.sh" |
| 24 | OUT=$T/out; B=$T/build |
| 25 | mkdir -p "$B/qual-runs/run1/R11" "$OUT" |
| 26 | printf '{"gate":"PASS"}\n' > "$B/qual-runs/run1/R11/rx_aien_faculty_receipt.json" |
| 27 | |
| 28 | wl_begin "$OUT" r11 |
| 29 | wl_guard_clean "$OUT" chipwait 2>/dev/null; rc=$? |
| 30 | check "chipwait refused while the r11 receipt is unarchived (exit 2)" '[ $rc = 2 ]' |
| 31 | check "refusal names the lane" 'wl_guard_clean "$OUT" chipwait 2>&1 | grep -q "lane r11 has an unarchived receipt"' |
| 32 | check "a lane is not refused by itself" 'wl_guard_clean "$OUT" r11' |
| 33 | |
| 34 | wl_r11_archive "$OUT" "$B"; rc=$? |
| 35 | sha=$(sha256sum "$B/qual-runs/run1/R11/rx_aien_faculty_receipt.json" | cut -c1-64) |
| 36 | check "r11 archive exits 0" '[ $rc = 0 ]' |
| 37 | check "archived under its sha256 name" '[ -f "$OUT/R11-living/rx_aien_faculty_receipt.$sha.json" ]' |
| 38 | check "archived copy is identical" 'cmp -s "$OUT/R11-living/rx_aien_faculty_receipt.$sha.json" "$B/qual-runs/run1/R11/rx_aien_faculty_receipt.json"' |
| 39 | check "chipwait allowed after archiving" 'wl_guard_clean "$OUT" chipwait' |
| 40 | rm -rf "$B" # what make clean does |
| 41 | check "receipt survives make clean" '[ -s "$OUT/R11-living/rx_aien_faculty_receipt.$sha.json" ]' |
| 42 | check "archiving twice keeps the same single file" 'mkdir -p "$B/qual-runs/run1/R11" && printf "{\"gate\":\"PASS\"}\n" > "$B/qual-runs/run1/R11/rx_aien_faculty_receipt.json" && wl_r11_archive "$OUT" "$B" && [ "$(ls "$OUT/R11-living" | wc -l)" = 1 ]' |
| 43 | |
| 44 | rm -rf "$B"; wl_begin "$OUT" r11b |
| 45 | wl_r11_archive "$OUT" "$B" 2>/dev/null; rc=$? |
| 46 | check "missing receipt: archive fails (exit 1)" '[ $rc = 1 ]' |
| 47 | check "missing receipt: clean still refused for that lane" '! wl_guard_clean "$OUT" chipwait 2>/dev/null' |
| 48 | wl_no_receipt "$OUT" r11b |
| 49 | check "explicit no-receipt mark releases the guard" 'wl_guard_clean "$OUT" chipwait' |
| 50 | |
| 51 | echo "window_lane_guard_test: $FAILS failures" |
| 52 | [ "$FAILS" = 0 ] |