Skip to content

cuda.core: Fix graphics tests - #2701

Open
juenglin wants to merge 7 commits into
NVIDIA:mainfrom
juenglin:graphics-tests
Open

cuda.core: Fix graphics tests#2701
juenglin wants to merge 7 commits into
NVIDIA:mainfrom
juenglin:graphics-tests

Conversation

@juenglin

@juenglin juenglin commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

The GL context helpers in cuda_core/tests/test_graphics.py and cuda_bindings/tests/test_graphics_apis.py wrapped yield in except Exception and called pytest.skip(), so CUDA errors, assertion failures, and TypeErrors raised in the test body were recorded as "could not create GL context" skips rather than failures. The cuda_core graphics tests also never requested init_cuda, so whether from_gl_buffer / from_gl_image succeeded depended on leftover thread state from the previous test (pytest-randomly seed).

This PR:

  • Splits each helper into a plain setup function (_configure_pyglet_headless, _open_gl_window, _setup_gl_buffer, _setup_gl_texture) and a thin context manager that wraps only the setup call in try/except so test-body exceptions propagate as failures.
  • Adds init_cuda to every cuda_core graphics test that touches CUDA, and uses init_cuda.create_stream() instead of a local _create_stream() helper.
  • Converts the cuda_core test classes to plain test functions (they carried no shared state or fixtures).
  • Fixes two StridedMemoryView.from_buffer call sites that passed dtype=np.float32 (a scalar type class) instead of np.dtype(np.float32).
  • Marks test_close_while_mapped_passes_stream_override as xfail(strict=True) because Buffer is an immutable Cython type and neither patch.object nor __class__ assignment can intercept Buffer.close.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 25, 2026
@juenglin juenglin added bug Something isn't working P0 High priority - Must do! test Improvements or additions to tests labels Aug 25, 2026
@juenglin juenglin added this to the cuda.core 1.2.0 milestone Aug 25, 2026
@juenglin juenglin self-assigned this Aug 25, 2026
Stop treating graphics test-body failures as GL-unavailable skips, and bind a CUDA context in those tests so missing thread state cannot hide real errors.
@juenglin

Copy link
Copy Markdown
Contributor Author

/ok to test baf3e23

@github-actions

Copy link
Copy Markdown


with patch.object(Buffer, "close", new=tracking_close):
resource.close(stream=close_stream)
@pytest.mark.xfail(

@juenglin juenglin Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get this test to work. Should I remove it?

============================================================= short test summary info =============================================================
FAILED cuda_core/tests/test_graphics.py::test_close_while_mapped_passes_stream_override - TypeError: cannot set 'close' attribute of immutable type 'cuda.core._memory._buffer.Buffer'
========================================================== 1 failed, 29 passed in 0.63s ===========================================================

@juenglin
juenglin marked this pull request as ready for review August 26, 2026 14:51
@github-actions github-actions Bot added the cuda.bindings Everything related to the cuda.bindings module label Aug 26, 2026
@juenglin

Copy link
Copy Markdown
Contributor Author

/ok to test 8fbb9cf

@juenglin

Copy link
Copy Markdown
Contributor Author

pre-commit.ci run

@juenglin

Copy link
Copy Markdown
Contributor Author

/ok to test 5dc9814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module P0 High priority - Must do! test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant