Skip to main content

Crate mock_mmio

Crate mock_mmio 

Source
Expand description

Support for mocking MMIO regions.

This crate provides the type MockMemoryOps allowing expectations to be set on accesses to a block of memory. This type is generated by the mockall crate - see its documentation for setting expectations.

§Usage Example

use mmio::Mmio;
use mockall::predicate::eq;
let mut ops = MockMemoryOps::new();
// Expect a single load32 call at offset 64, returning the value 0xabcd.
ops.expect_load32()
    .times(1)
    .with(eq(64))
    .return_const(0xabcd_u32);

let len = 1024;
// Create an MMIO region using the given mock ops and of the given size.
// The returned region may be split and sent to other threads.
let mmio = new_mock_mmio(&ops, len);
assert_eq!(mmio.load32(64), 0xabcd_u32);

Modules§

__mock_MockMemoryOps

Structs§

MockMemoryOps

Functions§

new_mock_mmio
Create a mock MMIO operation of the given len that uses the given mock ops.