omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / mutants-rpc.sh
| 1 | #!/bin/sh |
| 2 | # Mutation controls are test-only copies; no production source or historical receipt is rewritten. |
| 3 | set -eu |
| 4 | R=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) |
| 5 | t=$(mktemp -d /tmp/rpc-mutants.XXXXXX) |
| 6 | trap 'rm -rf "$t"' EXIT HUP INT TERM |
| 7 | sh "$R/tests/rpc_diff.sh" |
| 8 | mutate() { |
| 9 | name=$1; source=$2; pattern=$3; replacement=$4 |
| 10 | sed "s|$pattern|$replacement|" "$source" > "$t/$name.om" |
| 11 | if cmp -s "$source" "$t/$name.om"; then echo "mutant $name INVALID no change"; exit 2; fi |
| 12 | if [ "$source" = "$R/gsp/rpc.om" ]; then |
| 13 | if RPC_OM="$t/$name.om" sh "$R/tests/rpc_diff.sh" > "$t/$name.log" 2>&1; then cat "$t/$name.log"; echo "mutant $name SURVIVED"; exit 1; fi |
| 14 | else |
| 15 | if BOOT_OM="$t/$name.om" sh "$R/tests/rpc_diff.sh" > "$t/$name.log" 2>&1; then cat "$t/$name.log"; echo "mutant $name SURVIVED"; exit 1; fi |
| 16 | fi |
| 17 | # Compiler/setup refusal is not a detected behavioral mutant. |
| 18 | if ! grep -q 'rpc_diff: FAIL replay exit 101\|rpc_diff: FAIL exact frames' "$t/$name.log"; then |
| 19 | cat "$t/$name.log"; echo "mutant $name INVALID build/setup or unexpected trap"; exit 2 |
| 20 | fi |
| 21 | echo "mutant $name DETECTED" |
| 22 | } |
| 23 | mutate swaprx "$R/gsp/rpc.om" 'rd = rqget32 1 32' 'rd = rqget32 0 32' |
| 24 | mutate checksum "$R/gsp/rpc.om" 'rqput32 2 32 rqsum 2 mul div add add 80 n 7 8 8' 'rqput32 2 32 0' |
| 25 | mutate rxseq "$R/gsp/rpc.om" 'if ne rqget32 2 36 ulong get rqrx 0' 'if false' |
| 26 | mutate padding "$R/gsp/rpc.om" 'if ne rqsum 2 aligned 0' 'if false' |
| 27 | mutate version "$R/gsp/rpc.om" 'if or ne rqget32 2 48 RQVER ne rqget32 2 52 RQSIG' 'if false' |
| 28 | mutate timeout "$R/gsp/boot.om" 'ret bfail -11' 'ret 0' |
| 29 | mutate correlation "$R/gsp/boot.om" 'if not bcorrel' 'if false' |
| 30 | mutate guest "$R/gsp/boot.om" 'if ne get rqpriv 0 0' 'if false' |
| 31 | mutate seqtoken "$R/gsp/boot.om" 'if ne token get btoken 0' 'if false' |
| 32 | mutate seqgen "$R/gsp/boot.om" 'if ne gen get bgen 0' 'if false' |
| 33 | mutate handlerstatus "$R/gsp/boot.om" 'if ne get bresult 0 0' 'if false' |
| 34 | mutate pending "$R/gsp/boot.om" 'if eq get rqres 0 RQU32' 'if false' |
| 35 | mutate allocflags "$R/gsp/boot.om" 'if or ne rqget32 3 104 0 ne rqget32 3 108 0' 'if false' |
| 36 | mutate ctrlflags "$R/gsp/boot.om" 'if or ne rqget32 3 100 0 or ne rqget32 3 112 0 ne rqget32 3 116 0' 'if false' |
| 37 | mutate freeparent "$R/gsp/boot.om" 'if ne rqget32 3 84 0' 'if false' |
| 38 | mutate linkwait "$R/gsp/rpc.om" 'if eq get rqlink 0 0' 'if false' |
| 39 | mutate headerstatus "$R/gsp/boot.om" 'put bresult 0 get rqres 0' 'put bresult 0 0' |
| 40 | mutate routing "$R/gsp/rpc.om" 'if or ne rqget32 2 44 0 ne rqget32 2 76 0' 'if false' |
| 41 | mutate noncc "$R/gsp/rpc.om" 'if ne get rqtmp i 0' 'if false' |
| 42 | echo 'mutants-rpc: PASS all behavior controls detected; hardware NOT_RUN' |