Skip to content

Commit 9e42947

Browse files
rluo8rwgk
andauthored
test: skip IPC peer access tests when IPC is unavailable (#2092)
* test: skip IPC peer access tests when IPC is unavailable * 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. --------- Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
1 parent e7a94d4 commit 9e42947

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

cuda_core/tests/conftest.py

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

44
import multiprocessing
@@ -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(
@@ -286,6 +289,12 @@ def mempool_device_x3():
286289
return _mempool_device_impl(3)
287290

288291

292+
@pytest.fixture
293+
def ipc_mempool_device_x2(mempool_device_x2):
294+
"""Fixture that provides two IPC-capable mempool devices, or skips."""
295+
return _require_ipc_mempool_devices(mempool_device_x2)
296+
297+
289298
@pytest.fixture(
290299
params=[
291300
pytest.param((DeviceMemoryResource, DeviceMemoryResourceOptions), id="DeviceMR"),

cuda_core/tests/memory_ipc/test_peer_access.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class TestPeerAccessNotPreservedOnImport:
2121
"""
2222

2323
@pytest.mark.flaky(reruns=2)
24-
def test_main(self, mempool_device_x2):
25-
dev0, dev1 = mempool_device_x2
24+
def test_main(self, ipc_mempool_device_x2):
25+
dev0, dev1 = ipc_mempool_device_x2
2626

2727
# Parent Process - Create and Configure MR
2828
dev1.set_current()
@@ -61,8 +61,8 @@ class TestBufferPeerAccessAfterImport:
6161

6262
@pytest.mark.flaky(reruns=2)
6363
@pytest.mark.parametrize("grant_access_in_parent", [True, False])
64-
def test_main(self, mempool_device_x2, grant_access_in_parent):
65-
dev0, dev1 = mempool_device_x2
64+
def test_main(self, ipc_mempool_device_x2, grant_access_in_parent):
65+
dev0, dev1 = ipc_mempool_device_x2
6666

6767
# Parent Process - Create MR and Buffer
6868
dev1.set_current()

0 commit comments

Comments
 (0)