tests: switch from lazy_static to once_cell

Once_cell does not require using macro and is slated to become part of
Rust std at some point.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-06-20 14:05:17 +00:00 committed by Liu Wei
parent 8fa1098629
commit 32b855df3a
5 changed files with 8 additions and 17 deletions

4
Cargo.lock generated
View File

@ -165,10 +165,10 @@ dependencies = [
"epoll", "epoll",
"event_monitor", "event_monitor",
"hypervisor", "hypervisor",
"lazy_static",
"libc", "libc",
"log", "log",
"net_util", "net_util",
"once_cell",
"option_parser", "option_parser",
"seccompiler", "seccompiler",
"serde_json", "serde_json",
@ -1038,8 +1038,8 @@ version = "0.1.0"
dependencies = [ dependencies = [
"dirs", "dirs",
"epoll", "epoll",
"lazy_static",
"libc", "libc",
"once_cell",
"ssh2", "ssh2",
"vmm-sys-util", "vmm-sys-util",
"wait-timeout", "wait-timeout",

View File

@ -44,8 +44,8 @@ versionize_derive = { git = "https://github.com/cloud-hypervisor/versionize_deri
[dev-dependencies] [dev-dependencies]
dirs = "4.0.0" dirs = "4.0.0"
lazy_static= "1.4.0"
net_util = { path = "net_util" } net_util = { path = "net_util" }
once_cell = "1.12.0"
serde_json = "1.0.81" serde_json = "1.0.81"
test_infra = { path = "test_infra" } test_infra = { path = "test_infra" }
wait-timeout = "0.2.0" wait-timeout = "0.2.0"

View File

@ -7,8 +7,8 @@ edition = "2021"
[dependencies] [dependencies]
dirs = "4.0.0" dirs = "4.0.0"
epoll = "4.3.1" epoll = "4.3.1"
lazy_static = "1.4.0"
libc = "0.2.126" libc = "0.2.126"
once_cell = "1.12.0"
ssh2 = { version = "0.9.1", features = ["vendored-openssl"]} ssh2 = { version = "0.9.1", features = ["vendored-openssl"]}
vmm-sys-util = "0.9.0" vmm-sys-util = "0.9.0"
wait-timeout = "0.2.0" wait-timeout = "0.2.0"

View File

@ -3,9 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#[macro_use] use once_cell::sync::Lazy;
extern crate lazy_static;
use ssh2::Session; use ssh2::Session;
use std::env; use std::env;
use std::ffi::OsStr; use std::ffi::OsStr;
@ -722,9 +720,7 @@ pub fn exec_host_command_output(command: &str) -> Output {
pub const PIPE_SIZE: i32 = 32 << 20; pub const PIPE_SIZE: i32 = 32 << 20;
lazy_static! { static NEXT_VM_ID: Lazy<Mutex<u8>> = Lazy::new(|| Mutex::new(1));
static ref NEXT_VM_ID: Mutex<u8> = Mutex::new(1);
}
pub struct Guest { pub struct Guest {
pub tmp_dir: TempDir, pub tmp_dir: TempDir,

View File

@ -8,10 +8,6 @@
// related warnings for our quality workflow to pass. // related warnings for our quality workflow to pass.
#![allow(dead_code)] #![allow(dead_code)]
#[cfg(target_arch = "x86_64")]
#[macro_use]
extern crate lazy_static;
extern crate test_infra; extern crate test_infra;
use net_util::MacAddr; use net_util::MacAddr;
@ -6565,10 +6561,9 @@ mod sequential {
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
mod windows { mod windows {
use crate::*; use crate::*;
use once_cell::sync::Lazy;
lazy_static! { static NEXT_DISK_ID: Lazy<Mutex<u8>> = Lazy::new(|| Mutex::new(1));
static ref NEXT_DISK_ID: Mutex<u8> = Mutex::new(1);
}
struct WindowsGuest { struct WindowsGuest {
guest: Guest, guest: Guest,