test: add unit tests for IDE DMA engine #1591
Draft
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.
This PR adds comprehensive unit tests for the IDE DMA engine to improve test coverage of the complex DMA functionality that was modified in #633.
Changes
Added 5 focused unit tests that exercise the core DMA engine functionality in
perform_dma_memory_phase
:test_dma_read_multiple_prds
- Tests DMA read operations with multiple Physical Region Descriptors (PRDs), ensuring the DMA engine correctly processes descriptor chainstest_dma_write_multiple_prds
- Tests DMA write operations with multiple PRDs, validating data transfer across multiple memory regionstest_dma_read_zero_byte_count
- Tests the edge case where a PRD has zero byte count, which should be interpreted as 64KB according to the IDE specificationtest_dma_descriptor_read_error
- Tests error handling when DMA descriptor table reads fail due to invalid memory addressestest_dma_prd_boundary_handling
- Tests PRD boundary logic and descriptor chaining with different sized regionsBackground
The IDE DMA engine is a complex component that handles Physical Region Descriptor (PRD) tables for scatter-gather DMA operations. Issue #633 fixed a bug related to PRD exhaustion during write operations, but this area lacked comprehensive unit tests, making it difficult to reason about future changes.
These tests use the existing enlightened interface to trigger DMA operations while focusing on different DMA scenarios and edge cases that exercise the core engine logic.
Testing
All new tests pass and existing IDE tests continue to work:
Fixes #1587.
💡 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.