Skip to content

Commit 259a554

Browse files
authored
Minor testing rework. (#1184)
1 parent 9f1269b commit 259a554

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

cuda_core/tests/helpers/__init__.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import os
55
import pathlib
6-
import platform
76
import sys
87

98
CUDA_PATH = os.environ.get("CUDA_PATH")
@@ -20,16 +19,8 @@
2019

2120

2221
try:
23-
import cuda_python_test_helpers
22+
from cuda_python_test_helpers import * # noqa: F403
2423
except ImportError:
2524
# Import shared platform helpers for tests across repos
2625
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[3] / "cuda_python_test_helpers"))
27-
import cuda_python_test_helpers
28-
29-
30-
IS_WSL = cuda_python_test_helpers.IS_WSL
31-
supports_ipc_mempool = cuda_python_test_helpers.supports_ipc_mempool
32-
IS_WINDOWS = platform.system() == "Windows"
33-
34-
35-
del cuda_python_test_helpers
26+
from cuda_python_test_helpers import * # noqa: F403

cuda_core/tests/helpers/buffers.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import ctypes
5-
import sys
65

76
from cuda.core.experimental import Buffer, MemoryResource
87
from cuda.core.experimental._utils.cuda_utils import driver, handle_return
98

10-
if sys.platform.startswith("win"):
11-
libc = ctypes.CDLL("msvcrt.dll")
12-
else:
13-
libc = ctypes.CDLL("libc.so.6")
14-
9+
from . import libc
1510

1611
__all__ = ["DummyUnifiedMemoryResource", "PatternGen", "make_scratch_buffer", "compare_equal_buffers"]
1712

cuda_core/tests/helpers/latch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, device, timeout_sec=60):
4545
}
4646
4747
// Avoid 100% spin.
48-
__nanosleep(10000000); // 10 ms
48+
__nanosleep(1000000); // 1 ms
4949
}
5050
}
5151
"""

cuda_python_test_helpers/cuda_python_test_helpers/__init__.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
import ctypes
45
import functools
56
import os
7+
import platform
8+
import sys
69
from contextlib import suppress
710
from typing import Union
811

912
from cuda.core.experimental._utils.cuda_utils import handle_return
1013

14+
__all__ = [
15+
"IS_WINDOWS",
16+
"IS_WSL",
17+
"libc",
18+
"supports_ipc_mempool",
19+
]
20+
1121

1222
def _detect_wsl() -> bool:
1323
data = ""
@@ -19,6 +29,12 @@ def _detect_wsl() -> bool:
1929

2030

2131
IS_WSL: bool = _detect_wsl()
32+
IS_WINDOWS: bool = platform.system() == "Windows" or sys.platform.startswith("win")
33+
34+
if IS_WINDOWS:
35+
libc = ctypes.CDLL("msvcrt.dll")
36+
else:
37+
libc = ctypes.CDLL("libc.so.6")
2238

2339

2440
@functools.cache
@@ -54,9 +70,3 @@ def supports_ipc_mempool(device_id: Union[int, object]) -> bool:
5470
return (int(mask) & int(posix_fd)) != 0
5571
except Exception:
5672
return False
57-
58-
59-
__all__ = [
60-
"IS_WSL",
61-
"supports_ipc_mempool",
62-
]

0 commit comments

Comments
 (0)