mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
tests: move tests to tests/ directory and give the user cgroup perms
Signed-off-by: Levente Kurusa <lkurusa@acm.org>
This commit is contained in:
39
tests/pids.rs
Normal file
39
tests/pids.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
//! Integration tests about the pids subsystem
|
||||
extern crate cgroups;
|
||||
|
||||
use cgroups::{Cgroup, Resources, PidResources};
|
||||
use cgroups::pid::{PidController, PidMax};
|
||||
|
||||
#[test]
|
||||
fn create_and_delete_cgroup() {
|
||||
let hier = cgroups::hierarchies::V1::new();
|
||||
let cg = Cgroup::new(&hier, String::from("create_and_delete_cgroup"));
|
||||
{
|
||||
let pidcontroller: &PidController = cg.controller_of().unwrap();
|
||||
pidcontroller.set_pid_max(PidMax::Value(1337));
|
||||
assert_eq!(pidcontroller.get_pid_max(), Some(PidMax::Value(1337)));
|
||||
}
|
||||
cg.delete();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pid_pids_current_is_zero() {
|
||||
let hier = cgroups::hierarchies::V1::new();
|
||||
let cg = Cgroup::new(&hier, String::from("test_pid_pids_current_is_zero"));
|
||||
{
|
||||
let pidcontroller: &PidController = cg.controller_of().unwrap();
|
||||
assert_eq!(pidcontroller.get_pid_current(), 0);
|
||||
}
|
||||
cg.delete();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pid_pids_events_is_zero() {
|
||||
let hier = cgroups::hierarchies::V1::new();
|
||||
let cg = Cgroup::new(&hier, String::from("test_pid_pids_events_is_zero"));
|
||||
{
|
||||
let pidcontroller: &PidController = cg.controller_of().unwrap();
|
||||
assert_eq!(pidcontroller.get_pid_events(), 0);
|
||||
}
|
||||
cg.delete();
|
||||
}
|
||||
26
tests/resources.rs
Normal file
26
tests/resources.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
//! Integration test about setting resources using `apply()`
|
||||
extern crate cgroups;
|
||||
|
||||
use cgroups::{Cgroup, Resources, PidResources};
|
||||
use cgroups::pid::{PidController, PidMax};
|
||||
|
||||
#[test]
|
||||
fn pid_resources() {
|
||||
let hier = cgroups::hierarchies::V1::new();
|
||||
let cg = Cgroup::new(&hier, String::from("pid_resources"));
|
||||
{
|
||||
let res = Resources {
|
||||
pid: PidResources {
|
||||
update_values: true,
|
||||
maximum_number_of_processes: PidMax::Value(512),
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
cg.apply(&res);
|
||||
|
||||
/* verify */
|
||||
let pidcontroller: &PidController = cg.controller_of().unwrap();
|
||||
assert_eq!(pidcontroller.get_pid_max(), Some(PidMax::Value(512)));
|
||||
}
|
||||
cg.delete();
|
||||
}
|
||||
Reference in New Issue
Block a user