Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/coder/mutants.sh # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / coder / mutants.sh` 65 lines · 3543 bytes Raw Blame History 1 #!/bin/bash 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Break the ERC1 tool on purpose, once per check, and require that the test suite then FAILS. 4 # bash tests/coder/mutants.sh OMC [WORKDIR] 5 # Each mutant is a one-line sed edit of om/coder/erc.om (a copy; the repository file is not touched). 6 # The baseline must PASS first. Ends "ERC1 MUTANTS PASS n of n caught" (exit 0) or "... FAIL ..." (exit 1). 7 export LC_ALL=C 8 HERE=$(cd "$(dirname "$0")" && pwd) 9 ROOT=$(cd "$HERE/../.." && pwd) 10 OMC=${1:?usage: mutants.sh OMC [WORKDIR]} 11 W=${2:-$(mktemp -d)} 12 mkdir -p "$W" 13 SRC=$ROOT/om/coder/erc.om 14 15 # Every suite run has a wall-clock limit (MUTANT_TIMEOUT seconds): a mutant that makes the decoder loop is 16 # reported as MUTANT-HUNG and counts as not caught. MUTANT_FUZZ_N sets the random-damage count per run. 17 TMO=${MUTANT_TIMEOUT:-900} 18 QUICK=1 FUZZ_N=${MUTANT_FUZZ_N:-300} timeout "$TMO" bash "$HERE/synthetic.sh" "$OMC" "$W/base" > "$W/base.log" 2>&1 || { echo "ERC1 MUTANTS FAIL: the unmodified tool does not pass (or ran over ${TMO}s)"; tail -5 "$W/base.log"; exit 1; } 19 echo "baseline: $(tail -1 "$W/base.log")" 20 21 # name|sed expression 22 MUTANTS=( 23 'final-state check removed|s/^ret 12$/ret 0/' 24 'leftover-bytes check removed|s/^ret 11$/ret 0/' 25 'stream-exhausted check removed|s/^ret 10$/ret 0/' 26 'state range checks removed|s/^ret 9$/ret 0/' 27 'header CRC compare removed|s/^ret 6$/ret 0/' 28 'frequency-sum check removed|s/^ret 7$/ret 0/' 29 'offset checks removed|s/^ret 8$/ret 0/' 30 'total-length check removed|s/^ret 5$/ret 0/' 31 'row CRC-16 compare removed|s/^if ne crc16img a b ld16 add get CF 12 mul 2 r$/if ne a a/' 32 'matrix CRC-32 compare removed|s/^if ne xor crc `4294967295` get CF 4$/if ne crc crc/' 33 'encoder renormalisation bound wrong|s/^xm = shl f 17$/xm = shl f 16/' 34 'decoder drops the slot bias|s/^x = add mul get FR and en 255 shr x 14 shr en 8$/x = add mul get FR and en 255 shr x 14 0/' 35 'encoder uses another cumulative frequency|s/^x = add add shl div x f 14 rem x f get CM s$/x = add add shl div x f 14 rem x f get CM 0/' 36 'CRC-16 polynomial changed|s/xor shl h 1 4129 65535/xor shl h 1 4128 65535/' 37 'CRC-32 polynomial changed|s/`3988292384`/`3988292385`/' 38 'header CRC covers one byte less in the encoder|0,/^st32 hc xor crcimg `4294967295` 0 hc `4294967295`$/s//st32 hc xor crcimg `4294967295` 1 hc `4294967295`/' 39 ) 40 caught=0 41 n=${#MUTANTS[@]} 42 for m in "${MUTANTS[@]}"; do 43 name=${m%%|*}; expr=${m#*|} 44 mkdir -p "$W/m" 45 sed -e "$expr" "$SRC" > "$W/m/erc.om" 46 if cmp -s "$SRC" "$W/m/erc.om"; then echo "MUTANT-INVALID $name: the edit changed nothing"; continue; fi 47 # The largest ordinary fixture is below 2 MiB. Contain deliberately broken 48 # implementations and stop after the first recorded test assertion fails. 49 ERC_SRC="$W/m/erc.om" ERC_MUTANT_FIRST_FAILURE=1 QUICK=1 FUZZ_N=${MUTANT_FUZZ_N:-300} \ 50 timeout "$TMO" prlimit --fsize=`33554432`:`33554432` --core=0:0 -- \ 51 bash "$HERE/synthetic.sh" "$OMC" "$W/m" > "$W/m.log" 2>&1 52 rc=$? 53 if [ "$rc" = 42 ] && grep -q '^ERC1 MUTATION WITNESS:' "$W/m.log" && 54 ! grep -Eq 'File size limit exceeded|Killed|Segmentation fault' "$W/m.log"; then 55 echo "MUTANT-CAUGHT $name: $(tail -1 "$W/m.log")" 56 caught=$((caught + 1)) 57 elif [ "$rc" = 0 ]; then 58 echo "MUTANT-SURVIVED $name" 59 else 60 echo "MUTANT-INCONCLUSIVE $name: exit $rc without an ordinary assertion witness" 61 fi 62 done 63 if [ "$caught" = "$n" ]; then echo "ERC1 MUTANTS PASS $caught of $n caught"; exit 0; fi 64 echo "ERC1 MUTANTS FAIL $caught of $n caught" 65 exit 1