Skip to content

[SUBISSUE #5] Add KernelPlatformServices Host Tests and Kernel Shell DDK Verification Suite #254

Done

Description

@marcobuschini

Parent issue: #72 (follows #250, #251, #252, #253)

Problem

While drivers/dummy/ has host unit tests in tests/host/ddk_dummy_test.cpp using MockPlatformServices, the kernel-side DDK bridge (kernel/ddk/KernelPlatformServices.cpp) and end-to-end QEMU execution of DummyDriver against KernelPlatformServices are not yet directly tested.

Scope

  1. Host Unit Tests for KernelPlatformServices (tests/host/ddk_kernel_services_test.cpp):
    • map_mmio() / unmap_mmio(): reject zero paddr/size with Status::InvalidArg, return valid MmioRegion for valid MMIO addresses.
    • alloc_dma() / free_dma(): verify page-aligned allocation via MM::PageFrameAllocator, Status::Unsupported for align > page_size, Status::OutOfMemory on PFA exhaustion, and zero physical frame leaks (pfa_free_pages_count()) after DmaBuffer RAII destruction.
    • register_irq() / unregister_irq(): verify HAL::Platform::irq_register_handler() registration, irq_dispatch() trampoline invocation, Status::Busy on duplicate IRQ registration, and IrqHandle RAII unregistration.
    • acquire_irq_lock() / IrqLock: verify CPU interrupt enable/disable state preservation across lock/unlock and move semantics.
    • create_event() / destroy_event() / wake_one() / wake_all(): verify MAX_EVENTS slot pool allocation, Status::OutOfMemory when exhausted, and slot reclamation on EventHandle destruction.
    • log(): verify LogLevel mapping into Kernel::Log ring buffer.
  2. Kernel Shell test ddk Suite (kernel/shell/tests/test_ddk.cpp):
    • Add test ddk command in kernel/shell/shell.cpp and wire it into test all.
    • Instantiate DummyDriver via DriverMetadata against Kernel::DDK::kernel_platform_services() in QEMU, exercising probe(), init(), DMA zeroing, IrqLock, EventHandle, shutdown(), and zero PFA frame leaks.
  3. Out-of-Tree DDK Build Check:
    • Verify make export-ddk + standalone build of drivers/dummy/ against MILO_DDK_DIR=build/ddk succeeds cleanly.

Acceptance Criteria

  • tests/host/ddk_kernel_services_test.cpp passes under ASan/UBSan (make test-host).
  • test ddk and test all pass in QEMU with failed=0.
  • make format && make all && make export-ddk && make quality passes with zero warnings.

Metadata

Metadata

Assignees

Labels

subissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions