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 / tests / mmio_diff.sh

54 lines · 2515 bytes Raw Blame History
1#!/bin/sh
2# mmio_diff.sh: builds the .om GSP start-up trace (gsp/mmio.om + gsp/sim.om + tests/mmio_trace.om) and the
3# C reference trace (aienux PR #441 tests/gsp_boot_trace.c + gpu/gsp_mmio.c + gpu/gsp_sim.c, compiled
4# fresh into a temp dir as a test-only referee) and requires byte-identical stdout. Host only.
5# Env: AIENUX (aienux checkout), OMC (pinned omc), MMIO_OM (driver file to test; mutants use this).
6set -u
7here=$(cd "$(dirname "$0")/.." && pwd)
8AIENUX=${AIENUX:-/home/drakestapleton/work/OwnDriver/aienux}
9OMC=${OMC:-$here/build/omc}
10MMIO_OM=${MMIO_OM:-$here/gsp/mmio.om}
11OMC_SHA=$(sed -n 's/^OMC_SHA256=//p' "$here/tools/omc.pin")
12run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; }
13
14got=$(sha256sum "$OMC" | cut -d' ' -f1)
15if [ "$got" != "$OMC_SHA" ]; then
16 echo "mmio_diff: FAIL omc sha256 $got, pinned $OMC_SHA"; exit 2
17fi
18# The host trace must stay on the simulator: mode 0 only, no device words in the test driver,
19# while the BAR0 (mode 1) branch stays present in the driver.
20if grep -n 'gspmode [0-9]* [1-9]\|gspbar\|vfio\|mapnew\|/dev/\|/sys/' "$here/tests/mmio_trace.om"; then
21 echo "mmio_diff: FAIL test driver leaves simulator mode or names a device"; exit 2
22fi
23for w in 'ret mapget get gspbar 0 off 4' 'r = mapset get gspbar 0 off 4 v' 'r = sleepns get gsppns 0'; do
24 if ! grep -qxF "$w" "$here/gsp/mmio.om"; then
25 echo "mmio_diff: FAIL BAR0 branch line missing from gsp/mmio.om: $w"; exit 2
26 fi
27done
28
29t=$(mktemp -d /tmp/mmio_diff.XXXXXX) || exit 2
30trap 'rm -rf "$t"' EXIT
31k=$AIENUX/native/kernel
32if ! run cc -std=c11 -O1 -Wall -Werror -I"$k/gpu" -o "$t/ctrace" \
33 "$k/tests/gsp_boot_trace.c" "$k/gpu/gsp_mmio.c" "$k/gpu/gsp_sim.c"; then
34 echo "mmio_diff: FAIL C reference build"; exit 2
35fi
36run "$t/ctrace" > "$t/c.txt" || { echo "mmio_diff: FAIL C reference run"; exit 2; }
37if ! cat "$MMIO_OM" "$here/gsp/sim.om" "$here/tests/mmio_trace.om" | run "$OMC" > "$t/omtrace"; then
38 echo "mmio_diff: FAIL omc build"; exit 3
39fi
40chmod +x "$t/omtrace"
41run "$t/omtrace" > "$t/om.txt"
42rc=$?
43if [ "$rc" -ne 0 ]; then
44 echo "mmio_diff: FAIL om trace exit $rc"; exit 1
45fi
46n=$(wc -l < "$t/c.txt")
47if [ "$n" -eq 0 ]; then
48 echo "mmio_diff: FAIL empty C trace"; exit 2
49fi
50if ! cmp -s "$t/c.txt" "$t/om.txt"; then
51 echo "mmio_diff: FAIL traces differ ($(diff "$t/c.txt" "$t/om.txt" | grep -c '^[<>]') differing lines; C $n lines, om $(wc -l < "$t/om.txt"))"
52 exit 1
53fi
54echo "mmio_diff: PASS ($n lines identical, $(grep -c '^==' "$t/c.txt") scenarios, .om vs C reference)"