-
Notifications
You must be signed in to change notification settings - Fork 346
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 <1275177125@qq.com> Signed-off-by: lengrongfu <lenronfu@gmail.com>
- Loading branch information
1 parent
1580f21
commit 0295522
Showing
9 changed files
with
187 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ pub mod seccomp; | |
pub mod seccomp_notify; | ||
pub mod sysctl; | ||
pub mod tlb; | ||
pub mod process; |
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,4 @@ | ||
mod scheduler; | ||
|
||
pub use scheduler::get_scheduler_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use anyhow::{Context, Result}; | ||
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder, LinuxSchedulerPolicy, SchedulerBuilder}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_inside_container; | ||
|
||
////////// ANCHOR: create_spec policy: u32 | ||
fn create_spec(policy: LinuxSchedulerPolicy) -> Result<Spec> { | ||
let sc = SchedulerBuilder::default() | ||
.policy(policy) | ||
.nice(0i32) | ||
.build() | ||
.unwrap(); | ||
SpecBuilder::default() | ||
.process( | ||
ProcessBuilder::default() | ||
.args( | ||
["runtimetest", "hello_world"] | ||
.iter() | ||
.map(|s| s.to_string()) | ||
.collect::<Vec<String>>(), | ||
) | ||
.scheduler(sc) | ||
.build()?, | ||
) | ||
.build() | ||
.context("failed to create spec") | ||
} | ||
|
||
fn scheduler_policy_other_test() -> TestResult { | ||
let spec = test_result!(create_spec(LinuxSchedulerPolicy::SchedOther)); | ||
test_inside_container(spec, &|_| { | ||
Ok(()) | ||
}) | ||
} | ||
|
||
fn scheduler_policy_batch_test() -> TestResult { | ||
let spec = test_result!(create_spec(LinuxSchedulerPolicy::SchedBatch)); | ||
test_inside_container(spec, &|_| { | ||
Ok(()) | ||
}) | ||
} | ||
|
||
pub fn get_scheduler_test() -> TestGroup { | ||
let mut scheduler_policy_group = TestGroup::new("set_scheduler_policy"); | ||
let policy_fifo_test = Test::new("policy_fifo", Box::new(scheduler_policy_other_test)); | ||
let policy_rr_test = Test::new("policy_rr", Box::new(scheduler_policy_batch_test)); | ||
|
||
scheduler_policy_group.add(vec![Box::new(policy_fifo_test)]); | ||
scheduler_policy_group.add(vec![Box::new(policy_rr_test)]); | ||
|
||
scheduler_policy_group | ||
} |