Skip to content

test: add unit tests for IDE DMA engine #1591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 25, 2025

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:

  1. test_dma_read_multiple_prds - Tests DMA read operations with multiple Physical Region Descriptors (PRDs), ensuring the DMA engine correctly processes descriptor chains
  2. test_dma_write_multiple_prds - Tests DMA write operations with multiple PRDs, validating data transfer across multiple memory regions
  3. test_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 specification
  4. test_dma_descriptor_read_error - Tests error handling when DMA descriptor table reads fail due to invalid memory addresses
  5. test_dma_prd_boundary_handling - Tests PRD boundary logic and descriptor chaining with different sized regions

Background

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:

running 14 tests
test drive::hard_drive::tests::test_lba ... ok
test tests::identify_test_cd ... ok
test tests::enlightened_cmd_test_incomplete_prd ... ok
test tests::enlightened_hdd_cmd_test ... ok
test tests::enlightened_cd_cmd_test ... ok
test tests::identify_test_hdd ... ok
test tests::software_reset_test ... ok
test tests::read_sectors_test ... ok
test tests::test_dma_descriptor_read_error ... ok
test tests::test_dma_prd_boundary_handling ... ok
test tests::test_dma_read_zero_byte_count ... ok
test tests::test_dma_read_multiple_prds ... ok
test tests::test_dma_write_multiple_prds ... ok
test tests::write_sectors_test ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

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.

Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] test: add unit tests for IDE DMA engine test: add unit tests for IDE DMA engine Jun 25, 2025
@Copilot Copilot AI requested a review from benhillis June 25, 2025 04:02
Copilot finished work on behalf of benhillis June 25, 2025 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: add unit tests for IDE DMA engine
2 participants