Add initial pytest test suite and wire it into CI#23
Merged
Conversation
- tests/conftest.py: session-scoped HIP binary fixtures, GPU/hipcc detection helpers - tests/test_imports.py: verify all public API symbols are importable - tests/test_kernels.py: kernel discovery, line mapping, instruction extraction, filtering, basic blocks, Kernel wrapper - tests/test_arguments.py: argument metadata, nested structs, typedef resolution, template instantiations - pyproject.toml: add [tool.pytest.ini_options] with testpaths and -v flag - .github/workflows/ci.yml: add 'Run pytest' step after editable install Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add unittests to CI for KernelDB
Add initial pytest test suite and wire it into CI
Mar 18, 2026
mawad-amd
reviewed
Mar 18, 2026
- Remove exc_type=ImportError from pytest.importorskip() calls (added in pytest 8.x; CI runs 7.3.2) - Consolidate granular single-assertion tests into broader per-feature tests: test_imports.py: 15 -> 3 tests test_kernels.py: 35 -> 5 tests test_arguments.py: 25 -> 5 tests Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
- Fix test_kernel_lines and test_basic_blocks_and_kernel_wrapper: get_kernel_lines() can return line 0, relax assertion from ln > 0 to ln >= 0 - Remove unused requires_hipcc / requires_gpu / requires_rocm marks from conftest.py (fixtures already handle skipping) - Remove @requires_rocm decorator from all test functions in test_kernels.py and test_arguments.py (fixtures handle it) - Remove 'from conftest import requires_rocm' imports from test files Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Each test file embeds its own HIP source and compiles inline. conftest.py reduced to just the requires_rocm skip marker. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
We compile the binary ourselves with -g, so this should never be absent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KernelDB had no Python tests. This adds a pytest suite covering the core library features and hooks it into the existing CI pipeline.
Test structure
tests/conftest.py– Environment detection (_hipcc_available,_gpu_available), arequires_rocmskip marker, inline HIP source snippets for five test scenarios, and session-scoped fixtures that compile each binary once viahipcc -g.tests/test_imports.py– Validates the public API contract: all symbols in__all__are importable,__version__is set, and key classes (KernelDB,Kernel,Instruction,BasicBlock,CDNAKernel,ArchDescriptor,HsaAgent,KernelArgument) are accessible.tests/test_kernels.py– Covers kernel discovery (get_kernels), source-line mapping, instruction extraction with attribute checks (disassembly,line,column,file_name), regex filtering semantics, basic block extraction, and the high-levelKernelwrapper properties (.lines,.assembly,.files,.signature).tests/test_arguments.py– Covers argument metadata (name, type, size, alignment), pointer/scalar sizes,Kernel.has_arguments(), nested struct member recursion (BoundingBox→Point3D), typedef preservation vs. resolution (resolve_typedefs=False/True), and template instantiation (scale_values<float>/scale_values<double>).Configuration
pyproject.tomlgains a[tool.pytest.ini_options]section (testpaths = ["tests"],-v).CI gets a Run pytest step that runs
pytest tests/ -vinside the Apptainer container after the editable install:All GPU-dependent tests skip automatically via
@requires_rocmwhenhipccor an HSA agent is not present; all test modules skip cleanly when the C++ extension is not compiled.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.