Skip to content

Commit 73d6797

Browse files
committed
test: share IPC mempool fixture checks
Reuse the same IPC-mempool gating for single- and multi-device fixtures so nvbug 6176793 stays fixed without duplicating skip logic.
1 parent db55339 commit 73d6797

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

cuda_core/tests/conftest.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ def _device_id_from_resource_options(device, args, kwargs):
133133
return 0
134134

135135

136+
def _require_ipc_mempool_devices(devices):
137+
"""Return devices if they all support IPC-enabled mempools, otherwise skip."""
138+
from helpers import IS_WSL, supports_ipc_mempool
139+
140+
checked_devices = tuple(devices)
141+
142+
if not all(device.properties.handle_type_posix_file_descriptor_supported for device in checked_devices):
143+
pytest.skip("Device does not support IPC")
144+
145+
if IS_WSL or not all(supports_ipc_mempool(device) for device in checked_devices):
146+
pytest.skip("Driver rejects IPC-enabled mempool creation on this platform")
147+
148+
return devices
149+
150+
136151
@pytest.fixture(scope="session", autouse=True)
137152
def session_setup():
138153
# Always init CUDA.
@@ -199,25 +214,13 @@ def pop_all_contexts():
199214
@pytest.fixture
200215
def ipc_device():
201216
"""Obtains a device suitable for IPC-enabled mempool tests, or skips."""
202-
# Check if IPC is supported on this platform/device
203217
device = Device(0)
204218
device.set_current()
205219

206220
if not device.properties.memory_pools_supported:
207221
pytest.skip("Device does not support mempool operations")
208222

209-
# Note: Linux specific. Once Windows support for IPC is implemented, this
210-
# test should be updated.
211-
if not device.properties.handle_type_posix_file_descriptor_supported:
212-
pytest.skip("Device does not support IPC")
213-
214-
# Skip on WSL or if driver rejects IPC-enabled mempool creation on this platform/device
215-
from helpers import IS_WSL, supports_ipc_mempool
216-
217-
if IS_WSL or not supports_ipc_mempool(device):
218-
pytest.skip("Driver rejects IPC-enabled mempool creation on this platform")
219-
220-
return device
223+
return _require_ipc_mempool_devices((device,))[0]
221224

222225

223226
@pytest.fixture(
@@ -289,15 +292,7 @@ def mempool_device_x3():
289292
@pytest.fixture
290293
def ipc_mempool_device_x2(mempool_device_x2):
291294
"""Fixture that provides two IPC-capable mempool devices, or skips."""
292-
from helpers import IS_WSL, supports_ipc_mempool
293-
294-
if not all(device.properties.handle_type_posix_file_descriptor_supported for device in mempool_device_x2):
295-
pytest.skip("Device does not support IPC")
296-
297-
if IS_WSL or not all(supports_ipc_mempool(device) for device in mempool_device_x2):
298-
pytest.skip("Driver rejects IPC-enabled mempool creation on this platform")
299-
300-
return mempool_device_x2
295+
return _require_ipc_mempool_devices(mempool_device_x2)
301296

302297

303298
@pytest.fixture(

0 commit comments

Comments
 (0)