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 / tools / estimation / test_est5_window.sh

60 lines · 3284 bytes Raw Blame History
1#!/bin/sh
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# ESTIMATION v5 window tests: the collector refuses without the flag, a foreign build is
18# recorded and voids the window, a clean run is clean, the checker rejects a dead monitor.
19# Uses a stub load generator and a scratch HOME; reads thermal sysfs files only.
20set -u
21here=$(cd "$(dirname "$0")" && pwd)
22W=$(mktemp -d)
23trap 'rm -rf "$W"' EXIT
24pass=0; fail=0
25ok() { pass=$((pass + 1)); }
26bad() { echo "FAIL: $1" >&2; fail=$((fail + 1)); }
27mkdir -p "$W/home/workspace"
28printf '#!/bin/sh\nsleep "$2"\n' > "$W/est_stub"; chmod +x "$W/est_stub"
29# 1. no flag: refuse with 3
30HOME=$W/home sh "$here/est5_collect.sh" smoke 4 1 "$W/raw" "$W/est_stub" > /dev/null 2>&1; [ $? -eq 3 ] && ok || bad "no flag not refused"
31# 2. flag for another gate: refuse with 3
32printf 'owner x\ngate other\n' > "$W/home/workspace/.spark-quiet"
33HOME=$W/home sh "$here/est5_collect.sh" smoke 4 1 "$W/raw" "$W/est_stub" > /dev/null 2>&1; [ $? -eq 3 ] && ok || bad "wrong gate not refused"
34printf 'owner lane44\ngate est-v5\n' > "$W/home/workspace/.spark-quiet"
35# 3. clean 8 s smoke: exit 0, WINDOW_CLEAN, flag untouched, folder named -est5-smoke-silicon
36out=$(HOME=$W/home sh "$here/est5_collect.sh" smoke 8 1 "$W/raw" "$W/est_stub" 2> /dev/null); rc=$?
37[ $rc -eq 0 ] && ok || bad "clean run rc=$rc"
38grep -q '^WINDOW_CLEAN' "$out/WINDOW" 2> /dev/null && ok || bad "clean run not WINDOW_CLEAN"
39[ -f "$W/home/workspace/.spark-quiet" ] && ok || bad "collector removed the flag"
40case "$out" in *-est5-smoke-silicon) ok;; *) bad "folder name $out";; esac
41# 4. a foreign build (a process named make) during the run: exit 7 and WINDOW_VOID
42cp /bin/sleep "$W/make"
43( sleep 3; "$W/make" 4 ) &
44sleep 1
45out=$(HOME=$W/home sh "$here/est5_collect.sh" smoke 10 1 "$W/raw" "$W/est_stub" 2> /dev/null); rc=$?
46wait
47[ $rc -eq 7 ] && ok || bad "foreign make not void, rc=$rc"
48grep -q '^WINDOW_VOID' "$out/WINDOW" 2> /dev/null && ok || bad "foreign make not WINDOW_VOID"
49grep -q ' FOREIGN .* make$' "$out/process-monitor.log" && ok || bad "foreign make not logged"
50# 5. a foreign build already running at start: refuse with 3
51( "$W/make" 6 ) &
52sleep 1
53HOME=$W/home sh "$here/est5_collect.sh" smoke 4 1 "$W/raw" "$W/est_stub" > /dev/null 2>&1; [ $? -eq 3 ] && ok || bad "pre-existing make not refused"
54wait
55# 6. checker: dead monitor and missing log
56mkdir "$W/dead"; : > "$W/dead/process-monitor.log"
57sh "$here/est5_window_check.sh" "$W/dead" 2700 > /dev/null; [ $? -eq 1 ] && ok || bad "dead monitor not void"
58sh "$here/est5_window_check.sh" "$W/nolog" 2700 > /dev/null; [ $? -eq 1 ] && ok || bad "missing log not void"
59echo "test_est5_window: $pass passed, $fail failed"
60[ "$fail" -eq 0 ]