Skip to content

Commit

Permalink
add mkdir for test
Browse files Browse the repository at this point in the history
Signed-off-by: sat0ken <[email protected]>
  • Loading branch information
sat0ken committed Oct 30, 2024
1 parent ef26e24 commit 846df14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/process/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod process_test;
pub use process_test::get_process_test;
pub use process_test::get_process_test;
22 changes: 13 additions & 9 deletions tests/contest/contest/src/tests/process/process_test.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use crate::utils::test_inside_container;

Check warning on line 1 in tests/contest/contest/src/tests/process/process_test.rs

View workflow job for this annotation

GitHub Actions / check (x86_64, gnu)

Diff in /home/runner/work/youki/youki/tests/contest/contest/src/tests/process/process_test.rs

Check warning on line 1 in tests/contest/contest/src/tests/process/process_test.rs

View workflow job for this annotation

GitHub Actions / check (x86_64, gnu)

Diff in /home/runner/work/youki/youki/tests/contest/contest/src/tests/process/process_test.rs

Check warning on line 1 in tests/contest/contest/src/tests/process/process_test.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

Diff in /home/runner/work/youki/youki/tests/contest/contest/src/tests/process/process_test.rs

Check warning on line 1 in tests/contest/contest/src/tests/process/process_test.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

Diff in /home/runner/work/youki/youki/tests/contest/contest/src/tests/process/process_test.rs
use anyhow::{Context, Ok, Result};
use oci_spec::runtime::{
ProcessBuilder, Spec, SpecBuilder,
};
use anyhow::{bail, Context, Ok, Result};
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder};
use std::fs;
use test_framework::{test_result, Test, TestGroup, TestResult};

fn create_spec() -> Result<Spec> {
let spec = SpecBuilder::default()
.process(
ProcessBuilder::default()
.cwd("/test")
.env(vec![
"testa=valuea".into(),
"testb=123".into()
])
.env(vec!["testa=valuea".into(), "testb=123".into()])
.build()
.expect("error in creating process config"),
)
Expand All @@ -25,7 +21,15 @@ fn create_spec() -> Result<Spec> {

fn process_test() -> TestResult {
let spec = test_result!(create_spec());
test_inside_container(spec, &|_| Ok(()))
test_inside_container(spec, &|_| {
match fs::create_dir("/test") {
Result::Ok(_) => { /*This is expected*/ }
Err(e) => {
bail!(e)
}
}
Ok(())
})
}

pub fn get_process_test() -> TestGroup {
Expand Down
2 changes: 1 addition & 1 deletion tests/contest/runtimetest/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,4 @@ pub fn validate_rootfs() {
if entries != expected {
eprintln!("error due to rootfs want {expected:?}, got {entries:?}");
}
}
}

0 comments on commit 846df14

Please sign in to comment.