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 / seed / host / irq.sh
| 1 | #!/bin/sh |
| 2 | # Host-only qualification. GCC/QEMU/ptrace/Python are verification oracles only. |
| 3 | # Never opens /dev/vfio or /dev/nvidia, alters bindings, or touches a GPU service. |
| 4 | set -eu |
| 5 | cd "$(dirname "$0")/../.." |
| 6 | R=$PWD |
| 7 | OMC=${OMC:-"$R/seed/out/omc"} |
| 8 | B=${IRQ_WORK:-"$R/build/seed/irq"} |
| 9 | mkdir -p "$B" |
| 10 | B=$(CDPATH= cd -- "$B" && pwd) |
| 11 | expectrc() { |
| 12 | want=$1 |
| 13 | shift |
| 14 | set +e |
| 15 | "$@" |
| 16 | got=$? |
| 17 | set -e |
| 18 | [ "$got" = "$want" ] || { printf 'FAIL exit=%s expected=%s command=%s\n' "$got" "$want" "$*" >&2; return 1; } |
| 19 | } |
| 20 | compile() { |
| 21 | "$OMC" < "seed/host/tests/$1.om" > "$B/$1" 2> "$B/$1.err" |
| 22 | chmod +x "$B/$1" |
| 23 | } |
| 24 | for name in eventfd vfioirq irqlayout irqcheck irqnovfio; do compile "$name"; done |
| 25 | "${CC:-gcc}" -std=c11 -O2 -Wall -Wextra -Werror seed/host/irq-oracle.c -o "$B/oracle" |
| 26 | "$B/oracle" --layout > "$B/layout.txt" |
| 27 | cat "$B/layout.txt" |
| 28 | "$B/oracle" --bytes > "$B/gcc-layout.bin" |
| 29 | "$B/irqlayout" > "$B/omega-layout.bin" |
| 30 | cmp "$B/gcc-layout.bin" "$B/omega-layout.bin" |
| 31 | printf 'PASS GCC/Omega IRQ wire-layout differential\n' |
| 32 | "$B/eventfd" |
| 33 | "$B/eventfd" 2 |
| 34 | printf 'PASS real eventfd initial/read/write/drain/poll/close and table capacity\n' |
| 35 | (cd "$B"; ./irqcheck "$OMC") |
| 36 | "$B/oracle" "$B/vfioirq" 0 0 0 |
| 37 | "$B/oracle" "$B/vfioirq" 0 0 1 |
| 38 | "$B/oracle" "$B/vfioirq" '?' 0 0 |
| 39 | for mode in 1 2 3 4 5 6 7 8 9 ':' ';' '<' '=' '>'; do |
| 40 | "$B/oracle" "$B/vfioirq" "$mode" 103 0 |
| 41 | done |
| 42 | expectrc 103 "$B/irqnovfio" |
| 43 | QEMU=${QEMU_AARCH64:-qemu-aarch64} |
| 44 | "$B/oracle" "$B/vfioirq" '@' 0 0 |
| 45 | "$B/oracle" "$B/vfioirq" A 103 0 |
| 46 | command -v "$QEMU" >/dev/null || { printf 'NOT_RUN QEMU VFIO-less negative: missing qemu-aarch64\n' >&2; exit 3; } |
| 47 | expectrc 103 "$QEMU" "$B/irqnovfio" |
| 48 | "$QEMU" "$B/eventfd" |
| 49 | printf 'PASS QEMU user-mode VFIO-less refusal and real translated eventfd behavior (not system/hardware qualification)\n' |
| 50 | python3 seed/host/irq-mutants.py "$OMC" "$B/oracle" "$B/mutants" |
| 51 | sha256sum "$OMC" seed/omc/omc.om "$B/eventfd" "$B/vfioirq" "$B/irqlayout" |
| 52 | printf 'PASS typed VFIO IRQ/eventfd host qualification; real device IRQ delivery NOT_RUN\n' |