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 / runtime / artifact_format_mutants.py
| 1 | #!/usr/bin/env python3 |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | """Compile five real .om mutants; compilation failure is not a killed mutant.""" |
| 4 | import os |
| 5 | from pathlib import Path |
| 6 | import subprocess |
| 7 | import sys |
| 8 | import tempfile |
| 9 | sys.dont_write_bytecode=True |
| 10 | import artifact_format_gate as gate |
| 11 | |
| 12 | root=gate.ROOT |
| 13 | bridge=Path(os.environ['OMEGA_BRIDGE']) |
| 14 | env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) |
| 15 | mutants=( |
| 16 | ('artifact_format','artifact_format','if or eq ch 34 eq ch 92','if or eq ch 34 eq ch 93',()), |
| 17 | ('artifact_admit','artifact_admit','if not aa_digest b s 0','if aa_digest b s 0',('artifact_parse','artifact_policy','artifact_format')), |
| 18 | ('artifact_elf','artifact_elf','if ne ae_rd b 18 2 190','if ne ae_rd b 18 2 191',()), |
| 19 | ('artifact_admit-driver-boundary','artifact_admit','if lt have need','if le have need',('artifact_parse','artifact_policy','artifact_format')), |
| 20 | ('artifact_format-checksum-order','artifact_format','if eq i 2\nk = 13\nend\nif eq i 3\nk = 11','if eq i 2\nk = 11\nend\nif eq i 3\nk = 13',()), |
| 21 | ) |
| 22 | for name,unit,old,new,parts in mutants: |
| 23 | source=(root/'om/components'/f'{unit}.om').read_text() |
| 24 | assert source.count(old)==1 |
| 25 | with tempfile.TemporaryDirectory(prefix='artifact-mutant-') as td: |
| 26 | tmp=Path(td);om=tmp/f'{unit}.om' |
| 27 | composed=''.join((root/'om/components'/f'{p}.om').read_text()+'\n' for p in parts) |
| 28 | om.write_text(composed+source.replace(old,new)+'\n') |
| 29 | generated=tmp/f'cudapp_om_{unit}.c' |
| 30 | with generated.open('w') as out: |
| 31 | subprocess.run(['sh',str(bridge/'tools/bridge-seeded'),'c',str(om)],env=env,stdout=out,check=True) |
| 32 | lib=gate.build(tmp,[(generated.name,generated)]) |
| 33 | result=subprocess.run([sys.executable,str(root/'tests/runtime/artifact_format_gate.py'),'--library',str(lib)],capture_output=True,text=True) |
| 34 | log=root/'build/artifact-format'/f'mutant-{name}.log' |
| 35 | log.parent.mkdir(parents=True,exist_ok=True);log.write_text(result.stdout+result.stderr) |
| 36 | assert result.returncode==1 and 'AssertionError' in result.stderr,(name,result.returncode,result.stderr) |
| 37 | print(f'ARTIFACT-FORMAT mutant killed PASS {name} (compiled; differential rejected)',flush=True) |
| 38 | print(f'ARTIFACT-FORMAT mutants PASS killed={len(mutants)} compiled={len(mutants)}') |