diff --git a/cuda_bindings/tests/nvml/test_util.py b/cuda_bindings/tests/nvml/test_util.py new file mode 100644 index 00000000000..2eb46647777 --- /dev/null +++ b/cuda_bindings/tests/nvml/test_util.py @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + + +import pytest + +from cuda.bindings import nvml + +from . import util + + +class _FakeFieldValue: + nvml_return = nvml.Return.SUCCESS + + +@pytest.mark.agent_authored(model="claude-opus-5") +def test_supports_nvlink_queries_a_real_field_id(monkeypatch): + """The helper has to name an enum that exists; nvml.FI never did.""" + queried = {} + + def fake_device_get_field_values(device, fields): + queried["field_id"] = fields[0].field_id + return [_FakeFieldValue()] + + monkeypatch.setattr(nvml, "device_get_field_values", fake_device_get_field_values) + + assert util.supports_nvlink(object()) is True + assert queried["field_id"] == nvml.FieldId.DEV_NVLINK_GET_STATE diff --git a/cuda_bindings/tests/nvml/util.py b/cuda_bindings/tests/nvml/util.py index 129ded8f83c..7d63a141706 100644 --- a/cuda_bindings/tests/nvml/util.py +++ b/cuda_bindings/tests/nvml/util.py @@ -22,5 +22,5 @@ def supports_ecc(device): def supports_nvlink(device): fields = nvml.FieldValue(1) - fields[0].field_id = nvml.FI.DEV_NVLINK_GET_STATE + fields[0].field_id = nvml.FieldId.DEV_NVLINK_GET_STATE return nvml.device_get_field_values(device, fields)[0].nvml_return == nvml.Return.SUCCESS