mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-30 17:49:08 +00:00
Merge pull request #109 from vireshk/i2c/trim
i2c: Trim the device list to avoid errors
This commit is contained in:
commit
02fdac85e0
@ -163,9 +163,9 @@ impl TryFrom<I2cArgs> for I2cConfiguration {
|
||||
return Err(Error::SocketCountInvalid(0));
|
||||
}
|
||||
|
||||
let devices = AdapterConfig::try_from(args.device_list.as_str())?;
|
||||
let devices = AdapterConfig::try_from(args.device_list.trim())?;
|
||||
Ok(I2cConfiguration {
|
||||
socket_path: args.socket_path,
|
||||
socket_path: args.socket_path.trim().to_string(),
|
||||
socket_count: args.socket_count,
|
||||
devices,
|
||||
})
|
||||
@ -324,6 +324,12 @@ mod tests {
|
||||
fn test_parse_successful() {
|
||||
let socket_name = "vi2c.sock";
|
||||
|
||||
// Space before and after the device list and socket name
|
||||
let cmd_args = I2cArgs::from_args(" ./vi2c.sock", " 1:4 ", 1);
|
||||
let config = I2cConfiguration::try_from(cmd_args).unwrap();
|
||||
Listener::new(config.socket_path, true).unwrap();
|
||||
|
||||
// Valid configuration
|
||||
let cmd_args = I2cArgs::from_args(socket_name, "1:4,2:32:21,5:5:23", 5);
|
||||
let config = I2cConfiguration::try_from(cmd_args).unwrap();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user