omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / boot_dma.sh
| 1 | #!/bin/sh |
| 2 | # Host only. Explicit DMA oracle replaces chan/dma.om at link time; no actual VFIO calls. |
| 3 | set -eu |
| 4 | R=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) |
| 5 | OMC=${OMC:-$R/build/omc} |
| 6 | a=$(sha256sum "$OMC"); a=${a%% *} |
| 7 | [ "$a" = bcfa582892afca8f65e551fe56867d918d86e84540c7381be8fa9ef18d0cf0f6 ] || exit 2 |
| 8 | t=$(mktemp -d /tmp/boot-dma.XXXXXX) |
| 9 | trap 'rm -rf "$t"' EXIT HUP INT TERM |
| 10 | sed 's/fn main to int/fn dmatests to int/' "$R/tests/dma_check.om" > "$t/dma.om" |
| 11 | sed 's/fn main to int/fn artests to int/' "$R/tests/arena_trace.om" > "$t/arena.om" |
| 12 | build() { |
| 13 | cat "$R/tests/dma_replay.om" "$R/chan/gmmu.om" "$R/chan/mem.om" "$R/chan/chan.om" "$R/chan/sim.om" "$t/dma.om" "$R/gsp/rpc.om" "$R/gsp/replay.om" "$R/gsp/sysinfo.om" "$R/chan/params.om" "$R/gsp/boot.om" "$R/gsp/arena.om" "$R/gsp/connect.om" "$t/arena.om" "$1" "$R/tests/boot_dma.om" > "$t/all.om" |
| 14 | if ! "$OMC" < "$t/all.om" > "$t/replay"; then echo 'boot_dma: INVALID compile'; exit 2; fi |
| 15 | chmod +x "$t/replay" |
| 16 | } |
| 17 | build "$R/gsp/owned.om" |
| 18 | "$t/replay" |
| 19 | echo 'boot_dma: PASS exact owned staging, generations, publication refusal and timeout quarantine; hardware NOT_RUN' |
| 20 | sha256sum "$t/all.om" "$t/replay" |
| 21 | sed 's/if not arstdata get mmwh 0 get arused 0/if false/' "$R/gsp/owned.om" > "$t/nocopy.om" |
| 22 | build "$t/nocopy.om" |
| 23 | if "$t/replay"; then echo 'boot_dma: SURVIVED staging'; exit 1; else rc=$?; fi |
| 24 | [ "$rc" = 1 ] || { echo 'boot_dma: INVALID staging mutant'; exit 2; } |
| 25 | sed 's/ret mmwquar gen/ret MMOK/' "$R/gsp/owned.om" > "$t/noquar.om" |
| 26 | build "$t/noquar.om" |
| 27 | if "$t/replay"; then echo 'boot_dma: SURVIVED quarantine'; exit 1; else rc=$?; fi |
| 28 | [ "$rc" = 1 ] || { echo 'boot_dma: INVALID quarantine mutant'; exit 2; } |
| 29 | echo 'boot_dma: PASS both behavior mutants detected; hardware NOT_RUN' |