mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
cpuset: fail if trying to enable memory pressure on a non-root cg
Signed-off-by: Levente Kurusa <lkurusa@acm.org>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
extern crate cgroups;
|
||||
|
||||
use cgroups::{Cgroup, CgroupError};
|
||||
use cgroups::cpuset::CpuSetController;
|
||||
|
||||
#[test]
|
||||
fn test_cpuset_memory_pressure_root_cg() {
|
||||
let hier = cgroups::hierarchies::V1::new();
|
||||
let cg = Cgroup::new(&hier, String::from("test_cpuset_memory_pressure_root_cg"));
|
||||
{
|
||||
let cpuset: &CpuSetController = cg.controller_of().unwrap();
|
||||
|
||||
// This is not a root control group, so it should fail via InvalidOperation.
|
||||
let res = cpuset.set_enable_memory_pressure(true);
|
||||
assert!(res.is_err());
|
||||
assert_eq!(res.unwrap_err(), CgroupError::InvalidOperation);
|
||||
}
|
||||
cg.delete();
|
||||
}
|
||||
Reference in New Issue
Block a user