-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: lengrongfu <[email protected]>
- Loading branch information
1 parent
3f08ae7
commit 0a09bb0
Showing
6 changed files
with
202 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
tests/contest/contest/src/tests/io_priority/io_priority_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use crate::utils::test_inside_container; | ||
use anyhow::{Context, Result}; | ||
use oci_spec::runtime::{ | ||
IOPriorityClass, LinuxIOPriorityBuilder, ProcessBuilder, Spec, SpecBuilder, | ||
}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
fn create_spec(io_priority_class: IOPriorityClass, execute_test: &str) -> Result<Spec> { | ||
let io_p = LinuxIOPriorityBuilder::default() | ||
.class(io_priority_class) | ||
.priority(1) | ||
.build() | ||
.unwrap(); | ||
SpecBuilder::default() | ||
.process( | ||
ProcessBuilder::default() | ||
.args( | ||
["runtimetest", execute_test] | ||
.iter() | ||
.map(|s| s.to_string()) | ||
.collect::<Vec<String>>(), | ||
) | ||
.io_priority(io_p) | ||
.build()?, | ||
) | ||
.build() | ||
.context("failed to create spec") | ||
} | ||
|
||
fn io_priority_class_rt_test() -> TestResult { | ||
let spec = test_result!(create_spec( | ||
IOPriorityClass::IoprioClassRt, | ||
"io_priority_class_rt" | ||
)); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
fn io_priority_class_be_test() -> TestResult { | ||
let spec = test_result!(create_spec( | ||
IOPriorityClass::IoprioClassBe, | ||
"io_priority_class_be" | ||
)); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
fn io_priority_class_idle_test() -> TestResult { | ||
let spec = test_result!(create_spec( | ||
IOPriorityClass::IoprioClassIdle, | ||
"io_priority_class_idle" | ||
)); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
pub fn get_io_priority_test() -> TestGroup { | ||
let mut io_priority_group = TestGroup::new("set_io_priority"); | ||
let io_priority_class_rt = | ||
Test::new("io_priority_class_rt", Box::new(io_priority_class_rt_test)); | ||
let io_priority_class_be = | ||
Test::new("io_priority_class_be", Box::new(io_priority_class_be_test)); | ||
let io_priority_class_idle = Test::new( | ||
"io_priority_class_idle", | ||
Box::new(io_priority_class_idle_test), | ||
); | ||
|
||
io_priority_group.add(vec![Box::new(io_priority_class_rt)]); | ||
io_priority_group.add(vec![Box::new(io_priority_class_be)]); | ||
io_priority_group.add(vec![Box::new(io_priority_class_idle)]); | ||
|
||
io_priority_group | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod io_priority_test; | ||
|
||
pub use io_priority_test::get_io_priority_test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters