Skip to content

Commit 3dfafba

Browse files
committed
cmdline: update test for new virtio-net arguments
Signed-off-by: Jake Correnti <[email protected]>
1 parent 0f42cdd commit 3dfafba

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/cmdline.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ mod tests {
380380
"virtio-gpu,width=800,height=600",
381381
"--device",
382382
"virtio-input,keyboard",
383+
"--device",
384+
"virtio-net,unixgram=/Users/user/net.sock,mac=00:00:00:00:00:00,offloading=true,vfkitMagic=true",
383385
"--restful-uri",
384386
"tcp://localhost:49573",
385387
"--gui",
@@ -389,6 +391,23 @@ mod tests {
389391

390392
let mut args = Args::try_parse_from(cmdline).unwrap();
391393

394+
let net = args
395+
.devices
396+
.pop()
397+
.expect("expected 11th virtio device config");
398+
if let VirtioDeviceConfig::Net(net) = net {
399+
if let SocketConfig::UnixGram(path, offloading, send_vfkit_magic) = net.socket {
400+
assert_eq!(path, PathBuf::from_str("/Users/user/net.sock").unwrap());
401+
assert_eq!(offloading, true);
402+
assert_eq!(send_vfkit_magic, true);
403+
} else {
404+
panic!("expected virtio-net device to use the unixSocketPath argument");
405+
}
406+
assert_eq!(net.mac_address, MacAddress::new([0, 0, 0, 0, 0, 0]));
407+
} else {
408+
panic!("expected virtio-net device as 11th device config argument");
409+
}
410+
392411
let input = args
393412
.devices
394413
.pop()
@@ -441,10 +460,11 @@ mod tests {
441460
.pop()
442461
.expect("expected 6th virtio device config");
443462
if let VirtioDeviceConfig::Net(net) = net {
444-
assert_eq!(
445-
net.unix_socket_path,
446-
PathBuf::from_str("/Users/user/net.sock").unwrap()
447-
);
463+
if let SocketConfig::UnixSocketPath(path) = net.socket {
464+
assert_eq!(path, PathBuf::from_str("/Users/user/net.sock").unwrap());
465+
} else {
466+
panic!("expected virtio-net device to use the unixSocketPath argument");
467+
}
448468
assert_eq!(net.mac_address, MacAddress::new([0, 0, 0, 0, 0, 0]));
449469
} else {
450470
panic!("expected virtio-net device as 6th device config argument");

0 commit comments

Comments
 (0)