omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / tests / mutants-sec2.sh
| 1 | #!/bin/sh |
| 2 | set -eu |
| 3 | R=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) |
| 4 | sh "$R/tests/sec2_host.sh" |
| 5 | python3 - "$R" <<'PY' |
| 6 | import os,pathlib,subprocess,sys,tempfile |
| 7 | r=pathlib.Path(sys.argv[1]); source=(r/'gsp/sec2.om').read_text() |
| 8 | mutants=[('secure-wait','if not s2wait 0 get s2cfg 2','if false'),('response-wait','if not s2wait 1 get s2cfg 3','if false'),('package','if ne get s2cfg 1 2','if false'),('response-vendor','if ne s2get 4 353427070','if false'),('response-error','if ne get s2out 3 0','if false'),('pointer','if ne e div n 4','if false')] |
| 9 | with tempfile.TemporaryDirectory(prefix='sec2-mutants.') as d: |
| 10 | for name,old,new in mutants: |
| 11 | assert source.count(old)==1,name |
| 12 | p=pathlib.Path(d)/(name+'.om');p.write_text(source.replace(old,new)) |
| 13 | q=subprocess.run(['sh',str(r/'tests/sec2_host.sh')],env=dict(os.environ,SEC2_OM=str(p)),capture_output=True,text=True) |
| 14 | if q.returncode!=1 or 'sec2_host: FAIL case ' not in q.stderr: |
| 15 | sys.exit(f'INVALID/SURVIVED {name}: {q.returncode}\n{q.stdout}\n{q.stderr}') |
| 16 | print('mutants-sec2: DETECTED '+name) |
| 17 | print('mutants-sec2: PASS; hardware NOT_RUN') |
| 18 | PY |