Commit dd276c77 authored by Alexis Janon's avatar Alexis Janon
Browse files

Integration test for spawn command with no name field

parent 13a18184
extern crate cuttr; extern crate cuttr;
use cuttr::random::random_string;
use std::fs; use std::fs;
use std::path; use std::path;
use std::rc::Rc; use std::rc::Rc;
...@@ -233,3 +234,45 @@ fn test_spawn_cpuset() { ...@@ -233,3 +234,45 @@ fn test_spawn_cpuset() {
assert!(fs::remove_file(&result_path).is_ok()); assert!(fs::remove_file(&result_path).is_ok());
assert!(paths.iter().all(|p| !p.exists())); assert!(paths.iter().all(|p| !p.exists()));
} }
#[test]
// TODO: need cpuset cgroup: make it more generic (or robust)
fn test_spawn_cpuset_no_name() {
let result_file = format!("{}{}", SPAWN_CPUSET_RESULT_FILE, random_string(12));
let json = format!(
r#"
{{
"commands":[
{{
"command":"spawn",
"args":[
"cpuset"
],
"properties":{{
"cpuset.mems":"0",
"cpuset.cpus":"0"
}},
"cmd":"bash",
"cmd_args":[
"-c", "echo $(nproc) > {}"
]
}}
]
}}
"#,
result_file
);
let controllers = Rc::new(configuration::sysfscontroller::get_sys_fs_controllers().unwrap());
let paths = controllers
.values()
.map(SysFsController::get_path)
.map(path::Path::to_path_buf)
.map(|path| path.join(SPAWN_CPUSET_NAME))
.collect::<Vec<_>>();
let mut commands = parsing::parse_json(&json, controllers).unwrap();
assert!(commands.exec().is_ok());
let result_path = path::Path::new(&result_file);
assert_eq!(fs::read_to_string(&result_path).unwrap().trim(), "1");
assert!(fs::remove_file(&result_path).is_ok());
assert!(paths.iter().all(|p| !p.exists()));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment