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:
Levente Kurusa
2018-09-04 10:45:32 +02:00
parent 19e2847e15
commit be5db6ba50
3 changed files with 54 additions and 2 deletions
+19
View File
@@ -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();
}