mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Remove Box wrap of Cgroup.hire
It's unnecessary. Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
@@ -13,9 +13,8 @@ use std::collections::HashMap;
|
||||
#[test]
|
||||
fn test_tasks_iterator() {
|
||||
let h = cgroups::hierarchies::auto();
|
||||
let h = Box::new(&*h);
|
||||
let pid = libc::pid_t::from(nix::unistd::getpid()) as u64;
|
||||
let cg = Cgroup::new(h, String::from("test_tasks_iterator"));
|
||||
let cg = Cgroup::new(&*h, String::from("test_tasks_iterator"));
|
||||
{
|
||||
// Add a task to the control group.
|
||||
cg.add_task(CgroupPid::from(pid)).unwrap();
|
||||
@@ -45,13 +44,9 @@ fn test_cgroup_with_relative_paths() {
|
||||
}
|
||||
let h = cgroups::hierarchies::auto();
|
||||
let cgroup_root = h.root();
|
||||
let h = Box::new(&*h);
|
||||
let mut relative_paths = HashMap::new();
|
||||
let mem_relative_path = "/mmm/abc/def";
|
||||
relative_paths.insert("memory".to_string(), mem_relative_path.to_string());
|
||||
let cgroup_name = "test_cgroup_with_relative_paths";
|
||||
|
||||
let cg = Cgroup::new_with_relative_paths(h, String::from(cgroup_name), relative_paths);
|
||||
let cg = Cgroup::load(&*h, String::from(cgroup_name));
|
||||
{
|
||||
let subsystems = cg.subsystems();
|
||||
subsystems.into_iter().for_each(|sub| match sub {
|
||||
@@ -74,12 +69,7 @@ fn test_cgroup_with_relative_paths() {
|
||||
// cgroup_path = cgroup_root + relative_path + cgroup_name
|
||||
assert_eq!(
|
||||
cgroup_path,
|
||||
format!(
|
||||
"{}/memory{}/{}",
|
||||
cgroup_root.to_str().unwrap(),
|
||||
mem_relative_path,
|
||||
cgroup_name
|
||||
)
|
||||
format!("{}/memory/{}", cgroup_root.to_str().unwrap(), cgroup_name)
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
@@ -94,8 +84,7 @@ fn test_cgroup_v2() {
|
||||
return;
|
||||
}
|
||||
let h = cgroups::hierarchies::auto();
|
||||
let h = Box::new(&*h);
|
||||
let cg = Cgroup::new_with_relative_paths(h, String::from("test_v2"), HashMap::new());
|
||||
let cg = Cgroup::load(&*h, String::from("test_v2"));
|
||||
|
||||
let mem_controller: &MemController = cg.controller_of().unwrap();
|
||||
let (mem, swp, rev) = (4 * 1024 * 1000, 2 * 1024 * 1000, 1024 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user