-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e tests: Add test root readonly (#2976)
* add test root readonly true Signed-off-by: sat0ken <[email protected]> * fix test group name Signed-off-by: sat0ken <[email protected]> * fix format Signed-off-by: sat0ken <[email protected]> * remove blank line Signed-off-by: sat0ken <[email protected]> * remove unused import Signed-off-by: sat0ken <[email protected]> * fix format err Signed-off-by: sat0ken <[email protected]> * remove unnecessary return Signed-off-by: sat0ken <[email protected]> * separate test root readonly true and false Signed-off-by: sat0ken <[email protected]> * fix format err Signed-off-by: sat0ken <[email protected]> * change test_dir_write_access to pub fn to use test Signed-off-by: sat0ken <[email protected]> * check root readonly to use test_dir_write_access Signed-off-by: sat0ken <[email protected]> * fix format err Signed-off-by: sat0ken <[email protected]> * fix format err Signed-off-by: sat0ken <[email protected]> * remove blank line Signed-off-by: sat0ken <[email protected]> * separate two tests to root_readonly_true and root_readonly_false Signed-off-by: sat0ken <[email protected]> * change test_dir_read_access to pub fn to use test Signed-off-by: sat0ken <[email protected]> * fix debug message and add check read access Signed-off-by: sat0ken <[email protected]> * fix format err Signed-off-by: sat0ken <[email protected]> * add root_readonly test to main Signed-off-by: sat0ken <[email protected]> * add read access test when root readonly is false Signed-off-by: sat0ken <[email protected]> * fox type err Signed-off-by: sat0ken <[email protected]> * remove code err to raw os err Signed-off-by: sat0ken <[email protected]> * add CreateOptions Signed-off-by: sat0ken <[email protected]> --------- Signed-off-by: sat0ken <[email protected]>
- Loading branch information
Showing
7 changed files
with
92 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
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,2 @@ | ||
mod root_readonly_tests; | ||
pub use root_readonly_tests::get_root_readonly_test; |
44 changes: 44 additions & 0 deletions
44
tests/contest/contest/src/tests/root_readonly_true/root_readonly_tests.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,44 @@ | ||
use anyhow::{Context, Ok, Result}; | ||
use oci_spec::runtime::{ProcessBuilder, RootBuilder, Spec, SpecBuilder}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_inside_container; | ||
use crate::utils::test_utils::CreateOptions; | ||
|
||
fn create_spec(readonly: bool) -> Result<Spec> { | ||
let spec = SpecBuilder::default() | ||
.root(RootBuilder::default().readonly(readonly).build().unwrap()) | ||
.process( | ||
ProcessBuilder::default() | ||
.args(vec!["runtimetest".to_string(), "root_readonly".to_string()]) | ||
.build() | ||
.expect("error in creating config"), | ||
) | ||
.build() | ||
.context("failed to build spec")?; | ||
|
||
Ok(spec) | ||
} | ||
|
||
fn root_readonly_true_test() -> TestResult { | ||
let spec_true = test_result!(create_spec(true)); | ||
test_inside_container(spec_true, &CreateOptions::default(), &|_| Ok(())) | ||
} | ||
|
||
fn root_readonly_false_test() -> TestResult { | ||
let spec_false = test_result!(create_spec(false)); | ||
test_inside_container(spec_false, &CreateOptions::default(), &|_| Ok(())) | ||
} | ||
|
||
pub fn get_root_readonly_test() -> TestGroup { | ||
let mut root_readonly_test_group = TestGroup::new("root_readonly"); | ||
|
||
let test_true = Test::new("root_readonly_true_test", Box::new(root_readonly_true_test)); | ||
let test_false = Test::new( | ||
"root_readonly_false_test", | ||
Box::new(root_readonly_false_test), | ||
); | ||
root_readonly_test_group.add(vec![Box::new(test_true), Box::new(test_false)]); | ||
|
||
root_readonly_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
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