Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions cuda_bindings/pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cuda_bindings/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ repair-wheel-command = "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wh
required_plugins = "pytest-benchmark"
addopts = "--benchmark-disable --showlocals"
norecursedirs = ["tests/cython", "examples"]
xfail_strict = true
54 changes: 30 additions & 24 deletions cuda_bindings/tests/test_cufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import pathlib
import platform
import subprocess
import tempfile
from contextlib import suppress
from functools import cache
Expand All @@ -24,7 +25,9 @@
try:
from cuda.bindings import cufile
except ImportError:
cufile = None
cufile = cuFileError = None
else:
from cuda.bindings.cufile import cuFileError


def platform_is_wsl():
Expand Down Expand Up @@ -92,34 +95,24 @@ def cufileVersionLessThan(target):

@cache
def isSupportedFilesystem():
"""Check if the current filesystem is supported (ext4 or xfs)."""
try:
# Try to get filesystem type from /proc/mounts
with open("/proc/mounts") as f:
for line in f:
parts = line.split()
if len(parts) >= 2:
mount_point = parts[1]
fs_type = parts[2]

# Check if current directory is under this mount point
current_dir = os.path.abspath(".")
if current_dir.startswith(mount_point):
fs_type_lower = fs_type.lower()
logging.info(f"Current filesystem type: {fs_type_lower}")
return fs_type_lower in ["ext4", "xfs"]

# If we get here, we couldn't determine the filesystem type
logging.warning("Could not determine filesystem type from /proc/mounts")
return False
except Exception as e:
logging.error(f"Error checking filesystem type: {e}")
return False
"""Check if the current filesystem is supported (ext4 or xfs).

This uses `findmnt` so the kernel's mount table logic owns the decoding of the filesystem type.
"""
fs_type = subprocess.check_output(["findmnt", "-no", "FSTYPE", "-T", os.getcwd()], text=True).strip() # noqa: S603, S607
logging.info(f"Current filesystem type (findmnt): {fs_type}")
return fs_type in ("ext4", "xfs")


# Global skip condition for all tests if cuFile library is not available
pytestmark = pytest.mark.skipif(not cufileLibraryAvailable(), reason="cuFile library not available on this system")

xfail_handle_register = pytest.mark.xfail(
condition=isSupportedFilesystem() and os.environ.get("CI") is not None,
raises=cuFileError,
reason="handle_register call fails in CI for unknown reasons",
)


def test_cufile_success_defined():
"""Check if CUFILE_SUCCESS is defined in OpError enum."""
Expand Down Expand Up @@ -155,6 +148,7 @@ def driver(ctx):

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_handle_register():
"""Test file handle registration with cuFile."""
# Create test file
Expand Down Expand Up @@ -347,6 +341,7 @@ def test_buf_register_already_registered():

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_cufile_read_write():
"""Test cuFile read and write operations."""
# Create test file
Expand Down Expand Up @@ -437,6 +432,7 @@ def test_cufile_read_write():

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_cufile_read_write_host_memory():
"""Test cuFile read and write operations using host memory."""
# Create test file
Expand Down Expand Up @@ -523,6 +519,7 @@ def test_cufile_read_write_host_memory():

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_cufile_read_write_large():
"""Test cuFile read and write operations with large data."""
# Create test file
Expand Down Expand Up @@ -616,6 +613,7 @@ def test_cufile_read_write_large():

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("ctx")
@xfail_handle_register
def test_cufile_write_async(cufile_env_json):
"""Test cuFile asynchronous write operations."""
# Open cuFile driver
Expand Down Expand Up @@ -697,6 +695,7 @@ def test_cufile_write_async(cufile_env_json):

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("ctx")
@xfail_handle_register
def test_cufile_read_async(cufile_env_json):
"""Test cuFile asynchronous read operations."""
# Open cuFile driver
Expand Down Expand Up @@ -791,6 +790,7 @@ def test_cufile_read_async(cufile_env_json):

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("ctx")
@xfail_handle_register
def test_cufile_async_read_write(cufile_env_json):
"""Test cuFile asynchronous read and write operations in sequence."""
# Open cuFile driver
Expand Down Expand Up @@ -908,6 +908,7 @@ def test_cufile_async_read_write(cufile_env_json):

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_batch_io_basic():
"""Test basic batch IO operations with multiple read/write operations."""
# Create test file
Expand Down Expand Up @@ -1110,6 +1111,7 @@ def test_batch_io_basic():

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_batch_io_cancel():
"""Test batch IO cancellation."""
# Create test file
Expand Down Expand Up @@ -1193,6 +1195,7 @@ def test_batch_io_cancel():

@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("driver")
@xfail_handle_register
def test_batch_io_large_operations():
"""Test batch IO with large buffer operations."""
# Create test file
Expand Down Expand Up @@ -1584,6 +1587,7 @@ def test_stats_start_stop():
)
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("stats")
@xfail_handle_register
def test_get_stats_l1():
"""Test cuFile L1 statistics retrieval with file operations."""
# Create test file directly with O_DIRECT
Expand Down Expand Up @@ -1663,6 +1667,7 @@ def test_get_stats_l1():
)
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("stats")
@xfail_handle_register
def test_get_stats_l2():
"""Test cuFile L2 statistics retrieval with file operations."""
# Create test file directly with O_DIRECT
Expand Down Expand Up @@ -1746,6 +1751,7 @@ def test_get_stats_l2():
)
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
@pytest.mark.usefixtures("stats")
@xfail_handle_register
def test_get_stats_l3():
"""Test cuFile L3 statistics retrieval with file operations."""
# Create test file directly with O_DIRECT
Expand Down
Loading