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 / tools / estimation / test_est5_window.sh
| 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. |
| 20 | set -u |
| 21 | here=$(cd "$(dirname "$0")" && pwd) |
| 22 | W=$(mktemp -d) |
| 23 | trap 'rm -rf "$W"' EXIT |
| 24 | pass=0; fail=0 |
| 25 | ok() { pass=$((pass + 1)); } |
| 26 | bad() { echo "FAIL: $1" >&2; fail=$((fail + 1)); } |
| 27 | mkdir -p "$W/home/workspace" |
| 28 | printf '#!/bin/sh\nsleep "$2"\n' > "$W/est_stub"; chmod +x "$W/est_stub" |
| 29 | # 1. no flag: refuse with 3 |
| 30 | HOME=$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 |
| 32 | printf 'owner x\ngate other\n' > "$W/home/workspace/.spark-quiet" |
| 33 | HOME=$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" |
| 34 | printf '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 |
| 36 | out=$(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" |
| 38 | grep -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" |
| 40 | case "$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 |
| 42 | cp /bin/sleep "$W/make" |
| 43 | ( sleep 3; "$W/make" 4 ) & |
| 44 | sleep 1 |
| 45 | out=$(HOME=$W/home sh "$here/est5_collect.sh" smoke 10 1 "$W/raw" "$W/est_stub" 2> /dev/null); rc=$? |
| 46 | wait |
| 47 | [ $rc -eq 7 ] && ok || bad "foreign make not void, rc=$rc" |
| 48 | grep -q '^WINDOW_VOID' "$out/WINDOW" 2> /dev/null && ok || bad "foreign make not WINDOW_VOID" |
| 49 | grep -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 ) & |
| 52 | sleep 1 |
| 53 | HOME=$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" |
| 54 | wait |
| 55 | # 6. checker: dead monitor and missing log |
| 56 | mkdir "$W/dead"; : > "$W/dead/process-monitor.log" |
| 57 | sh "$here/est5_window_check.sh" "$W/dead" 2700 > /dev/null; [ $? -eq 1 ] && ok || bad "dead monitor not void" |
| 58 | sh "$here/est5_window_check.sh" "$W/nolog" 2700 > /dev/null; [ $? -eq 1 ] && ok || bad "missing log not void" |
| 59 | echo "test_est5_window: $pass passed, $fail failed" |
| 60 | [ "$fail" -eq 0 ] |