omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / arena_large.sh
| 1 | #!/bin/sh |
| 2 | # Host-only on AArch64. The simulator uses an anonymous CPU mapping. |
| 3 | set -eu |
| 4 | r=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) |
| 5 | fw=${1:?usage: arena_large.sh FIRMWARE VERIFIED_GB20B_PACKAGE} |
| 6 | package=${2:?missing GB20B package from fwprep} |
| 7 | compiler=${OMC:-$r/build/irq-omc} |
| 8 | pin=$(sed -n 's/^OMC_SHA256=//p' "$r/tools/irq-omc.pin") |
| 9 | printf '%s %s\n' "$pin" "$compiler" | sha256sum -c - |
| 10 | tmp=$(mktemp -d) |
| 11 | trap 'rm -rf "$tmp"' EXIT HUP INT TERM |
| 12 | ( |
| 13 | cd "$r" |
| 14 | test "$(tail -1 tools/ogd.units)" = ogd.om |
| 15 | sed '$d' tools/ogd.units | xargs cat |
| 16 | cat tests/arena_large.om |
| 17 | ) > "$tmp/large.om" |
| 18 | "$compiler" < "$tmp/large.om" > "$tmp/large" |
| 19 | chmod +x "$tmp/large" |
| 20 | python3 "$r/tests/arena_large.py" "$tmp/large" "$fw" "$package" |
| 21 | sha256sum "$tmp/large.om" "$tmp/large" |
| 22 | orig='ret arbyte get aroword arword o o' |
| 23 | test "$(grep -Fxc "$orig" "$tmp/large.om")" -eq 1 |
| 24 | sed "s/^$orig\$/ret uchar xor arbyte get aroword arword o o 1/" "$tmp/large.om" > "$tmp/mut.om" |
| 25 | "$compiler" < "$tmp/mut.om" > "$tmp/mut" |
| 26 | chmod +x "$tmp/mut" |
| 27 | if python3 "$r/tests/arena_large.py" "$tmp/mut" "$fw" "$package" > "$tmp/mut.log" 2>&1; then |
| 28 | echo 'FAIL high-byte copy mutant survived'; exit 1 |
| 29 | else |
| 30 | rc=$? |
| 31 | fi |
| 32 | test "$rc" = 1 |
| 33 | grep -Fxq 'AssertionError: firmware bytes changed' "$tmp/mut.log" |
| 34 | echo 'PASS compiled high-byte copy mutant ran and changed the firmware bytes' |