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 / platform_linux_rest_mutants.py

36 lines · 2013 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Independent source mutants for residual platform policies; no device access."""
3import os
4from pathlib import Path
5import subprocess
6import tempfile
7root = Path(__file__).resolve().parents[1]
8source = (root / 'om/platform-linux/plat_rest.om').read_text()
9mutants = (
10 ('page-round', 'pages = and add get m 0 4095', 'pages = and add get m 0 0'),
11 ('cursor-floor', 'if or lt cursor 65536', 'if or lt cursor 65535'),
12 ('marker-slash', 'if eq get m 1 47', 'if eq get m 1 48'),
13 ('marker-letter', 'ne get m pos 109', 'ne get m pos 110'),
14 ('stale-generation', 'ne get m 3 get m 1', 'eq get m 3 get m 1'),
15 ('time-scale', 'ret add mul get m 0 1000000000', 'ret add mul get m 0 1000000'),
16 ('queue-bound', 'if ge add i 1 get m 0', 'if gt add i 1 get m 0'),
17 ('sleep-remainder', 'put q 1 mul rem get m 0 1000', 'put q 1 mul div get m 0 1000'),
18)
19with tempfile.TemporaryDirectory(prefix='plat-rest-mutants-') as temp:
20 temp=Path(temp)
21 for name,old,new in mutants:
22 if source.count(old)!=1: raise SystemExit('FAIL ambiguous mutation site: '+name)
23 om=temp/(name+'.om'); c=temp/(name+'.c'); exe=temp/name
24 om.write_text(source.replace(old,new))
25 with c.open('w') as output:
26 env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
27 subprocess.run(['sh',os.environ['OMEGA_BRIDGE']+'/tools/bridge-seeded','c',str(om)],
28 stdout=output,env=env,check=True)
29 subprocess.run(['cc','-std=c11','-O2','-ffp-contract=off','-I'+str(root/'src'),
30 '-DPLAT_REST_IMPL="'+str(c)+'"',str(root/'tests/platform_linux_rest.c'),
31 '-o',str(exe)],check=True)
32 p=subprocess.run([str(exe)],capture_output=True,text=True)
33 if p.returncode==0 or 'FAIL platform rest' not in p.stderr:
34 raise SystemExit('FAIL survived or invalid mutant: '+name+': '+p.stderr)
35 print('KILLED '+name)
36print('PASS platform rest mutants (8 killed)')