omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / mutants-complete.sh
| 1 | #!/bin/sh |
| 2 | # tests/mutants-complete.sh: single-line mutants of chan/complete.om. |
| 3 | # Each mutant must compile and fail tests/complete_diff.sh (killed). |
| 4 | set -u |
| 5 | here=$(cd "$(dirname "$0")/.." && pwd) |
| 6 | t=$(mktemp -d /tmp/mutants-complete.XXXXXX) || exit 2 |
| 7 | trap 'rm -rf "$t"' EXIT |
| 8 | run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; } |
| 9 | |
| 10 | if ! sh "$here/tests/complete_diff.sh" > "$t/base.log" 2>&1; then |
| 11 | cat "$t/base.log"; echo "mutants-complete: FAIL baseline is not green"; exit 2 |
| 12 | fi |
| 13 | |
| 14 | cat <<'EOF' > "$t/list" |
| 15 | header method offset mutated|const CMSEMM uint 23|const CMSEMM uint 24 |
| 16 | release execute operation mutated to acquire|put cmwds 5 1|put cmwds 5 0 |
| 17 | address alignment check bypassed|if ne and va 3 0|if false |
| 18 | progress check operator flipped|if gt prog inflight|if ge prog inflight |
| 19 | stale observation accepted as pending|ret CMESTALE|ret 0 |
| 20 | capability check for DMA window bypassed|if or lt get mmwst 0 MMWDMA ge get mmwst 0 MMWQUAR|if false |
| 21 | quarantine on timeout skipped|r = gmquar b|r = GMOK |
| 22 | cmsub overcapacity check bypassed|if gt count sub sub ent 1 inflight|if false |
| 23 | EOF |
| 24 | |
| 25 | killed=0; survived=0; invalid=0; total=0 |
| 26 | while IFS='|' read -r desc orig mut; do |
| 27 | total=$((total + 1)) |
| 28 | mfile="$t/mut_$total.om" |
| 29 | if ! grep -qF "$orig" "$here/chan/complete.om"; then |
| 30 | echo "mutants-complete: INVALID pattern '$orig'"; invalid=$((invalid + 1)); continue |
| 31 | fi |
| 32 | sed "s/$orig/$mut/" "$here/chan/complete.om" > "$mfile" |
| 33 | if cmp -s "$mfile" "$here/chan/complete.om"; then |
| 34 | echo "mutants-complete: INVALID identical mutation '$desc'"; invalid=$((invalid + 1)); continue |
| 35 | fi |
| 36 | if COMPLETE_OM="$mfile" sh "$here/tests/complete_diff.sh" > "$t/run.log" 2>&1; then |
| 37 | echo "mutants-complete: SURVIVED mutant '$desc'"; survived=$((survived + 1)) |
| 38 | else |
| 39 | rc=$? |
| 40 | if [ "$rc" -eq 1 ]; then |
| 41 | echo "mutants-complete: KILLED mutant '$desc'" |
| 42 | killed=$((killed + 1)) |
| 43 | else |
| 44 | echo "mutants-complete: INVALID mutant '$desc' exit $rc" |
| 45 | cat "$t/run.log" |
| 46 | invalid=$((invalid + 1)) |
| 47 | fi |
| 48 | fi |
| 49 | done < "$t/list" |
| 50 | |
| 51 | echo "mutants-complete: $total total, $killed killed, $survived survived, $invalid invalid" |
| 52 | if [ "$survived" -gt 0 ] || [ "$invalid" -gt 0 ]; then |
| 53 | exit 1 |
| 54 | fi |
| 55 | echo "mutants-complete: PASS all mutants killed; hardware NOT_RUN" |