Module fake_queue

Source
Expand description

Fake queue for simulating driver interactions in unittests

To facilitate writing unittests it is useful to manipulate the queues from the perspective of a a driver. This module contains helpers that allow for:

  • Building simple descriptor chains
  • Publishing the build descriptors in the available ring
  • Receiving written descriptors from the used ring This functionality centers around the FakeQueue implementation.

For simplicity of writing tests the TestQueue struct packages together all the pieces commonly needed to write a test.

This module is available as, in addition to be used for writing the unittests for this library, it can also be used for writing unittests for actual virtio device drivers without needing a guest environment.

Structsยง

Chain
Descriptor chain that can be published in a FakeQueue
ChainBuilder
Builder for a Chain
ChainDataIter
Iterator for the data in a UsedChain
FakeQueue
Simulates driver side interactions of a queue for facilitating tests.
IdentityDriverMem
Implementation of crate::mem::DriverMem assuming the identity translation.
TestQueue
Wraps common state needed for writing test code with a FakeQueue.
UsedChain
Represents a chain returned by a device.