test_infra, tests: Introduce exec_host_command_output() function

This new function allows for better readability of the code by
factorizing a few of lines of code into a single one.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-06-04 10:09:10 +02:00
parent 8091c28dd5
commit 1e2aa769e5
2 changed files with 13 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ use std::net::TcpListener;
use std::net::TcpStream;
use std::os::unix::io::AsRawFd;
use std::path::Path;
use std::process::ExitStatus;
use std::process::{ExitStatus, Output};
use std::str::FromStr;
use std::thread;
use vmm_sys_util::tempdir::TempDir;
@@ -597,3 +597,10 @@ pub fn exec_host_command_status(command: &str) -> ExitStatus {
.status()
.expect(&format!("Expected '{}' to run", command))
}
pub fn exec_host_command_output(command: &str) -> Output {
std::process::Command::new("bash")
.args(&["-c", command])
.output()
.expect(&format!("Expected '{}' to run", command))
}