interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / qemu / test.sh

25 lines · 1701 bytes Raw Blame History
1#!/bin/sh
2# qemu/test.sh -- build w0, boot the QEMU bench (virt + SMMUv3, edu 0000:00:02.0 on vfio-pci in group 2,
3# a second edu 0000:00:03.0 left unbound), run qemu/w0.cmds and check every result.
4# Usage: sh qemu/test.sh [LOG] (KERNEL=... selects the guest kernel, see qemu/bench/run.sh)
5set -eu
6R=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
7LOG=${1:-$R/build/w0-edu.log}
8sh "$R/build.sh" >/dev/null
9sh "$R/qemu/bench/run.sh" "$R/build/w0" "$R/qemu/w0.cmds" "$LOG"
10fail=0
11# one rc per command, in order: bind+read, wrong group, unbound edu, virtio (not vfio-pci),
12# in-range extra read, read at the BAR0 size (oversized), misaligned read, usage, rebind after all
13want="0 3 4 4 0 103 103 2 0"
14got=$(tr -d '\r' < "$LOG" | sed -n 's/^\(.*[^0-9a-z_]\)\{0,1\}rc=\([0-9]*\)$/\2/p' | tr '\n' ' ' | sed 's/ $//')
15[ "$got" = "$want" ] || { echo "FAIL rc sequence: got [$got] want [$want]"; fail=1; }
16n=$(grep -c 'BOOT_0 \[0x000\] mapget 0x010000ed pread 0x010000ed' "$LOG" || true)
17[ "$n" = 5 ] || { echo "FAIL edu identity 0x010000ed via map and pread: $n of 5 runs"; fail=1; }
18n=$(grep -c 'config vendor/device \[0x00\] 0x11e81234' "$LOG" || true)
19[ "$n" = 5 ] || { echo "FAIL config vendor/device 1234:11e8: $n of 5 runs"; fail=1; }
20n=$(grep -c 'released device, group and container' "$LOG" || true)
21[ "$n" = 3 ] || { echo "FAIL release lines: $n of 3"; fail=1; }
22grep -q 'REFUSED: device iommu_group does not match GROUP' "$LOG" || { echo "FAIL wrong-group refusal"; fail=1; }
23[ "$(grep -c 'REFUSED: device is not bound to vfio-pci' "$LOG")" = 2 ] || { echo "FAIL unbound refusals"; fail=1; }
24[ $fail = 0 ] && echo "PASS w0 QEMU bench: bind, read 0x010000ed, release; 5 refusals ($LOG)"
25exit $fail