interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tests / window_lane_guard_test.sh

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