CI was updated and now claims higher code coverage. Adjusting the values
to what the CI claims now.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
CI complains not only when the score is too low but also when it is
too high. Accommodate the increased average coverage caused by adding
vhost-device-scmi and its unit tests.
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
There was a mix of just unwrapping (panicking) and catching and logging
errors. The unwrapping is not allowing for particulary pretty error
handling, so let's bubble the errors up by not crashing the thread,
but by just returning a Result<()> than is received when joining the
threads.
Not all .unwrap() uses were translated since a followup PR (#389) will
rework that code anyway (and get rid of the .unwrap() in the process).
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
We setup pretty-printing with all the thiserror-based Error structs, but
then only bubble the error up to the main, where it just gets printed
with the `Debug` trait.
This "catches" the error in the main and performs pretty printing using
the `Display` trait.
Before:
Error: FailedCreatingListener(SocketError(Os { code: 98, kind:
AddrInUse, message: "Address already in use" }))
After:
[2023-07-06T17:20:47Z ERROR vhost_device_scsi] Failed creating
listener: socket error: Address already in use (os error 98)
vhost-device-vsock is a bit special since it does not let error messages
bubble up to the main. It also does .unwrap() in most places, but it
_does_ pretty print errors during the main request handling part.
Had to slightly adjust the coverage since we have no tests for the main
functions.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
The upstream version doesn't compile the .c files locally and depends on
the package to be locally compiled and installed in advance.
It also doesn't provide pre-generated bindings, and requires bindgen
support.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Add several tests to get good coverage. Unfortunately,
it's a lot of new code and not easy to test everything.
We may add more mocks and tests in the future.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This patch adds testing modules for both main.rs and vu_rng.rs
in order to satisfy functional testing and code coverage.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
The i2c crate now uses log crate to publish error, info and warn
messages, but doesn't initialize a logger yet and these messages never
make it out.
Initialize the env_logger to see these messages.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
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>