Merge pull request #1358 from Tim-Zhang/remove-allow

Fix lints and remove allow attributes which silence these warnings
This commit is contained in:
Chelsea Mafrica 2021-02-05 12:17:29 -08:00 committed by GitHub
commit a12772c601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 59 additions and 101 deletions

View File

@ -26,12 +26,8 @@ const VSOCK_PORT: u16 = 1024;
const SERVER_ADDR_ENV_VAR: &str = "KATA_AGENT_SERVER_ADDR"; const SERVER_ADDR_ENV_VAR: &str = "KATA_AGENT_SERVER_ADDR";
const LOG_LEVEL_ENV_VAR: &str = "KATA_AGENT_LOG_LEVEL"; const LOG_LEVEL_ENV_VAR: &str = "KATA_AGENT_LOG_LEVEL";
// FIXME: unused
const TRACE_MODE_FLAG: &str = "agent.trace";
const USE_VSOCK_FLAG: &str = "agent.use_vsock";
#[derive(Debug)] #[derive(Debug)]
pub struct agentConfig { pub struct AgentConfig {
pub debug_console: bool, pub debug_console: bool,
pub dev_mode: bool, pub dev_mode: bool,
pub log_level: slog::Level, pub log_level: slog::Level,
@ -73,9 +69,9 @@ macro_rules! parse_cmdline_param {
}; };
} }
impl agentConfig { impl AgentConfig {
pub fn new() -> agentConfig { pub fn new() -> AgentConfig {
agentConfig { AgentConfig {
debug_console: false, debug_console: false,
dev_mode: false, dev_mode: false,
log_level: DEFAULT_LOG_LEVEL, log_level: DEFAULT_LOG_LEVEL,
@ -105,7 +101,7 @@ impl agentConfig {
HOTPLUG_TIMOUT_OPTION, HOTPLUG_TIMOUT_OPTION,
self.hotplug_timeout, self.hotplug_timeout,
get_hotplug_timeout, get_hotplug_timeout,
|hotplugTimeout: time::Duration| hotplugTimeout.as_secs() > 0 |hotplug_timeout: time::Duration| hotplug_timeout.as_secs() > 0
); );
// vsock port should be positive values // vsock port should be positive values
@ -315,7 +311,7 @@ mod tests {
#[test] #[test]
fn test_new() { fn test_new() {
let config = agentConfig::new(); let config = AgentConfig::new();
assert_eq!(config.debug_console, false); assert_eq!(config.debug_console, false);
assert_eq!(config.dev_mode, false); assert_eq!(config.dev_mode, false);
assert_eq!(config.log_level, DEFAULT_LOG_LEVEL); assert_eq!(config.log_level, DEFAULT_LOG_LEVEL);
@ -822,7 +818,7 @@ mod tests {
let filename = file_path.to_str().expect("failed to create filename"); let filename = file_path.to_str().expect("failed to create filename");
let mut config = agentConfig::new(); let mut config = AgentConfig::new();
let result = config.parse_cmdline(&filename.to_owned()); let result = config.parse_cmdline(&filename.to_owned());
assert!(result.is_err()); assert!(result.is_err());
@ -854,7 +850,7 @@ mod tests {
vars_to_unset.push(name); vars_to_unset.push(name);
} }
let mut config = agentConfig::new(); let mut config = AgentConfig::new();
assert_eq!(config.debug_console, false, "{}", msg); assert_eq!(config.debug_console, false, "{}", msg);
assert_eq!(config.dev_mode, false, "{}", msg); assert_eq!(config.dev_mode, false, "{}", msg);
assert_eq!(config.unified_cgroup_hierarchy, false, "{}", msg); assert_eq!(config.unified_cgroup_hierarchy, false, "{}", msg);

View File

@ -3,11 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#![allow(non_camel_case_types)]
#![allow(unused_parens)]
#![allow(unused_unsafe)]
#![allow(dead_code)]
#![allow(non_snake_case)]
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate oci; extern crate oci;
@ -87,11 +82,11 @@ const DEFAULT_BUF_SIZE: usize = 8 * 1024;
lazy_static! { lazy_static! {
static ref GLOBAL_DEVICE_WATCHER: Arc<Mutex<HashMap<String, Option<Sender<String>>>>> = static ref GLOBAL_DEVICE_WATCHER: Arc<Mutex<HashMap<String, Option<Sender<String>>>>> =
Arc::new(Mutex::new(HashMap::new())); Arc::new(Mutex::new(HashMap::new()));
static ref AGENT_CONFIG: Arc<RwLock<agentConfig>> = static ref AGENT_CONFIG: Arc<RwLock<AgentConfig>> =
Arc::new(RwLock::new(config::agentConfig::new())); Arc::new(RwLock::new(config::AgentConfig::new()));
} }
fn announce(logger: &Logger, config: &agentConfig) { fn announce(logger: &Logger, config: &AgentConfig) {
info!(logger, "announce"; info!(logger, "announce";
"agent-commit" => version::VERSION_COMMIT, "agent-commit" => version::VERSION_COMMIT,
@ -161,7 +156,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
// support vsock log // support vsock log
let (rfd, wfd) = unistd::pipe2(OFlag::O_CLOEXEC)?; let (rfd, wfd) = unistd::pipe2(OFlag::O_CLOEXEC)?;
let agentConfig = AGENT_CONFIG.clone(); let agent_config = AGENT_CONFIG.clone();
let init_mode = unistd::getpid() == Pid::from_raw(1); let init_mode = unistd::getpid() == Pid::from_raw(1);
if init_mode { if init_mode {
@ -182,7 +177,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
e e
})?; })?;
let mut config = agentConfig.write().await; let mut config = agent_config.write().await;
config.parse_cmdline(KERNEL_CMDLINE_FILE)?; config.parse_cmdline(KERNEL_CMDLINE_FILE)?;
init_agent_as_init(&logger, config.unified_cgroup_hierarchy)?; init_agent_as_init(&logger, config.unified_cgroup_hierarchy)?;
@ -190,10 +185,10 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
// once parsed cmdline and set the config, release the write lock // once parsed cmdline and set the config, release the write lock
// as soon as possible in case other thread would get read lock on // as soon as possible in case other thread would get read lock on
// it. // it.
let mut config = agentConfig.write().await; let mut config = agent_config.write().await;
config.parse_cmdline(KERNEL_CMDLINE_FILE)?; config.parse_cmdline(KERNEL_CMDLINE_FILE)?;
} }
let config = agentConfig.read().await; let config = agent_config.read().await;
let log_vport = config.log_vport as u32; let log_vport = config.log_vport as u32;
let log_handle = tokio::spawn(async move { let log_handle = tokio::spawn(async move {
@ -251,7 +246,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
}) })
} }
async fn start_sandbox(logger: &Logger, config: &agentConfig, init_mode: bool) -> Result<()> { async fn start_sandbox(logger: &Logger, config: &AgentConfig, init_mode: bool) -> Result<()> {
let shells = SHELLS.clone(); let shells = SHELLS.clone();
let debug_console_vport = config.debug_console_vport as u32; let debug_console_vport = config.debug_console_vport as u32;
@ -450,7 +445,7 @@ lazy_static! {
}; };
} }
use crate::config::agentConfig; use crate::config::AgentConfig;
use nix::sys::stat::Mode; use nix::sys::stat::Mode;
use std::os::unix::io::{FromRawFd, RawFd}; use std::os::unix::io::{FromRawFd, RawFd};
use std::path::PathBuf; use std::path::PathBuf;

View File

@ -187,9 +187,9 @@ fn update_guest_metrics() {
info!(sl!(), "failed to get guest KernelStats: {:?}", err); info!(sl!(), "failed to get guest KernelStats: {:?}", err);
} }
Ok(kernel_stats) => { Ok(kernel_stats) => {
set_gauge_vec_CPU_time(&GUEST_CPU_TIME, "total", &kernel_stats.total); set_gauge_vec_cpu_time(&GUEST_CPU_TIME, "total", &kernel_stats.total);
for (i, cpu_time) in kernel_stats.cpu_time.iter().enumerate() { for (i, cpu_time) in kernel_stats.cpu_time.iter().enumerate() {
set_gauge_vec_CPU_time(&GUEST_CPU_TIME, format!("{}", i).as_str(), &cpu_time); set_gauge_vec_cpu_time(&GUEST_CPU_TIME, format!("{}", i).as_str(), &cpu_time);
} }
} }
} }
@ -332,7 +332,7 @@ fn set_gauge_vec_meminfo(gv: &prometheus::GaugeVec, meminfo: &procfs::Meminfo) {
.set(meminfo.k_reclaimable.unwrap_or(0) as f64); .set(meminfo.k_reclaimable.unwrap_or(0) as f64);
} }
fn set_gauge_vec_CPU_time(gv: &prometheus::GaugeVec, cpu: &str, cpu_time: &procfs::CpuTime) { fn set_gauge_vec_cpu_time(gv: &prometheus::GaugeVec, cpu: &str, cpu_time: &procfs::CpuTime) {
gv.with_label_values(&[cpu, "user"]) gv.with_label_values(&[cpu, "user"])
.set(cpu_time.user as f64); .set(cpu_time.user as f64);
gv.with_label_values(&[cpu, "nice"]) gv.with_label_values(&[cpu, "nice"])

View File

@ -84,7 +84,7 @@ lazy_static! {
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct INIT_MOUNT { pub struct InitMount {
fstype: &'static str, fstype: &'static str,
src: &'static str, src: &'static str,
dest: &'static str, dest: &'static str,
@ -114,13 +114,13 @@ lazy_static!{
#[rustfmt::skip] #[rustfmt::skip]
lazy_static! { lazy_static! {
pub static ref INIT_ROOTFS_MOUNTS: Vec<INIT_MOUNT> = vec![ pub static ref INIT_ROOTFS_MOUNTS: Vec<InitMount> = vec![
INIT_MOUNT{fstype: "proc", src: "proc", dest: "/proc", options: vec!["nosuid", "nodev", "noexec"]}, InitMount{fstype: "proc", src: "proc", dest: "/proc", options: vec!["nosuid", "nodev", "noexec"]},
INIT_MOUNT{fstype: "sysfs", src: "sysfs", dest: "/sys", options: vec!["nosuid", "nodev", "noexec"]}, InitMount{fstype: "sysfs", src: "sysfs", dest: "/sys", options: vec!["nosuid", "nodev", "noexec"]},
INIT_MOUNT{fstype: "devtmpfs", src: "dev", dest: "/dev", options: vec!["nosuid"]}, InitMount{fstype: "devtmpfs", src: "dev", dest: "/dev", options: vec!["nosuid"]},
INIT_MOUNT{fstype: "tmpfs", src: "tmpfs", dest: "/dev/shm", options: vec!["nosuid", "nodev"]}, InitMount{fstype: "tmpfs", src: "tmpfs", dest: "/dev/shm", options: vec!["nosuid", "nodev"]},
INIT_MOUNT{fstype: "devpts", src: "devpts", dest: "/dev/pts", options: vec!["nosuid", "noexec"]}, InitMount{fstype: "devpts", src: "devpts", dest: "/dev/pts", options: vec!["nosuid", "noexec"]},
INIT_MOUNT{fstype: "tmpfs", src: "tmpfs", dest: "/run", options: vec!["nosuid", "nodev"]}, InitMount{fstype: "tmpfs", src: "tmpfs", dest: "/run", options: vec!["nosuid", "nodev"]},
]; ];
} }
@ -492,7 +492,7 @@ pub async fn add_storages(
Ok(mount_list) Ok(mount_list)
} }
fn mount_to_rootfs(logger: &Logger, m: &INIT_MOUNT) -> Result<()> { fn mount_to_rootfs(logger: &Logger, m: &InitMount) -> Result<()> {
let options_vec: Vec<&str> = m.options.clone(); let options_vec: Vec<&str> = m.options.clone();
let (flags, options) = parse_mount_flags_and_options(options_vec); let (flags, options) = parse_mount_flags_and_options(options_vec);
@ -568,11 +568,11 @@ pub fn get_cgroup_mounts(
logger: &Logger, logger: &Logger,
cg_path: &str, cg_path: &str,
unified_cgroup_hierarchy: bool, unified_cgroup_hierarchy: bool,
) -> Result<Vec<INIT_MOUNT>> { ) -> Result<Vec<InitMount>> {
// cgroup v2 // cgroup v2
// https://github.com/kata-containers/agent/blob/8c9bbadcd448c9a67690fbe11a860aaacc69813c/agent.go#L1249 // https://github.com/kata-containers/agent/blob/8c9bbadcd448c9a67690fbe11a860aaacc69813c/agent.go#L1249
if unified_cgroup_hierarchy { if unified_cgroup_hierarchy {
return Ok(vec![INIT_MOUNT { return Ok(vec![InitMount {
fstype: "cgroup2", fstype: "cgroup2",
src: "cgroup2", src: "cgroup2",
dest: "/sys/fs/cgroup", dest: "/sys/fs/cgroup",
@ -584,7 +584,7 @@ pub fn get_cgroup_mounts(
let reader = BufReader::new(file); let reader = BufReader::new(file);
let mut has_device_cgroup = false; let mut has_device_cgroup = false;
let mut cg_mounts: Vec<INIT_MOUNT> = vec![INIT_MOUNT { let mut cg_mounts: Vec<InitMount> = vec![InitMount {
fstype: "tmpfs", fstype: "tmpfs",
src: "tmpfs", src: "tmpfs",
dest: SYSFS_CGROUPPATH, dest: SYSFS_CGROUPPATH,
@ -630,7 +630,7 @@ pub fn get_cgroup_mounts(
if let Some(value) = CGROUPS.get(&fields[0]) { if let Some(value) = CGROUPS.get(&fields[0]) {
let key = CGROUPS.keys().find(|&&f| f == fields[0]).unwrap(); let key = CGROUPS.keys().find(|&&f| f == fields[0]).unwrap();
cg_mounts.push(INIT_MOUNT { cg_mounts.push(InitMount {
fstype: "cgroup", fstype: "cgroup",
src: "cgroup", src: "cgroup",
dest: *value, dest: *value,
@ -644,7 +644,7 @@ pub fn get_cgroup_mounts(
return Ok(Vec::new()); return Ok(Vec::new());
} }
cg_mounts.push(INIT_MOUNT { cg_mounts.push(InitMount {
fstype: "tmpfs", fstype: "tmpfs",
src: "tmpfs", src: "tmpfs",
dest: SYSFS_CGROUPPATH, dest: SYSFS_CGROUPPATH,
@ -1142,21 +1142,21 @@ mod tests {
let drain = slog::Discard; let drain = slog::Discard;
let logger = slog::Logger::root(drain, o!()); let logger = slog::Logger::root(drain, o!());
let first_mount = INIT_MOUNT { let first_mount = InitMount {
fstype: "tmpfs", fstype: "tmpfs",
src: "tmpfs", src: "tmpfs",
dest: SYSFS_CGROUPPATH, dest: SYSFS_CGROUPPATH,
options: vec!["nosuid", "nodev", "noexec", "mode=755"], options: vec!["nosuid", "nodev", "noexec", "mode=755"],
}; };
let last_mount = INIT_MOUNT { let last_mount = InitMount {
fstype: "tmpfs", fstype: "tmpfs",
src: "tmpfs", src: "tmpfs",
dest: SYSFS_CGROUPPATH, dest: SYSFS_CGROUPPATH,
options: vec!["remount", "ro", "nosuid", "nodev", "noexec", "mode=755"], options: vec!["remount", "ro", "nosuid", "nodev", "noexec", "mode=755"],
}; };
let cg_devices_mount = INIT_MOUNT { let cg_devices_mount = InitMount {
fstype: "cgroup", fstype: "cgroup",
src: "cgroup", src: "cgroup",
dest: "/sys/fs/cgroup/devices", dest: "/sys/fs/cgroup/devices",

View File

@ -68,6 +68,7 @@ impl Namespace {
self self
} }
#[allow(dead_code)]
pub fn set_root_dir(mut self, dir: &str) -> Self { pub fn set_root_dir(mut self, dir: &str) -> Self {
self.persistent_ns_dir = dir.to_string(); self.persistent_ns_dir = dir.to_string();
self self

View File

@ -40,11 +40,12 @@ pub enum AddressFilter {
/// Return addresses that belong to the given interface. /// Return addresses that belong to the given interface.
LinkIndex(u32), LinkIndex(u32),
/// Get addresses with the given prefix. /// Get addresses with the given prefix.
#[allow(dead_code)]
IpAddress(IpAddr), IpAddress(IpAddr),
} }
/// A high level wrapper for netlink (and `rtnetlink` crate) for use by the Agent's RPC. /// A high level wrapper for netlink (and `rtnetlink` crate) for use by the Agent's RPC.
/// It is expected to be consumed by the `agentService`, so it operates with protobuf /// It is expected to be consumed by the `AgentService`, so it operates with protobuf
/// structures directly for convenience. /// structures directly for convenience.
#[derive(Debug)] #[derive(Debug)]
pub struct Handle { pub struct Handle {
@ -215,17 +216,6 @@ impl Handle {
Ok(()) Ok(())
} }
pub async fn delete_links<I>(&mut self, list: I) -> Result<()>
where
I: IntoIterator<Item = u32>,
{
for index in list.into_iter() {
self.handle.link().del(index).execute().await?;
}
Ok(())
}
async fn query_routes( async fn query_routes(
&self, &self,
ip_version: Option<IpVersion>, ip_version: Option<IpVersion>,
@ -742,6 +732,7 @@ impl Address {
self.0.header.family == packet::constants::AF_INET6 as u8 self.0.header.family == packet::constants::AF_INET6 as u8
} }
#[allow(dead_code)]
fn prefix(&self) -> u8 { fn prefix(&self) -> u8 {
self.0.header.prefix_len self.0.header.prefix_len
} }

View File

@ -139,10 +139,10 @@ mod tests {
assert_eq!(true, content.is_ok()); assert_eq!(true, content.is_ok());
let content = content.unwrap(); let content = content.unwrap();
let expected_DNS: Vec<&str> = content.split('\n').collect(); let expected_dns: Vec<&str> = content.split('\n').collect();
// assert the data are the same as /run/kata-containers/sandbox/resolv.conf // assert the data are the same as /run/kata-containers/sandbox/resolv.conf
assert_eq!(dns, expected_DNS); assert_eq!(dns, expected_dns);
// umount /etc/resolv.conf // umount /etc/resolv.conf
let _ = mount::umount(dst_filename); let _ = mount::umount(dst_filename);

View File

@ -76,11 +76,11 @@ macro_rules! sl {
} }
#[derive(Clone)] #[derive(Clone)]
pub struct agentService { pub struct AgentService {
sandbox: Arc<Mutex<Sandbox>>, sandbox: Arc<Mutex<Sandbox>>,
} }
impl agentService { impl AgentService {
async fn do_create_container( async fn do_create_container(
&self, &self,
req: protocols::agent::CreateContainerRequest, req: protocols::agent::CreateContainerRequest,
@ -493,7 +493,7 @@ impl agentService {
} }
#[async_trait] #[async_trait]
impl protocols::agent_ttrpc::AgentService for agentService { impl protocols::agent_ttrpc::AgentService for AgentService {
async fn create_container( async fn create_container(
&self, &self,
_ctx: &TtrpcContext, _ctx: &TtrpcContext,
@ -665,8 +665,8 @@ impl protocols::agent_ttrpc::AgentService for agentService {
let resp = Empty::new(); let resp = Empty::new();
if res.is_some() { if res.is_some() {
let ociRes = rustjail::resources_grpc_to_oci(&res.unwrap()); let oci_res = rustjail::resources_grpc_to_oci(&res.unwrap());
match ctr.set(ociRes) { match ctr.set(oci_res) {
Err(e) => { Err(e) => {
return Err(ttrpc_error(ttrpc::Code::INTERNAL, e.to_string())); return Err(ttrpc_error(ttrpc::Code::INTERNAL, e.to_string()));
} }
@ -1203,10 +1203,10 @@ impl protocols::agent_ttrpc::AgentService for agentService {
} }
#[derive(Clone)] #[derive(Clone)]
struct healthService; struct HealthService;
#[async_trait] #[async_trait]
impl protocols::health_ttrpc::Health for healthService { impl protocols::health_ttrpc::Health for HealthService {
async fn check( async fn check(
&self, &self,
_ctx: &TtrpcContext, _ctx: &TtrpcContext,
@ -1334,13 +1334,13 @@ fn find_process<'a>(
} }
pub fn start(s: Arc<Mutex<Sandbox>>, server_address: &str) -> TtrpcServer { pub fn start(s: Arc<Mutex<Sandbox>>, server_address: &str) -> TtrpcServer {
let agent_service = Box::new(agentService { sandbox: s }) let agent_service = Box::new(AgentService { sandbox: s })
as Box<dyn protocols::agent_ttrpc::AgentService + Send + Sync>; as Box<dyn protocols::agent_ttrpc::AgentService + Send + Sync>;
let agent_worker = Arc::new(agent_service); let agent_worker = Arc::new(agent_service);
let health_service = let health_service =
Box::new(healthService {}) as Box<dyn protocols::health_ttrpc::Health + Send + Sync>; Box::new(HealthService {}) as Box<dyn protocols::health_ttrpc::Health + Send + Sync>;
let health_worker = Arc::new(health_service); let health_worker = Arc::new(health_service);
let aservice = protocols::agent_ttrpc::create_agent_service(agent_worker); let aservice = protocols::agent_ttrpc::create_agent_service(agent_worker);
@ -1670,7 +1670,7 @@ fn load_kernel_module(module: &protocols::agent::KernelModule) -> Result<()> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::protocols::agent_ttrpc::AgentService; use crate::protocols::agent_ttrpc::AgentService as _;
use oci::{Hook, Hooks}; use oci::{Hook, Hooks};
use ttrpc::{r#async::TtrpcContext, MessageHeader}; use ttrpc::{r#async::TtrpcContext, MessageHeader};
@ -1725,7 +1725,7 @@ mod tests {
let logger = slog::Logger::root(slog::Discard, o!()); let logger = slog::Logger::root(slog::Discard, o!());
let sandbox = Sandbox::new(&logger).unwrap(); let sandbox = Sandbox::new(&logger).unwrap();
let agent_service = Box::new(agentService { let agent_service = Box::new(AgentService {
sandbox: Arc::new(Mutex::new(sandbox)), sandbox: Arc::new(Mutex::new(sandbox)),
}); });
@ -1742,7 +1742,7 @@ mod tests {
let logger = slog::Logger::root(slog::Discard, o!()); let logger = slog::Logger::root(slog::Discard, o!());
let sandbox = Sandbox::new(&logger).unwrap(); let sandbox = Sandbox::new(&logger).unwrap();
let agent_service = Box::new(agentService { let agent_service = Box::new(AgentService {
sandbox: Arc::new(Mutex::new(sandbox)), sandbox: Arc::new(Mutex::new(sandbox)),
}); });
@ -1759,7 +1759,7 @@ mod tests {
let logger = slog::Logger::root(slog::Discard, o!()); let logger = slog::Logger::root(slog::Discard, o!());
let sandbox = Sandbox::new(&logger).unwrap(); let sandbox = Sandbox::new(&logger).unwrap();
let agent_service = Box::new(agentService { let agent_service = Box::new(AgentService {
sandbox: Arc::new(Mutex::new(sandbox)), sandbox: Arc::new(Mutex::new(sandbox)),
}); });

View File

@ -150,14 +150,6 @@ impl Sandbox {
Ok(()) Ok(())
} }
pub fn is_running(&self) -> bool {
self.running
}
pub fn set_hostname(&mut self, hostname: String) {
self.hostname = hostname;
}
pub async fn setup_shared_namespaces(&mut self) -> Result<bool> { pub async fn setup_shared_namespaces(&mut self) -> Result<bool> {
// Set up shared IPC namespace // Set up shared IPC namespace
self.shared_ipcns = Namespace::new(&self.logger) self.shared_ipcns = Namespace::new(&self.logger)
@ -388,7 +380,7 @@ fn online_cpus(logger: &Logger, num: i32) -> Result<i32> {
logger, logger,
SYSFS_CPU_ONLINE_PATH, SYSFS_CPU_ONLINE_PATH,
r"cpu[0-9]+", r"cpu[0-9]+",
(num - onlined_count), num - onlined_count,
); );
if r.is_err() { if r.is_err() {
return r; return r;
@ -732,25 +724,6 @@ mod tests {
assert!(s.hooks.as_ref().unwrap().poststop.is_empty()); assert!(s.hooks.as_ref().unwrap().poststop.is_empty());
} }
#[tokio::test]
async fn test_sandbox_is_running() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
s.running = true;
assert!(s.is_running());
s.running = false;
assert!(!s.is_running());
}
#[tokio::test]
async fn test_sandbox_set_hostname() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
let hostname = "abc123";
s.set_hostname(hostname.to_string());
assert_eq!(s.hostname, hostname);
}
#[tokio::test] #[tokio::test]
async fn test_sandbox_set_destroy() { async fn test_sandbox_set_destroy() {
let logger = slog::Logger::root(slog::Discard, o!()); let logger = slog::Logger::root(slog::Discard, o!());

View File

@ -7,6 +7,8 @@
// WARNING: This file is auto-generated - DO NOT EDIT! // WARNING: This file is auto-generated - DO NOT EDIT!
// //
#![allow(dead_code)]
pub const AGENT_VERSION: &str = "@AGENT_VERSION@"; pub const AGENT_VERSION: &str = "@AGENT_VERSION@";
pub const API_VERSION: &str = "@API_VERSION@"; pub const API_VERSION: &str = "@API_VERSION@";
pub const VERSION_COMMIT: &str = "@VERSION_COMMIT@"; pub const VERSION_COMMIT: &str = "@VERSION_COMMIT@";