pub struct MockMmioRegionBuilder { /* private fields */ }Expand description
Strict thread-safe mock (interaction testing) for MMIO (MmioRegion).
The MmioRegion implementation imposes a global ordering on MMIO accesses
performed by multiple threads. If the code under test uses a non-thread-safe
MmioRegion implementation, the mock introduces cross-thread
synchronization points that do not exist in the code under test.
Expectations are verified after this builder and all the MockMmioRegions
it produced are dropped. Tests do not need to keep the builder alive while
the code under test uses the regions. Conversely, dropping the builder does
not verify expectations while a region is still in use.
Implementations§
Source§impl MockMmioRegionBuilder
impl MockMmioRegionBuilder
Sourcepub fn new(region_size_bytes: usize) -> Self
pub fn new(region_size_bytes: usize) -> Self
Creates a new mock MMIO region covering region_size_bytes bytes.
Sourcepub fn region_size_bytes(&self) -> usize
pub fn region_size_bytes(&self) -> usize
Returns the configured region size in bytes.
Sourcepub fn expect<F: FnOnce(&mut ExpectedTraceBuilder<'_>)>(&self, f: F)
pub fn expect<F: FnOnce(&mut ExpectedTraceBuilder<'_>)>(&self, f: F)
Posts expectations using the closure trace builder.
ExpectedTraceBuilder implements the expectation API provided to the
closure.
Expectations posted by multiple calls are appended to a single global expectation list, in call order.
Sourcepub fn build(&self) -> MockMmioRegion
pub fn build(&self) -> MockMmioRegion
Constructs a splittable, sendable MmioRegion wrapping this mock.
The returned region, and any sub-region split off of it, keeps the expectation list alive. Expectations are verified when the last region and this builder are dropped.