@@ -380,6 +380,8 @@ mod tests {
380
380
"virtio-gpu,width=800,height=600" ,
381
381
"--device" ,
382
382
"virtio-input,keyboard" ,
383
+ "--device" ,
384
+ "virtio-net,unixgram=/Users/user/net.sock,mac=00:00:00:00:00:00,offloading=true,vfkitMagic=true" ,
383
385
"--restful-uri" ,
384
386
"tcp://localhost:49573" ,
385
387
"--gui" ,
@@ -389,6 +391,23 @@ mod tests {
389
391
390
392
let mut args = Args :: try_parse_from ( cmdline) . unwrap ( ) ;
391
393
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
+
392
411
let input = args
393
412
. devices
394
413
. pop ( )
@@ -441,10 +460,11 @@ mod tests {
441
460
. pop ( )
442
461
. expect ( "expected 6th virtio device config" ) ;
443
462
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
+ }
448
468
assert_eq ! ( net. mac_address, MacAddress :: new( [ 0 , 0 , 0 , 0 , 0 , 0 ] ) ) ;
449
469
} else {
450
470
panic ! ( "expected virtio-net device as 6th device config argument" ) ;
0 commit comments