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/mutants-uvm.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 / mutants-uvm.sh` 76 lines ยท 2802 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Deliberately broken variants of the UVM units. A mutant must still compile 4 # and must make the independent checker fail. A corrupted good trace must 5 # also fail the checker. Surviving a mutant, or accepting a corrupted trace, 6 # is a failed test. 7 set -eu 8 here=$(CDPATH= cd -- "$(dirname "$0")" && pwd) 9 repo=$(CDPATH= cd -- "$here/.." && pwd) 10 omc=/home/drakestapleton/work/cudastack/omega-mv/seed/out/omc 11 tmp=$(mktemp -d) 12 trap 'rm -rf "$tmp"' EXIT 13 14 echo "mutants-uvm: baseline" 15 if ! sh "$here/uvm_diff.sh" > "$tmp/base.log" 2>&1; then 16 echo "mutants-uvm: baseline is not green" >&2 17 cat "$tmp/base.log" >&2 18 exit 2 19 fi 20 cat "$tmp/base.log" 21 22 # Rebuild the good trace once so the gate negative control has bytes to flip. 23 cat "$repo/uvm/fmt.om" "$repo/uvm/pt.om" "$repo/uvm/fault.om" "$repo/tests/uvm_trace.om" > "$tmp/good.om" 24 taskset -c 10-14 nice -n 10 "$omc" < "$tmp/good.om" > "$tmp/good.bin" 25 chmod +x "$tmp/good.bin" 26 taskset -c 10-14 nice -n 10 "$tmp/good.bin" > "$tmp/good.txt" 27 python3 - "$tmp/good.txt" "$tmp/bad.txt" <<'PY' 28 import sys 29 text = open(sys.argv[1], "r", encoding="utf-8").read() 30 old = "W 0 `0000000080001014`" 31 new = "W 0 `0000000080001015`" 32 if old not in text: 33 sys.stderr.write("gate line missing\n") 34 sys.exit(1) 35 open(sys.argv[2], "w", encoding="utf-8").write(text.replace(old, new, 1)) 36 PY 37 if python3 "$here/uvm_check.py" "$tmp/bad.txt" > "$tmp/gate.log" 2>&1; then 38 echo "mutants-uvm: corrupted trace was accepted" >&2 39 exit 1 40 fi 41 echo "mutants-uvm: gate negative control killed" 42 43 run_mutant() { 44 name=$1 45 file=$2 46 old=$3 47 new=$4 48 n=$(grep -F -c "$old" "$file" || true) 49 if [ "$n" != "1" ]; then 50 echo "mutants-uvm: $name pattern found $n times" >&2 51 exit 1 52 fi 53 mkdir -p "$tmp/$name" 54 sed "s|$old|$new|" "$file" > "$tmp/$name/$(basename "$file")" 55 FMT_OM=$repo/uvm/fmt.om 56 PT_OM=$repo/uvm/pt.om 57 FAULT_OM=$repo/uvm/fault.om 58 case $(basename "$file") in 59 fmt.om) FMT_OM=$tmp/$name/fmt.om ;; 60 pt.om) PT_OM=$tmp/$name/pt.om ;; 61 fault.om) FAULT_OM=$tmp/$name/fault.om ;; 62 esac 63 if FMT_OM=$FMT_OM PT_OM=$PT_OM FAULT_OM=$FAULT_OM sh "$here/uvm_diff.sh" > "$tmp/$name.log" 2>&1; then 64 echo "mutants-uvm: $name SURVIVED" >&2 65 exit 1 66 fi 67 echo "mutants-uvm: $name killed" 68 } 69 70 run_mutant aperture "$repo/uvm/fmt.om" 'v = or ulong 1 shl and ap 3 1' 'v = or ulong 1 shl and ap 3 2' 71 run_mutant align "$repo/uvm/pt.om" 'if ne and va sub page 1 0' 'if ne ulong 0 0' 72 run_mutant overlap "$repo/uvm/pt.om" 'if or eq r UVMAPPED eq r UVCONF' 'if eq r UVCONF' 73 run_mutant replay "$repo/uvm/fault.om" 'if eq get uvfrep 0 0' 'if eq get uvfrep 0 2' 74 run_mutant alloc "$repo/uvm/pt.om" 'if uvoverlap va sz' 'if eq ulong 0 1' 75 76 echo "mutants-uvm: PASS (baseline green, gate killed, 5 mutants killed)"