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 / mutants-mmio.sh

63 lines · 3541 bytes Raw Blame History
1#!/bin/sh
2# mutants-mmio.sh: single-token (one is a two-line order swap) mutants of gsp/mmio.om; each must make
3# tests/mmio_diff.sh go red. The simulator and the test driver are never mutated. A mutant must change
4# exactly the named line(s) and still compile; otherwise it is INVALID and the run fails.
5set -u
6here=$(cd "$(dirname "$0")/.." && pwd)
7src=$here/gsp/mmio.om
8diff_sh=$here/tests/mmio_diff.sh
9t=$(mktemp -d /tmp/mutants-mmio.XXXXXX) || exit 2
10trap 'rm -rf "$t"' EXIT
11
12if ! sh "$diff_sh" > "$t/base.log" 2>&1; then
13 cat "$t/base.log"; echo "mutants-mmio: FAIL baseline is not green"; exit 2
14fi
15
16# desc|old line|new line[|old line 2|new line 2] (whole-line matches, each exactly once)
17cat > "$t/list" <<'EOF'
18QTAIL written after QHEAD (doorbell before tail)|gspwr S2QT sub mul dw 4 4|gspwr S2QH 0|gspwr S2QH 0|gspwr S2QT sub mul dw 4 4
19EMEMC AINCW bit 23 instead of 24|const AINCW ulong 16777216|const AINCW ulong 8388608
20emem dword formula 32 dwords per block|const DWBLK ulong 64|const DWBLK ulong 32
21poll budget off by one (gt for ge)|if ge n b|if gt n b
22lockdown high-half check shifts 31|if eq m1 shr pa 32|if eq m1 shr pa 31
23CPUCTL active bit 6 instead of 7|const CPUACT ulong 128|const CPUACT ulong 64
24notify writes 1 to QUEUE_HEAD|gspwr GQH 0|gspwr GQH 1
25FALCON_OS gets fmc_args_pa, not app_version|gspwr GOS get gin 2|gspwr GOS get gin 1
26mask timeout reports the lockdown code|ret gspfail EMASK|ret gspfail ELOCK
27tail not zero-padded (one byte past len)|while lt add i k ln bound 4|while le add i k ln bound 4
28target-lock mask covers the low byte|const PRIVMSK ulong 4294967040|const PRIVMSK ulong 4294967295
29lockdown bit 12 instead of 13|const LOCKDN ulong 8192|const LOCKDN ulong 4096
30dword count rounds down|dw = div add ln 3 4|dw = div add ln 0 4
31QUEUE_TAIL = padded size, not size - 4|gspwr S2QT sub mul dw 4 4|gspwr S2QT sub mul dw 4 0
32SEC2 busy value off by one|const CMDBUSY ulong 3221342974|const CMDBUSY ulong 3221342975
33FMC error reported as OK|ret gspfail EFMC|ret gspfail EOK
34step 8 waits for MAILBOX0 zero|ret or eq and h LOCKDN 0 ne m0 0|ret or eq and h LOCKDN 0 eq m0 0
35EMEM pointer check inverted|if ne and sub ememdw ea st M32 dw|if eq and sub ememdw ea st M32 dw
36channel bound refuses exactly 1024 bytes|if or eq ln 0 gt ln CHBYTES|if or eq ln 0 ge ln CHBYTES
37step 1 waits for HEAD != TAIL|ret eq hd gsprd S2QT|ret ne hd gsprd S2QT
38SEC2 timeout reads MAILBOX0 for MAILBOX1|put gout 7 gsprd S2MB1|put gout 7 gsprd S2MB0
39HWCFG2 zero counts as released|if eq h 0|if eq h 1
40EOF
41
42killed=0; survived=0; invalid=0
43while IFS='|' read -r desc o1 n1 o2 n2; do
44 m=$t/mmio.om
45 awk -v o1="$o1" -v n1="$n1" -v o2="${o2:-}" -v n2="${n2:-}" '
46 $0 == o1 && !d1 { print n1; c1++; d1 = 1; next }
47 o2 != "" && $0 == o2 && !d2 { print n2; c2++; d2 = 1; next }
48 $0 == o1 { c1++ } o2 != "" && $0 == o2 { c2++ }
49 { print }
50 END { if (c1 != 1 || (o2 != "" && c2 != 1)) exit 1 }' "$src" > "$m"
51 if [ $? -ne 0 ] || cmp -s "$src" "$m"; then
52 echo "mutant INVALID (pattern not matched exactly once): $desc"; invalid=$((invalid + 1)); continue
53 fi
54 MMIO_OM=$m sh "$diff_sh" > "$t/m.log" 2>&1
55 rc=$?
56 case $rc in
57 0) echo "mutant SURVIVED: $desc"; survived=$((survived + 1)) ;;
58 1) echo "mutant killed: $desc"; killed=$((killed + 1)) ;;
59 *) echo "mutant INVALID (exit $rc: $(cat "$t/m.log")): $desc"; invalid=$((invalid + 1)) ;;
60 esac
61done < "$t/list"
62echo "mutants-mmio: $killed killed, $survived survived, $invalid invalid"
63[ "$survived" -eq 0 ] && [ "$invalid" -eq 0 ] && [ "$killed" -ge 10 ]