forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
57 lines (39 loc) · 1.72 KB
/
conftest.py
File metadata and controls
57 lines (39 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import logging
import os
import pytest
_LOGGER_NAME = "cuda_pathfinder.test_info"
def _log_filename():
strictness = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "see_what_works")
return f"pathfinder-test-info-summary-{strictness}.txt"
def pytest_configure(config):
log_path = config.rootpath / _log_filename()
log_path.unlink(missing_ok=True)
@pytest.fixture(scope="session")
def _info_summary_handler(request):
log_path = request.config.rootpath / _log_filename()
handler = logging.FileHandler(log_path, mode="w")
handler.setFormatter(logging.Formatter("%(test_node)s: %(message)s"))
logger = logging.getLogger(_LOGGER_NAME)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.propagate = False
yield handler
logger.removeHandler(handler)
handler.close()
@pytest.fixture
def info_log(request, _info_summary_handler):
return logging.LoggerAdapter(
logging.getLogger(_LOGGER_NAME),
extra={"test_node": request.node.name},
)
def skip_if_missing_libnvcudla_so(libname: str, *, timeout: float) -> None:
if libname not in ("cudla", "nvcudla"):
return
# Keep the import inside the helper so unrelated import issues do not fail
# pytest collection for the whole test suite.
from cuda.pathfinder._dynamic_libs import load_nvidia_dynamic_lib as load_nvidia_dynamic_lib_module
if load_nvidia_dynamic_lib_module._loadable_via_canary_subprocess("nvcudla", timeout=timeout):
return
pytest.skip("libnvcudla.so is not loadable via canary subprocess on this host.")