Skip to content

Commit ad4a531

Browse files
rwgkcursoragent
andcommitted
pathfinder: deduplicate test setup helpers
Share the guard-rails-off fixture and small CTK sandbox builders so the touched pathfinder tests stay easier to extend and less error-prone. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent bbddbec commit ad4a531

8 files changed

Lines changed: 91 additions & 124 deletions

cuda_pathfinder/tests/compatibility_guard_rails_test_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,33 @@ def _write_cuda_h(
7878
)
7979

8080

81+
def _make_ctk_root(
82+
ctk_root: Path,
83+
toolkit_version: str,
84+
*,
85+
include_dir_parts: tuple[str, ...] = ("targets", "x86_64-linux", "include"),
86+
) -> Path:
87+
_write_cuda_h(ctk_root, toolkit_version, include_dir_parts=include_dir_parts)
88+
return ctk_root
89+
90+
8191
def _touch(path: Path) -> str:
8292
path.parent.mkdir(parents=True, exist_ok=True)
8393
path.touch()
8494
return str(path)
8595

8696

97+
def _touch_ctk_file(
98+
ctk_root: Path,
99+
toolkit_version: str,
100+
relative_path: str | Path,
101+
*,
102+
include_dir_parts: tuple[str, ...] = ("targets", "x86_64-linux", "include"),
103+
) -> str:
104+
_make_ctk_root(ctk_root, toolkit_version, include_dir_parts=include_dir_parts)
105+
return _touch(ctk_root / Path(relative_path))
106+
107+
87108
def _loaded_dl(abs_path: str, *, found_via: str = "CUDA_PATH") -> LoadedDL:
88109
return LoadedDL(
89110
abs_path=abs_path,

cuda_pathfinder/tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ def _append(message):
3131
return _append
3232

3333

34+
@pytest.fixture
35+
def disable_process_wide_compatibility_guard_rails(monkeypatch):
36+
monkeypatch.setenv("CUDA_PATHFINDER_COMPATIBILITY_GUARD_RAILS", "off")
37+
38+
3439
def skip_if_missing_libnvcudla_so(libname: str, *, timeout: float) -> None:
3540
if libname not in ("cudla", "nvcudla"):
3641
return

cuda_pathfinder/tests/test_compatibility_guard_rails.py

Lines changed: 54 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
_loaded_dl,
1313
_located_bitcode_lib,
1414
_located_static_lib,
15+
_make_ctk_root,
1516
_patch_dynamic_lib_loader,
1617
_touch,
18+
_touch_ctk_file,
1719
_write_cuda_h,
1820
)
1921
from packaging.specifiers import SpecifierSet
@@ -34,13 +36,12 @@
3436

3537

3638
def test_same_dynamic_link_component_requires_exact_ctk_major_minor_match(monkeypatch, tmp_path):
37-
cublas_root = tmp_path / "cuda-12.8"
38-
cusolver_root = tmp_path / "cuda-12.9"
39-
_write_cuda_h(cublas_root, "12.8.20250303")
40-
_write_cuda_h(cusolver_root, "12.9.20250531")
41-
42-
cublas_path = _touch(cublas_root / "targets" / "x86_64-linux" / "lib" / "libcublas.so.12")
43-
cusolver_path = _touch(cusolver_root / "targets" / "x86_64-linux" / "lib" / "libcusolver.so.12")
39+
cublas_path = _touch_ctk_file(tmp_path / "cuda-12.8", "12.8.20250303", "targets/x86_64-linux/lib/libcublas.so.12")
40+
cusolver_path = _touch_ctk_file(
41+
tmp_path / "cuda-12.9",
42+
"12.9.20250531",
43+
"targets/x86_64-linux/lib/libcusolver.so.12",
44+
)
4445

4546
_patch_dynamic_lib_loader(
4647
monkeypatch,
@@ -59,13 +60,12 @@ def test_same_dynamic_link_component_requires_exact_ctk_major_minor_match(monkey
5960

6061

6162
def test_independent_dynamic_libs_may_resolve_to_different_ctk_minors(monkeypatch, tmp_path):
62-
nvrtc_root = tmp_path / "cuda-12.8"
63-
nvjitlink_root = tmp_path / "cuda-12.9"
64-
_write_cuda_h(nvrtc_root, "12.8.20250303")
65-
_write_cuda_h(nvjitlink_root, "12.9.20250531")
66-
67-
nvrtc_path = _touch(nvrtc_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
68-
nvjitlink_path = _touch(nvjitlink_root / "targets" / "x86_64-linux" / "lib" / "libnvJitLink.so.12")
63+
nvrtc_path = _touch_ctk_file(tmp_path / "cuda-12.8", "12.8.20250303", "targets/x86_64-linux/lib/libnvrtc.so.12")
64+
nvjitlink_path = _touch_ctk_file(
65+
tmp_path / "cuda-12.9",
66+
"12.9.20250531",
67+
"targets/x86_64-linux/lib/libnvJitLink.so.12",
68+
)
6969

7070
_patch_dynamic_lib_loader(
7171
monkeypatch,
@@ -83,13 +83,8 @@ def test_independent_dynamic_libs_may_resolve_to_different_ctk_minors(monkeypatc
8383

8484

8585
def test_toolchain_companions_require_exact_ctk_major_minor_match(monkeypatch, tmp_path):
86-
static_root = tmp_path / "cuda-12.8"
87-
binary_root = tmp_path / "cuda-12.9"
88-
_write_cuda_h(static_root, "12.8.20250303")
89-
_write_cuda_h(binary_root, "12.9.20250531")
90-
91-
static_path = _touch(static_root / "targets" / "x86_64-linux" / "lib" / "libcudadevrt.a")
92-
binary_path = _touch(binary_root / "bin" / "nvcc")
86+
static_path = _touch_ctk_file(tmp_path / "cuda-12.8", "12.8.20250303", "targets/x86_64-linux/lib/libcudadevrt.a")
87+
binary_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "bin/nvcc")
9388

9489
monkeypatch.setattr(
9590
compatibility_module,
@@ -113,13 +108,12 @@ def test_toolchain_companions_require_exact_ctk_major_minor_match(monkeypatch, t
113108

114109

115110
def test_declared_ltoir_pipeline_requires_nvjitlink_not_older_than_nvrtc(monkeypatch, tmp_path):
116-
nvrtc_root = tmp_path / "cuda-12.9"
117-
nvjitlink_root = tmp_path / "cuda-12.8"
118-
_write_cuda_h(nvrtc_root, "12.9.20250531")
119-
_write_cuda_h(nvjitlink_root, "12.8.20250303")
120-
121-
nvrtc_path = _touch(nvrtc_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
122-
nvjitlink_path = _touch(nvjitlink_root / "targets" / "x86_64-linux" / "lib" / "libnvJitLink.so.12")
111+
nvrtc_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
112+
nvjitlink_path = _touch_ctk_file(
113+
tmp_path / "cuda-12.8",
114+
"12.8.20250303",
115+
"targets/x86_64-linux/lib/libnvJitLink.so.12",
116+
)
123117

124118
_patch_dynamic_lib_loader(
125119
monkeypatch,
@@ -140,13 +134,12 @@ def test_declared_ltoir_pipeline_requires_nvjitlink_not_older_than_nvrtc(monkeyp
140134

141135

142136
def test_declared_ltoir_pipeline_allows_same_major_newer_nvjitlink(monkeypatch, tmp_path):
143-
nvrtc_root = tmp_path / "cuda-12.8"
144-
nvjitlink_root = tmp_path / "cuda-12.9"
145-
_write_cuda_h(nvrtc_root, "12.8.20250303")
146-
_write_cuda_h(nvjitlink_root, "12.9.20250531")
147-
148-
nvrtc_path = _touch(nvrtc_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
149-
nvjitlink_path = _touch(nvjitlink_root / "targets" / "x86_64-linux" / "lib" / "libnvJitLink.so.12")
137+
nvrtc_path = _touch_ctk_file(tmp_path / "cuda-12.8", "12.8.20250303", "targets/x86_64-linux/lib/libnvrtc.so.12")
138+
nvjitlink_path = _touch_ctk_file(
139+
tmp_path / "cuda-12.9",
140+
"12.9.20250531",
141+
"targets/x86_64-linux/lib/libnvJitLink.so.12",
142+
)
150143

151144
_patch_dynamic_lib_loader(
152145
monkeypatch,
@@ -169,13 +162,12 @@ def test_declared_ltoir_pipeline_allows_same_major_newer_nvjitlink(monkeypatch,
169162

170163
@pytest.mark.parametrize("artifact_kind", ("ptx", "elf", "cubin"))
171164
def test_declared_non_lto_pipeline_allows_cross_major_nvrtc_to_nvjitlink(monkeypatch, tmp_path, artifact_kind):
172-
nvrtc_root = tmp_path / "cuda-12.8"
173-
nvjitlink_root = tmp_path / "cuda-13.0"
174-
_write_cuda_h(nvrtc_root, "12.8.20250303")
175-
_write_cuda_h(nvjitlink_root, "13.0.20251003")
176-
177-
nvrtc_path = _touch(nvrtc_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
178-
nvjitlink_path = _touch(nvjitlink_root / "targets" / "x86_64-linux" / "lib" / "libnvJitLink.so.13")
165+
nvrtc_path = _touch_ctk_file(tmp_path / "cuda-12.8", "12.8.20250303", "targets/x86_64-linux/lib/libnvrtc.so.12")
166+
nvjitlink_path = _touch_ctk_file(
167+
tmp_path / "cuda-13.0",
168+
"13.0.20251003",
169+
"targets/x86_64-linux/lib/libnvJitLink.so.13",
170+
)
179171

180172
_patch_dynamic_lib_loader(
181173
monkeypatch,
@@ -197,13 +189,12 @@ def test_declared_non_lto_pipeline_allows_cross_major_nvrtc_to_nvjitlink(monkeyp
197189

198190

199191
def test_declared_nvvm_pipeline_remains_conservative(monkeypatch, tmp_path):
200-
nvvm_root = tmp_path / "cuda-12.8"
201-
nvjitlink_root = tmp_path / "cuda-12.9"
202-
_write_cuda_h(nvvm_root, "12.8.20250303")
203-
_write_cuda_h(nvjitlink_root, "12.9.20250531")
204-
205-
nvvm_path = _touch(nvvm_root / "nvvm" / "lib64" / "libnvvm.so.4")
206-
nvjitlink_path = _touch(nvjitlink_root / "targets" / "x86_64-linux" / "lib" / "libnvJitLink.so.12")
192+
nvvm_path = _touch_ctk_file(tmp_path / "cuda-12.8", "12.8.20250303", "nvvm/lib64/libnvvm.so.4")
193+
nvjitlink_path = _touch_ctk_file(
194+
tmp_path / "cuda-12.9",
195+
"12.9.20250531",
196+
"targets/x86_64-linux/lib/libnvJitLink.so.12",
197+
)
207198

208199
_patch_dynamic_lib_loader(
209200
monkeypatch,
@@ -238,9 +229,7 @@ def test_declared_dynamic_lib_pipeline_rejects_invalid_artifact_kind():
238229

239230

240231
def test_driver_major_must_not_be_older_than_ctk_major(monkeypatch, tmp_path):
241-
ctk_root = tmp_path / "cuda-13.0"
242-
_write_cuda_h(ctk_root, "13.0.20251003")
243-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.13")
232+
lib_path = _touch_ctk_file(tmp_path / "cuda-13.0", "13.0.20251003", "targets/x86_64-linux/lib/libnvrtc.so.13")
244233

245234
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
246235

@@ -292,9 +281,7 @@ def test_other_packaging_raises_insufficient_metadata(monkeypatch, tmp_path):
292281

293282
def test_driver_libs_do_not_lock_ctk_anchor(monkeypatch, tmp_path):
294283
driver_lib_path = _touch(tmp_path / "driver-root" / "libnvidia-ml.so.1")
295-
ctk_root = tmp_path / "cuda-12.9"
296-
_write_cuda_h(ctk_root, "12.9.20250531")
297-
ctk_lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
284+
ctk_lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
298285

299286
_patch_dynamic_lib_loader(
300287
monkeypatch,
@@ -315,12 +302,9 @@ def test_driver_libs_do_not_mask_later_ctk_mismatch(monkeypatch, tmp_path):
315302
driver_lib_path = _touch(tmp_path / "driver-root" / "libnvidia-ml.so.1")
316303
lib_root = tmp_path / "cuda-12.8"
317304
hdr_root = tmp_path / "cuda-12.9"
318-
_write_cuda_h(lib_root, "12.8.20250303")
319-
_write_cuda_h(hdr_root, "12.9.20250531")
320-
321-
lib_path = _touch(lib_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
305+
lib_path = _touch_ctk_file(lib_root, "12.8.20250303", "targets/x86_64-linux/lib/libnvrtc.so.12")
322306
hdr_dir = hdr_root / "targets" / "x86_64-linux" / "include"
323-
_touch(hdr_dir / "nvrtc.h")
307+
_touch_ctk_file(hdr_root, "12.9.20250531", "targets/x86_64-linux/include/nvrtc.h")
324308

325309
_patch_dynamic_lib_loader(
326310
monkeypatch,
@@ -385,9 +369,7 @@ def test_wheel_metadata_accepts_exact_and_range_requirements(monkeypatch, tmp_pa
385369

386370

387371
def test_ctk_version_constraint_accepts_pep440_string(monkeypatch, tmp_path):
388-
ctk_root = tmp_path / "cuda-12.9"
389-
_write_cuda_h(ctk_root, "12.9.20250531")
390-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
372+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
391373

392374
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
393375

@@ -402,9 +384,7 @@ def test_ctk_version_constraint_accepts_pep440_string(monkeypatch, tmp_path):
402384

403385

404386
def test_ctk_version_constraint_accepts_specifier_set_instance(monkeypatch, tmp_path):
405-
ctk_root = tmp_path / "cuda-12.9"
406-
_write_cuda_h(ctk_root, "12.9.20250531")
407-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
387+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
408388

409389
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
410390

@@ -419,9 +399,7 @@ def test_ctk_version_constraint_accepts_specifier_set_instance(monkeypatch, tmp_
419399

420400

421401
def test_ctk_version_constraint_failure_raises(monkeypatch, tmp_path):
422-
ctk_root = tmp_path / "cuda-12.9"
423-
_write_cuda_h(ctk_root, "12.9.20250531")
424-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
402+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
425403

426404
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
427405

@@ -440,8 +418,7 @@ def test_ctk_version_constraint_rejects_invalid_specifier():
440418

441419

442420
def test_resolved_items_capture_relation_metadata(tmp_path):
443-
ctk_root = tmp_path / "cuda-12.9"
444-
_write_cuda_h(ctk_root, "12.9.20250531")
421+
ctk_root = _make_ctk_root(tmp_path / "cuda-12.9", "12.9.20250531")
445422

446423
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
447424
header_dir = ctk_root / "targets" / "x86_64-linux" / "include"
@@ -471,8 +448,7 @@ def test_resolved_items_capture_relation_metadata(tmp_path):
471448

472449

473450
def test_static_bitcode_and_binary_methods_participate_in_checks(monkeypatch, tmp_path):
474-
ctk_root = tmp_path / "cuda-12.9"
475-
_write_cuda_h(ctk_root, "12.9.20250531")
451+
ctk_root = _make_ctk_root(tmp_path / "cuda-12.9", "12.9.20250531")
476452

477453
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
478454
static_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libcudadevrt.a")
@@ -505,9 +481,7 @@ def test_static_bitcode_and_binary_methods_participate_in_checks(monkeypatch, tm
505481

506482

507483
def test_guard_rails_query_driver_cuda_version_by_default(monkeypatch, tmp_path):
508-
ctk_root = tmp_path / "cuda-12.9"
509-
_write_cuda_h(ctk_root, "12.9.20250531")
510-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
484+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
511485

512486
query_calls: list[int] = []
513487

@@ -533,9 +507,7 @@ def fake_query_driver_cuda_version() -> DriverCudaVersion:
533507

534508

535509
def test_guard_rails_wrap_driver_query_failures(monkeypatch, tmp_path):
536-
ctk_root = tmp_path / "cuda-12.9"
537-
_write_cuda_h(ctk_root, "12.9.20250531")
538-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
510+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
539511

540512
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
541513

@@ -556,9 +528,7 @@ def fail_query_driver_cuda_version() -> DriverCudaVersion:
556528

557529

558530
def test_guard_rails_accept_minor_version_compatibility_with_driver_release_branch(monkeypatch, tmp_path):
559-
ctk_root = tmp_path / "cuda-12.9"
560-
_write_cuda_h(ctk_root, "12.9.20250531")
561-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
531+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
562532

563533
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
564534

@@ -573,9 +543,7 @@ def test_guard_rails_accept_minor_version_compatibility_with_driver_release_bran
573543

574544

575545
def test_guard_rails_reject_same_major_older_driver_when_release_branch_too_old(monkeypatch, tmp_path):
576-
ctk_root = tmp_path / "cuda-12.9"
577-
_write_cuda_h(ctk_root, "12.9.20250531")
578-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
546+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
579547

580548
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
581549

@@ -592,9 +560,7 @@ def test_guard_rails_reject_same_major_older_driver_when_release_branch_too_old(
592560

593561

594562
def test_guard_rails_require_driver_release_metadata_for_same_major_older_driver(monkeypatch, tmp_path):
595-
ctk_root = tmp_path / "cuda-12.9"
596-
_write_cuda_h(ctk_root, "12.9.20250531")
597-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
563+
lib_path = _touch_ctk_file(tmp_path / "cuda-12.9", "12.9.20250531", "targets/x86_64-linux/lib/libnvrtc.so.12")
598564

599565
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
600566

cuda_pathfinder/tests/test_compatibility_guard_rails_public.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
_located_bitcode_lib,
1717
_located_static_lib,
1818
_touch,
19-
_write_cuda_h,
19+
_touch_ctk_file,
2020
compatibility_module,
2121
process_wide_module,
2222
)
@@ -208,8 +208,7 @@ def test_driver_compatibility_override_is_linux_only(monkeypatch):
208208
)
209209
def test_public_driver_mismatch_advertises_forward_compatibility_override(monkeypatch, tmp_path):
210210
ctk_root = tmp_path / "cuda-13.0"
211-
_write_cuda_h(ctk_root, "13.0.20251003")
212-
lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.13")
211+
lib_path = _touch_ctk_file(ctk_root, "13.0.20251003", "targets/x86_64-linux/lib/libnvrtc.so.13")
213212

214213
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
215214
monkeypatch.setattr(
@@ -238,8 +237,7 @@ def fail_raw_fallback(_libname: str) -> LoadedDL:
238237
)
239238
def test_public_driver_mismatch_falls_back_when_assuming_forward_compatibility(monkeypatch, tmp_path):
240239
ctk_root = tmp_path / "cuda-13.0"
241-
_write_cuda_h(ctk_root, "13.0.20251003")
242-
guarded_lib_path = _touch(ctk_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.13")
240+
guarded_lib_path = _touch_ctk_file(ctk_root, "13.0.20251003", "targets/x86_64-linux/lib/libnvrtc.so.13")
243241
raw_loaded = _loaded_dl("/opt/mock/libnvrtc.so.13", found_via="system-search")
244242

245243
monkeypatch.setenv(DRIVER_COMPATIBILITY_ENV_VAR, "assume_forward_compatibility")
@@ -267,12 +265,9 @@ def test_public_driver_mismatch_falls_back_when_assuming_forward_compatibility(m
267265
def test_forward_compatibility_override_does_not_relax_ctk_coherence_checks(monkeypatch, tmp_path):
268266
lib_root = tmp_path / "cuda-12.8"
269267
hdr_root = tmp_path / "cuda-12.9"
270-
_write_cuda_h(lib_root, "12.8.20250303")
271-
_write_cuda_h(hdr_root, "12.9.20250531")
272-
273-
lib_path = _touch(lib_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
268+
lib_path = _touch_ctk_file(lib_root, "12.8.20250303", "targets/x86_64-linux/lib/libnvrtc.so.12")
274269
hdr_dir = hdr_root / "targets" / "x86_64-linux" / "include"
275-
_touch(hdr_dir / "nvrtc.h")
270+
_touch_ctk_file(hdr_root, "12.9.20250531", "targets/x86_64-linux/include/nvrtc.h")
276271

277272
monkeypatch.setenv(DRIVER_COMPATIBILITY_ENV_VAR, "assume_forward_compatibility")
278273
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
@@ -297,12 +292,9 @@ def test_forward_compatibility_override_does_not_relax_ctk_coherence_checks(monk
297292
def test_public_apis_share_process_wide_guard_rails_state(monkeypatch, tmp_path):
298293
lib_root = tmp_path / "cuda-12.8"
299294
hdr_root = tmp_path / "cuda-12.9"
300-
_write_cuda_h(lib_root, "12.8.20250303")
301-
_write_cuda_h(hdr_root, "12.9.20250531")
302-
303-
lib_path = _touch(lib_root / "targets" / "x86_64-linux" / "lib" / "libnvrtc.so.12")
295+
lib_path = _touch_ctk_file(lib_root, "12.8.20250303", "targets/x86_64-linux/lib/libnvrtc.so.12")
304296
hdr_dir = hdr_root / "targets" / "x86_64-linux" / "include"
305-
_touch(hdr_dir / "nvrtc.h")
297+
_touch_ctk_file(hdr_root, "12.9.20250531", "targets/x86_64-linux/include/nvrtc.h")
306298

307299
monkeypatch.setattr(compatibility_module, "_load_nvidia_dynamic_lib", lambda _libname: _loaded_dl(lib_path))
308300
monkeypatch.setattr(

0 commit comments

Comments
 (0)