aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / disk / tests / omega_nvme_test.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Host/disposable-QEMU verification only; no device path argument exists. |
| 4 | set -eu |
| 5 | cd "$(dirname "$0")/../../.." |
| 6 | : "${AIEN_OMC:?set AIEN_OMC to the existing pinned seeded compiler}" |
| 7 | want=$(sed -n 's/^omc-sha256 //p' PIN) |
| 8 | actual=$(sha256sum "$AIEN_OMC") |
| 9 | [ "${actual%% *}" = "$want" ] || { echo 'compiler pin mismatch' >&2; exit 2; } |
| 10 | out=${OMEGA_NVME_EVIDENCE:-$(mktemp -d /tmp/omega-nvme-evidence-XXXXXX)} |
| 11 | mkdir -p "$out" |
| 12 | case "$out" in /*) ;; *) echo 'evidence directory must be absolute' >&2; exit 2;; esac |
| 13 | base=native/disk |
| 14 | compose() { cat "$base/omega_nvme.om" "$base/omega_nvme_transport.om" "$1"; } |
| 15 | compile() { nice -n 15 "$AIEN_OMC" < "$1" > "$2"; chmod +x "$2"; } |
| 16 | compose "$base/omega_nvme_main.om" > "$out/read.om" |
| 17 | compile "$out/read.om" "$out/read" |
| 18 | compose "$base/tests/omega_nvme_probe.om" > "$out/probe.om" |
| 19 | compile "$out/probe.om" "$out/probe" |
| 20 | compose "$base/tests/omega_nvme_adminwrap.om" > "$out/adminwrap.om" |
| 21 | compile "$out/adminwrap.om" "$out/adminwrap" |
| 22 | compose "$base/tests/omega_nvme_failstop.om" > "$out/failstop.om" |
| 23 | compile "$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" |
| 27 | for 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" |
| 29 | done |
| 30 | nice -n 15 "$out/runner" "$out/adminwrap" adminwrap >> "$out/host.log" |
| 31 | for c in cid sqid sqhead phase timeout cfs; do |
| 32 | nice -n 15 "$out/runner" "$out/failstop" "$c" >> "$out/host.log" |
| 33 | done |
| 34 | for c in opcode0 opcode1 opcode8 opcode9 opcode128 opcode132 adminformat; do |
| 35 | nice -n 15 "$out/runner" "$out/probe" "$c" >> "$out/host.log" |
| 36 | done |
| 37 | # Remove exactly the named three-line refusal block in disposable sources. |
| 38 | # These are verification mutants, never source edits or candidate artifacts. |
| 39 | mutate() { |
| 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" |
| 43 | for 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" |
| 56 | done |
| 57 | # Retention negative control: delete only the in-flight ownership marker. |
| 58 | awk '$0=="put st 1 1" {hits++;next} {print} END {if(hits!=1)exit 2}' "$out/read.om" > "$out/mutant-retention.om" |
| 59 | compile "$out/mutant-retention.om" "$out/mutant-retention" |
| 60 | if 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 |
| 62 | fi |
| 63 | echo 'PASS killed retention guard-removal mutant' >> "$out/mutants.log" |
| 64 | : > "$out/qemu.log" |
| 65 | # Firmware identity is intentionally pinned; a different QEMU version refuses. |
| 66 | qemu-system-aarch64 --version > "$out/qemu-version.txt" |
| 67 | for 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" |
| 69 | done |
| 70 | sha256sum "$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" |
| 72 | printf '%s\n' 'PASS Omega NVMe host + QEMU + guard mutants; physical NOT_RUN' | tee "$out/result.txt" |
| 73 | printf 'Evidence: %s\n' "$out" |