Skip to content

Commit dca3469

Browse files
committed
test(bindings): Fix unsupported FS check in cufile
This is a follow-up from making cufile tests use temporary directories as noted by Leo I don't think QA is a problem, because the previous xfail was guarded by having `CI` in the environment variables. However, the `isSupportedFilesystem` was using the wrong directory now as we are now running the test in the temporary directory. My suspicion is that there is some additional check that would be strictly needed (e.g. to check that it isn't just ext4 but also directly mounted on a local nvme device) but I have not figured out a check for that.
1 parent ac3b15d commit dca3469

1 file changed

Lines changed: 23 additions & 31 deletions

File tree

cuda_bindings/tests/test_cufile.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,20 @@ def cufileVersionLessThan(target):
7878
return True # Assume old version if any error occurs
7979

8080

81-
@cache
82-
def isSupportedFilesystem():
83-
"""Check if the current filesystem is supported (ext4 or xfs).
81+
@pytest.fixture(scope="session")
82+
def skipIfUnsupportedFilesystem(tmpdir_factory):
83+
"""Fixture that skips if the current filesystem is supported (ext4 or xfs).
84+
85+
The actual requirements are probably both stricter (ext4 was not working on CI previously)
86+
and possibly also less strict.
8487
8588
This uses `findmnt` so the kernel's mount table logic owns the decoding of the filesystem type.
8689
"""
87-
fs_type = subprocess.check_output(["findmnt", "-no", "FSTYPE", "-T", os.getcwd()], text=True).strip() # noqa: S603, S607
90+
cmd = ["findmnt", "-no", "FSTYPE", "-T", tmpdir_factory.getbasetemp()]
91+
fs_type = subprocess.check_output(cmd, text=True).strip() # noqa S603, S607
8892
logging.info(f"Current filesystem type (findmnt): {fs_type}")
89-
return fs_type in ("ext4", "xfs")
93+
if fs_type not in ("ext4", "xfs"):
94+
pytest.skip("cuFile handle_register requires ext4 or xfs filesystem")
9095

9196

9297
@cache
@@ -195,8 +200,7 @@ def driver(ctx):
195200
cufile.driver_close()
196201

197202

198-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
199-
@pytest.mark.usefixtures("driver")
203+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
200204
def test_handle_register(tmpdir):
201205
"""Test file handle registration with cuFile."""
202206
# Create test file
@@ -385,8 +389,7 @@ def test_buf_register_already_registered():
385389
cuda.cuMemFree(buf_ptr)
386390

387391

388-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
389-
@pytest.mark.usefixtures("driver")
392+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
390393
def test_cufile_read_write(tmpdir):
391394
"""Test cuFile read and write operations."""
392395
# Create test file
@@ -469,8 +472,7 @@ def test_cufile_read_write(tmpdir):
469472
cuda.cuMemFree(read_buf)
470473

471474

472-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
473-
@pytest.mark.usefixtures("driver")
475+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
474476
def test_cufile_read_write_host_memory(tmpdir):
475477
"""Test cuFile read and write operations using host memory."""
476478
# Create test file
@@ -549,8 +551,7 @@ def test_cufile_read_write_host_memory(tmpdir):
549551
cuda.cuMemFreeHost(read_buf)
550552

551553

552-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
553-
@pytest.mark.usefixtures("driver")
554+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
554555
def test_cufile_read_write_large(tmpdir):
555556
"""Test cuFile read and write operations with large data."""
556557
# Create test file
@@ -636,8 +637,7 @@ def test_cufile_read_write_large(tmpdir):
636637
cuda.cuMemFree(read_buf)
637638

638639

639-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
640-
@pytest.mark.usefixtures("ctx", "cufile_env_json", "driver")
640+
@pytest.mark.usefixtures("ctx", "cufile_env_json", "driver", "skipIfUnsupportedFilesystem")
641641
def test_cufile_write_async(tmpdir):
642642
"""Test cuFile asynchronous write operations."""
643643
# Create test file
@@ -711,8 +711,7 @@ def test_cufile_write_async(tmpdir):
711711
os.close(fd)
712712

713713

714-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
715-
@pytest.mark.usefixtures("ctx", "cufile_env_json", "driver")
714+
@pytest.mark.usefixtures("ctx", "cufile_env_json", "driver", "skipIfUnsupportedFilesystem")
716715
def test_cufile_read_async(tmpdir):
717716
"""Test cuFile asynchronous read operations."""
718717
# Create test file
@@ -799,8 +798,7 @@ def test_cufile_read_async(tmpdir):
799798
os.close(fd)
800799

801800

802-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
803-
@pytest.mark.usefixtures("ctx", "cufile_env_json", "driver")
801+
@pytest.mark.usefixtures("ctx", "cufile_env_json", "driver", "skipIfUnsupportedFilesystem")
804802
def test_cufile_async_read_write(tmpdir):
805803
"""Test cuFile asynchronous read and write operations in sequence."""
806804
# Create test file
@@ -910,8 +908,7 @@ def test_cufile_async_read_write(tmpdir):
910908
os.close(fd)
911909

912910

913-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
914-
@pytest.mark.usefixtures("driver")
911+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
915912
def test_batch_io_basic(tmpdir):
916913
"""Test basic batch IO operations with multiple read/write operations."""
917914
# Create test file
@@ -1106,8 +1103,7 @@ def test_batch_io_basic(tmpdir):
11061103
cuda.cuMemFree(buf)
11071104

11081105

1109-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
1110-
@pytest.mark.usefixtures("driver")
1106+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
11111107
def test_batch_io_cancel(tmpdir):
11121108
"""Test batch IO cancellation."""
11131109
# Create test file
@@ -1183,8 +1179,7 @@ def test_batch_io_cancel(tmpdir):
11831179
cuda.cuMemFree(buf)
11841180

11851181

1186-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
1187-
@pytest.mark.usefixtures("driver")
1182+
@pytest.mark.usefixtures("driver", "skipIfUnsupportedFilesystem")
11881183
def test_batch_io_large_operations(tmpdir):
11891184
"""Test batch IO with large buffer operations."""
11901185
# Create test file
@@ -1585,8 +1580,7 @@ def test_stats_start_stop():
15851580
@pytest.mark.skipif(
15861581
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
15871582
)
1588-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
1589-
@pytest.mark.usefixtures("stats")
1583+
@pytest.mark.usefixtures("stats", "skipIfUnsupportedFilesystem")
15901584
@pytest.mark.thread_unsafe(reason="cuFile stats counters and collection state are process-global")
15911585
def test_get_stats_l1(tmpdir):
15921586
"""Test cuFile L1 statistics retrieval with file operations."""
@@ -1663,8 +1657,7 @@ def test_get_stats_l1(tmpdir):
16631657
@pytest.mark.skipif(
16641658
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
16651659
)
1666-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
1667-
@pytest.mark.usefixtures("stats")
1660+
@pytest.mark.usefixtures("stats", "skipIfUnsupportedFilesystem")
16681661
@pytest.mark.thread_unsafe(reason="cuFile stats counters and collection state are process-global")
16691662
def test_get_stats_l2(tmpdir):
16701663
"""Test cuFile L2 statistics retrieval with file operations."""
@@ -1745,8 +1738,7 @@ def test_get_stats_l2(tmpdir):
17451738
@pytest.mark.skipif(
17461739
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
17471740
)
1748-
@pytest.mark.skipif(not isSupportedFilesystem(), reason="cuFile handle_register requires ext4 or xfs filesystem")
1749-
@pytest.mark.usefixtures("stats")
1741+
@pytest.mark.usefixtures("stats", "skipIfUnsupportedFilesystem")
17501742
@pytest.mark.thread_unsafe(reason="cuFile stats counters and collection state are process-global")
17511743
def test_get_stats_l3(tmpdir):
17521744
"""Test cuFile L3 statistics retrieval with file operations."""

0 commit comments

Comments
 (0)