Trait TestDriver

Source
pub trait TestDriver {
    type Error: Error + 'static;

    // Required method
    fn write_input_and_read_output(
        &mut self,
        inputs: &[InputEntry<'_>],
    ) -> Result<Vec<OutputEntry<'_>>, Self::Error>;

    // Provided method
    fn write_input(
        &mut self,
        inputs: &[InputEntry<'_>],
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Communicate with the device under test

The main function of interest is write_input_and_read_output which should write the provided inputs to the device under test (DUT), wait for the outputs to stabilize, and then read the output values and return a them to the caller.

We have chosen to use a single function write_input_and_read_output for both input and output, instead of more generic write_input and read_output functions, since knowing that the output is only ever read right after some input was provided can simplify implementing the driver. For example a simple driver can work over a simple serial interface, where it writes the inputs to the DUT (maybe through some sort of test bed) and then get the resulting outputs back.

Required Associated Types§

Source

type Error: Error + 'static

Error returned by the driver

Required Methods§

Source

fn write_input_and_read_output( &mut self, inputs: &[InputEntry<'_>], ) -> Result<Vec<OutputEntry<'_>>, Self::Error>

Write input to the device under test and return the resulting output values

The list of output values should always be returned in the same order.

Provided Methods§

Source

fn write_input(&mut self, inputs: &[InputEntry<'_>]) -> Result<(), Self::Error>

Write input to the device under test

By default this simply calls Self::write_input_and_read_output and ignores the output. An optimized driver can directly implement this method to avoid reading the output which might be costly.

Implementors§