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/pm_gate.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 / pm_gate.sh` 34 lines ยท 1940 bytes Raw Blame History 1 #!/bin/sh 2 # pm_gate.sh: runtime-PM planted fault (tests/pm_gate.om) on the real gsp/mmio.om, then two mutants that 3 # must go red: the gate removed, and the gate accepting any runtime_status text. Host only: the device 4 # file is a temp file, never /sys. Exit 0 PASS, 1 FAIL, 2 setup. 5 set -u 6 here=$(cd "$(dirname "$0")/.." && pwd) 7 OMC=${OMC:-$here/build/omc} 8 OMC_SHA=$(sed -n 's/^OMC_SHA256=//p' "$here/tools/omc.pin") 9 run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; } 10 [ "$(sha256sum "$OMC" | cut -d' ' -f1)" = "$OMC_SHA" ] || { echo "pm_gate: FAIL omc pin"; exit 2; } 11 t=$(mktemp -d /tmp/pm_gate.XXXXXX) || exit 2 12 trap 'rm -rf "$t"' EXIT 13 printf 'suspended\n' > "$t/sus" 14 printf 'active\n' > "$t/act" 15 printf 'activa\n' > "$t/near" 16 # build SRC -> run -> exit code 17 try() { 18 cat "$1" "$here/gsp/sim.om" "$here/tests/pm_gate.om" | run "$OMC" > "$t/p" 2>"$t/err" || return 200 19 chmod +x "$t/p" 20 run "$t/p" "$t/sus" "$t/act" "$t/near" >/dev/null 2>&1 21 } 22 try "$here/gsp/mmio.om"; rc=$? 23 [ "$rc" -eq 0 ] || { echo "pm_gate: FAIL baseline exit $rc"; exit 1; } 24 # mutant 1: the gate call removed (3 lines: if not gsppm / ret gspfail EPM / end) 25 awk '$0=="if not gsppm"{s=3} s>0{s--; next} {print}' "$here/gsp/mmio.om" > "$t/m1.om" 26 cmp -s "$here/gsp/mmio.om" "$t/m1.om" && { echo "pm_gate: FAIL mutant 1 did not apply"; exit 2; } 27 try "$t/m1.om"; m1=$? 28 # mutant 2: the reader stops comparing bytes 29 awk '$0=="if ne get gpmb i get pmact i"{print "if false"; next} {print}' "$here/gsp/mmio.om" > "$t/m2.om" 30 cmp -s "$here/gsp/mmio.om" "$t/m2.om" && { echo "pm_gate: FAIL mutant 2 did not apply"; exit 2; } 31 try "$t/m2.om"; m2=$? 32 [ "$m1" -ne 0 ] && [ "$m1" -ne 200 ] || { echo "pm_gate: FAIL mutant 1 (gate removed) exit $m1"; exit 1; } 33 [ "$m2" -ne 0 ] && [ "$m2" -ne 200 ] || { echo "pm_gate: FAIL mutant 2 (any text accepted) exit $m2"; exit 1; } 34 echo "pm_gate: PASS (5 cases; mutants red: gate removed exit $m1, any text accepted exit $m2)"