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 / native / disk / tests / omega_nvme_test.sh

73 lines · 4036 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# Host/disposable-QEMU verification only; no device path argument exists.
4set -eu
5cd "$(dirname "$0")/../../.."
6: "${AIEN_OMC:?set AIEN_OMC to the existing pinned seeded compiler}"
7want=$(sed -n 's/^omc-sha256 //p' PIN)
8actual=$(sha256sum "$AIEN_OMC")
9[ "${actual%% *}" = "$want" ] || { echo 'compiler pin mismatch' >&2; exit 2; }
10out=${OMEGA_NVME_EVIDENCE:-$(mktemp -d /tmp/omega-nvme-evidence-XXXXXX)}
11mkdir -p "$out"
12case "$out" in /*) ;; *) echo 'evidence directory must be absolute' >&2; exit 2;; esac
13base=native/disk
14compose() { cat "$base/omega_nvme.om" "$base/omega_nvme_transport.om" "$1"; }
15compile() { nice -n 15 "$AIEN_OMC" < "$1" > "$2"; chmod +x "$2"; }
16compose "$base/omega_nvme_main.om" > "$out/read.om"
17compile "$out/read.om" "$out/read"
18compose "$base/tests/omega_nvme_probe.om" > "$out/probe.om"
19compile "$out/probe.om" "$out/probe"
20compose "$base/tests/omega_nvme_adminwrap.om" > "$out/adminwrap.om"
21compile "$out/adminwrap.om" "$out/adminwrap"
22compose "$base/tests/omega_nvme_failstop.om" > "$out/failstop.om"
23compile "$out/failstop.om" "$out/failstop"
24${CC:-cc} -std=c11 -O2 -Wall -Wextra -Werror -Wno-unused-function \
25 "$base/tests/omega_nvme_runner.c" "$base/disk_nvme.c" "$base/disk.c" -o "$out/runner"
26: > "$out/host.log"
27for c in healthy singlepage lba4k dstrd serial firmware approval nsid extent range before prp zero metadata format nsze sqes cqes cap stride readytimeout readycfs status; do
28 nice -n 15 "$out/runner" "$out/read" "$c" >> "$out/host.log"
29done
30nice -n 15 "$out/runner" "$out/adminwrap" adminwrap >> "$out/host.log"
31for c in cid sqid sqhead phase timeout cfs; do
32 nice -n 15 "$out/runner" "$out/failstop" "$c" >> "$out/host.log"
33done
34for c in opcode0 opcode1 opcode8 opcode9 opcode128 opcode132 adminformat; do
35 nice -n 15 "$out/runner" "$out/probe" "$c" >> "$out/host.log"
36done
37# Remove exactly the named three-line refusal block in disposable sources.
38# These are verification mutants, never source edits or candidate artifacts.
39mutate() {
40 awk -v target="$1" 'BEGIN {skip=0;hits=0} $0==target {skip=3;hits++} skip>0 {skip--;next} {print} END {if(hits!=1)exit 2}' "$2" > "$3"
41}
42: > "$out/mutants.log"
43for spec in 'cid|if ne and dw3 65535 cid|cid|read' \
44 'sqid|if ne shr dw2 16 q|sqid|read' \
45 'status|if ne and shr dw3 17 2047 0|status|read' \
46 'sqhead|if ne and dw2 65535 get tail q|sqhead|read' \
47 'reopen|if gt get st 0 0|timeout|failstop' \
48 'opcode|if not ok|opcode1|probe'; do
49 name=${spec%%|*}; rest=${spec#*|}; guard=${rest%%|*}; rest=${rest#*|}; case_name=${rest%%|*}; source=${rest#*|}
50 mutate "$guard" "$out/$source.om" "$out/mutant-$name.om"
51 compile "$out/mutant-$name.om" "$out/mutant-$name"
52 if nice -n 15 "$out/runner" "$out/mutant-$name" "$case_name" > "$out/mutant-$name.log" 2>&1; then
53 echo "FAIL mutant survived $name" >&2; exit 1
54 fi
55 echo "PASS killed guard-removal mutant $name (baseline case passed)" >> "$out/mutants.log"
56done
57# Retention negative control: delete only the in-flight ownership marker.
58awk '$0=="put st 1 1" {hits++;next} {print} END {if(hits!=1)exit 2}' "$out/read.om" > "$out/mutant-retention.om"
59compile "$out/mutant-retention.om" "$out/mutant-retention"
60if nice -n 15 "$out/runner" "$out/mutant-retention" timeout > "$out/mutant-retention.log" 2>&1; then
61 echo 'FAIL retention mutant survived' >&2; exit 1
62fi
63echo 'PASS killed retention guard-removal mutant' >> "$out/mutants.log"
64: > "$out/qemu.log"
65# Firmware identity is intentionally pinned; a different QEMU version refuses.
66qemu-system-aarch64 --version > "$out/qemu-version.txt"
67for c in healthy serial firmware approval nsid extent range before prp zero; do
68 nice -n 15 "$out/runner" "$out/read" "$c" qemu >> "$out/qemu.log"
69done
70sha256sum "$AIEN_OMC" "$base/omega_nvme.om" "$base/omega_nvme_transport.om" \
71 "$base/omega_nvme_main.om" "$base/tests/omega_nvme_runner.c" "$out/read" > "$out/sha256.txt"
72printf '%s\n' 'PASS Omega NVMe host + QEMU + guard mutants; physical NOT_RUN' | tee "$out/result.txt"
73printf 'Evidence: %s\n' "$out"