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/api_rest_mutants.py # 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 / api_rest_mutants.py` 42 lines · 2756 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Run inside bwrap. Mutate temporary Omega compositions, never tracked files.""" 4 import os 5 from pathlib import Path 6 import subprocess 7 import tempfile 8 9 root = Path(__file__).resolve().parents[1] 10 bridge = Path(os.environ['OMEGA_BRIDGE']) 11 env = dict(os.environ, OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) 12 build = root / 'build/api-rest' 13 cases = [ 14 ('launch-low-half', 'ar_launch', ['om/apirest/launch.om'], 'uint and get q 0 `4294967295`', 'uint get q 0'), 15 ('cache-invalid', 'ar_cache', ['om/apirest/cache.om'], 'if eq get a add b get q 2 0', 'if ne get a add b get q 2 0'), 16 ('pinned-victim', 'ar_victim', ['om/apirest/victim.om'], 'if eq get x add b get q 3 0', 'if ne get x add b get q 3 0'), 17 ('upload-byte-count', 'ar_mstep', ['om/apirest/data.om', 'om/api/apish_shp.om', 'om/apirest/mstep.om'], 'put q 12 mul get q 11 2', 'put q 12 mul get q 11 4'), 18 ('swiglu-copy-order', 'ar_pfcopy', ['om/apirest/data.om', 'om/api/apish_shp.om', 'om/apirest/pfcopy.om'], 'src = swsrc uint p uint get q 0', 'src = swsrc uint get q 0 uint p'), 19 ('swiglu-ratio-order', 'ar_pfratio', ['om/apirest/data.om', 'om/api/apish_shp.om', 'om/apirest/pfratio.om'], 'p = swsrc uint p uint get q 0', 'p = swsrc uint get q 0 uint p'), 20 ('slot-pin-wrap', 'ar_slot', ['om/apirest/data.om', 'om/api/apish_slot.om', 'om/apirest/slot.om'], 'uint and get rec 1 `4294967295`', 'uint get rec 1'), 21 ] 22 subprocess.run(['sh', 'tests/api_rest_run.sh'], cwd=root, check=True) 23 with tempfile.TemporaryDirectory(prefix='api-rest-mutants-') as tmp: 24 tmp = Path(tmp) 25 for name, unit, parts, before, after in cases: 26 text = '\n'.join((root / p).read_text() for p in parts) 27 if text.count(before) != 1: 28 raise SystemExit(f'FAIL {name}: mutation site count {text.count(before)}') 29 src = tmp / (name + '.om'); src.write_text(text.replace(before, after)) 30 c = tmp / (name + '.c') 31 with c.open('w') as out: 32 subprocess.run(['sh', str(bridge / 'tools/bridge-seeded'), '--runtime-views', 'c', str(src)], cwd=root, env=env, stdout=out, check=True) 33 obj = tmp / (name + '.o') 34 subprocess.run(['cc', '-std=gnu11', '-O2', '-ffp-contract=off', '-c', str(c), '-o', str(obj)], check=True) 35 objects = [str(p) for p in sorted(build.glob('*.o')) if p.name != 'cudapp_om_' + unit + '.o'] 36 exe = tmp / name 37 subprocess.run(['cc', '-o', str(exe), *objects, str(obj), str(root/'build/libomega_gpu.a'), '-lm', '-lpthread'], check=True) 38 p = subprocess.run([str(exe)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) 39 if p.returncode == 0: 40 raise SystemExit(f'FAIL mutant survived: {name}') 41 print(f'KILLED {name} rc={p.returncode} {p.stdout.strip()}', flush=True) 42 print(f'PASS api-rest mutants killed={len(cases)}')