mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-26 22:48:17 +00:00
[i2c] Add a test to check the working of funcs()
The funcs() implementation is buggy as it doesn't take "func" by reference and it only defaults to SMBUS and hence the I2C protocol is never chosen as a function. This test fails currently. Suggested-by: Andreea Florescu <fandree@amazon.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
parent
91d84b481e
commit
e28f3af61b
@ -552,6 +552,23 @@ pub mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_funcs() {
|
||||
let i2c_device = DummyDevice {
|
||||
funcs_result: I2C_FUNC_SMBUS_ALL as i32,
|
||||
..Default::default()
|
||||
};
|
||||
let adapter = I2cAdapter::new(i2c_device).unwrap();
|
||||
assert_eq!(adapter.smbus, true);
|
||||
|
||||
let i2c_device = DummyDevice {
|
||||
funcs_result: I2C_FUNC_I2C as i32,
|
||||
..Default::default()
|
||||
};
|
||||
let adapter = I2cAdapter::new(i2c_device).unwrap();
|
||||
assert_eq!(adapter.smbus, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_i2c_map() {
|
||||
let adapter_config = AdapterConfig::try_from("1:4,2:32:21,5:10:23").unwrap();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user