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/mutation_runner_json_test.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 / mutation_runner_json_test.sh` 49 lines · 2361 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Regression: tools/mutation_runner.sh must write a receipt that parses as JSON 6 # and round-trips every string losslessly, including quotes, backslashes, tabs, 7 # control bytes and a multi-line build-failure note. Before the fix the guards 8 # text was inserted raw and the note had quotes/backslashes deleted. 9 set -u 10 here=$(cd "$(dirname "$0")/.." && pwd) 11 t=$(mktemp -d "${TMPDIR:-/tmp}/mrjson.XXXXXX") || exit 1 12 trap 'rm -rf "$t"' EXIT INT TERM 13 mkdir -p "$t/src" 14 printf 'value 1\n' > "$t/src/a.txt" 15 tab=$(printf '\t'); esc=$(printf '\033'); bel=$(printf '\007') 16 guards="checks \"q >= 1\" and back\\slash${tab}tab ${esc}[esc ${bel}bel" 17 printf '%s\n' "M_KILL~a.txt~s/value 1/value 2/~$guards" "M_BUILD~a.txt~s/value 1/value 3/~build \"breaks\"" > "$t/rows" 18 # The build fails only for mutant M_BUILD, with an error line holding quotes and a backslash. 19 build='if grep -q "value 3" a.txt; then echo "x.c:1: error: bad \"tok\" \\ here"; exit 1; fi' 20 sh "$here/tools/mutation_runner.sh" -k table -m "$t/rows" -d "$t/src" -b "$build" \ 21 -t 'grep -q "value 1" a.txt' -o "$t/out.json" >"$t/log" 2>&1 22 GUARDS=$guards python3 - "$t/out.json" <<'PY' || { echo "mutation runner JSON: FAIL"; exit 1; } 23 import json, os, sys 24 try: 25 d = json.load(open(sys.argv[1])) 26 except ValueError as e: 27 print("receipt does not parse:", e); sys.exit(1) 28 m = {r["id"]: r for r in d["mutants"]} 29 want = { 30 ("M_KILL", "checks"): os.environ["GUARDS"], 31 ("M_KILL", "status"): "KILLED", 32 ("M_BUILD", "checks"): 'build "breaks"', 33 ("M_BUILD", "status"): "ERROR", 34 ("M_BUILD", "note"): 'build failed: x.c:1: error: bad "tok" \\ here', 35 } 36 bad = [(k, m.get(k[0], {}).get(k[1]), v) for k, v in want.items() if m.get(k[0], {}).get(k[1]) != v] 37 for b in bad: print("mismatch", b) 38 sys.exit(1 if bad else 0) 39 PY 40 # A receipt destination that cannot be opened must fail before running mutants. 41 if sh "$here/tools/mutation_runner.sh" -k table -m "$t/rows" -d "$t/src" \ 42 -t 'touch ran; exit 1' -o "$t/missing/out.json" >"$t/unwritable.log" 2>&1; then 43 echo "mutation runner JSON: FAIL (unwritable receipt accepted)" 44 exit 1 45 else 46 rc=$? 47 [ "$rc" -eq 2 ] || { echo "mutation runner JSON: FAIL (receipt exit $rc)"; exit 1; } 48 fi 49 echo "mutation runner JSON: PASS"