interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / scripts / lib_verify_summary.sh

91 lines · 4364 bytes Raw Blame History
1#!/usr/bin/env 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# lib_verify_summary.sh: the skipped-step bookkeeping and the closing verdict
18# of scripts/verify_all.sh, kept here so the verdict can be tested without
19# cargo or QEMU. Source it; or run `bash scripts/lib_verify_summary.sh
20# --self-test` for negative controls.
21#
22# Rule: the last line of verify_all.sh says what actually ran. A skipped step
23# makes the verdict NOT_RUN for that step (never "PASS"), and AIENOS_STRICT=1
24# turns any skipped step into a failure. QEMU steps are emulator evidence only;
25# hardware is never checked by verify_all.sh.
26
27SKIPPED_STEPS=()
28
29skipped() {
30 echo "SKIPPED: $*"
31 SKIPPED_STEPS+=("$*")
32 if [[ "${AIENOS_STRICT:-0}" == "1" ]]; then
33 echo "STRICT FAIL: a step was skipped under AIENOS_STRICT=1 ($*)" >&2
34 exit 1
35 fi
36}
37
38# run_or_skip DESCRIPTION COMMAND...: a script that exits 3 reports NOT_RUN (it
39# skipped a check class); that is a skipped step here, never a pass. Any other
40# nonzero exit stops the harness, as before.
41run_or_skip() {
42 local desc="$1" rc=0; shift
43 "$@" || rc=$?
44 if [[ "${rc}" == 3 ]]; then skipped "${desc}: the script reported NOT_RUN (exit 3)"
45 elif [[ "${rc}" != 0 ]]; then exit "${rc}"; fi
46 return 0
47}
48
49final_verdict() {
50 echo ""
51 echo "============================================================"
52 if [[ ${#SKIPPED_STEPS[@]} -eq 0 ]]; then
53 echo "VERIFY_ALL: PASS (every step ran; QEMU steps are emulator evidence only, hardware NOT_RUN)"
54 else
55 printf 'NOT_RUN skipped step: %s\n' "${SKIPPED_STEPS[@]}"
56 echo "VERIFY_ALL: NOT_RUN (${#SKIPPED_STEPS[@]} step(s) skipped; every step that ran passed; not a full pass)"
57 fi
58 echo "============================================================"
59}
60
61if [[ "${BASH_SOURCE[0]}" == "$0" && "${1:-}" == --self-test ]]; then
62 lib="${BASH_SOURCE[0]}"; st=0
63 ok() { echo "PASS $*"; }
64 bad() { echo "FAIL $*"; st=1; }
65 # Each case runs in its own shell so exit paths are observable.
66 case_out() { AIENOS_STRICT="${STRICT:-0}" bash -c 'source "$1"; shift; eval "$@"' _ "${lib}" "$1" 2>&1; }
67
68 out="$(case_out 'final_verdict')"
69 grep -qF 'VERIFY_ALL: PASS' <<<"${out}" && ok "no skipped step -> VERIFY_ALL: PASS" || bad "clean run did not print PASS"
70
71 out="$(case_out 'skipped "demo step" >/dev/null; final_verdict')"
72 if grep -qF 'VERIFY_ALL: NOT_RUN (1 step(s) skipped' <<<"${out}" && ! grep -qF 'VERIFY_ALL: PASS' <<<"${out}"; then
73 ok "one skipped step -> VERIFY_ALL: NOT_RUN, never PASS (the old banner said PASSED regardless)"
74 else bad "skipped step verdict wrong: ${out}"; fi
75 grep -qF 'skipped step: demo step' <<<"${out}" && ok "the skipped step is named in the verdict" || bad "skipped step not named"
76
77 rc=0; STRICT=1 case_out 'skipped "demo step"' >/dev/null || rc=$?
78 [[ "${rc}" == 1 ]] && ok "AIENOS_STRICT=1: a skipped step exits 1" || bad "strict skip exited ${rc}"
79
80 rc=0; out="$(case_out 'run_or_skip demo bash -c "exit 3"; final_verdict')" || rc=$?
81 if [[ "${rc}" == 0 ]] && grep -qF 'VERIFY_ALL: NOT_RUN' <<<"${out}"; then ok "a child exiting 3 (NOT_RUN) is a skipped step"; else bad "exit-3 child: rc=${rc}"; fi
82
83 rc=0; case_out 'run_or_skip demo bash -c "exit 1"; echo reached' >/dev/null || rc=$?
84 [[ "${rc}" == 1 ]] && ok "a child exiting 1 stops the harness" || bad "exit-1 child: rc=${rc}"
85
86 rc=0; out="$(case_out 'run_or_skip demo true; final_verdict')" || rc=$?
87 [[ "${rc}" == 0 ]] && grep -qF 'VERIFY_ALL: PASS' <<<"${out}" && ok "a child exiting 0 is not a skip" || bad "exit-0 child: rc=${rc}"
88
89 if [[ ${st} == 0 ]]; then echo "VERIFY_ALL_SUMMARY_SELF_TEST: PASS"; exit 0; fi
90 echo "VERIFY_ALL_SUMMARY_SELF_TEST: FAIL"; exit 1
91fi