-
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.
test(integration_test): port 'runtime-tools/validation/linux_seccomp' (…
…#2531) * test(integration_test): port 'runtime-tools/validation/linux_seccomp' Signed-off-by: Xiaoyang Liu <[email protected]> * test(integration_test): address code review suggestions Co-authored-by: Yashodhan <[email protected]> Signed-off-by: Xiaoyang Liu <[email protected]> * test(integration_test): format the code Signed-off-by: Xiaoyang Liu <[email protected]> --------- Signed-off-by: Xiaoyang Liu <[email protected]> Co-authored-by: Yashodhan <[email protected]>
- Loading branch information
1 parent
3c7cc26
commit 18f3dd7
Showing
5 changed files
with
71 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use oci_spec::runtime::{ | ||
LinuxBuilder, LinuxSeccomp, LinuxSeccompAction, LinuxSeccompBuilder, LinuxSyscallBuilder, | ||
ProcessBuilder, Spec, SpecBuilder, | ||
}; | ||
use test_framework::{Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_inside_container; | ||
|
||
fn create_spec(seccomp: LinuxSeccomp) -> Spec { | ||
SpecBuilder::default() | ||
.linux( | ||
LinuxBuilder::default() | ||
.seccomp(seccomp) | ||
.build() | ||
.expect("error in building linux config"), | ||
) | ||
.process( | ||
ProcessBuilder::default() | ||
.args(vec!["runtimetest".to_string(), "seccomp".to_string()]) | ||
.build() | ||
.expect("error in creating process config"), | ||
) | ||
.build() | ||
.unwrap() | ||
} | ||
|
||
fn seccomp_test() -> TestResult { | ||
let spec = create_spec( | ||
LinuxSeccompBuilder::default() | ||
.default_action(LinuxSeccompAction::ScmpActAllow) | ||
.syscalls(vec![LinuxSyscallBuilder::default() | ||
.names(vec![String::from("getcwd")]) | ||
.action(LinuxSeccompAction::ScmpActErrno) | ||
.build() | ||
.unwrap()]) | ||
.build() | ||
.unwrap(), | ||
); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
pub fn get_seccomp_test() -> TestGroup { | ||
let mut test_group = TestGroup::new("seccomp"); | ||
let seccomp_test = Test::new("seccomp_test", Box::new(seccomp_test)); | ||
test_group.add(vec![Box::new(seccomp_test)]); | ||
|
||
test_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
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