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

58 lines · 2763 bytes Raw Blame History
1#!/bin/sh
2# tests/mutants-rmchan.sh: single-line mutants of chan/rmchan.om.
3# Each mutant must compile and fail tests/rmchan_diff.sh (killed).
4set -u
5here=$(cd "$(dirname "$0")/.." && pwd)
6t=$(mktemp -d /tmp/mutants-rmchan.XXXXXX) || exit 2
7trap 'rm -rf "$t"' EXIT
8run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; }
9
10if ! sh "$here/tests/rmchan_diff.sh" > "$t/base.log" 2>&1; then
11 cat "$t/base.log"; echo "mutants-rmchan: FAIL baseline is not green"; exit 2
12fi
13
14cat <<'EOF' > "$t/list"
15schedule enable command mutated to disable|r = pasched 1 0 0|r = pasched 0 0 0
16schedule disable command mutated to enable|r = pasched 0 0 0|r = pasched 1 0 0
17TSG allocation class mutated|r = brmalloc get rmhcli 0 get rmhdev 0 get rmhtsg 0 PACTSG b|r = brmalloc get rmhcli 0 get rmhdev 0 get rmhtsg 0 PACVAS b
18channel allocation parent mutated|r = brmalloc get rmhcli 0 get rmhdev 0 get rmhchan 0 PACGPF b|r = brmalloc get rmhcli 0 get rmhtsg 0 get rmhchan 0 PACGPF b
19free sequence inverted|r = brmfree get rmhcli 0 get rmhctx 0 b|r = brmfree get rmhcli 0 get rmhtsg 0 b
20rebinding retained RM slot permitted|if or ne get rmst 0 RMSIDLE ne get rmepoch 0 0|if false
21RM free before semaphore drain permitted|if ne st RMSDRND|if false
22publication active state check bypassed|if ne get rmst 0 RMSACTV|if false
23submission stale release sequence accepted|if ne uint mmrd32 add va mul i 4 get cmwds i|if false
24schedule ACK leaves channel only prepared|put chopen get rmslot 0 1|note no activation
25RM bind accepts a channel that is not prepared|if or ne get chopen c 2 ne get chepoch c gen|if ne get chepoch c gen
26EOF
27
28killed=0; survived=0; invalid=0; total=0
29while IFS='|' read -r desc orig mut; do
30 total=$((total + 1))
31 mfile="$t/mut_$total.om"
32 if ! grep -qF "$orig" "$here/chan/rmchan.om"; then
33 echo "mutants-rmchan: INVALID pattern '$orig'"; invalid=$((invalid + 1)); continue
34 fi
35 sed "s/$orig/$mut/" "$here/chan/rmchan.om" > "$mfile"
36 if cmp -s "$mfile" "$here/chan/rmchan.om"; then
37 echo "mutants-rmchan: INVALID identical mutation '$desc'"; invalid=$((invalid + 1)); continue
38 fi
39 if RMCHAN_OM="$mfile" sh "$here/tests/rmchan_diff.sh" > "$t/run.log" 2>&1; then
40 echo "mutants-rmchan: SURVIVED mutant '$desc'"; survived=$((survived + 1))
41 else
42 rc=$?
43 if [ "$rc" -eq 1 ]; then
44 echo "mutants-rmchan: KILLED mutant '$desc'"
45 killed=$((killed + 1))
46 else
47 echo "mutants-rmchan: INVALID mutant '$desc' exit $rc"
48 cat "$t/run.log"
49 invalid=$((invalid + 1))
50 fi
51 fi
52done < "$t/list"
53
54echo "mutants-rmchan: $total total, $killed killed, $survived survived, $invalid invalid"
55if [ "$survived" -gt 0 ] || [ "$invalid" -gt 0 ]; then
56 exit 1
57fi
58echo "mutants-rmchan: PASS all mutants killed; hardware NOT_RUN"