Skip to content

Commit 5b2012a

Browse files
committed
Add validate_abs_path() in test_load_nvidia_dynamic_lib.py
1 parent 97f1c36 commit 5b2012a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ def build_child_process_failed_for_libname_message(libname, result):
6262
)
6363

6464

65+
def validate_abs_path(abs_path):
66+
assert abs_path, f"empty path: {abs_path=!r}"
67+
assert os.path.isabs(abs_path), f"not absolute: {abs_path=!r}"
68+
assert os.path.isfile(abs_path), f"not a file: {abs_path=!r}"
69+
70+
6571
def child_process_func(libname):
6672
import os
6773

@@ -70,6 +76,7 @@ def child_process_func(libname):
7076
loaded_dl_fresh = load_nvidia_dynamic_lib(libname)
7177
if loaded_dl_fresh.was_already_loaded_from_elsewhere:
7278
raise RuntimeError("loaded_dl_fresh.was_already_loaded_from_elsewhere")
79+
validate_abs_path(loaded_dl_fresh.abs_path)
7380

7481
loaded_dl_from_cache = load_nvidia_dynamic_lib(libname)
7582
if loaded_dl_from_cache is not loaded_dl_fresh:
@@ -80,6 +87,7 @@ def child_process_func(libname):
8087
raise RuntimeError("loaded_dl_no_cache.was_already_loaded_from_elsewhere")
8188
if not os.path.samefile(loaded_dl_no_cache.abs_path, loaded_dl_fresh.abs_path):
8289
raise RuntimeError(f"not os.path.samefile({loaded_dl_no_cache.abs_path=!r}, {loaded_dl_fresh.abs_path=!r})")
90+
validate_abs_path(loaded_dl_no_cache.abs_path)
8391

8492
sys.stdout.write(f"{loaded_dl_fresh.abs_path!r}\n")
8593

0 commit comments

Comments
 (0)