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 / localrouter / negative_control.py

33 lines · 1576 bytes Raw Blame History
1#!/usr/bin/env python3
2# SPDX-License-Identifier: MIT
3"""Remove the shared-lock guard in a temporary copy; its test must fail."""
4from pathlib import Path
5import shutil
6import subprocess
7import sys
8import tempfile
9
10
11root = Path(__file__).resolve().parents[2]
12with tempfile.TemporaryDirectory(prefix="localrouter-control-") as name:
13 temp = Path(name)
14 for relative in ("tools/localrouter/setup.py", "tests/localrouter/test_setup.py"):
15 target = temp / relative
16 target.parent.mkdir(parents=True, exist_ok=True)
17 shutil.copyfile(root / relative, target)
18 script = temp / "tools/localrouter/setup.py"
19 text = script.read_text()
20 before = 'require(cfg.get("gpu_lock") == "",'
21 if text.count(before) != 1:
22 sys.exit("FAIL: shared-lock guard was not found exactly once")
23 script.write_text(text.replace(before, 'require(True,'))
24 run = subprocess.run([sys.executable, "-m", "unittest", "discover", "-s",
25 "tests/localrouter", "-p", "test_setup.py", "-v"],
26 cwd=temp, capture_output=True, text=True)
27 output = run.stdout + run.stderr
28 # A crash/import failure cannot count as detecting this control.
29 if run.returncode == 0 or "AssertionError: ValueError not raised" not in output or "FAILED (failures=1)" not in output:
30 print(output)
31 sys.exit("FAIL: removing the shared-lock guard did not fail its intended check")
32 print("PASS: shared-lock guard removed in scratch copy; intended rejection test failed")
33 print("mutant exit code:", run.returncode)