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-sysinfo.sh

61 lines · 3205 bytes Raw Blame History
1#!/bin/sh
2# mutants-sysinfo.sh: single-line mutants of gsp/sysinfo.om; each must make tests/sysinfo_diff.sh go red.
3# The test driver and the C reference are never mutated. A mutant must change exactly the named line and still
4# compile; otherwise it is INVALID and the run fails.
5set -u
6here=$(cd "$(dirname "$0")/.." && pwd)
7src=$here/gsp/sysinfo.om
8diff_sh=$here/tests/sysinfo_diff.sh
9t=$(mktemp -d /tmp/mutants-sysinfo.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-sysinfo: 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'
18oorArch offset 104 -> 105|put sioff 16 104|put sioff 16 105
19capsMethodData.status offset 828 -> 832|put sioff 44 828|put sioff 44 832
20FHBBusInfo.revisionID size 1 -> 2|put sisz 34 1|put sisz 34 2
21fit check shifts 7 bits per byte|ret eq shr v mul sz 8 0|ret eq shr v mul sz 7 0
22fit check skips 4-byte fields|if lt sz 8|if lt sz 4
23three tokens accepted (k != 2 check dropped)|if ne get sipos 0 b|if gt get sipos 0 b
240X prefix not taken as hex|if or eq x 120 eq x 88|if eq x 120
25leading 0 read as decimal, not octal|base = 8|base = 10
26bytes not little endian (7-bit shift)|put siout add o b uchar and shr v mul b 8 255|put siout add o b uchar and shr v mul b 7 255
27line limit 512 -> 513|const SILINE ulong 512|const SILINE ulong 513
28comment cut on $ not #|if eq get sitxt h 35|if eq get sitxt h 36
29overflow test ignores the digit|if gt v div sub SIMAX64 d base|if gt v div SIMAX64 base
30text not cut at NUL|if eq get sitxt i 0|if eq get sitxt i 1
31name lookup matches prefixes|if eq sub i s n|if ge sub i s n
32token width 127 -> 128|while and lt p b lt n 127 bound 600|while and lt p b lt n 128 bound 600
33does-not-fit value shown to 41 chars|siwval 40|siwval 41
34lower-case hex digit value off by one|ret sub ulong c 87|ret sub ulong c 86
35leading + not skipped|if eq get sivb 0 43|if eq get sivb 0 44
36CR (13) not whitespace|ret or eq c 32 and ge c 9 le c 13|ret or eq c 32 and ge c 9 le c 12
37text limit refuses exactly 65536 bytes|if gt n SITXMAX|if ge n SITXMAX
38EOF
39
40killed=0; survived=0; invalid=0
41while IFS='|' read -r desc o1 n1 o2 n2; do
42 m=$t/sysinfo.om
43 awk -v o1="$o1" -v n1="$n1" -v o2="${o2:-}" -v n2="${n2:-}" '
44 $0 == o1 && !d1 { print n1; c1++; d1 = 1; next }
45 o2 != "" && $0 == o2 && !d2 { print n2; c2++; d2 = 1; next }
46 $0 == o1 { c1++ } o2 != "" && $0 == o2 { c2++ }
47 { print }
48 END { if (c1 != 1 || (o2 != "" && c2 != 1)) exit 1 }' "$src" > "$m"
49 if [ $? -ne 0 ] || cmp -s "$src" "$m"; then
50 echo "mutant INVALID (pattern not matched exactly once): $desc"; invalid=$((invalid + 1)); continue
51 fi
52 SYSINFO_OM=$m sh "$diff_sh" > "$t/m.log" 2>&1
53 rc=$?
54 case $rc in
55 0) echo "mutant SURVIVED: $desc"; survived=$((survived + 1)) ;;
56 1) echo "mutant killed: $desc"; killed=$((killed + 1)) ;;
57 *) echo "mutant INVALID (exit $rc: $(cat "$t/m.log")): $desc"; invalid=$((invalid + 1)) ;;
58 esac
59done < "$t/list"
60echo "mutants-sysinfo: $killed killed, $survived survived, $invalid invalid"
61[ "$survived" -eq 0 ] && [ "$invalid" -eq 0 ] && [ "$killed" -ge 10 ]