Add tests to validate processing of descriptors and read/write data.
The design is based on the virtio_queue::mock::MockSplitQueue
implementation, which is used to add a set of descriptors to the memory.
The same memory is then processed via DescriptorChain and the same set
of descriptors magically appear.
This patch adds various tests for success and failure and also validate
the data read or written.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Commands like SMBUS Quick don't require a buffer for the request and are
called as zero-length requests. The specification allows such requests
under the VIRTIO_I2C_F_ZERO_LENGTH_REQUEST feature, which is mandatory
to be implemented by the devices now.
Add support for zero-length requests.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Add tests to validate the data processed by rdwr() and smbus(). The
coverage score went up significantly as a result of all recent tests.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The data needs to be sent for I2C_SMBUS_BYTE command and we need to make
sure we don't access the same for I2C_SMBUS_QUICK command after the
command is processed.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reorganize SmbusMsg::new() to return Result<> from the match block
itself.
Suggested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Pointer access is inherently unsafe in Rust, change the layout of
structures to avoid using that.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Before the constructor of this function was opening the device
corresponding to the passed path. This did not allow for properly
mocking the device functionality. Now the device is passed as a
parameter instead, which allows us to tweak what the device returns for
ioctl calls, and we can thus test multiple scenarios.
Signed-off-by: Andreea Florescu <fandree@amazon.com>
Coverage is now increased by ~9%. Further tests should be relatively
straightforward to write by using the mock structure `DummyDevice`.
Signed-off-by: Andreea Florescu <fandree@amazon.com>
This still doesn't emulate the descriptors and descriptor chains over
the vrings. That will be added later.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reduce the test coverage score as the files apart from i2c.rs are
mostly boilerplate code and it is difficult to test them as well as it
may not be worth it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>