Skip to content

Commit 0e5935e

Browse files
committed
CI: Optionally skip tests that raise CUDA API errors
1 parent dde857b commit 0e5935e

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

cuda_bindings/tests/test_cuda.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8+
import os
89
import platform
910
import shutil
1011
import textwrap
@@ -83,6 +84,10 @@ def test_cuda_memcpy():
8384
assert err == cuda.CUresult.CUDA_SUCCESS
8485

8586

87+
@pytest.mark.skipif(
88+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
89+
reason="The compute-sanitzer is running, and this test intentionally causes an API error.",
90+
)
8691
def test_cuda_array():
8792
(err,) = cuda.cuInit(0)
8893
assert err == cuda.CUresult.CUDA_SUCCESS
@@ -236,6 +241,10 @@ def test_cuda_uuid_list_access():
236241
assert err == cuda.CUresult.CUDA_SUCCESS
237242

238243

244+
@pytest.mark.skipif(
245+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
246+
reason="FIXME: This test causes an API error.",
247+
)
239248
def test_cuda_cuModuleLoadDataEx():
240249
(err,) = cuda.cuInit(0)
241250
assert err == cuda.CUresult.CUDA_SUCCESS
@@ -251,6 +260,7 @@ def test_cuda_cuModuleLoadDataEx():
251260
cuda.CUjit_option.CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES,
252261
cuda.CUjit_option.CU_JIT_LOG_VERBOSE,
253262
]
263+
# FIXME: This function call raises CUDA_ERROR_INVALID_VALUE
254264
err, mod = cuda.cuModuleLoadDataEx(0, 0, option_keys, [])
255265

256266
(err,) = cuda.cuCtxDestroy(ctx)
@@ -622,6 +632,10 @@ def test_cuda_coredump_attr():
622632
assert err == cuda.CUresult.CUDA_SUCCESS
623633

624634

635+
@pytest.mark.skipif(
636+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
637+
reason="The compute-sanitzer is running, and this test intentionally causes an API error.",
638+
)
625639
def test_get_error_name_and_string():
626640
(err,) = cuda.cuInit(0)
627641
assert err == cuda.CUresult.CUDA_SUCCESS
@@ -950,6 +964,10 @@ def test_CUmemDecompressParams_st():
950964
assert int(desc.dstActBytes) == 0
951965

952966

967+
@pytest.mark.skipif(
968+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
969+
reason="The compute-sanitzer is running, and this test intentionally causes an API error.",
970+
)
953971
def test_all_CUresult_codes():
954972
max_code = int(max(cuda.CUresult))
955973
# Smoke test. CUDA_ERROR_UNKNOWN = 999, but intentionally using literal value.
@@ -982,12 +1000,20 @@ def test_all_CUresult_codes():
9821000
assert num_good >= 76 # CTK 11.0.3_450.51.06
9831001

9841002

1003+
@pytest.mark.skipif(
1004+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
1005+
reason="The compute-sanitzer is running, and this test intentionally causes an API error.",
1006+
)
9851007
def test_cuKernelGetName_failure():
9861008
err, name = cuda.cuKernelGetName(0)
9871009
assert err == cuda.CUresult.CUDA_ERROR_INVALID_VALUE
9881010
assert name is None
9891011

9901012

1013+
@pytest.mark.skipif(
1014+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
1015+
reason="The compute-sanitzer is running, and this test intentionally causes an API error.",
1016+
)
9911017
def test_cuFuncGetName_failure():
9921018
err, name = cuda.cuFuncGetName(0)
9931019
assert err == cuda.CUresult.CUDA_ERROR_INVALID_VALUE

cuda_bindings/tests/test_cudart.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# is strictly prohibited.
88
import ctypes
99
import math
10+
import os
1011

1112
import numpy as np
1213
import pytest
@@ -70,6 +71,10 @@ def test_cudart_memcpy():
7071
assertSuccess(err)
7172

7273

74+
@pytest.mark.skipif(
75+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
76+
reason="The compute-sanitzer is running, and this test intentionally causes an API error.",
77+
)
7378
def test_cudart_hostRegister():
7479
# Use hostRegister API to check for correct enum return values
7580
page_size = 80

cuda_core/tests/test_cuda_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
22
#
33
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4+
import os
45

56
import pytest
67

@@ -40,6 +41,13 @@ def test_runtime_cuda_error_explanations_health():
4041
assert not extra_expl
4142

4243

44+
@pytest.mark.skipif(
45+
os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") == "1",
46+
reason=(
47+
"The compute-sanitzer is running, and this test causes an API error "
48+
"when the driver is too old to know about all of the error codes."
49+
),
50+
)
4351
def test_check_driver_error():
4452
num_unexpected = 0
4553
for error in driver.CUresult:

cuda_core/tests/test_event.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ def test_event_init_disabled():
2020
cuda.core.experimental._event.Event() # Ensure back door is locked.
2121

2222

23-
@pytest.mark.parametrize("enable_timing", [True, False, None])
23+
@pytest.mark.parametrize(
24+
"enable_timing",
25+
[
26+
True,
27+
]
28+
+ ([False, None] if os.environ.get("CUDA_PYTHON_SANITIZER_RUNNING", "0") != "1" else []),
29+
)
2430
def test_timing(init_cuda, enable_timing):
2531
options = EventOptions(enable_timing=enable_timing)
2632
stream = Device().create_stream()

0 commit comments

Comments
 (0)