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
CUDApp / tests / leftovers_mutants.py
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | """Change Omega, regenerate with the pinned frontend, exercise the real wrappers.""" |
| 3 | import os |
| 4 | from pathlib import Path |
| 5 | import shlex |
| 6 | import subprocess |
| 7 | import sys |
| 8 | |
| 9 | root = Path(__file__).resolve().parent.parent |
| 10 | out = Path(sys.argv[1]).resolve() |
| 11 | out.mkdir(parents=True, exist_ok=True) |
| 12 | source = (root / 'om/components/leftovers.om').read_text() |
| 13 | mutants = [ |
| 14 | ('alphabet', 'ge value 97 le value 122', 'ge value 98 le value 122'), |
| 15 | ('punctuation', 'eq value 58 eq value 126', 'eq value 59 eq value 126'), |
| 16 | ('ordinal', 'ret value\nend\nret 0\nend\nfn leftover_acquire', 'ret 0\nend\nret 0\nend\nfn leftover_acquire'), |
| 17 | ('acquire', 'if eq okay 0', 'if ne okay 0'), |
| 18 | ('poison', 'if eq state 2\nret 1', 'if eq state 1\nret 1'), |
| 19 | ('context', 'eq present 0', 'eq present 1'), |
| 20 | ('release', 'lt index 32', 'lt index 31'), |
| 21 | ] |
| 22 | bridge = os.environ['OMEGA_BRIDGE'] |
| 23 | env = dict(os.environ, OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) |
| 24 | for name, old, new in mutants: |
| 25 | if source.count(old) != 1: |
| 26 | raise SystemExit(f'FAIL {name}: mutation site not unique') |
| 27 | directory = out / name |
| 28 | directory.mkdir(exist_ok=True) |
| 29 | unit = directory / 'leftovers.om' |
| 30 | unit.write_text(source.replace(old, new)) |
| 31 | generated = directory / 'leftovers.c' |
| 32 | with generated.open('w') as stream: |
| 33 | subprocess.run(['sh', bridge + '/tools/bridge-freest', 'c', str(unit)], env=env, stdout=stream, check=True) |
| 34 | binary = directory / 'diff' |
| 35 | subprocess.run(shlex.split(os.environ.get('CC', 'cc')) + ['-std=gnu11', '-O2', '-Wall', '-Wextra', '-Werror', '-Isrc', 'tests/leftovers_test.c', str(generated), 'src/cudapp_freest_pathcopy.c', '-o', str(binary)], cwd=root, check=True) |
| 36 | with (directory / 'run.log').open('w') as stream: |
| 37 | result = subprocess.run([str(binary)], stdout=stream, stderr=subprocess.STDOUT) |
| 38 | if result.returncode != 1: |
| 39 | raise SystemExit(f'FAIL {name}: expected assertion exit 1, got {result.returncode}') |
| 40 | print(f'KILLED {name}', flush=True) |
| 41 | print(f'LEFTOVERS MUTANTS PASS killed={len(mutants)}') |