Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-gpu-driver/blob/main/tests/chan_diff.sh # omega-gpu-driver aien-dev/omega-gpu-driver Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-gpu-driver / tests / chan_diff.sh` 66 lines ยท 3098 bytes Raw Blame History 1 #!/bin/sh 2 # chan_diff.sh: builds the .om channel trace (chan/gmmu.om + chan/mem.om + chan/chan.om + chan/sim.om + 3 # tests/chan_trace.om) and the C reference trace (aienux PR #441 tests/gpu_chan_trace.c + gpu/gmmu.c + 4 # gpu/gpu_mem.c + gpu/gpu_chan.c + gpu/gpu_sim.c, compiled fresh into a temp dir as a test-only referee) 5 # and requires byte-identical stdout. Host only: the trace runs on the simulator (mmmode 0). 6 # Env: AIENUX (aienux checkout), OMC (pinned omc), GMMU_OM / MEM_OM / CHAN_OM / GSIM_OM (unit files to 7 # test; mutants use these), CHAN_REF (a C trace already produced by this script's referee build, so a 8 # mutant run skips the rebuild; the file must be non-empty). 9 set -u 10 here=$(cd "$(dirname "$0")/.." && pwd) 11 AIENUX=${AIENUX:-/home/drakestapleton/work/OwnDriver/aienux} 12 OMC=${OMC:-$here/build/omc} 13 GMMU_OM=${GMMU_OM:-$here/chan/gmmu.om} 14 MEM_OM=${MEM_OM:-$here/chan/mem.om} 15 CHAN_OM=${CHAN_OM:-$here/chan/chan.om} 16 GSIM_OM=${GSIM_OM:-$here/chan/sim.om} 17 CHAN_REF=${CHAN_REF:-} 18 OMC_SHA=$(sed -n 's/^OMC_SHA256=//p' "$here/tools/omc.pin") 19 run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; } 20 21 got=$(sha256sum "$OMC" | cut -d' ' -f1) 22 if [ "$got" != "$OMC_SHA" ]; then 23 echo "chan_diff: FAIL omc sha256 $got, pinned $OMC_SHA"; exit 2 24 fi 25 # The host trace must stay on the simulator: mode 0 only, no device words in the test driver, 26 # while the BAR0 (mode 1) branch stays present in the register seam. 27 if grep -n 'mmmode [0-9]* [1-9]\|mmbar\|vfio\|mapnew\|/dev/\|/sys/' "$here/tests/chan_trace.om"; then 28 echo "chan_diff: FAIL test driver leaves simulator mode or names a device"; exit 2 29 fi 30 for w in 'ret mapget get mmbar 0 off 4' 'r = mapset get mmbar 0 off 4 v'; do 31 if ! grep -qxF "$w" "$GMMU_OM"; then 32 echo "chan_diff: FAIL BAR0 branch line missing from chan/gmmu.om: $w"; exit 2 33 fi 34 done 35 36 t=$(mktemp -d /tmp/chan_diff.XXXXXX) || exit 2 37 trap 'rm -rf "$t"' EXIT 38 if [ -n "$CHAN_REF" ]; then 39 [ -s "$CHAN_REF" ] || { echo "chan_diff: FAIL CHAN_REF $CHAN_REF missing or empty"; exit 2; } 40 cp "$CHAN_REF" "$t/c.txt" || exit 2 41 else 42 k=$AIENUX/native/kernel 43 if ! run cc -std=c11 -O1 -Wall -Werror -I"$k/gpu" -o "$t/ctrace" \ 44 "$k/tests/gpu_chan_trace.c" "$k/gpu/gmmu.c" "$k/gpu/gpu_mem.c" "$k/gpu/gpu_chan.c" "$k/gpu/gpu_sim.c"; then 45 echo "chan_diff: FAIL C reference build"; exit 2 46 fi 47 run "$t/ctrace" > "$t/c.txt" || { echo "chan_diff: FAIL C reference run"; exit 2; } 48 fi 49 if ! cat "$here/chan/dma.om" "$GMMU_OM" "$MEM_OM" "$CHAN_OM" "$GSIM_OM" "$here/tests/chan_trace.om" | run "$OMC" > "$t/omtrace"; then 50 echo "chan_diff: FAIL omc build"; exit 3 51 fi 52 chmod +x "$t/omtrace" 53 run "$t/omtrace" > "$t/om.txt" 54 rc=$? 55 if [ "$rc" -ne 0 ]; then 56 echo "chan_diff: FAIL om trace exit $rc"; exit 1 57 fi 58 n=$(wc -l < "$t/c.txt") 59 if [ "$n" -eq 0 ]; then 60 echo "chan_diff: FAIL empty C trace"; exit 2 61 fi 62 if ! cmp -s "$t/c.txt" "$t/om.txt"; then 63 echo "chan_diff: FAIL traces differ ($(diff "$t/c.txt" "$t/om.txt" | grep -c '^[<>]') differing lines; C $n lines, om $(wc -l < "$t/om.txt"))" 64 exit 1 65 fi 66 echo "chan_diff: PASS ($n lines identical, .om vs C reference)"