mirror of
https://github.com/containers/youki
synced 2024-05-21 23:16:09 +02:00
80f1f36ae9
* Move individual rust-oci-tests components in the tests dir We can use several things from test_framework and even integration_test for additional tests such as podman rootless and wasm tests Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com> * fix scripts and docs for the new dir structure Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com> --------- Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>
31 lines
900 B
Rust
31 lines
900 B
Rust
use super::get_result_from_output;
|
|
use crate::utils::get_runtime_path;
|
|
use anyhow::Result;
|
|
use std::path::Path;
|
|
use std::process::{Command, Stdio};
|
|
use test_framework::assert_result_eq;
|
|
|
|
pub fn exec(
|
|
project_path: &Path,
|
|
id: &str,
|
|
exec_cmd: Vec<&str>,
|
|
expected_output: Option<&str>,
|
|
) -> Result<()> {
|
|
let res = Command::new(get_runtime_path())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped())
|
|
.arg("--root")
|
|
.arg(project_path.join("runtime"))
|
|
.arg("exec")
|
|
.arg(id)
|
|
.args(exec_cmd)
|
|
.spawn()
|
|
.expect("failed to execute exec command")
|
|
.wait_with_output();
|
|
if let Some(expect) = expected_output {
|
|
let act = String::from_utf8(res.as_ref().unwrap().stdout.clone()).unwrap();
|
|
assert_result_eq!(expect, act.as_str(), "unexpected stdout.").unwrap();
|
|
}
|
|
get_result_from_output(res)
|
|
}
|