interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / leftovers_mutants.py

41 lines · 2094 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2"""Change Omega, regenerate with the pinned frontend, exercise the real wrappers."""
3import os
4from pathlib import Path
5import shlex
6import subprocess
7import sys
8
9root = Path(__file__).resolve().parent.parent
10out = Path(sys.argv[1]).resolve()
11out.mkdir(parents=True, exist_ok=True)
12source = (root / 'om/components/leftovers.om').read_text()
13mutants = [
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]
22bridge = os.environ['OMEGA_BRIDGE']
23env = dict(os.environ, OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
24for 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)
41print(f'LEFTOVERS MUTANTS PASS killed={len(mutants)}')