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/seq_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 / seq_diff.sh` 95 lines ยท 5149 bytes Raw Blame History 1 #!/bin/sh 2 # seq_diff.sh: builds the .om GSP CPU sequencer (gsp/seq.om, run by tests/seq_trace.om on gsp/sim.om in mode 0) and 3 # the C reference (aienux PR #441 native/kernel/gpu/gsp_seq.c + gsp_sim.c, driven by tests/seq_ref.c, compiled fresh 4 # into a temp dir as a test-only referee), runs every case of tests/seq_cases.txt through both and requires 5 # byte-identical traces (rc, why, delays, core calls, save[8], register log, violations) and the same exit code. 6 # Also: malformed case input stops both the same way; a corrupted buffer is refused; the .om-only refusals 7 # (nwords cap, poll budget cap) match fixed expected lines. Host only: no device is opened. 8 # Env: AIENUX (aienux checkout), OMC (pinned omc), SEQ_OM (library file to test; mutants use this). 9 set -u 10 here=$(cd "$(dirname "$0")/.." && pwd) 11 AIENUX=${AIENUX:-/home/drakestapleton/work/OwnDriver/aienux} 12 OMC=${OMC:-$here/build/omc} 13 SEQ_OM=${SEQ_OM:-$here/gsp/seq.om} 14 OMC_SHA=$(sed -n 's/^OMC_SHA256=//p' "$here/tools/omc.pin") 15 run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; } 16 17 got=$(sha256sum "$OMC" | cut -d' ' -f1) 18 if [ "$got" != "$OMC_SHA" ]; then 19 echo "seq_diff: FAIL omc sha256 $got, pinned $OMC_SHA"; exit 2 20 fi 21 if grep -n 'put gspmode [0-9]* [1-9]\|gspbar\|vfio\|mapnew\|/dev/\|/sys/' "$here/tests/seq_trace.om" "$SEQ_OM"; then 22 echo "seq_diff: FAIL sequencer or test driver names a device"; exit 2 23 fi 24 25 t=$(mktemp -d /tmp/seq_diff.XXXXXX) || exit 2 26 trap 'rm -rf "$t"' EXIT 27 k=$AIENUX/native/kernel 28 if ! run cc -std=c11 -O1 -Wall -Werror -I"$k/gpu" -o "$t/ref" "$here/tests/seq_ref.c" "$k/gpu/gsp_seq.c" "$k/gpu/gsp_sim.c"; then 29 echo "seq_diff: FAIL C reference build"; exit 2 30 fi 31 if ! cat "$here/gsp/mmio.om" "$here/gsp/sim.om" "$SEQ_OM" "$here/tests/seq_trace.om" | run "$OMC" > "$t/om"; then 32 echo "seq_diff: FAIL omc build"; exit 3 33 fi 34 chmod +x "$t/om" 35 36 fail=0 37 # both tools on one input: stdout then the exit code 38 both() { # infile tag 39 run "$t/ref" < "$1" > "$t/c.$2"; echo "exit $?" >> "$t/c.$2" 40 run "$t/om" < "$1" > "$t/o.$2"; echo "exit $?" >> "$t/o.$2" 41 if ! cmp -s "$t/c.$2" "$t/o.$2"; then 42 echo "seq_diff: $2 differs (C left, .om right)"; diff "$t/c.$2" "$t/o.$2" | head -12; fail=1 43 fi 44 } 45 cases=$here/tests/seq_cases.txt 46 both "$cases" cases 47 want=$(grep -vc '^#' "$cases") 48 n=$(grep -c '^== ' "$t/o.cases") 49 if [ "$n" -ne "$want" ] || [ "$(tail -n 1 "$t/o.cases")" != "exit 0" ]; then 50 echo "seq_diff: ran $n of $want cases"; tail -n 1 "$t/o.cases"; fail=1 51 fi 52 # every refusal the C has must be among the cases 53 for w in 'empty buffer' 'cmdIndex not inside the buffer' 'unknown opcode' 'opcode overruns cmdIndex' 'poll timed out' \ 54 'save index out of range' 'core opcode with no core callback' 'core opcode failed'; do 55 if ! grep -q " rc=-1 why=$w " "$t/o.cases"; then echo "seq_diff: no case refuses with '$w'"; fail=1; fi 56 done 57 # malformed case input: both stop with exit 2 after the same output 58 printf 'write 0 4 0 0 4 3 3 0 `8653504` 2748\nbad 0 4 x\n' > "$t/bad1" 59 printf 'write 0 4 0 0 4 3 3 0 `8653504` 2748\nshort 0 4 0 0 4 3 3 0 `8653504`\n' > "$t/bad2" 60 printf 'big 0 4 0 0 4 3 3 0 `8653504` `4294967296`\n' > "$t/bad3" 61 for b in bad1 bad2 bad3; do 62 both "$t/$b" "$b" 63 if [ "$(tail -n 1 "$t/o.$b")" != "exit 2" ]; then echo "seq_diff: $b not refused"; fail=1; fi 64 done 65 # negative control: the modify case with its opcode corrupted (1 -> 9) is refused by both, nothing written after it 66 grep '^modify ' "$cases" | sed 's/ 255 1 `8653504` / 255 9 `8653504` /' > "$t/corrupt" 67 both "$t/corrupt" corrupt 68 if ! grep -qx '== modify rc=-1 why=unknown opcode delays=0/0 core=0 ops= save=0,0,0,0,0,0,0,0, nlog=1 violations=0' "$t/o.corrupt"; then 69 echo "seq_diff: negative control not refused"; cat "$t/o.corrupt"; fail=1 70 fi 71 # the comparison itself can go red: a changed modify mask (10 -> 255) on the C side must not match the .om trace 72 grep '^modify ' "$cases" > "$t/m.ok" 73 sed 's/ `8653504` 10 5$/ `8653504` 255 5/' "$t/m.ok" > "$t/m.bad" 74 run "$t/ref" < "$t/m.bad" > "$t/c.mbad" 75 run "$t/om" < "$t/m.ok" > "$t/o.mok" 76 if ! grep -q '^modify .* 255 5$' "$t/m.bad" || cmp -s "$t/c.mbad" "$t/o.mok"; then echo "seq_diff: changed mask not detected"; fail=1; fi 77 # .om-only refusals (the C has no such limits); cmdIndex is still checked first, as in the C 78 cat > "$t/only" <<'EOF' 79 cap 0 4 0 0 16385 0 0 80 capidx 0 4 0 0 16385 16385 0 81 bigbud 0 999999 0 0 2 1 1 3 82 EOF 83 run "$t/om" < "$t/only" > "$t/only.got" 84 cat > "$t/only.want" <<'EOF' 85 == cap rc=-1 why=nwords over 16384 delays=0/0 core=0 ops= save=0,0,0,0,0,0,0,0, nlog=0 violations=0 86 == capidx rc=-1 why=cmdIndex not inside the buffer delays=0/0 core=0 ops= save=0,0,0,0,0,0,0,0, nlog=0 violations=0 87 == bigbud rc=-1 why=poll budget over 999998 delays=0/0 core=0 ops= save=0,0,0,0,0,0,0,0, nlog=0 violations=0 88 EOF 89 if ! cmp -s "$t/only.want" "$t/only.got"; then 90 echo "seq_diff: .om-only refusals differ"; diff "$t/only.want" "$t/only.got"; fail=1 91 fi 92 if [ "$fail" -ne 0 ]; then 93 echo "seq_diff: FAIL"; exit 1 94 fi 95 echo "seq_diff: PASS ($n cases identical trace+exit, 8 C refusals covered, 3 malformed inputs stop alike, negative control refused, changed mask detected, 3 .om-only refusals; .om vs C reference)"