-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add process test Signed-off-by: sat0ken <[email protected]> * rm unused imports Signed-off-by: sat0ken <[email protected]> * fix err Signed-off-by: sat0ken <[email protected]> * fix set env Signed-off-by: sat0ken <[email protected]> * fix format err Signed-off-by: sat0ken <[email protected]> * add mkdir for test Signed-off-by: sat0ken <[email protected]> * set permision to /test Signed-off-by: sat0ken <[email protected]> * fix my miss of delete Signed-off-by: sat0ken <[email protected]> * set process args to run test Signed-off-by: sat0ken <[email protected]> * fix check process env Signed-off-by: sat0ken <[email protected]> * fix create cwd dir Signed-off-by: sat0ken <[email protected]> * fix err to set env value Signed-off-by: sat0ken <[email protected]> * fix err to append env value to default Signed-off-by: sat0ken <[email protected]> * delete unnecessary code Signed-off-by: sat0ken <[email protected]> * fix to compare variables Signed-off-by: sat0ken <[email protected]> * remove unused import Signed-off-by: sat0ken <[email protected]> * fix error message actual/expected val Signed-off-by: Yashodhan Joshi <[email protected]> --------- Signed-off-by: sat0ken <[email protected]> Signed-off-by: Yashodhan Joshi <[email protected]> Co-authored-by: Yashodhan Joshi <[email protected]>
- Loading branch information
Showing
6 changed files
with
90 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,2 @@ | ||
mod process_test; | ||
pub use process_test::get_process_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,50 @@ | ||
use std::fs; | ||
|
||
use anyhow::{bail, Context, Ok, Result}; | ||
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_inside_container; | ||
|
||
fn create_spec() -> Result<Spec> { | ||
let mut process = ProcessBuilder::default() | ||
.args(vec!["runtimetest".to_string(), "process".to_string()]) | ||
.cwd("/test") | ||
.build() | ||
.expect("error in creating process config"); | ||
let mut env = process.env().clone().unwrap(); | ||
env.push("testa=valuea".to_string()); | ||
env.push("testb=123".to_string()); | ||
process.set_env(Some(env)); | ||
|
||
let spec = SpecBuilder::default() | ||
.process(process) | ||
.build() | ||
.context("failed to build spec")?; | ||
|
||
Ok(spec) | ||
} | ||
|
||
fn process_test() -> TestResult { | ||
let spec = test_result!(create_spec()); | ||
|
||
test_inside_container(spec, &|bundle| { | ||
match fs::create_dir(bundle.join("test")) { | ||
Result::Ok(_) => { /*This is expected*/ } | ||
Err(e) => { | ||
bail!(e) | ||
} | ||
} | ||
|
||
Ok(()) | ||
}) | ||
} | ||
|
||
pub fn get_process_test() -> TestGroup { | ||
let mut process_test_group = TestGroup::new("process"); | ||
|
||
let test = Test::new("process_test", Box::new(process_test)); | ||
process_test_group.add(vec![Box::new(test)]); | ||
|
||
process_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