mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: remove once_cell; superseded by std::*
We now have types in the Rust standard library. Dropping the dependency. I found this by using the `clippy::pedantic` group. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
100c6d8142
commit
4182ef91e0
@@ -506,11 +506,10 @@ impl AsRawFd for Tap {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::net::Ipv4Addr;
|
||||
use std::sync::{mpsc, Mutex};
|
||||
use std::sync::{mpsc, LazyLock, Mutex};
|
||||
use std::time::Duration;
|
||||
use std::{str, thread};
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use pnet::packet::ethernet::{EtherTypes, EthernetPacket, MutableEthernetPacket};
|
||||
use pnet::packet::ip::IpNextHeaderProtocols;
|
||||
use pnet::packet::ipv4::{Ipv4Packet, MutableIpv4Packet};
|
||||
@@ -525,13 +524,14 @@ mod tests {
|
||||
static DATA_STRING: &str = "test for tap";
|
||||
static SUBNET_MASK: &str = "255.255.255.0";
|
||||
|
||||
// We needed to have a mutex as a global variable, so we used once_cell for testing. The main
|
||||
// We needed to have a mutex as a global variable, so we use a once cell for testing. The main
|
||||
// potential problem, caused by tests being run in parallel by cargo, is creating different
|
||||
// TAPs and trying to associate the same address, so we hide the IP address &str behind this
|
||||
// mutex, more as a convention to remember to lock it at the very beginning of each function
|
||||
// susceptible to this issue. Another variant is to use a different IP address per function,
|
||||
// but we must remember to pick an unique one each time.
|
||||
static TAP_IP_LOCK: Lazy<Mutex<&'static str>> = Lazy::new(|| Mutex::new("192.168.241.1"));
|
||||
static TAP_IP_LOCK: LazyLock<Mutex<&'static str>> =
|
||||
LazyLock::new(|| Mutex::new("192.168.241.1"));
|
||||
|
||||
// Describes the outcomes we are currently interested in when parsing a packet (we use
|
||||
// an UDP packet for testing).
|
||||
|
||||
Reference in New Issue
Block a user