Skip to content

Commit

Permalink
test(mmds): Do not use MmdsNetworkStack::new() in tests
Browse files Browse the repository at this point in the history
There is no need to use MmdsNetworkStack::new() instead of
MmdsNetworkStack::new_with_defaults() in tests that pass the same
default values.

Signed-off-by: Takahiro Itazuri <[email protected]>
  • Loading branch information
zulinx86 committed Nov 14, 2024
1 parent 588c7f0 commit bc4da15
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions src/vmm/src/mmds/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,8 @@ mod tests {
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
let mut ns = MmdsNetworkStack::new(
mac,
ip,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
Arc::new(Mutex::new(Mmds::default())),
);
let mut ns =
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));

let mut eth =
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_ARP).unwrap();
Expand All @@ -580,14 +574,8 @@ mod tests {
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
let ns = MmdsNetworkStack::new(
mac,
ip,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
Arc::new(Mutex::new(Mmds::default())),
);
let ns =
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));

let mut eth =
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_IPV4).unwrap();
Expand All @@ -606,14 +594,8 @@ mod tests {
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
let mut ns = MmdsNetworkStack::new(
mac,
ip,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
Arc::new(Mutex::new(Mmds::default())),
);
let mut ns =
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));

// try IPv4 with detour_arp
let mut eth =
Expand Down

0 comments on commit bc4da15

Please sign in to comment.